OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // A class to emluate GLES2 over command buffers. | 5 // A class to emluate GLES2 over command buffers. |
6 | 6 |
7 #include "../client/gles2_implementation.h" | 7 #include "../client/gles2_implementation.h" |
8 #include <GLES2/gles2_command_buffer.h> | 8 #include <GLES2/gles2_command_buffer.h> |
9 #include "../client/mapped_memory.h" | 9 #include "../client/mapped_memory.h" |
10 #include "../common/gles2_cmd_utils.h" | 10 #include "../common/gles2_cmd_utils.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 // Overridden from IdHandlerInterface. | 54 // Overridden from IdHandlerInterface. |
55 virtual bool MarkAsUsedForBind(GLuint id) { | 55 virtual bool MarkAsUsedForBind(GLuint id) { |
56 return id == 0 ? true : id_allocator_.MarkAsUsed(id); | 56 return id == 0 ? true : id_allocator_.MarkAsUsed(id); |
57 } | 57 } |
58 private: | 58 private: |
59 IdAllocator id_allocator_; | 59 IdAllocator id_allocator_; |
60 }; | 60 }; |
61 | 61 |
| 62 // An id handler for non-shared ids that are never reused. |
| 63 class NonSharedNonReusedIdHandler : public IdHandlerInterface { |
| 64 public: |
| 65 NonSharedNonReusedIdHandler() : last_id_(0) { } |
| 66 virtual ~NonSharedNonReusedIdHandler() { } |
| 67 |
| 68 // Overridden from IdHandlerInterface. |
| 69 virtual void MakeIds(GLuint id_offset, GLsizei n, GLuint* ids) { |
| 70 for (GLsizei ii = 0; ii < n; ++ii) { |
| 71 ids[ii] = ++last_id_ + id_offset; |
| 72 } |
| 73 } |
| 74 |
| 75 // Overridden from IdHandlerInterface. |
| 76 virtual void FreeIds(GLsizei /* n */, const GLuint* /* ids */) { |
| 77 // Ids are never freed. |
| 78 } |
| 79 |
| 80 // Overridden from IdHandlerInterface. |
| 81 virtual bool MarkAsUsedForBind(GLuint /* id */) { |
| 82 // This is only used for Shaders and Programs which have no bind. |
| 83 return false; |
| 84 } |
| 85 |
| 86 private: |
| 87 GLuint last_id_; |
| 88 }; |
| 89 |
62 // An id handler for shared ids. | 90 // An id handler for shared ids. |
63 class SharedIdHandler : public IdHandlerInterface { | 91 class SharedIdHandler : public IdHandlerInterface { |
64 public: | 92 public: |
65 SharedIdHandler( | 93 SharedIdHandler( |
66 GLES2Implementation* gles2, | 94 GLES2Implementation* gles2, |
67 id_namespaces::IdNamespaces id_namespace) | 95 id_namespaces::IdNamespaces id_namespace) |
68 : gles2_(gles2), | 96 : gles2_(gles2), |
69 id_namespace_(id_namespace) { | 97 id_namespace_(id_namespace) { |
70 } | 98 } |
71 | 99 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 renderbuffer_id_handler_.reset( | 460 renderbuffer_id_handler_.reset( |
433 new SharedIdHandler(this, id_namespaces::kRenderbuffers)); | 461 new SharedIdHandler(this, id_namespaces::kRenderbuffers)); |
434 program_and_shader_id_handler_.reset( | 462 program_and_shader_id_handler_.reset( |
435 new SharedIdHandler(this, id_namespaces::kProgramsAndShaders)); | 463 new SharedIdHandler(this, id_namespaces::kProgramsAndShaders)); |
436 texture_id_handler_.reset( | 464 texture_id_handler_.reset( |
437 new SharedIdHandler(this, id_namespaces::kTextures)); | 465 new SharedIdHandler(this, id_namespaces::kTextures)); |
438 } else { | 466 } else { |
439 buffer_id_handler_.reset(new NonSharedIdHandler()); | 467 buffer_id_handler_.reset(new NonSharedIdHandler()); |
440 framebuffer_id_handler_.reset(new NonSharedIdHandler()); | 468 framebuffer_id_handler_.reset(new NonSharedIdHandler()); |
441 renderbuffer_id_handler_.reset(new NonSharedIdHandler()); | 469 renderbuffer_id_handler_.reset(new NonSharedIdHandler()); |
442 program_and_shader_id_handler_.reset(new NonSharedIdHandler()); | 470 program_and_shader_id_handler_.reset(new NonSharedNonReusedIdHandler()); |
443 texture_id_handler_.reset(new NonSharedIdHandler()); | 471 texture_id_handler_.reset(new NonSharedIdHandler()); |
444 } | 472 } |
445 | 473 |
446 #if defined(GLES2_SUPPORT_CLIENT_SIDE_BUFFERS) | 474 #if defined(GLES2_SUPPORT_CLIENT_SIDE_BUFFERS) |
447 GLint max_vertex_attribs; | 475 GLint max_vertex_attribs; |
448 GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs); | 476 GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs); |
449 | 477 |
450 buffer_id_handler_->MakeIds( | 478 buffer_id_handler_->MakeIds( |
451 kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); | 479 kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); |
452 | 480 |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 } | 1641 } |
1614 | 1642 |
1615 void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) { | 1643 void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) { |
1616 SetBucketAsCString(kResultBucketId, extension); | 1644 SetBucketAsCString(kResultBucketId, extension); |
1617 helper_->RequestExtensionCHROMIUM(kResultBucketId); | 1645 helper_->RequestExtensionCHROMIUM(kResultBucketId); |
1618 helper_->SetBucketSize(kResultBucketId, 0); | 1646 helper_->SetBucketSize(kResultBucketId, 0); |
1619 } | 1647 } |
1620 | 1648 |
1621 } // namespace gles2 | 1649 } // namespace gles2 |
1622 } // namespace gpu | 1650 } // namespace gpu |
OLD | NEW |