| 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 COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_IMPL_H_ | |
| 6 #define COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_IMPL_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "base/single_thread_task_runner.h" | |
| 11 #include "components/view_manager/public/interfaces/command_buffer.mojom.h" | |
| 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | |
| 13 | |
| 14 namespace gles2 { | |
| 15 class CommandBufferDriver; | |
| 16 class CommandBufferImplObserver; | |
| 17 class GpuState; | |
| 18 | |
| 19 // This class listens to the CommandBuffer message pipe on a low-latency thread | |
| 20 // so that we can insert sync points without blocking on the GL driver. It | |
| 21 // forwards most method calls to the CommandBufferDriver, which runs on the | |
| 22 // same thread as the native viewport. | |
| 23 class CommandBufferImpl : public mojo::CommandBuffer { | |
| 24 public: | |
| 25 CommandBufferImpl(mojo::InterfaceRequest<CommandBuffer> request, | |
| 26 scoped_refptr<GpuState> gpu_state, | |
| 27 scoped_ptr<CommandBufferDriver> driver); | |
| 28 | |
| 29 // mojo::CommandBuffer: | |
| 30 void Initialize(mojo::CommandBufferSyncClientPtr sync_client, | |
| 31 mojo::CommandBufferSyncPointClientPtr sync_point_client, | |
| 32 mojo::CommandBufferLostContextObserverPtr loss_observer, | |
| 33 mojo::ScopedSharedBufferHandle shared_state) override; | |
| 34 void SetGetBuffer(int32_t buffer) override; | |
| 35 void Flush(int32_t put_offset) override; | |
| 36 void MakeProgress(int32_t last_get_offset) override; | |
| 37 void RegisterTransferBuffer(int32_t id, | |
| 38 mojo::ScopedSharedBufferHandle transfer_buffer, | |
| 39 uint32_t size) override; | |
| 40 void DestroyTransferBuffer(int32_t id) override; | |
| 41 void InsertSyncPoint(bool retire) override; | |
| 42 void RetireSyncPoint(uint32_t sync_point) override; | |
| 43 void Echo(const mojo::Callback<void()>& callback) override; | |
| 44 void CreateImage(int32_t id, | |
| 45 mojo::ScopedHandle memory_handle, | |
| 46 int32_t type, | |
| 47 mojo::SizePtr size, | |
| 48 int32_t format, | |
| 49 int32_t internal_format) override; | |
| 50 void DestroyImage(int32_t id) override; | |
| 51 | |
| 52 void DidLoseContext(); | |
| 53 | |
| 54 void set_observer(CommandBufferImplObserver* observer) { | |
| 55 observer_ = observer; | |
| 56 } | |
| 57 | |
| 58 private: | |
| 59 class CommandBufferDriverClientImpl; | |
| 60 | |
| 61 friend class base::DeleteHelper<CommandBufferImpl>; | |
| 62 | |
| 63 ~CommandBufferImpl() override; | |
| 64 | |
| 65 void BindToRequest(mojo::InterfaceRequest<CommandBuffer> request); | |
| 66 | |
| 67 void OnConnectionError(); | |
| 68 | |
| 69 scoped_refptr<GpuState> gpu_state_; | |
| 70 scoped_refptr<base::SingleThreadTaskRunner> driver_task_runner_; | |
| 71 scoped_ptr<CommandBufferDriver> driver_; | |
| 72 mojo::CommandBufferSyncPointClientPtr sync_point_client_; | |
| 73 mojo::Binding<CommandBuffer> binding_; | |
| 74 CommandBufferImplObserver* observer_; | |
| 75 base::WeakPtrFactory<CommandBufferImpl> weak_ptr_factory_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); | |
| 78 }; | |
| 79 | |
| 80 } // namespace gles2 | |
| 81 | |
| 82 #endif // COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_IMPL_H_ | |
| OLD | NEW |