Fix broken channel icon in chrome://help on CrOS
[chromium-blink-merge.git] / mojo / gles2 / command_buffer_client_impl.h
bloba01c12ccd8d5ae68e55154430fce1efd6cd8b0d0
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>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/view_manager/public/interfaces/command_buffer.mojom.h"
13 #include "gpu/command_buffer/client/gpu_control.h"
14 #include "gpu/command_buffer/common/command_buffer.h"
15 #include "gpu/command_buffer/common/command_buffer_shared.h"
17 namespace base {
18 class RunLoop;
21 namespace gles2 {
22 class CommandBufferClientImpl;
24 class CommandBufferDelegate {
25 public:
26 virtual ~CommandBufferDelegate();
27 virtual void ContextLost();
30 class CommandBufferClientImpl : public mojo::CommandBufferLostContextObserver,
31 public gpu::CommandBuffer,
32 public gpu::GpuControl {
33 public:
34 explicit CommandBufferClientImpl(
35 CommandBufferDelegate* delegate,
36 const MojoAsyncWaiter* async_waiter,
37 mojo::ScopedMessagePipeHandle command_buffer_handle);
38 ~CommandBufferClientImpl() override;
40 // CommandBuffer implementation:
41 bool Initialize() override;
42 State GetLastState() override;
43 int32_t GetLastToken() override;
44 void Flush(int32_t put_offset) override;
45 void OrderingBarrier(int32_t put_offset) override;
46 void WaitForTokenInRange(int32_t start, int32_t end) override;
47 void WaitForGetOffsetInRange(int32_t start, int32_t end) override;
48 void SetGetBuffer(int32_t shm_id) override;
49 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
50 int32_t* id) override;
51 void DestroyTransferBuffer(int32_t id) override;
53 // gpu::GpuControl implementation:
54 gpu::Capabilities GetCapabilities() override;
55 int32_t CreateImage(ClientBuffer buffer,
56 size_t width,
57 size_t height,
58 unsigned internalformat) override;
59 void DestroyImage(int32_t id) override;
60 int32_t CreateGpuMemoryBufferImage(size_t width,
61 size_t height,
62 unsigned internalformat,
63 unsigned usage) override;
64 uint32 InsertSyncPoint() override;
65 uint32 InsertFutureSyncPoint() override;
66 void RetireSyncPoint(uint32 sync_point) override;
67 void SignalSyncPoint(uint32 sync_point,
68 const base::Closure& callback) override;
69 void SignalQuery(uint32 query, const base::Closure& callback) override;
70 void SetSurfaceVisible(bool visible) override;
71 uint32 CreateStreamTexture(uint32 texture_id) override;
72 void SetLock(base::Lock*) override;
73 bool IsGpuChannelLost() override;
75 private:
76 class SyncClientImpl;
77 class SyncPointClientImpl;
79 // mojo::CommandBufferLostContextObserver implementation:
80 void DidLoseContext(int32_t lost_reason) override;
82 void TryUpdateState();
83 void MakeProgressAndUpdateState();
85 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; }
87 CommandBufferDelegate* delegate_;
88 mojo::Binding<mojo::CommandBufferLostContextObserver> observer_binding_;
89 mojo::CommandBufferPtr command_buffer_;
90 scoped_ptr<SyncClientImpl> sync_client_impl_;
91 scoped_ptr<SyncPointClientImpl> sync_point_client_impl_;
93 gpu::Capabilities capabilities_;
94 State last_state_;
95 mojo::ScopedSharedBufferHandle shared_state_handle_;
96 gpu::CommandBufferSharedState* shared_state_;
97 int32_t last_put_offset_;
98 int32_t next_transfer_buffer_id_;
100 // Image IDs are allocated in sequence.
101 int next_image_id_;
103 const MojoAsyncWaiter* async_waiter_;
106 } // gles2
108 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_