| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DRIVER_H_ | 5 #ifndef COMPONENTS_MUS_GLES2_COMMAND_BUFFER_DRIVER_H_ |
| 6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_DRIVER_H_ | 6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_DRIVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "gpu/command_buffer/common/capabilities.h" | 17 #include "gpu/command_buffer/common/capabilities.h" |
| 18 #include "gpu/command_buffer/common/command_buffer.h" | 18 #include "gpu/command_buffer/common/command_buffer.h" |
| 19 #include "gpu/command_buffer/common/command_buffer_id.h" | 19 #include "gpu/command_buffer/common/command_buffer_id.h" |
| 20 #include "gpu/command_buffer/common/constants.h" | 20 #include "gpu/command_buffer/common/constants.h" |
| 21 #include "mojo/public/cpp/bindings/array.h" | 21 #include "mojo/public/cpp/bindings/array.h" |
| 22 #include "mojo/public/cpp/system/buffer.h" | 22 #include "mojo/public/cpp/system/buffer.h" |
| 23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
| 24 #include "ui/gfx/swap_result.h" |
| 24 #include "ui/mojo/geometry/geometry.mojom.h" | 25 #include "ui/mojo/geometry/geometry.mojom.h" |
| 25 | 26 |
| 26 namespace gpu { | 27 namespace gpu { |
| 27 class CommandBufferService; | 28 class CommandBufferService; |
| 28 class CommandExecutor; | 29 class CommandExecutor; |
| 29 class SyncPointClient; | 30 class SyncPointClient; |
| 30 class SyncPointOrderData; | 31 class SyncPointOrderData; |
| 31 namespace gles2 { | 32 namespace gles2 { |
| 32 class GLES2Decoder; | 33 class GLES2Decoder; |
| 33 } | 34 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 // This class receives CommandBuffer messages on the same thread as the native | 46 // This class receives CommandBuffer messages on the same thread as the native |
| 46 // viewport. | 47 // viewport. |
| 47 class CommandBufferDriver : base::NonThreadSafe { | 48 class CommandBufferDriver : base::NonThreadSafe { |
| 48 public: | 49 public: |
| 49 class Client { | 50 class Client { |
| 50 public: | 51 public: |
| 51 virtual ~Client(); | 52 virtual ~Client(); |
| 52 virtual void DidLoseContext(uint32_t reason) = 0; | 53 virtual void DidLoseContext(uint32_t reason) = 0; |
| 53 virtual void UpdateVSyncParameters(int64_t timebase, int64_t interval) = 0; | 54 virtual void UpdateVSyncParameters(int64_t timebase, int64_t interval) = 0; |
| 55 virtual void OnGpuCompletedSwapBuffers(gfx::SwapResult result) = 0; |
| 54 }; | 56 }; |
| 55 CommandBufferDriver(gpu::CommandBufferNamespace command_buffer_namespace, | 57 CommandBufferDriver(gpu::CommandBufferNamespace command_buffer_namespace, |
| 56 gpu::CommandBufferId command_buffer_id, | 58 gpu::CommandBufferId command_buffer_id, |
| 57 gfx::AcceleratedWidget widget, | 59 gfx::AcceleratedWidget widget, |
| 58 scoped_refptr<GpuState> gpu_state); | 60 scoped_refptr<GpuState> gpu_state); |
| 59 ~CommandBufferDriver(); | 61 ~CommandBufferDriver(); |
| 60 | 62 |
| 61 void set_client(scoped_ptr<Client> client) { client_ = std::move(client); } | 63 // The class owning the CommandBufferDriver instance (e.g. CommandBufferLocal) |
| 64 // is itself the Client implementation so CommandBufferDriver does not own the |
| 65 // client. |
| 66 void set_client(Client* client) { client_ = client; } |
| 62 | 67 |
| 63 bool Initialize(mojo::ScopedSharedBufferHandle shared_state, | 68 bool Initialize(mojo::ScopedSharedBufferHandle shared_state, |
| 64 mojo::Array<int32_t> attribs); | 69 mojo::Array<int32_t> attribs); |
| 65 void SetGetBuffer(int32_t buffer); | 70 void SetGetBuffer(int32_t buffer); |
| 66 void Flush(int32_t put_offset); | 71 void Flush(int32_t put_offset); |
| 67 void RegisterTransferBuffer(int32_t id, | 72 void RegisterTransferBuffer(int32_t id, |
| 68 mojo::ScopedSharedBufferHandle transfer_buffer, | 73 mojo::ScopedSharedBufferHandle transfer_buffer, |
| 69 uint32_t size); | 74 uint32_t size); |
| 70 void DestroyTransferBuffer(int32_t id); | 75 void DestroyTransferBuffer(int32_t id); |
| 71 void CreateImage(int32_t id, | 76 void CreateImage(int32_t id, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 116 |
| 112 // Callbacks: | 117 // Callbacks: |
| 113 void OnUpdateVSyncParameters(const base::TimeTicks timebase, | 118 void OnUpdateVSyncParameters(const base::TimeTicks timebase, |
| 114 const base::TimeDelta interval); | 119 const base::TimeDelta interval); |
| 115 void OnFenceSyncRelease(uint64_t release); | 120 void OnFenceSyncRelease(uint64_t release); |
| 116 bool OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id, | 121 bool OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id, |
| 117 gpu::CommandBufferId command_buffer_id, | 122 gpu::CommandBufferId command_buffer_id, |
| 118 uint64_t release); | 123 uint64_t release); |
| 119 void OnParseError(); | 124 void OnParseError(); |
| 120 void OnContextLost(uint32_t reason); | 125 void OnContextLost(uint32_t reason); |
| 126 void OnGpuCompletedSwapBuffers(gfx::SwapResult result); |
| 121 | 127 |
| 122 const gpu::CommandBufferNamespace command_buffer_namespace_; | 128 const gpu::CommandBufferNamespace command_buffer_namespace_; |
| 123 const gpu::CommandBufferId command_buffer_id_; | 129 const gpu::CommandBufferId command_buffer_id_; |
| 124 gfx::AcceleratedWidget widget_; | 130 gfx::AcceleratedWidget widget_; |
| 125 scoped_ptr<Client> client_; | 131 Client* client_; // NOT OWNED. |
| 126 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 132 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
| 127 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | 133 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
| 128 scoped_ptr<gpu::CommandExecutor> executor_; | 134 scoped_ptr<gpu::CommandExecutor> executor_; |
| 129 scoped_refptr<gpu::SyncPointOrderData> sync_point_order_data_; | 135 scoped_refptr<gpu::SyncPointOrderData> sync_point_order_data_; |
| 130 scoped_ptr<gpu::SyncPointClient> sync_point_client_; | 136 scoped_ptr<gpu::SyncPointClient> sync_point_client_; |
| 131 scoped_refptr<gfx::GLContext> context_; | 137 scoped_refptr<gfx::GLContext> context_; |
| 132 scoped_refptr<gfx::GLSurface> surface_; | 138 scoped_refptr<gfx::GLSurface> surface_; |
| 133 scoped_refptr<GpuState> gpu_state_; | 139 scoped_refptr<GpuState> gpu_state_; |
| 134 | 140 |
| 135 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; | 141 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; |
| 136 base::Callback<void(int32_t)> context_lost_callback_; | 142 base::Callback<void(int32_t)> context_lost_callback_; |
| 137 | 143 |
| 138 base::TimeTicks process_delayed_work_time_; | 144 base::TimeTicks process_delayed_work_time_; |
| 139 uint32_t previous_processed_num_; | 145 uint32_t previous_processed_num_; |
| 140 base::TimeTicks last_idle_time_; | 146 base::TimeTicks last_idle_time_; |
| 141 | 147 |
| 142 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; | 148 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; |
| 143 | 149 |
| 144 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); | 150 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); |
| 145 }; | 151 }; |
| 146 | 152 |
| 147 } // namespace mus | 153 } // namespace mus |
| 148 | 154 |
| 149 #endif // COMPONENTS_GLES2_COMMAND_BUFFER_DRIVER_H_ | 155 #endif // COMPONENTS_GLES2_COMMAND_BUFFER_DRIVER_H_ |
| OLD | NEW |