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 #include "../client/atomicops.h" | 5 #include "../client/atomicops.h" |
6 #include "../client/share_group.h" | 6 #include "../client/share_group.h" |
7 #include "../client/gles2_implementation.h" | 7 #include "../client/gles2_implementation.h" |
8 #include "../client/program_info_manager.h" | 8 #include "../client/program_info_manager.h" |
9 #include "../common/id_allocator.h" | 9 #include "../common/id_allocator.h" |
10 #include "../common/logging.h" | 10 #include "../common/logging.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // We need to ensure that the delete call is evaluated on the service side | 52 // We need to ensure that the delete call is evaluated on the service side |
53 // before any other contexts issue commands using these client ids. | 53 // before any other contexts issue commands using these client ids. |
54 gl_impl->helper()->CommandBufferHelper::Flush(); | 54 gl_impl->helper()->CommandBufferHelper::Flush(); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 // Overridden from IdHandlerInterface. | 58 // Overridden from IdHandlerInterface. |
59 virtual bool MarkAsUsedForBind(GLuint id) { | 59 virtual bool MarkAsUsedForBind(GLuint id) { |
60 return id == 0 ? true : id_allocator_.MarkAsUsed(id); | 60 return id == 0 ? true : id_allocator_.MarkAsUsed(id); |
61 } | 61 } |
62 private: | 62 protected: |
63 IdAllocator id_allocator_; | 63 IdAllocator id_allocator_; |
64 }; | 64 }; |
65 | 65 |
66 // An id handler that require Gen before Bind. | 66 // An id handler that require Gen before Bind. |
67 class StrictIdHandler : public IdHandlerInterface { | 67 class StrictIdHandler : public IdHandler { |
68 public: | 68 public: |
69 StrictIdHandler() { } | 69 StrictIdHandler() { } |
70 virtual ~StrictIdHandler() { } | 70 virtual ~StrictIdHandler() { } |
71 | 71 |
72 // Overridden from IdHandlerInterface. | 72 // Overridden from IdHandler. |
73 virtual void Destroy(GLES2Implementation* /* gl_impl */) { | |
74 } | |
75 | |
76 // Overridden from IdHandlerInterface. | |
77 virtual void MakeIds( | |
78 GLES2Implementation* /* gl_impl */, | |
79 GLuint id_offset, GLsizei n, GLuint* ids) { | |
80 if (id_offset == 0) { | |
81 for (GLsizei ii = 0; ii < n; ++ii) { | |
82 ids[ii] = id_allocator_.AllocateID(); | |
83 } | |
84 } else { | |
85 for (GLsizei ii = 0; ii < n; ++ii) { | |
86 ids[ii] = id_allocator_.AllocateIDAtOrAbove(id_offset); | |
87 id_offset = ids[ii] + 1; | |
88 } | |
89 } | |
90 } | |
91 | |
92 // Overridden from IdHandlerInterface. | |
93 virtual bool FreeIds( | |
94 GLES2Implementation* gl_impl, | |
95 GLsizei n, const GLuint* ids, DeleteFn delete_fn) { | |
96 for (GLsizei ii = 0; ii < n; ++ii) { | |
97 id_allocator_.FreeID(ids[ii]); | |
98 } | |
99 (gl_impl->*delete_fn)(n, ids); | |
100 // We need to ensure that the delete call is evaluated on the service side | |
101 // before any other contexts issue commands using these client ids. | |
102 gl_impl->helper()->CommandBufferHelper::Flush(); | |
103 return true; | |
104 } | |
105 | |
106 // Overridden from IdHandlerInterface. | |
107 virtual bool MarkAsUsedForBind(GLuint id) { | 73 virtual bool MarkAsUsedForBind(GLuint id) { |
108 GPU_DCHECK(id == 0 || id_allocator_.InUse(id)); | 74 GPU_DCHECK(id == 0 || id_allocator_.InUse(id)); |
109 return true; | 75 return IdHandler::MarkAsUsedForBind(id); |
110 } | 76 } |
111 private: | |
112 IdAllocator id_allocator_; | |
113 }; | 77 }; |
114 | 78 |
115 // An id handler for ids that are never reused. | 79 // An id handler for ids that are never reused. |
116 class NonReusedIdHandler : public IdHandlerInterface { | 80 class NonReusedIdHandler : public IdHandlerInterface { |
117 public: | 81 public: |
118 NonReusedIdHandler() : last_id_(0) { } | 82 NonReusedIdHandler() : last_id_(0) { } |
119 virtual ~NonReusedIdHandler() { } | 83 virtual ~NonReusedIdHandler() { } |
120 | 84 |
121 // Overridden from IdHandlerInterface. | 85 // Overridden from IdHandlerInterface. |
122 virtual void Destroy(GLES2Implementation* /* gl_impl */) { | 86 virtual void Destroy(GLES2Implementation* /* gl_impl */) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 231 } |
268 | 232 |
269 void ShareGroup::SetGLES2ImplementationForDestruction( | 233 void ShareGroup::SetGLES2ImplementationForDestruction( |
270 GLES2Implementation* gl_impl) { | 234 GLES2Implementation* gl_impl) { |
271 gles2_ = gl_impl; | 235 gles2_ = gl_impl; |
272 } | 236 } |
273 | 237 |
274 | 238 |
275 } // namespace gles2 | 239 } // namespace gles2 |
276 } // namespace gpu | 240 } // namespace gpu |
277 | |
OLD | NEW |