| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ | 5 #ifndef COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ |
| 6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ | 6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "components/mus/gles2/command_buffer_driver.h" |
| 14 #include "components/mus/public/interfaces/command_buffer.mojom.h" | 15 #include "components/mus/public/interfaces/command_buffer.mojom.h" |
| 15 #include "gpu/command_buffer/common/command_buffer.h" | 16 #include "gpu/command_buffer/common/command_buffer.h" |
| 16 #include "mojo/public/cpp/bindings/binding.h" | 17 #include "mojo/public/cpp/bindings/binding.h" |
| 17 | 18 |
| 18 namespace mus { | 19 namespace mus { |
| 19 | 20 |
| 20 class CommandBufferDriver; | 21 class CommandBufferDriver; |
| 21 class GpuState; | 22 class GpuState; |
| 22 | 23 |
| 23 // This class listens to the CommandBuffer message pipe on a low-latency thread | 24 // This class listens to the CommandBuffer message pipe on a low-latency thread |
| 24 // so that we can insert sync points without blocking on the GL driver. It | 25 // so that we can insert sync points without blocking on the GL driver. It |
| 25 // forwards most method calls to the CommandBufferDriver, which runs on the | 26 // forwards most method calls to the CommandBufferDriver, which runs on the |
| 26 // same thread as the native viewport. | 27 // same thread as the native viewport. |
| 27 class CommandBufferImpl : public mojom::CommandBuffer { | 28 class CommandBufferImpl : public mojom::CommandBuffer, |
| 29 public CommandBufferDriver::Client { |
| 28 public: | 30 public: |
| 29 CommandBufferImpl(mojo::InterfaceRequest<CommandBuffer> request, | 31 CommandBufferImpl(mojo::InterfaceRequest<CommandBuffer> request, |
| 30 scoped_refptr<GpuState> gpu_state); | 32 scoped_refptr<GpuState> gpu_state); |
| 31 void DidLoseContext(uint32_t reason); | |
| 32 | 33 |
| 33 private: | 34 private: |
| 34 class CommandBufferDriverClientImpl; | 35 class CommandBufferDriverClientImpl; |
| 35 ~CommandBufferImpl() override; | 36 ~CommandBufferImpl() override; |
| 36 | 37 |
| 38 // CommandBufferDriver::Client. All called on the GPU thread. |
| 39 void DidLoseContext(uint32_t reason) override; |
| 40 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override; |
| 41 void OnGpuCompletedSwapBuffers(gfx::SwapResult result) override; |
| 42 |
| 37 // mojom::CommandBuffer: | 43 // mojom::CommandBuffer: |
| 38 void Initialize( | 44 void Initialize( |
| 39 mojom::CommandBufferClientPtr client, | 45 mojom::CommandBufferClientPtr client, |
| 40 mojo::ScopedSharedBufferHandle shared_state, | 46 mojo::ScopedSharedBufferHandle shared_state, |
| 41 mojo::Array<int32_t> attribs, | 47 mojo::Array<int32_t> attribs, |
| 42 const mojom::CommandBuffer::InitializeCallback& callback) override; | 48 const mojom::CommandBuffer::InitializeCallback& callback) override; |
| 43 void SetGetBuffer(int32_t buffer) override; | 49 void SetGetBuffer(int32_t buffer) override; |
| 44 void Flush(int32_t put_offset) override; | 50 void Flush(int32_t put_offset) override; |
| 45 void MakeProgress( | 51 void MakeProgress( |
| 46 int32_t last_get_offset, | 52 int32_t last_get_offset, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 scoped_ptr<CommandBufferDriver> driver_; | 114 scoped_ptr<CommandBufferDriver> driver_; |
| 109 scoped_ptr<mojo::Binding<CommandBuffer>> binding_; | 115 scoped_ptr<mojo::Binding<CommandBuffer>> binding_; |
| 110 mojom::CommandBufferClientPtr client_; | 116 mojom::CommandBufferClientPtr client_; |
| 111 | 117 |
| 112 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); | 118 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); |
| 113 }; | 119 }; |
| 114 | 120 |
| 115 } // namespace mus | 121 } // namespace mus |
| 116 | 122 |
| 117 #endif // COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ | 123 #endif // COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ |
| OLD | NEW |