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" | |
30 #include "gpu/command_buffer/client/mapped_memory.h" | 29 #include "gpu/command_buffer/client/mapped_memory.h" |
31 #include "gpu/command_buffer/client/ref_counted.h" | 30 #include "gpu/command_buffer/client/ref_counted.h" |
32 #include "gpu/command_buffer/client/share_group.h" | 31 #include "gpu/command_buffer/client/share_group.h" |
33 #include "gpu/command_buffer/common/capabilities.h" | 32 #include "gpu/command_buffer/common/capabilities.h" |
34 #include "gpu/command_buffer/common/debug_marker_manager.h" | 33 #include "gpu/command_buffer/common/debug_marker_manager.h" |
35 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 34 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
36 | 35 |
37 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT | 36 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT |
38 #if defined(GLES2_INLINE_OPTIMIZATION) | 37 #if defined(GLES2_INLINE_OPTIMIZATION) |
39 // TODO(gman): Replace with macros that work with inline optmization. | 38 // TODO(gman): Replace with macros that work with inline optmization. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 class IdAllocator; | 104 class IdAllocator; |
106 class ScopedTransferBufferPtr; | 105 class ScopedTransferBufferPtr; |
107 class TransferBufferInterface; | 106 class TransferBufferInterface; |
108 | 107 |
109 namespace gles2 { | 108 namespace gles2 { |
110 | 109 |
111 class GLES2CmdHelper; | 110 class GLES2CmdHelper; |
112 class VertexArrayObjectManager; | 111 class VertexArrayObjectManager; |
113 class QueryTracker; | 112 class QueryTracker; |
114 | 113 |
| 114 class GLES2ImplementationErrorMessageCallback { |
| 115 public: |
| 116 virtual ~GLES2ImplementationErrorMessageCallback() { } |
| 117 virtual void OnErrorMessage(const char* msg, int id) = 0; |
| 118 }; |
| 119 |
115 // This class emulates GLES2 over command buffers. It can be used by a client | 120 // This class emulates GLES2 over command buffers. It can be used by a client |
116 // program so that the program does not need deal with shared memory and command | 121 // program so that the program does not need deal with shared memory and command |
117 // buffer management. See gl2_lib.h. Note that there is a performance gain to | 122 // buffer management. See gl2_lib.h. Note that there is a performance gain to |
118 // be had by changing your code to use command buffers directly by using the | 123 // be had by changing your code to use command buffers directly by using the |
119 // GLES2CmdHelper but that entails changing your code to use and deal with | 124 // GLES2CmdHelper but that entails changing your code to use and deal with |
120 // shared memory and synchronization issues. | 125 // shared memory and synchronization issues. |
121 class GLES2_IMPL_EXPORT GLES2Implementation | 126 class GLES2_IMPL_EXPORT GLES2Implementation |
122 : NON_EXPORTED_BASE(public GLES2Interface), | 127 : NON_EXPORTED_BASE(public GLES2Interface), |
123 NON_EXPORTED_BASE(public ContextSupport), | 128 NON_EXPORTED_BASE(public ContextSupport), |
124 NON_EXPORTED_BASE(public GpuControlClient), | |
125 NON_EXPORTED_BASE(public base::trace_event::MemoryDumpProvider) { | 129 NON_EXPORTED_BASE(public base::trace_event::MemoryDumpProvider) { |
126 public: | 130 public: |
127 enum MappedMemoryLimit { | 131 enum MappedMemoryLimit { |
128 kNoLimit = MappedMemoryManager::kNoLimit, | 132 kNoLimit = MappedMemoryManager::kNoLimit, |
129 }; | 133 }; |
130 | 134 |
131 // Stores GL state that never changes. | 135 // Stores GL state that never changes. |
132 struct GLES2_IMPL_EXPORT GLStaticState { | 136 struct GLES2_IMPL_EXPORT GLStaticState { |
133 GLStaticState(); | 137 GLStaticState(); |
134 ~GLStaticState(); | 138 ~GLStaticState(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 void Swap() override; | 206 void Swap() override; |
203 void PartialSwapBuffers(const gfx::Rect& sub_buffer) override; | 207 void PartialSwapBuffers(const gfx::Rect& sub_buffer) override; |
204 void CommitOverlayPlanes() override; | 208 void CommitOverlayPlanes() override; |
205 void ScheduleOverlayPlane(int plane_z_order, | 209 void ScheduleOverlayPlane(int plane_z_order, |
206 gfx::OverlayTransform plane_transform, | 210 gfx::OverlayTransform plane_transform, |
207 unsigned overlay_texture_id, | 211 unsigned overlay_texture_id, |
208 const gfx::Rect& display_bounds, | 212 const gfx::Rect& display_bounds, |
209 const gfx::RectF& uv_rect) override; | 213 const gfx::RectF& uv_rect) override; |
210 uint64_t ShareGroupTracingGUID() const override; | 214 uint64_t ShareGroupTracingGUID() const override; |
211 | 215 |
212 void SetErrorMessageCallback( | |
213 const base::Callback<void(const char*, int32_t)>& callback); | |
214 void SetLostContextCallback(const base::Closure& callback); | |
215 | |
216 void GetProgramInfoCHROMIUMHelper(GLuint program, | 216 void GetProgramInfoCHROMIUMHelper(GLuint program, |
217 std::vector<int8_t>* result); | 217 std::vector<int8_t>* result); |
218 GLint GetAttribLocationHelper(GLuint program, const char* name); | 218 GLint GetAttribLocationHelper(GLuint program, const char* name); |
219 GLint GetUniformLocationHelper(GLuint program, const char* name); | 219 GLint GetUniformLocationHelper(GLuint program, const char* name); |
220 GLint GetFragDataIndexEXTHelper(GLuint program, const char* name); | 220 GLint GetFragDataIndexEXTHelper(GLuint program, const char* name); |
221 GLint GetFragDataLocationHelper(GLuint program, const char* name); | 221 GLint GetFragDataLocationHelper(GLuint program, const char* name); |
222 bool GetActiveAttribHelper( | 222 bool GetActiveAttribHelper( |
223 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, | 223 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, |
224 GLint* size, GLenum* type, char* name); | 224 GLint* size, GLenum* type, char* name); |
225 bool GetActiveUniformHelper( | 225 bool GetActiveUniformHelper( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // ContextSupport implementation. | 257 // ContextSupport implementation. |
258 void SignalSyncToken(const gpu::SyncToken& sync_token, | 258 void SignalSyncToken(const gpu::SyncToken& sync_token, |
259 const base::Closure& callback) override; | 259 const base::Closure& callback) override; |
260 void SignalQuery(uint32_t query, const base::Closure& callback) override; | 260 void SignalQuery(uint32_t query, const base::Closure& callback) override; |
261 void SetAggressivelyFreeResources(bool aggressively_free_resources) override; | 261 void SetAggressivelyFreeResources(bool aggressively_free_resources) override; |
262 | 262 |
263 // base::trace_event::MemoryDumpProvider implementation. | 263 // base::trace_event::MemoryDumpProvider implementation. |
264 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 264 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
265 base::trace_event::ProcessMemoryDump* pmd) override; | 265 base::trace_event::ProcessMemoryDump* pmd) override; |
266 | 266 |
| 267 void SetErrorMessageCallback( |
| 268 GLES2ImplementationErrorMessageCallback* callback) { |
| 269 error_message_callback_ = callback; |
| 270 } |
| 271 |
267 ShareGroup* share_group() const { | 272 ShareGroup* share_group() const { |
268 return share_group_.get(); | 273 return share_group_.get(); |
269 } | 274 } |
270 | 275 |
271 const Capabilities& capabilities() const { | 276 const Capabilities& capabilities() const { |
272 return capabilities_; | 277 return capabilities_; |
273 } | 278 } |
274 | 279 |
275 GpuControl* gpu_control() { | 280 GpuControl* gpu_control() { |
276 return gpu_control_; | 281 return gpu_control_; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 private: | 411 private: |
407 GLES2Implementation* gles2_implementation_; | 412 GLES2Implementation* gles2_implementation_; |
408 }; | 413 }; |
409 | 414 |
410 // Gets the value of the result. | 415 // Gets the value of the result. |
411 template <typename T> | 416 template <typename T> |
412 T GetResultAs() { | 417 T GetResultAs() { |
413 return static_cast<T>(GetResultBuffer()); | 418 return static_cast<T>(GetResultBuffer()); |
414 } | 419 } |
415 | 420 |
416 // GpuControlClient implementation. | |
417 void OnGpuControlLostContext() final; | |
418 void OnGpuControlErrorMessage(const char* message, int32_t id) final; | |
419 | |
420 void* GetResultBuffer(); | 421 void* GetResultBuffer(); |
421 int32_t GetResultShmId(); | 422 int32_t GetResultShmId(); |
422 uint32_t GetResultShmOffset(); | 423 uint32_t GetResultShmOffset(); |
423 | 424 |
424 bool IsChromiumFramebufferMultisampleAvailable(); | 425 bool IsChromiumFramebufferMultisampleAvailable(); |
425 | 426 |
426 bool IsExtensionAvailableHelper( | 427 bool IsExtensionAvailableHelper( |
427 const char* extension, ExtensionStatus* status); | 428 const char* extension, ExtensionStatus* status); |
428 | 429 |
429 // Gets the GLError through our wrapper. | 430 // Gets the GLError through our wrapper. |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 scoped_ptr<MappedMemoryManager> mapped_memory_; | 818 scoped_ptr<MappedMemoryManager> mapped_memory_; |
818 | 819 |
819 scoped_refptr<ShareGroup> share_group_; | 820 scoped_refptr<ShareGroup> share_group_; |
820 ShareGroupContextData share_group_context_data_; | 821 ShareGroupContextData share_group_context_data_; |
821 | 822 |
822 scoped_ptr<QueryTracker> query_tracker_; | 823 scoped_ptr<QueryTracker> query_tracker_; |
823 scoped_ptr<IdAllocator> query_id_allocator_; | 824 scoped_ptr<IdAllocator> query_id_allocator_; |
824 | 825 |
825 scoped_ptr<BufferTracker> buffer_tracker_; | 826 scoped_ptr<BufferTracker> buffer_tracker_; |
826 | 827 |
827 base::Callback<void(const char*, int32_t)> error_message_callback_; | 828 GLES2ImplementationErrorMessageCallback* error_message_callback_; |
828 base::Closure lost_context_callback_; | |
829 #if DCHECK_IS_ON() | |
830 bool lost_context_ = false; | |
831 #endif | |
832 | 829 |
833 int current_trace_stack_; | 830 int current_trace_stack_; |
834 | 831 |
835 GpuControl* gpu_control_; | 832 GpuControl* gpu_control_; |
836 | 833 |
837 Capabilities capabilities_; | 834 Capabilities capabilities_; |
838 | 835 |
839 // Flag to indicate whether the implementation can retain resources, or | 836 // Flag to indicate whether the implementation can retain resources, or |
840 // whether it should aggressively free them. | 837 // whether it should aggressively free them. |
841 bool aggressively_free_resources_; | 838 bool aggressively_free_resources_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 | 887 |
891 inline bool GLES2Implementation::GetTexParameterivHelper( | 888 inline bool GLES2Implementation::GetTexParameterivHelper( |
892 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 889 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
893 return false; | 890 return false; |
894 } | 891 } |
895 | 892 |
896 } // namespace gles2 | 893 } // namespace gles2 |
897 } // namespace gpu | 894 } // namespace gpu |
898 | 895 |
899 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 896 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
OLD | NEW |