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