Delete historical data usage from store when user clears data usage.
[chromium-blink-merge.git] / mojo / gles2 / command_buffer_client_impl.h
blobb5e2db3227f30d334eaec95244ac95fd81a47856
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_
6 #define MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_
8 #include <map>
9 #include <vector>
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/mus/public/interfaces/command_buffer.mojom.h"
14 #include "gpu/command_buffer/client/gpu_control.h"
15 #include "gpu/command_buffer/common/command_buffer.h"
16 #include "gpu/command_buffer/common/command_buffer_shared.h"
17 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
19 namespace base {
20 class RunLoop;
23 namespace gles2 {
24 class CommandBufferClientImpl;
26 class CommandBufferDelegate {
27 public:
28 virtual ~CommandBufferDelegate();
29 virtual void ContextLost();
32 class CommandBufferClientImpl : public mojo::CommandBufferLostContextObserver,
33 public gpu::CommandBuffer,
34 public gpu::GpuControl {
35 public:
36 explicit CommandBufferClientImpl(
37 CommandBufferDelegate* delegate,
38 const std::vector<int32_t>& attribs,
39 const MojoAsyncWaiter* async_waiter,
40 mojo::ScopedMessagePipeHandle command_buffer_handle);
41 ~CommandBufferClientImpl() override;
43 // CommandBuffer implementation:
44 bool Initialize() override;
45 State GetLastState() override;
46 int32_t GetLastToken() override;
47 void Flush(int32_t put_offset) override;
48 void OrderingBarrier(int32_t put_offset) override;
49 void WaitForTokenInRange(int32_t start, int32_t end) override;
50 void WaitForGetOffsetInRange(int32_t start, int32_t end) override;
51 void SetGetBuffer(int32_t shm_id) override;
52 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
53 int32_t* id) override;
54 void DestroyTransferBuffer(int32_t id) override;
56 // gpu::GpuControl implementation:
57 gpu::Capabilities GetCapabilities() override;
58 int32_t CreateImage(ClientBuffer buffer,
59 size_t width,
60 size_t height,
61 unsigned internalformat) override;
62 void DestroyImage(int32_t id) override;
63 int32_t CreateGpuMemoryBufferImage(size_t width,
64 size_t height,
65 unsigned internalformat,
66 unsigned usage) override;
67 uint32 InsertSyncPoint() override;
68 uint32 InsertFutureSyncPoint() override;
69 void RetireSyncPoint(uint32 sync_point) override;
70 void SignalSyncPoint(uint32 sync_point,
71 const base::Closure& callback) override;
72 void SignalQuery(uint32 query, const base::Closure& callback) override;
73 void SetSurfaceVisible(bool visible) override;
74 uint32 CreateStreamTexture(uint32 texture_id) override;
75 void SetLock(base::Lock*) override;
76 bool IsGpuChannelLost() override;
77 gpu::CommandBufferNamespace GetNamespaceID() const override;
78 uint64_t GetCommandBufferID() const override;
80 private:
81 class SyncClientImpl;
82 class SyncPointClientImpl;
84 // mojo::CommandBufferLostContextObserver implementation:
85 void DidLoseContext(int32_t lost_reason) override;
87 void TryUpdateState();
88 void MakeProgressAndUpdateState();
90 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; }
92 CommandBufferDelegate* delegate_;
93 std::vector<int32_t> attribs_;
94 mojo::Binding<mojo::CommandBufferLostContextObserver> observer_binding_;
95 mojo::CommandBufferPtr command_buffer_;
96 scoped_ptr<SyncClientImpl> sync_client_impl_;
97 scoped_ptr<SyncPointClientImpl> sync_point_client_impl_;
99 gpu::Capabilities capabilities_;
100 State last_state_;
101 mojo::ScopedSharedBufferHandle shared_state_handle_;
102 gpu::CommandBufferSharedState* shared_state_;
103 int32_t last_put_offset_;
104 int32_t next_transfer_buffer_id_;
106 // Image IDs are allocated in sequence.
107 int next_image_id_;
109 const MojoAsyncWaiter* async_waiter_;
112 } // gles2
114 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_