[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / mojo / gles2 / command_buffer_client_impl.h
blobf2d19b029f20c9d54e3d5025776ce30880218ffa
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();
30 virtual void DrawAnimationFrame();
33 class CommandBufferClientImpl : public CommandBufferClient,
34 public ErrorHandler,
35 public gpu::CommandBuffer,
36 public gpu::GpuControl {
37 public:
38 explicit CommandBufferClientImpl(
39 CommandBufferDelegate* delegate,
40 const MojoAsyncWaiter* async_waiter,
41 ScopedMessagePipeHandle command_buffer_handle);
42 virtual ~CommandBufferClientImpl();
44 // CommandBuffer implementation:
45 virtual bool Initialize() OVERRIDE;
46 virtual State GetLastState() OVERRIDE;
47 virtual int32 GetLastToken() OVERRIDE;
48 virtual void Flush(int32 put_offset) OVERRIDE;
49 virtual void WaitForTokenInRange(int32 start, int32 end) OVERRIDE;
50 virtual void WaitForGetOffsetInRange(int32 start, int32 end) OVERRIDE;
51 virtual void SetGetBuffer(int32 shm_id) OVERRIDE;
52 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
53 int32* id) OVERRIDE;
54 virtual void DestroyTransferBuffer(int32 id) OVERRIDE;
56 // gpu::GpuControl implementation:
57 virtual gpu::Capabilities GetCapabilities() OVERRIDE;
58 virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(size_t width,
59 size_t height,
60 unsigned internalformat,
61 unsigned usage,
62 int32* id) OVERRIDE;
63 virtual void DestroyGpuMemoryBuffer(int32 id) OVERRIDE;
64 virtual uint32 InsertSyncPoint() OVERRIDE;
65 virtual uint32 InsertFutureSyncPoint() OVERRIDE;
66 virtual void RetireSyncPoint(uint32 sync_point) OVERRIDE;
67 virtual void SignalSyncPoint(uint32 sync_point,
68 const base::Closure& callback) OVERRIDE;
69 virtual void SignalQuery(uint32 query,
70 const base::Closure& callback) OVERRIDE;
71 virtual void SetSurfaceVisible(bool visible) OVERRIDE;
72 virtual void Echo(const base::Closure& callback) OVERRIDE;
73 virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE;
75 void RequestAnimationFrames();
76 void CancelAnimationFrames();
78 private:
79 class SyncClientImpl;
81 // CommandBufferClient implementation:
82 virtual void DidDestroy() OVERRIDE;
83 virtual void LostContext(int32_t lost_reason) OVERRIDE;
84 virtual void DrawAnimationFrame() OVERRIDE;
86 // ErrorHandler implementation:
87 virtual void OnConnectionError() OVERRIDE;
89 void TryUpdateState();
90 void MakeProgressAndUpdateState();
92 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; }
94 CommandBufferDelegate* delegate_;
95 CommandBufferPtr command_buffer_;
96 scoped_ptr<SyncClientImpl> sync_client_impl_;
98 State last_state_;
99 mojo::ScopedSharedBufferHandle shared_state_handle_;
100 gpu::CommandBufferSharedState* shared_state_;
101 int32 last_put_offset_;
102 int32 next_transfer_buffer_id_;
104 const MojoAsyncWaiter* async_waiter_;
107 } // gles2
108 } // mojo
110 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_