Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / mojo / gles2 / command_buffer_client_impl.h
blobe1921695f4b1c837a13e4e1833c18191ce01ffb4
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 "gpu/command_buffer/client/gpu_control.h"
13 #include "gpu/command_buffer/common/command_buffer.h"
14 #include "gpu/command_buffer/common/command_buffer_shared.h"
15 #include "mojo/public/cpp/bindings/error_handler.h"
16 #include "mojo/services/gles2/command_buffer.mojom.h"
18 namespace base {
19 class RunLoop;
22 namespace mojo {
23 namespace gles2 {
24 class CommandBufferClientImpl;
26 class CommandBufferDelegate {
27 public:
28 virtual ~CommandBufferDelegate();
29 virtual void ContextLost();
32 class CommandBufferClientImpl : public CommandBufferClient,
33 public ErrorHandler,
34 public gpu::CommandBuffer,
35 public gpu::GpuControl {
36 public:
37 explicit CommandBufferClientImpl(
38 CommandBufferDelegate* delegate,
39 const MojoAsyncWaiter* async_waiter,
40 ScopedMessagePipeHandle command_buffer_handle);
41 virtual ~CommandBufferClientImpl();
43 // CommandBuffer implementation:
44 virtual bool Initialize() OVERRIDE;
45 virtual State GetLastState() OVERRIDE;
46 virtual int32 GetLastToken() OVERRIDE;
47 virtual void Flush(int32 put_offset) OVERRIDE;
48 virtual void WaitForTokenInRange(int32 start, int32 end) OVERRIDE;
49 virtual void WaitForGetOffsetInRange(int32 start, int32 end) OVERRIDE;
50 virtual void SetGetBuffer(int32 shm_id) OVERRIDE;
51 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
52 int32* id) OVERRIDE;
53 virtual void DestroyTransferBuffer(int32 id) OVERRIDE;
55 // gpu::GpuControl implementation:
56 virtual gpu::Capabilities GetCapabilities() OVERRIDE;
57 virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(size_t width,
58 size_t height,
59 unsigned internalformat,
60 unsigned usage,
61 int32* id) OVERRIDE;
62 virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE;
63 virtual uint32 InsertSyncPoint() OVERRIDE;
64 virtual uint32 InsertFutureSyncPoint() OVERRIDE;
65 virtual void RetireSyncPoint(uint32 sync_point) OVERRIDE;
66 virtual void SignalSyncPoint(uint32 sync_point,
67 const base::Closure& callback) OVERRIDE;
68 virtual void SignalQuery(uint32 query,
69 const base::Closure& callback) OVERRIDE;
70 virtual void SetSurfaceVisible(bool visible) OVERRIDE;
71 virtual void Echo(const base::Closure& callback) OVERRIDE;
72 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE;
74 private:
75 class SyncClientImpl;
77 // CommandBufferClient implementation:
78 virtual void DidDestroy() OVERRIDE;
79 virtual void LostContext(int32_t lost_reason) OVERRIDE;
81 // ErrorHandler implementation:
82 virtual void OnConnectionError() OVERRIDE;
84 void TryUpdateState();
85 void MakeProgressAndUpdateState();
87 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; }
89 CommandBufferDelegate* delegate_;
90 CommandBufferPtr command_buffer_;
91 scoped_ptr<SyncClientImpl> sync_client_impl_;
93 State last_state_;
94 mojo::ScopedSharedBufferHandle shared_state_handle_;
95 gpu::CommandBufferSharedState* shared_state_;
96 int32 last_put_offset_;
97 int32 next_transfer_buffer_id_;
99 const MojoAsyncWaiter* async_waiter_;
102 } // gles2
103 } // mojo
105 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_