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_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 <GLES2/gl2.h> | 8 #include <GLES2/gl2.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <queue> | 11 #include <queue> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "../common/gles2_cmd_utils.h" | 16 #include "../common/gles2_cmd_utils.h" |
17 #include "../common/scoped_ptr.h" | 17 #include "../common/scoped_ptr.h" |
18 #include "../client/gles2_cmd_helper.h" | 18 #include "../client/gles2_cmd_helper.h" |
19 #include "../client/ring_buffer.h" | 19 #include "../client/ring_buffer.h" |
20 | 20 |
21 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT | 21 #if !defined(NDEBUG) && !defined(__native_client__) && !defined(GLES2_CONFORMANC
E_TESTS) // NOLINT |
22 #if defined(GLES2_INLINE_OPTIMIZATION) | 22 #if defined(GLES2_INLINE_OPTIMIZATION) |
23 // TODO(gman): Replace with macros that work with inline optmization. | 23 // TODO(gman): Replace with macros that work with inline optmization. |
| 24 #define GPU_CLIENT_SINGLE_THREAD_CHECK() |
24 #define GPU_CLIENT_LOG(args) | 25 #define GPU_CLIENT_LOG(args) |
25 #define GPU_CLIENT_LOG_CODE_BLOCK(code) | 26 #define GPU_CLIENT_LOG_CODE_BLOCK(code) |
26 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) | 27 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) |
27 #else | 28 #else |
28 #include "base/logging.h" | 29 #include "base/logging.h" |
| 30 #define GPU_CLIENT_SINGLE_THREAD_CHECK() SingleThreadChecker checker(this); |
29 #define GPU_CLIENT_LOG(args) DLOG_IF(INFO, debug_) << args; | 31 #define GPU_CLIENT_LOG(args) DLOG_IF(INFO, debug_) << args; |
30 #define GPU_CLIENT_LOG_CODE_BLOCK(code) code | 32 #define GPU_CLIENT_LOG_CODE_BLOCK(code) code |
31 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) code | 33 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) code |
32 #define GPU_CLIENT_DEBUG | 34 #define GPU_CLIENT_DEBUG |
33 #endif | 35 #endif |
34 #else | 36 #else |
| 37 #define GPU_CLIENT_SINGLE_THREAD_CHECK() |
35 #define GPU_CLIENT_LOG(args) | 38 #define GPU_CLIENT_LOG(args) |
36 #define GPU_CLIENT_LOG_CODE_BLOCK(code) | 39 #define GPU_CLIENT_LOG_CODE_BLOCK(code) |
37 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) | 40 #define GPU_CLIENT_DCHECK_CODE_BLOCK(code) |
38 #endif | 41 #endif |
39 | 42 |
40 // Check that destination pointers point to initialized memory. | 43 // Check that destination pointers point to initialized memory. |
41 // When the context is lost, calling GL function has no effect so if destination | 44 // When the context is lost, calling GL function has no effect so if destination |
42 // pointers point to initialized memory it can often lead to crash bugs. eg. | 45 // pointers point to initialized memory it can often lead to crash bugs. eg. |
43 // | 46 // |
44 // GLsizei len; | 47 // GLsizei len; |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 379 } |
377 | 380 |
378 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture | 381 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture |
379 GLuint bound_texture_2d; | 382 GLuint bound_texture_2d; |
380 | 383 |
381 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with | 384 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with |
382 // glBindTexture | 385 // glBindTexture |
383 GLuint bound_texture_cube_map; | 386 GLuint bound_texture_cube_map; |
384 }; | 387 }; |
385 | 388 |
| 389 // Checks for single threaded access. |
| 390 class SingleThreadChecker { |
| 391 public: |
| 392 SingleThreadChecker(GLES2Implementation* gles2_implementation); |
| 393 ~SingleThreadChecker(); |
| 394 |
| 395 private: |
| 396 GLES2Implementation* gles2_implementation_; |
| 397 }; |
| 398 |
386 // Gets the value of the result. | 399 // Gets the value of the result. |
387 template <typename T> | 400 template <typename T> |
388 T GetResultAs() { | 401 T GetResultAs() { |
389 return static_cast<T>(transfer_buffer_.GetResultBuffer()); | 402 return static_cast<T>(transfer_buffer_.GetResultBuffer()); |
390 } | 403 } |
391 | 404 |
392 int32 GetResultShmId() { | 405 int32 GetResultShmId() { |
393 return transfer_buffer_.GetShmId(); | 406 return transfer_buffer_.GetShmId(); |
394 } | 407 } |
395 | 408 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 uint32 error_bits_; | 548 uint32 error_bits_; |
536 | 549 |
537 // Whether or not to print debugging info. | 550 // Whether or not to print debugging info. |
538 bool debug_; | 551 bool debug_; |
539 | 552 |
540 // Whether or not this context is sharing resources. | 553 // Whether or not this context is sharing resources. |
541 bool sharing_resources_; | 554 bool sharing_resources_; |
542 | 555 |
543 bool bind_generates_resource_; | 556 bool bind_generates_resource_; |
544 | 557 |
| 558 // Used to check for single threaded access. |
| 559 int use_count_; |
| 560 |
545 // Map of GLenum to Strings for glGetString. We need to cache these because | 561 // Map of GLenum to Strings for glGetString. We need to cache these because |
546 // the pointer passed back to the client has to remain valid for eternity. | 562 // the pointer passed back to the client has to remain valid for eternity. |
547 typedef std::map<uint32, std::set<std::string> > GLStringMap; | 563 typedef std::map<uint32, std::set<std::string> > GLStringMap; |
548 GLStringMap gl_strings_; | 564 GLStringMap gl_strings_; |
549 | 565 |
550 // Similar cache for glGetRequestableExtensionsCHROMIUM. We don't | 566 // Similar cache for glGetRequestableExtensionsCHROMIUM. We don't |
551 // have an enum for this so handle it separately. | 567 // have an enum for this so handle it separately. |
552 std::set<std::string> requestable_extensions_set_; | 568 std::set<std::string> requestable_extensions_set_; |
553 | 569 |
554 typedef std::map<const void*, MappedBuffer> MappedBufferMap; | 570 typedef std::map<const void*, MappedBuffer> MappedBufferMap; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 610 |
595 inline bool GLES2Implementation::GetTexParameterivHelper( | 611 inline bool GLES2Implementation::GetTexParameterivHelper( |
596 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { | 612 GLenum /* target */, GLenum /* pname */, GLint* /* params */) { |
597 return false; | 613 return false; |
598 } | 614 } |
599 | 615 |
600 } // namespace gles2 | 616 } // namespace gles2 |
601 } // namespace gpu | 617 } // namespace gpu |
602 | 618 |
603 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ | 619 #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ |
OLD | NEW |