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 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { | |
35 return control_thread_.task_runner(); | |
jamesr
2014/11/19 06:43:02
the threading rules for these objects is not clear
abarth-chromium
2014/11/19 15:42:11
I'm happy to add comments about which thread these
| |
36 } | |
37 gfx::GLShareGroup* share_group() const { return share_group_.get(); } | |
38 gpu::gles2::MailboxManager* mailbox_manager() const { | |
39 return mailbox_manager_.get(); | |
40 } | |
41 | |
42 private: | |
43 friend class base::RefCounted<State>; | |
44 ~State(); | |
45 | |
46 base::Thread control_thread_; | |
47 scoped_refptr<gfx::GLShareGroup> share_group_; | |
48 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | |
49 }; | |
50 | |
51 GpuImpl(InterfaceRequest<Gpu> request, const scoped_refptr<State>& state); | |
31 ~GpuImpl() override; | 52 ~GpuImpl() override; |
32 | 53 |
33 void CreateOnscreenGLES2Context( | 54 void CreateOnscreenGLES2Context( |
34 uint64_t native_viewport_id, | 55 uint64_t native_viewport_id, |
35 SizePtr size, | 56 SizePtr size, |
36 InterfaceRequest<CommandBuffer> command_buffer_request) override; | 57 InterfaceRequest<CommandBuffer> command_buffer_request) override; |
37 | 58 |
38 void CreateOffscreenGLES2Context( | 59 void CreateOffscreenGLES2Context( |
39 InterfaceRequest<CommandBuffer> command_buffer_request) override; | 60 InterfaceRequest<CommandBuffer> command_buffer_request) override; |
40 | 61 |
41 private: | 62 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_; | 63 StrongBinding<Gpu> binding_; |
64 scoped_refptr<State> state_; | |
48 | 65 |
49 DISALLOW_COPY_AND_ASSIGN(GpuImpl); | 66 DISALLOW_COPY_AND_ASSIGN(GpuImpl); |
50 }; | 67 }; |
51 | 68 |
52 } // namespace mojo | 69 } // namespace mojo |
OLD | NEW |