| 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_VIEW_MANAGER_GLES2_COMMAND_BUFFER_DRIVER_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_DRIVER_H_ |
| 6 #define COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_DRIVER_H_ | 6 #define COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_DRIVER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "components/view_manager/public/interfaces/command_buffer.mojom.h" | 14 #include "components/view_manager/public/interfaces/command_buffer.mojom.h" |
| 15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 16 #include "ui/gfx/native_widget_types.h" | |
| 17 | 16 |
| 18 namespace gpu { | 17 namespace gpu { |
| 19 class CommandBufferService; | 18 class CommandBufferService; |
| 20 class GpuScheduler; | 19 class GpuScheduler; |
| 21 class GpuControlService; | 20 class GpuControlService; |
| 22 namespace gles2 { | 21 namespace gles2 { |
| 23 class GLES2Decoder; | 22 class GLES2Decoder; |
| 24 } | 23 } |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace gfx { | 26 namespace gfx { |
| 28 class GLContext; | 27 class GLContext; |
| 29 class GLSurface; | 28 class GLSurface; |
| 30 } | 29 } |
| 31 | 30 |
| 32 namespace gles2 { | 31 namespace gles2 { |
| 33 | 32 |
| 34 class GpuState; | 33 class GpuState; |
| 35 | 34 |
| 36 // This class receives CommandBuffer messages on the same thread as the native | 35 // This class receives CommandBuffer messages on the same thread as the native |
| 37 // viewport. | 36 // viewport. |
| 38 class CommandBufferDriver { | 37 class CommandBufferDriver { |
| 39 public: | 38 public: |
| 40 class Client { | 39 class Client { |
| 41 public: | 40 public: |
| 42 virtual ~Client(); | 41 virtual ~Client(); |
| 43 virtual void UpdateVSyncParameters(base::TimeTicks timebase, | |
| 44 base::TimeDelta interval) = 0; | |
| 45 virtual void DidLoseContext() = 0; | 42 virtual void DidLoseContext() = 0; |
| 46 }; | 43 }; |
| 47 // Offscreen. | |
| 48 explicit CommandBufferDriver(scoped_refptr<GpuState> gpu_state); | 44 explicit CommandBufferDriver(scoped_refptr<GpuState> gpu_state); |
| 49 | 45 |
| 50 // Onscreen. | |
| 51 CommandBufferDriver( | |
| 52 gfx::AcceleratedWidget widget, | |
| 53 scoped_refptr<GpuState> gpu_state, | |
| 54 const base::Callback<void(CommandBufferDriver*)>& destruct_callback); | |
| 55 ~CommandBufferDriver(); | 46 ~CommandBufferDriver(); |
| 56 | 47 |
| 57 void set_client(scoped_ptr<Client> client) { client_ = client.Pass(); } | 48 void set_client(scoped_ptr<Client> client) { client_ = client.Pass(); } |
| 58 | 49 |
| 59 void Initialize(mojo::CommandBufferSyncClientPtr sync_client, | 50 void Initialize(mojo::CommandBufferSyncClientPtr sync_client, |
| 60 mojo::CommandBufferLostContextObserverPtr loss_observer, | 51 mojo::CommandBufferLostContextObserverPtr loss_observer, |
| 61 mojo::ScopedSharedBufferHandle shared_state); | 52 mojo::ScopedSharedBufferHandle shared_state); |
| 62 void SetGetBuffer(int32_t buffer); | 53 void SetGetBuffer(int32_t buffer); |
| 63 void Flush(int32_t put_offset); | 54 void Flush(int32_t put_offset); |
| 64 void MakeProgress(int32_t last_get_offset); | 55 void MakeProgress(int32_t last_get_offset); |
| 65 void RegisterTransferBuffer(int32_t id, | 56 void RegisterTransferBuffer(int32_t id, |
| 66 mojo::ScopedSharedBufferHandle transfer_buffer, | 57 mojo::ScopedSharedBufferHandle transfer_buffer, |
| 67 uint32_t size); | 58 uint32_t size); |
| 68 void DestroyTransferBuffer(int32_t id); | 59 void DestroyTransferBuffer(int32_t id); |
| 69 void Echo(const mojo::Callback<void()>& callback); | 60 void Echo(const mojo::Callback<void()>& callback); |
| 70 void CreateImage(int32_t id, | 61 void CreateImage(int32_t id, |
| 71 mojo::ScopedHandle memory_handle, | 62 mojo::ScopedHandle memory_handle, |
| 72 int32_t type, | 63 int32_t type, |
| 73 mojo::SizePtr size, | 64 mojo::SizePtr size, |
| 74 int32_t format, | 65 int32_t format, |
| 75 int32_t internal_format); | 66 int32_t internal_format); |
| 76 void DestroyImage(int32_t id); | 67 void DestroyImage(int32_t id); |
| 77 | 68 |
| 78 // Called at shutdown to destroy the X window. This is needed when the parent | |
| 79 // window is being destroyed. Otherwise X calls for this window will fail. | |
| 80 void DestroyWindow(); | |
| 81 | |
| 82 private: | 69 private: |
| 83 bool MakeCurrent(); | 70 bool MakeCurrent(); |
| 84 bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state); | 71 bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state); |
| 85 void OnResize(gfx::Size size, float scale_factor); | 72 void OnResize(gfx::Size size, float scale_factor); |
| 86 bool OnWaitSyncPoint(uint32_t sync_point); | 73 bool OnWaitSyncPoint(uint32_t sync_point); |
| 87 void OnSyncPointRetired(); | 74 void OnSyncPointRetired(); |
| 88 void OnParseError(); | 75 void OnParseError(); |
| 89 void OnContextLost(uint32_t reason); | 76 void OnContextLost(uint32_t reason); |
| 90 void OnUpdateVSyncParameters(const base::TimeTicks timebase, | |
| 91 const base::TimeDelta interval); | |
| 92 void DestroyDecoder(); | 77 void DestroyDecoder(); |
| 93 | 78 |
| 94 scoped_ptr<Client> client_; | 79 scoped_ptr<Client> client_; |
| 95 mojo::CommandBufferSyncClientPtr sync_client_; | 80 mojo::CommandBufferSyncClientPtr sync_client_; |
| 96 mojo::CommandBufferLostContextObserverPtr loss_observer_; | 81 mojo::CommandBufferLostContextObserverPtr loss_observer_; |
| 97 gfx::AcceleratedWidget widget_; | |
| 98 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 82 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
| 99 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | 83 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
| 100 scoped_ptr<gpu::GpuScheduler> scheduler_; | 84 scoped_ptr<gpu::GpuScheduler> scheduler_; |
| 101 scoped_refptr<gfx::GLContext> context_; | 85 scoped_refptr<gfx::GLContext> context_; |
| 102 scoped_refptr<gfx::GLSurface> surface_; | 86 scoped_refptr<gfx::GLSurface> surface_; |
| 103 scoped_refptr<GpuState> gpu_state_; | 87 scoped_refptr<GpuState> gpu_state_; |
| 104 | 88 |
| 105 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; | 89 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; |
| 106 base::Callback<void(int32_t)> context_lost_callback_; | 90 base::Callback<void(int32_t)> context_lost_callback_; |
| 107 | 91 |
| 108 base::Callback<void(CommandBufferDriver*)> destruct_callback_; | |
| 109 | |
| 110 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; | 92 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; |
| 111 | 93 |
| 112 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); | 94 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); |
| 113 }; | 95 }; |
| 114 | 96 |
| 115 } // namespace gles2 | 97 } // namespace gles2 |
| 116 | 98 |
| 117 #endif // COMPONENTS_GLES2_COMMAND_BUFFER_DRIVER_H_ | 99 #endif // COMPONENTS_GLES2_COMMAND_BUFFER_DRIVER_H_ |
| OLD | NEW |