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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 public: | 136 public: |
137 TextureIdAllocator(GLES2Interface* gl, | 137 TextureIdAllocator(GLES2Interface* gl, |
138 size_t texture_id_allocation_chunk_size) | 138 size_t texture_id_allocation_chunk_size) |
139 : IdAllocator(gl, texture_id_allocation_chunk_size) {} | 139 : IdAllocator(gl, texture_id_allocation_chunk_size) {} |
140 virtual ~TextureIdAllocator() { | 140 virtual ~TextureIdAllocator() { |
141 gl_->DeleteTextures(id_allocation_chunk_size_ - next_id_index_, | 141 gl_->DeleteTextures(id_allocation_chunk_size_ - next_id_index_, |
142 ids_.get() + next_id_index_); | 142 ids_.get() + next_id_index_); |
143 } | 143 } |
144 | 144 |
145 // Overridden from IdAllocator: | 145 // Overridden from IdAllocator: |
146 virtual GLuint NextId() OVERRIDE { | 146 virtual GLuint NextId() override { |
147 if (next_id_index_ == id_allocation_chunk_size_) { | 147 if (next_id_index_ == id_allocation_chunk_size_) { |
148 gl_->GenTextures(id_allocation_chunk_size_, ids_.get()); | 148 gl_->GenTextures(id_allocation_chunk_size_, ids_.get()); |
149 next_id_index_ = 0; | 149 next_id_index_ = 0; |
150 } | 150 } |
151 | 151 |
152 return ids_[next_id_index_++]; | 152 return ids_[next_id_index_++]; |
153 } | 153 } |
154 | 154 |
155 private: | 155 private: |
156 DISALLOW_COPY_AND_ASSIGN(TextureIdAllocator); | 156 DISALLOW_COPY_AND_ASSIGN(TextureIdAllocator); |
157 }; | 157 }; |
158 | 158 |
159 class BufferIdAllocator : public IdAllocator { | 159 class BufferIdAllocator : public IdAllocator { |
160 public: | 160 public: |
161 BufferIdAllocator(GLES2Interface* gl, size_t buffer_id_allocation_chunk_size) | 161 BufferIdAllocator(GLES2Interface* gl, size_t buffer_id_allocation_chunk_size) |
162 : IdAllocator(gl, buffer_id_allocation_chunk_size) {} | 162 : IdAllocator(gl, buffer_id_allocation_chunk_size) {} |
163 virtual ~BufferIdAllocator() { | 163 virtual ~BufferIdAllocator() { |
164 gl_->DeleteBuffers(id_allocation_chunk_size_ - next_id_index_, | 164 gl_->DeleteBuffers(id_allocation_chunk_size_ - next_id_index_, |
165 ids_.get() + next_id_index_); | 165 ids_.get() + next_id_index_); |
166 } | 166 } |
167 | 167 |
168 // Overridden from IdAllocator: | 168 // Overridden from IdAllocator: |
169 virtual GLuint NextId() OVERRIDE { | 169 virtual GLuint NextId() override { |
170 if (next_id_index_ == id_allocation_chunk_size_) { | 170 if (next_id_index_ == id_allocation_chunk_size_) { |
171 gl_->GenBuffers(id_allocation_chunk_size_, ids_.get()); | 171 gl_->GenBuffers(id_allocation_chunk_size_, ids_.get()); |
172 next_id_index_ = 0; | 172 next_id_index_ = 0; |
173 } | 173 } |
174 | 174 |
175 return ids_[next_id_index_++]; | 175 return ids_[next_id_index_++]; |
176 } | 176 } |
177 | 177 |
178 private: | 178 private: |
179 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); | 179 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); |
180 }; | 180 }; |
181 | 181 |
182 // Generic fence implementation for query objects. Fence has passed when query | 182 // Generic fence implementation for query objects. Fence has passed when query |
183 // result is available. | 183 // result is available. |
184 class QueryFence : public ResourceProvider::Fence { | 184 class QueryFence : public ResourceProvider::Fence { |
185 public: | 185 public: |
186 QueryFence(gpu::gles2::GLES2Interface* gl, unsigned query_id) | 186 QueryFence(gpu::gles2::GLES2Interface* gl, unsigned query_id) |
187 : gl_(gl), query_id_(query_id) {} | 187 : gl_(gl), query_id_(query_id) {} |
188 | 188 |
189 // Overridden from ResourceProvider::Fence: | 189 // Overridden from ResourceProvider::Fence: |
190 virtual void Set() OVERRIDE {} | 190 virtual void Set() override {} |
191 virtual bool HasPassed() OVERRIDE { | 191 virtual bool HasPassed() override { |
192 unsigned available = 1; | 192 unsigned available = 1; |
193 gl_->GetQueryObjectuivEXT( | 193 gl_->GetQueryObjectuivEXT( |
194 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); | 194 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); |
195 return !!available; | 195 return !!available; |
196 } | 196 } |
197 | 197 |
198 private: | 198 private: |
199 virtual ~QueryFence() {} | 199 virtual ~QueryFence() {} |
200 | 200 |
201 gpu::gles2::GLES2Interface* gl_; | 201 gpu::gles2::GLES2Interface* gl_; |
(...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 ContextProvider* context_provider = output_surface_->context_provider(); | 2073 ContextProvider* context_provider = output_surface_->context_provider(); |
2074 return context_provider ? context_provider->ContextGL() : NULL; | 2074 return context_provider ? context_provider->ContextGL() : NULL; |
2075 } | 2075 } |
2076 | 2076 |
2077 class GrContext* ResourceProvider::GrContext() const { | 2077 class GrContext* ResourceProvider::GrContext() const { |
2078 ContextProvider* context_provider = output_surface_->context_provider(); | 2078 ContextProvider* context_provider = output_surface_->context_provider(); |
2079 return context_provider ? context_provider->GrContext() : NULL; | 2079 return context_provider ? context_provider->GrContext() : NULL; |
2080 } | 2080 } |
2081 | 2081 |
2082 } // namespace cc | 2082 } // namespace cc |
OLD | NEW |