Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: cc/resources/resource_provider.cc

Issue 1157943004: cc: [WIP] Use worker context and OrderingBarrierCHROMIUM for one-copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle sync while copying texture. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 next_id_index_ = 0; 200 next_id_index_ = 0;
201 } 201 }
202 202
203 return ids_[next_id_index_++]; 203 return ids_[next_id_index_++];
204 } 204 }
205 205
206 private: 206 private:
207 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); 207 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator);
208 }; 208 };
209 209
210 // Query object based fence implementation used to detect completion of copy 210 } // namespace
211 // texture operations. Fence has passed when query result is available.
212 class CopyTextureFence : public ResourceProvider::Fence {
213 public:
214 CopyTextureFence(gpu::gles2::GLES2Interface* gl, unsigned query_id)
215 : gl_(gl), query_id_(query_id) {}
216 211
217 // Overridden from ResourceProvider::Fence: 212 bool ResourceProvider::CopyTextureFence::HasPassed() {
218 void Set() override {} 213 unsigned available = 1;
219 bool HasPassed() override { 214 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_AVAILABLE_EXT,
220 unsigned available = 1; 215 &available);
221 gl_->GetQueryObjectuivEXT( 216 if (!available)
222 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); 217 return false;
223 if (!available)
224 return false;
225 218
226 ProcessResult(); 219 ProcessResult();
227 return true; 220 return true;
228 } 221 }
229 void Wait() override { 222 void ResourceProvider::CopyTextureFence::Wait() {
230 // ProcessResult() will wait for result to become available. 223 // ProcessResult() will wait for result to become available.
231 ProcessResult(); 224 ProcessResult();
232 } 225 }
233 226
234 private: 227 void ResourceProvider::CopyTextureFence::ProcessResult() {
235 ~CopyTextureFence() override {}
236
237 void ProcessResult() {
238 unsigned time_elapsed_us = 0; 228 unsigned time_elapsed_us = 0;
239 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_EXT, &time_elapsed_us); 229 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_EXT, &time_elapsed_us);
240 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.CopyTextureLatency", time_elapsed_us, 230 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.CopyTextureLatency", time_elapsed_us,
241 0, 256000, 50); 231 0, 256000, 50);
242 } 232 }
243 233
244 gpu::gles2::GLES2Interface* gl_;
245 unsigned query_id_;
246
247 DISALLOW_COPY_AND_ASSIGN(CopyTextureFence);
248 };
249
250 } // namespace
251
252 ResourceProvider::Resource::~Resource() {} 234 ResourceProvider::Resource::~Resource() {}
253 235
254 ResourceProvider::Resource::Resource(GLuint texture_id, 236 ResourceProvider::Resource::Resource(GLuint texture_id,
255 const gfx::Size& size, 237 const gfx::Size& size,
256 Origin origin, 238 Origin origin,
257 GLenum target, 239 GLenum target,
258 GLenum filter, 240 GLenum filter,
259 GLenum texture_pool, 241 GLenum texture_pool,
260 GLint wrap_mode, 242 GLint wrap_mode,
261 TextureHint hint, 243 TextureHint hint,
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 } 2040 }
2059 2041
2060 class GrContext* ResourceProvider::GrContext(bool worker_context) const { 2042 class GrContext* ResourceProvider::GrContext(bool worker_context) const {
2061 ContextProvider* context_provider = 2043 ContextProvider* context_provider =
2062 worker_context ? output_surface_->worker_context_provider() 2044 worker_context ? output_surface_->worker_context_provider()
2063 : output_surface_->context_provider(); 2045 : output_surface_->context_provider();
2064 return context_provider ? context_provider->GrContext() : NULL; 2046 return context_provider ? context_provider->GrContext() : NULL;
2065 } 2047 }
2066 2048
2067 } // namespace cc 2049 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698