OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 private: | 149 private: |
150 GLES2Interface* gl_; | 150 GLES2Interface* gl_; |
151 GLenum unit_; | 151 GLenum unit_; |
152 }; | 152 }; |
153 | 153 |
154 class TextureIdAllocator : public IdAllocator { | 154 class TextureIdAllocator : public IdAllocator { |
155 public: | 155 public: |
156 TextureIdAllocator(GLES2Interface* gl, | 156 TextureIdAllocator(GLES2Interface* gl, |
157 size_t texture_id_allocation_chunk_size) | 157 size_t texture_id_allocation_chunk_size) |
158 : IdAllocator(gl, texture_id_allocation_chunk_size) {} | 158 : IdAllocator(gl, texture_id_allocation_chunk_size) {} |
159 virtual ~TextureIdAllocator() { | 159 ~TextureIdAllocator() override { |
160 gl_->DeleteTextures(id_allocation_chunk_size_ - next_id_index_, | 160 gl_->DeleteTextures(id_allocation_chunk_size_ - next_id_index_, |
161 ids_.get() + next_id_index_); | 161 ids_.get() + next_id_index_); |
162 } | 162 } |
163 | 163 |
164 // Overridden from IdAllocator: | 164 // Overridden from IdAllocator: |
165 virtual GLuint NextId() override { | 165 GLuint NextId() override { |
166 if (next_id_index_ == id_allocation_chunk_size_) { | 166 if (next_id_index_ == id_allocation_chunk_size_) { |
167 gl_->GenTextures(id_allocation_chunk_size_, ids_.get()); | 167 gl_->GenTextures(id_allocation_chunk_size_, ids_.get()); |
168 next_id_index_ = 0; | 168 next_id_index_ = 0; |
169 } | 169 } |
170 | 170 |
171 return ids_[next_id_index_++]; | 171 return ids_[next_id_index_++]; |
172 } | 172 } |
173 | 173 |
174 private: | 174 private: |
175 DISALLOW_COPY_AND_ASSIGN(TextureIdAllocator); | 175 DISALLOW_COPY_AND_ASSIGN(TextureIdAllocator); |
176 }; | 176 }; |
177 | 177 |
178 class BufferIdAllocator : public IdAllocator { | 178 class BufferIdAllocator : public IdAllocator { |
179 public: | 179 public: |
180 BufferIdAllocator(GLES2Interface* gl, size_t buffer_id_allocation_chunk_size) | 180 BufferIdAllocator(GLES2Interface* gl, size_t buffer_id_allocation_chunk_size) |
181 : IdAllocator(gl, buffer_id_allocation_chunk_size) {} | 181 : IdAllocator(gl, buffer_id_allocation_chunk_size) {} |
182 virtual ~BufferIdAllocator() { | 182 ~BufferIdAllocator() override { |
183 gl_->DeleteBuffers(id_allocation_chunk_size_ - next_id_index_, | 183 gl_->DeleteBuffers(id_allocation_chunk_size_ - next_id_index_, |
184 ids_.get() + next_id_index_); | 184 ids_.get() + next_id_index_); |
185 } | 185 } |
186 | 186 |
187 // Overridden from IdAllocator: | 187 // Overridden from IdAllocator: |
188 virtual GLuint NextId() override { | 188 GLuint NextId() override { |
189 if (next_id_index_ == id_allocation_chunk_size_) { | 189 if (next_id_index_ == id_allocation_chunk_size_) { |
190 gl_->GenBuffers(id_allocation_chunk_size_, ids_.get()); | 190 gl_->GenBuffers(id_allocation_chunk_size_, ids_.get()); |
191 next_id_index_ = 0; | 191 next_id_index_ = 0; |
192 } | 192 } |
193 | 193 |
194 return ids_[next_id_index_++]; | 194 return ids_[next_id_index_++]; |
195 } | 195 } |
196 | 196 |
197 private: | 197 private: |
198 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); | 198 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); |
199 }; | 199 }; |
200 | 200 |
201 // Generic fence implementation for query objects. Fence has passed when query | 201 // Generic fence implementation for query objects. Fence has passed when query |
202 // result is available. | 202 // result is available. |
203 class QueryFence : public ResourceProvider::Fence { | 203 class QueryFence : public ResourceProvider::Fence { |
204 public: | 204 public: |
205 QueryFence(gpu::gles2::GLES2Interface* gl, unsigned query_id) | 205 QueryFence(gpu::gles2::GLES2Interface* gl, unsigned query_id) |
206 : gl_(gl), query_id_(query_id) {} | 206 : gl_(gl), query_id_(query_id) {} |
207 | 207 |
208 // Overridden from ResourceProvider::Fence: | 208 // Overridden from ResourceProvider::Fence: |
209 virtual void Set() override {} | 209 void Set() override {} |
210 virtual bool HasPassed() override { | 210 bool HasPassed() override { |
211 unsigned available = 1; | 211 unsigned available = 1; |
212 gl_->GetQueryObjectuivEXT( | 212 gl_->GetQueryObjectuivEXT( |
213 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); | 213 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); |
214 return !!available; | 214 return !!available; |
215 } | 215 } |
216 | 216 |
217 private: | 217 private: |
218 virtual ~QueryFence() {} | 218 ~QueryFence() override {} |
219 | 219 |
220 gpu::gles2::GLES2Interface* gl_; | 220 gpu::gles2::GLES2Interface* gl_; |
221 unsigned query_id_; | 221 unsigned query_id_; |
222 | 222 |
223 DISALLOW_COPY_AND_ASSIGN(QueryFence); | 223 DISALLOW_COPY_AND_ASSIGN(QueryFence); |
224 }; | 224 }; |
225 | 225 |
226 } // namespace | 226 } // namespace |
227 | 227 |
228 ResourceProvider::Resource::Resource() | 228 ResourceProvider::Resource::Resource() |
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 ContextProvider* context_provider = output_surface_->context_provider(); | 2091 ContextProvider* context_provider = output_surface_->context_provider(); |
2092 return context_provider ? context_provider->ContextGL() : NULL; | 2092 return context_provider ? context_provider->ContextGL() : NULL; |
2093 } | 2093 } |
2094 | 2094 |
2095 class GrContext* ResourceProvider::GrContext() const { | 2095 class GrContext* ResourceProvider::GrContext() const { |
2096 ContextProvider* context_provider = output_surface_->context_provider(); | 2096 ContextProvider* context_provider = output_surface_->context_provider(); |
2097 return context_provider ? context_provider->GrContext() : NULL; | 2097 return context_provider ? context_provider->GrContext() : NULL; |
2098 } | 2098 } |
2099 | 2099 |
2100 } // namespace cc | 2100 } // namespace cc |
OLD | NEW |