OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CLIENT_GLES2_IMPLEMENTATION_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <list> | 11 #include <list> |
12 #include <map> | 12 #include <map> |
13 #include <queue> | 13 #include <queue> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
23 #include "base/trace_event/memory_dump_provider.h" | 23 #include "base/trace_event/memory_dump_provider.h" |
24 #include "gpu/command_buffer/client/buffer_tracker.h" | 24 #include "gpu/command_buffer/client/buffer_tracker.h" |
25 #include "gpu/command_buffer/client/client_context_state.h" | 25 #include "gpu/command_buffer/client/client_context_state.h" |
26 #include "gpu/command_buffer/client/context_support.h" | 26 #include "gpu/command_buffer/client/context_support.h" |
27 #include "gpu/command_buffer/client/gles2_impl_export.h" | 27 #include "gpu/command_buffer/client/gles2_impl_export.h" |
28 #include "gpu/command_buffer/client/gles2_interface.h" | 28 #include "gpu/command_buffer/client/gles2_interface.h" |
| 29 #include "gpu/command_buffer/client/gpu_control_client.h" |
29 #include "gpu/command_buffer/client/mapped_memory.h" | 30 #include "gpu/command_buffer/client/mapped_memory.h" |
30 #include "gpu/command_buffer/client/ref_counted.h" | 31 #include "gpu/command_buffer/client/ref_counted.h" |
31 #include "gpu/command_buffer/client/share_group.h" | 32 #include "gpu/command_buffer/client/share_group.h" |
32 #include "gpu/command_buffer/common/capabilities.h" | 33 #include "gpu/command_buffer/common/capabilities.h" |
33 #include "gpu/command_buffer/common/debug_marker_manager.h" | 34 #include "gpu/command_buffer/common/debug_marker_manager.h" |
34 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 35 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
35 | 36 |
36 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT | 37 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT |
37 #if defined(GLES2_INLINE_OPTIMIZATION) | 38 #if defined(GLES2_INLINE_OPTIMIZATION) |
38 // TODO(gman): Replace with macros that work with inline optmization. | 39 // TODO(gman): Replace with macros that work with inline optmization. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 class IdAllocator; | 105 class IdAllocator; |
105 class ScopedTransferBufferPtr; | 106 class ScopedTransferBufferPtr; |
106 class TransferBufferInterface; | 107 class TransferBufferInterface; |
107 | 108 |
108 namespace gles2 { | 109 namespace gles2 { |
109 | 110 |
110 class GLES2CmdHelper; | 111 class GLES2CmdHelper; |
111 class VertexArrayObjectManager; | 112 class VertexArrayObjectManager; |
112 class QueryTracker; | 113 class QueryTracker; |
113 | 114 |
114 class GLES2ImplementationErrorMessageCallback { | |
115 public: | |
116 virtual ~GLES2ImplementationErrorMessageCallback() { } | |
117 virtual void OnErrorMessage(const char* msg, int id) = 0; | |
118 }; | |
119 | |
120 // This class emulates GLES2 over command buffers. It can be used by a client | 115 // This class emulates GLES2 over command buffers. It can be used by a client |
121 // program so that the program does not need deal with shared memory and command | 116 // program so that the program does not need deal with shared memory and command |
122 // buffer management. See gl2_lib.h. Note that there is a performance gain to | 117 // buffer management. See gl2_lib.h. Note that there is a performance gain to |
123 // be had by changing your code to use command buffers directly by using the | 118 // be had by changing your code to use command buffers directly by using the |
124 // GLES2CmdHelper but that entails changing your code to use and deal with | 119 // GLES2CmdHelper but that entails changing your code to use and deal with |
125 // shared memory and synchronization issues. | 120 // shared memory and synchronization issues. |
126 class GLES2_IMPL_EXPORT GLES2Implementation | 121 class GLES2_IMPL_EXPORT GLES2Implementation |
127 : NON_EXPORTED_BASE(public GLES2Interface), | 122 : NON_EXPORTED_BASE(public GLES2Interface), |
128 NON_EXPORTED_BASE(public ContextSupport), | 123 NON_EXPORTED_BASE(public ContextSupport), |
| 124 NON_EXPORTED_BASE(public GpuControlClient), |
129 NON_EXPORTED_BASE(public base::trace_event::MemoryDumpProvider) { | 125 NON_EXPORTED_BASE(public base::trace_event::MemoryDumpProvider) { |
130 public: | 126 public: |
131 enum MappedMemoryLimit { | 127 enum MappedMemoryLimit { |
132 kNoLimit = MappedMemoryManager::kNoLimit, | 128 kNoLimit = MappedMemoryManager::kNoLimit, |
133 }; | 129 }; |
134 | 130 |
135 // Stores GL state that never changes. | 131 // Stores GL state that never changes. |
136 struct GLES2_IMPL_EXPORT GLStaticState { | 132 struct GLES2_IMPL_EXPORT GLStaticState { |
137 GLStaticState(); | 133 GLStaticState(); |
138 ~GLStaticState(); | 134 ~GLStaticState(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 void Swap() override; | 202 void Swap() override; |
207 void PartialSwapBuffers(const gfx::Rect& sub_buffer) override; | 203 void PartialSwapBuffers(const gfx::Rect& sub_buffer) override; |
208 void CommitOverlayPlanes() override; | 204 void CommitOverlayPlanes() override; |
209 void ScheduleOverlayPlane(int plane_z_order, | 205 void ScheduleOverlayPlane(int plane_z_order, |
210 gfx::OverlayTransform plane_transform, | 206 gfx::OverlayTransform plane_transform, |
211 unsigned overlay_texture_id, | 207 unsigned overlay_texture_id, |
212 const gfx::Rect& display_bounds, | 208 const gfx::Rect& display_bounds, |
213 const gfx::RectF& uv_rect) override; | 209 const gfx::RectF& uv_rect) override; |
214 uint64_t ShareGroupTracingGUID() const override; | 210 uint64_t ShareGroupTracingGUID() const override; |
215 | 211 |
| 212 // GpuControlClient implementation. |
| 213 void OnGpuControlLostContext() override; |
| 214 void OnGpuControlErrorMessage(const char* message, int32_t id) override; |
| 215 |
| 216 void SetErrorMessageCallback( |
| 217 const base::Callback<void(const char*, int32_t)>& callback); |
| 218 void SetLostContextCallback(const base::Closure& callback); |
| 219 |
216 void GetProgramInfoCHROMIUMHelper(GLuint program, | 220 void GetProgramInfoCHROMIUMHelper(GLuint program, |
217 std::vector<int8_t>* result); | 221 std::vector<int8_t>* result); |
218 GLint GetAttribLocationHelper(GLuint program, const char* name); | 222 GLint GetAttribLocationHelper(GLuint program, const char* name); |
219 GLint GetUniformLocationHelper(GLuint program, const char* name); | 223 GLint GetUniformLocationHelper(GLuint program, const char* name); |
220 GLint GetFragDataIndexEXTHelper(GLuint program, const char* name); | 224 GLint GetFragDataIndexEXTHelper(GLuint program, const char* name); |
221 GLint GetFragDataLocationHelper(GLuint program, const char* name); | 225 GLint GetFragDataLocationHelper(GLuint program, const char* name); |
222 bool GetActiveAttribHelper( | 226 bool GetActiveAttribHelper( |
223 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, | 227 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, |
224 GLint* size, GLenum* type, char* name); | 228 GLint* size, GLenum* type, char* name); |
225 bool GetActiveUniformHelper( | 229 bool GetActiveUniformHelper( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // ContextSupport implementation. | 261 // ContextSupport implementation. |
258 void SignalSyncToken(const gpu::SyncToken& sync_token, | 262 void SignalSyncToken(const gpu::SyncToken& sync_token, |
259 const base::Closure& callback) override; | 263 const base::Closure& callback) override; |
260 void SignalQuery(uint32_t query, const base::Closure& callback) override; | 264 void SignalQuery(uint32_t query, const base::Closure& callback) override; |
261 void SetAggressivelyFreeResources(bool aggressively_free_resources) override; | 265 void SetAggressivelyFreeResources(bool aggressively_free_resources) override; |
262 | 266 |
263 // base::trace_event::MemoryDumpProvider implementation. | 267 // base::trace_event::MemoryDumpProvider implementation. |
264 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 268 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
265 base::trace_event::ProcessMemoryDump* pmd) override; | 269 base::trace_event::ProcessMemoryDump* pmd) override; |
266 | 270 |
267 void SetErrorMessageCallback( | |
268 GLES2ImplementationErrorMessageCallback* callback) { | |
269 error_message_callback_ = callback; | |
270 } | |
271 | |
272 ShareGroup* share_group() const { | 271 ShareGroup* share_group() const { |
273 return share_group_.get(); | 272 return share_group_.get(); |
274 } | 273 } |
275 | 274 |
276 const Capabilities& capabilities() const { | 275 const Capabilities& capabilities() const { |
277 return capabilities_; | 276 return capabilities_; |
278 } | 277 } |
279 | 278 |
280 GpuControl* gpu_control() { | 279 GpuControl* gpu_control() { |
281 return gpu_control_; | 280 return gpu_control_; |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 scoped_ptr<MappedMemoryManager> mapped_memory_; | 817 scoped_ptr<MappedMemoryManager> mapped_memory_; |
819 | 818 |
820 scoped_refptr<ShareGroup> share_group_; | 819 scoped_refptr<ShareGroup> share_group_; |
821 ShareGroupContextData share_group_context_data_; | 820 ShareGroupContextData share_group_context_data_; |
822 | 821 |
823 scoped_ptr<QueryTracker> query_tracker_; | 822 scoped_ptr<QueryTracker> query_tracker_; |
824 scoped_ptr<IdAllocator> query_id_allocator_; | 823 scoped_ptr<IdAllocator> query_id_allocator_; |
825 | 824 |
826 scoped_ptr<BufferTracker> buffer_tracker_; | 825 scoped_ptr<BufferTracker> buffer_tracker_; |
827 | 826 |
828 GLES2ImplementationErrorMessageCallback* error_message_callback_; | 827 base::Callback<void(const char*, int32_t)> error_message_callback_; |
| 828 base::Closure lost_context_callback_; |
829 | 829 |
830 int current_trace_stack_; | 830 int current_trace_stack_; |
831 | 831 |
832 GpuControl* gpu_control_; | 832 GpuControl* gpu_control_; |
833 | 833 |
834 Capabilities capabilities_; | 834 Capabilities capabilities_; |
835 | 835 |
836 // Flag to indicate whether the implementation can retain resources, or | 836 // Flag to indicate whether the implementation can retain resources, or |
837 // whether it should aggressively free them. | 837 // whether it should aggressively free them. |
838 bool aggressively_free_resources_; | 838 bool aggressively_free_resources_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 887 |
888 inline bool GLES2Implementation::GetTexParameterivHelper( | 888 inline bool GLES2Implementation::GetTexParameterivHelper( |
889 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 889 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
890 return false; | 890 return false; |
891 } | 891 } |
892 | 892 |
893 } // namespace gles2 | 893 } // namespace gles2 |
894 } // namespace gpu | 894 } // namespace gpu |
895 | 895 |
896 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 896 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
OLD | NEW |