| 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 SERVICES_GLES2_GPU_IMPL_H_ | 5 #ifndef SERVICES_GLES2_GPU_IMPL_H_ |
| 6 #define SERVICES_GLES2_GPU_IMPL_H_ | 6 #define SERVICES_GLES2_GPU_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "mojo/public/cpp/bindings/interface_request.h" | 11 #include "mojo/public/cpp/bindings/interface_request.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "mojo/services/geometry/public/interfaces/geometry.mojom.h" | 13 #include "mojo/services/geometry/public/interfaces/geometry.mojom.h" |
| 14 #include "mojo/services/gpu/public/interfaces/command_buffer.mojom.h" | 14 #include "mojo/services/gpu/public/interfaces/command_buffer.mojom.h" |
| 15 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h" | 15 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h" |
| 16 #include "services/gles2/gpu_state.h" |
| 16 | 17 |
| 17 namespace gfx { | 18 namespace gfx { |
| 18 class GLShareGroup; | 19 class GLShareGroup; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace gpu { | 22 namespace gpu { |
| 22 class SyncPointManager; | 23 class SyncPointManager; |
| 23 namespace gles2 { | 24 namespace gles2 { |
| 24 class MailboxManager; | 25 class MailboxManager; |
| 25 } | 26 } |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace gles2 { | 29 namespace gles2 { |
| 29 | 30 |
| 30 class GpuImpl : public mojo::Gpu { | 31 class GpuImpl : public mojo::Gpu { |
| 31 public: | 32 public: |
| 32 // We need to share these across all CommandBuffer instances so that contexts | |
| 33 // they create can share resources with each other via mailboxes. | |
| 34 class State : public base::RefCounted<State> { | |
| 35 public: | |
| 36 State(); | |
| 37 | |
| 38 // We run the CommandBufferImpl on the control_task_runner, which forwards | |
| 39 // most method class to the CommandBufferDriver, which runs on the "driver", | |
| 40 // thread (i.e., the thread on which GpuImpl instances are created). | |
| 41 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { | |
| 42 return control_thread_.task_runner(); | |
| 43 } | |
| 44 | |
| 45 // These objects are intended to be used on the "driver" thread (i.e., the | |
| 46 // thread on which GpuImpl instances are created). | |
| 47 gfx::GLShareGroup* share_group() const { return share_group_.get(); } | |
| 48 gpu::gles2::MailboxManager* mailbox_manager() const { | |
| 49 return mailbox_manager_.get(); | |
| 50 } | |
| 51 gpu::SyncPointManager* sync_point_manager() const { | |
| 52 return sync_point_manager_.get(); | |
| 53 } | |
| 54 | |
| 55 private: | |
| 56 friend class base::RefCounted<State>; | |
| 57 ~State(); | |
| 58 | |
| 59 base::Thread control_thread_; | |
| 60 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; | |
| 61 scoped_refptr<gfx::GLShareGroup> share_group_; | |
| 62 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | |
| 63 }; | |
| 64 | |
| 65 GpuImpl(mojo::InterfaceRequest<mojo::Gpu> request, | 33 GpuImpl(mojo::InterfaceRequest<mojo::Gpu> request, |
| 66 const scoped_refptr<State>& state); | 34 const scoped_refptr<GpuState>& state); |
| 67 ~GpuImpl() override; | 35 ~GpuImpl() override; |
| 68 | 36 |
| 69 void CreateOnscreenGLES2Context( | 37 private: |
| 70 uint64_t native_viewport_id, | |
| 71 mojo::SizePtr size, | |
| 72 mojo::InterfaceRequest<mojo::CommandBuffer> command_buffer_request, | |
| 73 mojo::ViewportParameterListenerPtr listener) override; | |
| 74 | |
| 75 void CreateOffscreenGLES2Context(mojo::InterfaceRequest<mojo::CommandBuffer> | 38 void CreateOffscreenGLES2Context(mojo::InterfaceRequest<mojo::CommandBuffer> |
| 76 command_buffer_request) override; | 39 command_buffer_request) override; |
| 77 | 40 |
| 78 private: | |
| 79 mojo::StrongBinding<Gpu> binding_; | 41 mojo::StrongBinding<Gpu> binding_; |
| 80 scoped_refptr<State> state_; | 42 scoped_refptr<GpuState> state_; |
| 81 | 43 |
| 82 DISALLOW_COPY_AND_ASSIGN(GpuImpl); | 44 DISALLOW_COPY_AND_ASSIGN(GpuImpl); |
| 83 }; | 45 }; |
| 84 | 46 |
| 85 } // namespace gles2 | 47 } // namespace gles2 |
| 86 | 48 |
| 87 #endif // SERVICES_GLES2_GPU_IMPL_H_ | 49 #endif // SERVICES_GLES2_GPU_IMPL_H_ |
| OLD | NEW |