OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ | |
6 #define MOJO_SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/macros.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/single_thread_task_runner.h" | |
12 #include "base/timer/timer.h" | |
13 #include "mojo/services/public/interfaces/gpu/command_buffer.mojom.h" | |
14 #include "ui/gfx/native_widget_types.h" | |
15 #include "ui/gfx/size.h" | |
16 | |
17 namespace gpu { | |
18 class CommandBufferService; | |
19 class GpuScheduler; | |
20 class GpuControlService; | |
21 class SyncPointManager; | |
22 namespace gles2 { | |
23 class GLES2Decoder; | |
24 class MailboxManager; | |
25 } | |
26 } | |
27 | |
28 namespace gfx { | |
29 class GLContext; | |
30 class GLShareGroup; | |
31 class GLSurface; | |
32 } | |
33 | |
34 namespace mojo { | |
35 | |
36 class CommandBufferDriver { | |
37 public: | |
38 class Client { | |
39 public: | |
40 virtual void DidDestroy() = 0; | |
41 virtual void UpdateVSyncParameters(base::TimeTicks timebase, | |
42 base::TimeDelta interval) = 0; | |
43 virtual void LostContext(int32_t lost_reason) = 0; | |
44 | |
45 protected: | |
46 virtual ~Client(); | |
47 }; | |
48 // Offscreen. | |
49 CommandBufferDriver(gfx::GLShareGroup* share_group, | |
50 gpu::gles2::MailboxManager* mailbox_manager, | |
51 gpu::SyncPointManager* sync_point_manager); | |
52 // Onscreen. | |
53 CommandBufferDriver(gfx::AcceleratedWidget widget, | |
54 const gfx::Size& size, | |
55 gfx::GLShareGroup* share_group, | |
56 gpu::gles2::MailboxManager* mailbox_manager, | |
57 gpu::SyncPointManager* sync_point_manager); | |
58 ~CommandBufferDriver(); | |
59 | |
60 void set_client(Client* client) { client_ = client; } | |
61 | |
62 void Initialize(CommandBufferSyncClientPtr sync_client, | |
63 ScopedSharedBufferHandle shared_state); | |
64 void SetGetBuffer(int32_t buffer); | |
65 void Flush(int32_t put_offset); | |
66 void MakeProgress(int32_t last_get_offset); | |
67 void RegisterTransferBuffer(int32_t id, | |
68 ScopedSharedBufferHandle transfer_buffer, | |
69 uint32_t size); | |
70 void DestroyTransferBuffer(int32_t id); | |
71 void Echo(const Callback<void()>& callback); | |
72 | |
73 private: | |
74 bool DoInitialize(ScopedSharedBufferHandle shared_state); | |
75 void OnResize(gfx::Size size, float scale_factor); | |
76 bool OnWaitSyncPoint(uint32_t sync_point); | |
77 void OnSyncPointRetired(); | |
78 void OnParseError(); | |
79 void OnContextLost(uint32_t reason); | |
80 void OnUpdateVSyncParameters(const base::TimeTicks timebase, | |
81 const base::TimeDelta interval); | |
82 | |
83 Client* client_; | |
84 CommandBufferSyncClientPtr sync_client_; | |
85 gfx::AcceleratedWidget widget_; | |
86 gfx::Size size_; | |
87 scoped_ptr<gpu::CommandBufferService> command_buffer_; | |
88 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | |
89 scoped_ptr<gpu::GpuScheduler> scheduler_; | |
90 scoped_refptr<gfx::GLContext> context_; | |
91 scoped_refptr<gfx::GLSurface> surface_; | |
92 scoped_refptr<gfx::GLShareGroup> share_group_; | |
93 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | |
94 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; | |
95 | |
96 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; | |
97 base::Callback<void(int32_t)> context_lost_callback_; | |
98 | |
99 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); | |
102 }; | |
103 | |
104 } // namespace mojo | |
105 | |
106 #endif // MOJO_SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ | |
OLD | NEW |