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

Side by Side Diff: trunk/src/cc/output/gl_renderer.cc

Issue 299923005: Revert 272565 "Re-land: cc: Fail more visibly when sync queries ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 default: 168 default:
169 NOTREACHED(); 169 NOTREACHED();
170 return SamplerType2D; 170 return SamplerType2D;
171 } 171 }
172 } 172 }
173 173
174 // Smallest unit that impact anti-aliasing output. We use this to 174 // Smallest unit that impact anti-aliasing output. We use this to
175 // determine when anti-aliasing is unnecessary. 175 // determine when anti-aliasing is unnecessary.
176 const float kAntiAliasingEpsilon = 1.0f / 1024.0f; 176 const float kAntiAliasingEpsilon = 1.0f / 1024.0f;
177 177
178 // Block or crash if the number of pending sync queries reach this high as
179 // something is seriously wrong on the service side if this happens.
180 const size_t kMaxPendingSyncQueries = 16;
181
182 } // anonymous namespace 178 } // anonymous namespace
183 179
184 class GLRenderer::ScopedUseGrContext { 180 class GLRenderer::ScopedUseGrContext {
185 public: 181 public:
186 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, 182 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer,
187 DrawingFrame* frame) { 183 DrawingFrame* frame) {
188 if (!renderer->output_surface_->context_provider()->GrContext()) 184 if (!renderer->output_surface_->context_provider()->GrContext())
189 return scoped_ptr<ScopedUseGrContext>(); 185 return scoped_ptr<ScopedUseGrContext>();
190 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); 186 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame));
191 } 187 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 241
246 void End() { gl_->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); } 242 void End() { gl_->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); }
247 243
248 bool IsPending() { 244 bool IsPending() {
249 unsigned available = 1; 245 unsigned available = 1;
250 gl_->GetQueryObjectuivEXT( 246 gl_->GetQueryObjectuivEXT(
251 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); 247 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available);
252 return !available; 248 return !available;
253 } 249 }
254 250
255 void Wait() {
256 unsigned result = 0;
257 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_EXT, &result);
258 }
259
260 private: 251 private:
261 class Fence : public ResourceProvider::Fence { 252 class Fence : public ResourceProvider::Fence {
262 public: 253 public:
263 explicit Fence(base::WeakPtr<GLRenderer::SyncQuery> query) 254 explicit Fence(base::WeakPtr<GLRenderer::SyncQuery> query)
264 : query_(query) {} 255 : query_(query) {}
265 256
266 // Overridden from ResourceProvider::Fence: 257 // Overridden from ResourceProvider::Fence:
267 virtual bool HasPassed() OVERRIDE { 258 virtual bool HasPassed() OVERRIDE {
268 return !query_ || !query_->IsPending(); 259 return !query_ || !query_->IsPending();
269 } 260 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 434 }
444 435
445 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { 436 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) {
446 if (frame->device_viewport_rect.IsEmpty()) 437 if (frame->device_viewport_rect.IsEmpty())
447 return; 438 return;
448 439
449 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); 440 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame");
450 441
451 scoped_refptr<ResourceProvider::Fence> read_lock_fence; 442 scoped_refptr<ResourceProvider::Fence> read_lock_fence;
452 if (use_sync_query_) { 443 if (use_sync_query_) {
453 // Block until oldest sync query has passed if the number of pending queries
454 // ever reach kMaxPendingSyncQueries.
455 if (pending_sync_queries_.size() >= kMaxPendingSyncQueries) {
456 LOG(ERROR) << "Reached limit of pending sync queries.";
457
458 pending_sync_queries_.front()->Wait();
459 DCHECK(!pending_sync_queries_.front()->IsPending());
460 }
461
462 while (!pending_sync_queries_.empty()) { 444 while (!pending_sync_queries_.empty()) {
463 if (pending_sync_queries_.front()->IsPending()) 445 if (pending_sync_queries_.front()->IsPending())
464 break; 446 break;
465 447
466 available_sync_queries_.push_back(pending_sync_queries_.take_front()); 448 available_sync_queries_.push_back(pending_sync_queries_.take_front());
467 } 449 }
468 450
469 current_sync_query_ = available_sync_queries_.empty() 451 current_sync_query_ = available_sync_queries_.empty()
470 ? make_scoped_ptr(new SyncQuery(gl_)) 452 ? make_scoped_ptr(new SyncQuery(gl_))
471 : available_sync_queries_.take_front(); 453 : available_sync_queries_.take_front();
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 context_support_->ScheduleOverlayPlane( 3156 context_support_->ScheduleOverlayPlane(
3175 overlay.plane_z_order, 3157 overlay.plane_z_order,
3176 overlay.transform, 3158 overlay.transform,
3177 pending_overlay_resources_.back()->texture_id(), 3159 pending_overlay_resources_.back()->texture_id(),
3178 overlay.display_rect, 3160 overlay.display_rect,
3179 overlay.uv_rect); 3161 overlay.uv_rect);
3180 } 3162 }
3181 } 3163 }
3182 3164
3183 } // namespace cc 3165 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698