OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 const gfx::Size& size, | 54 const gfx::Size& size, |
55 const gles2::DisallowedExtensions& disallowed_extensions, | 55 const gles2::DisallowedExtensions& disallowed_extensions, |
56 const char* allowed_extensions, | 56 const char* allowed_extensions, |
57 const std::vector<int32>& attribs, | 57 const std::vector<int32>& attribs, |
58 GpuScheduler* parent, | 58 GpuScheduler* parent, |
59 uint32 parent_texture_id); | 59 uint32 parent_texture_id); |
60 | 60 |
61 void Destroy(); | 61 void Destroy(); |
62 void DestroyCommon(); | 62 void DestroyCommon(); |
63 | 63 |
64 virtual void ProcessCommands(); | 64 void PutChanged(bool sync); |
65 | 65 |
66 // Helper which causes a call to ProcessCommands to be scheduled later. | 66 // Helper which causes a call to ProcessCommands to be scheduled later. |
67 void ScheduleProcessCommands(); | 67 void ScheduleProcessCommands(); |
68 | 68 |
69 // Implementation of CommandBufferEngine. | 69 // Implementation of CommandBufferEngine. |
70 virtual Buffer GetSharedMemoryBuffer(int32 shm_id); | 70 virtual Buffer GetSharedMemoryBuffer(int32 shm_id); |
71 virtual void set_token(int32 token); | 71 virtual void set_token(int32 token); |
72 virtual bool SetGetOffset(int32 offset); | 72 virtual bool SetGetOffset(int32 offset); |
73 virtual int32 GetGetOffset(); | 73 virtual int32 GetGetOffset(); |
74 | 74 |
(...skipping 23 matching lines...) Expand all Loading... |
98 // renderer and GPU processes. | 98 // renderer and GPU processes. |
99 uint64 swap_buffers_count() const; | 99 uint64 swap_buffers_count() const; |
100 void set_acknowledged_swap_buffers_count( | 100 void set_acknowledged_swap_buffers_count( |
101 uint64 acknowledged_swap_buffers_count); | 101 uint64 acknowledged_swap_buffers_count); |
102 | 102 |
103 void DidDestroySurface(); | 103 void DidDestroySurface(); |
104 #endif | 104 #endif |
105 | 105 |
106 // Sets a callback that is called when a glResizeCHROMIUM command | 106 // Sets a callback that is called when a glResizeCHROMIUM command |
107 // is processed. | 107 // is processed. |
108 virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback); | 108 void SetResizeCallback(Callback1<gfx::Size>::Type* callback); |
109 | 109 |
110 // Sets a callback which is called when a SwapBuffers command is processed. | 110 // Sets a callback which is called when a SwapBuffers command is processed. |
111 // Must be called after Initialize(). | 111 // Must be called after Initialize(). |
112 // It is not defined on which thread this callback is called. | 112 // It is not defined on which thread this callback is called. |
113 virtual void SetSwapBuffersCallback(Callback0::Type* callback); | 113 void SetSwapBuffersCallback(Callback0::Type* callback); |
114 | 114 |
115 virtual void SetCommandProcessedCallback(Callback0::Type* callback); | 115 void SetCommandProcessedCallback(Callback0::Type* callback); |
116 | 116 |
117 // Sets a callback which is called after a Set/WaitLatch command is processed. | 117 // Sets a callback which is called after a Set/WaitLatch command is processed. |
118 // The bool parameter will be true for SetLatch, and false for a WaitLatch | 118 // The bool parameter will be true for SetLatch, and false for a WaitLatch |
119 // that is blocked. An unblocked WaitLatch will not trigger a callback. | 119 // that is blocked. An unblocked WaitLatch will not trigger a callback. |
120 void SetLatchCallback(const base::Callback<void(bool)>& callback) { | 120 void SetLatchCallback(const base::Callback<void(bool)>& callback) { |
121 decoder_->SetLatchCallback(callback); | 121 decoder_->SetLatchCallback(callback); |
122 } | 122 } |
123 | 123 |
124 // Get the GLES2Decoder associated with this scheduler. | 124 // Get the GLES2Decoder associated with this scheduler. |
125 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 125 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
126 | 126 |
127 protected: | 127 protected: |
128 // Perform common initialization. Takes ownership of GLContext. | 128 // Perform common initialization. Takes ownership of GLContext. |
129 bool InitializeCommon( | 129 bool InitializeCommon( |
130 gfx::GLContext* context, | 130 gfx::GLContext* context, |
131 const gfx::Size& size, | 131 const gfx::Size& size, |
132 const gles2::DisallowedExtensions& disallowed_extensions, | 132 const gles2::DisallowedExtensions& disallowed_extensions, |
133 const char* allowed_extensions, | 133 const char* allowed_extensions, |
134 const std::vector<int32>& attribs, | 134 const std::vector<int32>& attribs, |
135 gles2::GLES2Decoder* parent_decoder, | 135 gles2::GLES2Decoder* parent_decoder, |
136 uint32 parent_texture_id); | 136 uint32 parent_texture_id); |
137 | 137 |
138 | 138 |
139 private: | 139 private: |
140 // Called via a callback just before we are supposed to call the | 140 // Called via a callback just before we are supposed to call the |
141 // user's swap buffers callback. | 141 // user's swap buffers callback. |
142 virtual void WillSwapBuffers(); | 142 void WillSwapBuffers(); |
| 143 void ProcessCommands(); |
143 | 144 |
144 // The GpuScheduler holds a weak reference to the CommandBuffer. The | 145 // The GpuScheduler holds a weak reference to the CommandBuffer. The |
145 // CommandBuffer owns the GpuScheduler and holds a strong reference to it | 146 // CommandBuffer owns the GpuScheduler and holds a strong reference to it |
146 // through the ProcessCommands callback. | 147 // through the ProcessCommands callback. |
147 CommandBuffer* command_buffer_; | 148 CommandBuffer* command_buffer_; |
148 | 149 |
149 int commands_per_update_; | 150 int commands_per_update_; |
150 | 151 |
151 scoped_ptr<gles2::GLES2Decoder> decoder_; | 152 scoped_ptr<gles2::GLES2Decoder> decoder_; |
152 scoped_ptr<CommandParser> parser_; | 153 scoped_ptr<CommandParser> parser_; |
153 | 154 |
154 #if defined(OS_MACOSX) | 155 #if defined(OS_MACOSX) |
155 scoped_ptr<AcceleratedSurface> surface_; | 156 scoped_ptr<AcceleratedSurface> surface_; |
156 uint64 swap_buffers_count_; | 157 uint64 swap_buffers_count_; |
157 uint64 acknowledged_swap_buffers_count_; | 158 uint64 acknowledged_swap_buffers_count_; |
158 #endif | 159 #endif |
159 | 160 |
160 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; | 161 ScopedRunnableMethodFactory<GpuScheduler> method_factory_; |
161 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; | 162 scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; |
162 scoped_ptr<Callback0::Type> command_processed_callback_; | 163 scoped_ptr<Callback0::Type> command_processed_callback_; |
163 }; | 164 }; |
164 | 165 |
165 } // namespace gpu | 166 } // namespace gpu |
166 | 167 |
167 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ | 168 #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ |
OLD | NEW |