| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | |
| 6 #define MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 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/public/interfaces/gpu/command_buffer.mojom.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class RunLoop; | |
| 20 } | |
| 21 | |
| 22 namespace mojo { | |
| 23 namespace gles2 { | |
| 24 class CommandBufferClientImpl; | |
| 25 | |
| 26 class CommandBufferDelegate { | |
| 27 public: | |
| 28 virtual ~CommandBufferDelegate(); | |
| 29 virtual void ContextLost(); | |
| 30 }; | |
| 31 | |
| 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 ~CommandBufferClientImpl() override; | |
| 42 | |
| 43 // CommandBuffer implementation: | |
| 44 bool Initialize() override; | |
| 45 State GetLastState() override; | |
| 46 int32 GetLastToken() override; | |
| 47 void Flush(int32 put_offset) override; | |
| 48 void WaitForTokenInRange(int32 start, int32 end) override; | |
| 49 void WaitForGetOffsetInRange(int32 start, int32 end) override; | |
| 50 void SetGetBuffer(int32 shm_id) override; | |
| 51 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, | |
| 52 int32* id) override; | |
| 53 void DestroyTransferBuffer(int32 id) override; | |
| 54 | |
| 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 | |
| 75 private: | |
| 76 class SyncClientImpl; | |
| 77 | |
| 78 // CommandBufferClient implementation: | |
| 79 void DidDestroy() override; | |
| 80 void LostContext(int32_t lost_reason) override; | |
| 81 | |
| 82 // ErrorHandler implementation: | |
| 83 void OnConnectionError() override; | |
| 84 | |
| 85 void TryUpdateState(); | |
| 86 void MakeProgressAndUpdateState(); | |
| 87 | |
| 88 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; } | |
| 89 | |
| 90 CommandBufferDelegate* delegate_; | |
| 91 CommandBufferPtr command_buffer_; | |
| 92 scoped_ptr<SyncClientImpl> sync_client_impl_; | |
| 93 | |
| 94 State last_state_; | |
| 95 mojo::ScopedSharedBufferHandle shared_state_handle_; | |
| 96 gpu::CommandBufferSharedState* shared_state_; | |
| 97 int32 last_put_offset_; | |
| 98 int32 next_transfer_buffer_id_; | |
| 99 | |
| 100 const MojoAsyncWaiter* async_waiter_; | |
| 101 }; | |
| 102 | |
| 103 } // gles2 | |
| 104 } // mojo | |
| 105 | |
| 106 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | |
| OLD | NEW |