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