OLD | NEW |
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 Loading... |
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 |
178 } // anonymous namespace | 182 } // anonymous namespace |
179 | 183 |
180 class GLRenderer::ScopedUseGrContext { | 184 class GLRenderer::ScopedUseGrContext { |
181 public: | 185 public: |
182 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, | 186 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, |
183 DrawingFrame* frame) { | 187 DrawingFrame* frame) { |
184 if (!renderer->output_surface_->context_provider()->GrContext()) | 188 if (!renderer->output_surface_->context_provider()->GrContext()) |
185 return scoped_ptr<ScopedUseGrContext>(); | 189 return scoped_ptr<ScopedUseGrContext>(); |
186 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); | 190 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); |
187 } | 191 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 245 |
242 void End() { gl_->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); } | 246 void End() { gl_->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); } |
243 | 247 |
244 bool IsPending() { | 248 bool IsPending() { |
245 unsigned available = 1; | 249 unsigned available = 1; |
246 gl_->GetQueryObjectuivEXT( | 250 gl_->GetQueryObjectuivEXT( |
247 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); | 251 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); |
248 return !available; | 252 return !available; |
249 } | 253 } |
250 | 254 |
| 255 void Wait() { |
| 256 unsigned result = 0; |
| 257 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_EXT, &result); |
| 258 } |
| 259 |
251 private: | 260 private: |
252 class Fence : public ResourceProvider::Fence { | 261 class Fence : public ResourceProvider::Fence { |
253 public: | 262 public: |
254 explicit Fence(base::WeakPtr<GLRenderer::SyncQuery> query) | 263 explicit Fence(base::WeakPtr<GLRenderer::SyncQuery> query) |
255 : query_(query) {} | 264 : query_(query) {} |
256 | 265 |
257 // Overridden from ResourceProvider::Fence: | 266 // Overridden from ResourceProvider::Fence: |
258 virtual bool HasPassed() OVERRIDE { | 267 virtual bool HasPassed() OVERRIDE { |
259 return !query_ || !query_->IsPending(); | 268 return !query_ || !query_->IsPending(); |
260 } | 269 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 443 } |
435 | 444 |
436 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 445 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
437 if (frame->device_viewport_rect.IsEmpty()) | 446 if (frame->device_viewport_rect.IsEmpty()) |
438 return; | 447 return; |
439 | 448 |
440 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); | 449 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); |
441 | 450 |
442 scoped_refptr<ResourceProvider::Fence> read_lock_fence; | 451 scoped_refptr<ResourceProvider::Fence> read_lock_fence; |
443 if (use_sync_query_) { | 452 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 |
444 while (!pending_sync_queries_.empty()) { | 462 while (!pending_sync_queries_.empty()) { |
445 if (pending_sync_queries_.front()->IsPending()) | 463 if (pending_sync_queries_.front()->IsPending()) |
446 break; | 464 break; |
447 | 465 |
448 available_sync_queries_.push_back(pending_sync_queries_.take_front()); | 466 available_sync_queries_.push_back(pending_sync_queries_.take_front()); |
449 } | 467 } |
450 | 468 |
451 current_sync_query_ = available_sync_queries_.empty() | 469 current_sync_query_ = available_sync_queries_.empty() |
452 ? make_scoped_ptr(new SyncQuery(gl_)) | 470 ? make_scoped_ptr(new SyncQuery(gl_)) |
453 : available_sync_queries_.take_front(); | 471 : available_sync_queries_.take_front(); |
(...skipping 2767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3221 context_support_->ScheduleOverlayPlane( | 3239 context_support_->ScheduleOverlayPlane( |
3222 overlay.plane_z_order, | 3240 overlay.plane_z_order, |
3223 overlay.transform, | 3241 overlay.transform, |
3224 pending_overlay_resources_.back()->texture_id(), | 3242 pending_overlay_resources_.back()->texture_id(), |
3225 overlay.display_rect, | 3243 overlay.display_rect, |
3226 overlay.uv_rect); | 3244 overlay.uv_rect); |
3227 } | 3245 } |
3228 } | 3246 } |
3229 | 3247 |
3230 } // namespace cc | 3248 } // namespace cc |
OLD | NEW |