OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_COMMAND_BUFFER_DRIVER_H_ | 5 #ifndef SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ |
6 #define SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ | 6 #define SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 class GLShareGroup; | 30 class GLShareGroup; |
31 class GLSurface; | 31 class GLSurface; |
32 } | 32 } |
33 | 33 |
34 namespace gles2 { | 34 namespace gles2 { |
35 | 35 |
36 class CommandBufferDriver { | 36 class CommandBufferDriver { |
37 public: | 37 public: |
38 class Client { | 38 class Client { |
39 public: | 39 public: |
40 virtual void DidDestroy() = 0; | 40 virtual ~Client(); |
41 virtual void UpdateVSyncParameters(base::TimeTicks timebase, | 41 virtual void UpdateVSyncParameters(base::TimeTicks timebase, |
42 base::TimeDelta interval) = 0; | 42 base::TimeDelta interval) = 0; |
43 virtual void LostContext(int32_t lost_reason) = 0; | 43 virtual void DidLoseContext() = 0; |
44 | |
45 protected: | |
46 virtual ~Client(); | |
47 }; | 44 }; |
48 // Offscreen. | 45 // Offscreen. |
49 CommandBufferDriver(gfx::GLShareGroup* share_group, | 46 CommandBufferDriver(gfx::GLShareGroup* share_group, |
50 gpu::gles2::MailboxManager* mailbox_manager, | 47 gpu::gles2::MailboxManager* mailbox_manager, |
51 gpu::SyncPointManager* sync_point_manager); | 48 gpu::SyncPointManager* sync_point_manager); |
52 // Onscreen. | 49 // Onscreen. |
53 CommandBufferDriver(gfx::AcceleratedWidget widget, | 50 CommandBufferDriver(gfx::AcceleratedWidget widget, |
54 const gfx::Size& size, | 51 const gfx::Size& size, |
55 gfx::GLShareGroup* share_group, | 52 gfx::GLShareGroup* share_group, |
56 gpu::gles2::MailboxManager* mailbox_manager, | 53 gpu::gles2::MailboxManager* mailbox_manager, |
57 gpu::SyncPointManager* sync_point_manager); | 54 gpu::SyncPointManager* sync_point_manager); |
58 ~CommandBufferDriver(); | 55 ~CommandBufferDriver(); |
59 | 56 |
60 void set_client(Client* client) { client_ = client; } | 57 void set_client(scoped_ptr<Client> client) { client_ = client.Pass(); } |
61 | 58 |
62 void Initialize(mojo::CommandBufferSyncClientPtr sync_client, | 59 void Initialize(mojo::CommandBufferSyncClientPtr sync_client, |
| 60 mojo::CommandBufferLostContextObserverPtr loss_observer, |
63 mojo::ScopedSharedBufferHandle shared_state); | 61 mojo::ScopedSharedBufferHandle shared_state); |
64 void SetGetBuffer(int32_t buffer); | 62 void SetGetBuffer(int32_t buffer); |
65 void Flush(int32_t put_offset); | 63 void Flush(int32_t put_offset); |
66 void MakeProgress(int32_t last_get_offset); | 64 void MakeProgress(int32_t last_get_offset); |
67 void RegisterTransferBuffer(int32_t id, | 65 void RegisterTransferBuffer(int32_t id, |
68 mojo::ScopedSharedBufferHandle transfer_buffer, | 66 mojo::ScopedSharedBufferHandle transfer_buffer, |
69 uint32_t size); | 67 uint32_t size); |
70 void DestroyTransferBuffer(int32_t id); | 68 void DestroyTransferBuffer(int32_t id); |
71 void Echo(const mojo::Callback<void()>& callback); | 69 void Echo(const mojo::Callback<void()>& callback); |
72 | 70 |
73 private: | 71 private: |
74 bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state); | 72 bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state); |
75 void OnResize(gfx::Size size, float scale_factor); | 73 void OnResize(gfx::Size size, float scale_factor); |
76 bool OnWaitSyncPoint(uint32_t sync_point); | 74 bool OnWaitSyncPoint(uint32_t sync_point); |
77 void OnSyncPointRetired(); | 75 void OnSyncPointRetired(); |
78 void OnParseError(); | 76 void OnParseError(); |
79 void OnContextLost(uint32_t reason); | 77 void OnContextLost(uint32_t reason); |
80 void OnUpdateVSyncParameters(const base::TimeTicks timebase, | 78 void OnUpdateVSyncParameters(const base::TimeTicks timebase, |
81 const base::TimeDelta interval); | 79 const base::TimeDelta interval); |
82 | 80 |
83 Client* client_; | 81 scoped_ptr<Client> client_; |
84 mojo::CommandBufferSyncClientPtr sync_client_; | 82 mojo::CommandBufferSyncClientPtr sync_client_; |
| 83 mojo::CommandBufferLostContextObserverPtr loss_observer_; |
85 gfx::AcceleratedWidget widget_; | 84 gfx::AcceleratedWidget widget_; |
86 gfx::Size size_; | 85 gfx::Size size_; |
87 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 86 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
88 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | 87 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
89 scoped_ptr<gpu::GpuScheduler> scheduler_; | 88 scoped_ptr<gpu::GpuScheduler> scheduler_; |
90 scoped_refptr<gfx::GLContext> context_; | 89 scoped_refptr<gfx::GLContext> context_; |
91 scoped_refptr<gfx::GLSurface> surface_; | 90 scoped_refptr<gfx::GLSurface> surface_; |
92 scoped_refptr<gfx::GLShareGroup> share_group_; | 91 scoped_refptr<gfx::GLShareGroup> share_group_; |
93 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 92 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
94 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; | 93 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; |
95 | 94 |
96 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; | 95 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; |
97 base::Callback<void(int32_t)> context_lost_callback_; | 96 base::Callback<void(int32_t)> context_lost_callback_; |
98 | 97 |
99 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; | 98 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; |
100 | 99 |
101 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); | 100 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); |
102 }; | 101 }; |
103 | 102 |
104 } // namespace gles2 | 103 } // namespace gles2 |
105 | 104 |
106 #endif // SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ | 105 #endif // SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ |
OLD | NEW |