Inline NetLog IPv6 reachability events.
[chromium-blink-merge.git] / mojo / gles2 / command_buffer_client_impl.h
blob875f7bbcf9a233021016af99519251194f2748ba
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/gpu/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"
16 #include "mojo/public/cpp/bindings/error_handler.h"
18 namespace base {
19 class RunLoop;
22 namespace gles2 {
23 class CommandBufferClientImpl;
25 class CommandBufferDelegate {
26 public:
27 virtual ~CommandBufferDelegate();
28 virtual void ContextLost();
31 class CommandBufferClientImpl : public mojo::CommandBufferLostContextObserver,
32 public mojo::ErrorHandler,
33 public gpu::CommandBuffer,
34 public gpu::GpuControl {
35 public:
36 explicit CommandBufferClientImpl(
37 CommandBufferDelegate* delegate,
38 const MojoAsyncWaiter* async_waiter,
39 mojo::ScopedMessagePipeHandle command_buffer_handle);
40 ~CommandBufferClientImpl() override;
42 // CommandBuffer implementation:
43 bool Initialize() override;
44 State GetLastState() override;
45 int32_t GetLastToken() override;
46 void Flush(int32_t put_offset) override;
47 void OrderingBarrier(int32_t put_offset) override;
48 void WaitForTokenInRange(int32_t start, int32_t end) override;
49 void WaitForGetOffsetInRange(int32_t start, int32_t end) override;
50 void SetGetBuffer(int32_t shm_id) override;
51 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
52 int32_t* id) override;
53 void DestroyTransferBuffer(int32_t id) override;
55 // gpu::GpuControl implementation:
56 gpu::Capabilities GetCapabilities() override;
57 int32_t CreateImage(ClientBuffer buffer,
58 size_t width,
59 size_t height,
60 unsigned internalformat) override;
61 void DestroyImage(int32_t id) override;
62 int32_t CreateGpuMemoryBufferImage(size_t width,
63 size_t height,
64 unsigned internalformat,
65 unsigned usage) override;
66 uint32 InsertSyncPoint() override;
67 uint32 InsertFutureSyncPoint() override;
68 void RetireSyncPoint(uint32 sync_point) override;
69 void SignalSyncPoint(uint32 sync_point,
70 const base::Closure& callback) override;
71 void SignalQuery(uint32 query, const base::Closure& callback) override;
72 void SetSurfaceVisible(bool visible) override;
73 uint32 CreateStreamTexture(uint32 texture_id) override;
74 void SetLock(base::Lock*) override;
76 private:
77 class SyncClientImpl;
78 class SyncPointClientImpl;
80 // mojo::CommandBufferLostContextObserver implementation:
81 void DidLoseContext(int32_t lost_reason) override;
83 // mojo::ErrorHandler implementation:
84 void OnConnectionError() override;
86 void TryUpdateState();
87 void MakeProgressAndUpdateState();
89 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; }
91 CommandBufferDelegate* delegate_;
92 mojo::Binding<mojo::CommandBufferLostContextObserver> observer_binding_;
93 mojo::CommandBufferPtr command_buffer_;
94 scoped_ptr<SyncClientImpl> sync_client_impl_;
95 scoped_ptr<SyncPointClientImpl> sync_point_client_impl_;
97 gpu::Capabilities capabilities_;
98 State last_state_;
99 mojo::ScopedSharedBufferHandle shared_state_handle_;
100 gpu::CommandBufferSharedState* shared_state_;
101 int32_t last_put_offset_;
102 int32_t next_transfer_buffer_id_;
104 const MojoAsyncWaiter* async_waiter_;
107 } // gles2
109 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_