| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h" | 43 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h" |
| 44 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 44 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 45 #include "ui/gfx/geometry/quad_f.h" | 45 #include "ui/gfx/geometry/quad_f.h" |
| 46 #include "ui/gfx/geometry/rect_conversions.h" | 46 #include "ui/gfx/geometry/rect_conversions.h" |
| 47 | 47 |
| 48 using gpu::gles2::GLES2Interface; | 48 using gpu::gles2::GLES2Interface; |
| 49 | 49 |
| 50 namespace cc { | 50 namespace cc { |
| 51 namespace { | 51 namespace { |
| 52 | 52 |
| 53 class FallbackFence : public ResourceProvider::Fence { | |
| 54 public: | |
| 55 explicit FallbackFence(gpu::gles2::GLES2Interface* gl) | |
| 56 : gl_(gl), has_passed_(true) {} | |
| 57 | |
| 58 // Overridden from ResourceProvider::Fence: | |
| 59 void Set() override { has_passed_ = false; } | |
| 60 bool HasPassed() override { | |
| 61 if (!has_passed_) { | |
| 62 has_passed_ = true; | |
| 63 Synchronize(); | |
| 64 } | |
| 65 return true; | |
| 66 } | |
| 67 void Wait() override { HasPassed(); } | |
| 68 | |
| 69 private: | |
| 70 ~FallbackFence() override {} | |
| 71 | |
| 72 void Synchronize() { | |
| 73 TRACE_EVENT0("cc", "FallbackFence::Synchronize"); | |
| 74 gl_->Finish(); | |
| 75 } | |
| 76 | |
| 77 gpu::gles2::GLES2Interface* gl_; | |
| 78 bool has_passed_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(FallbackFence); | |
| 81 }; | |
| 82 | |
| 83 bool NeedsIOSurfaceReadbackWorkaround() { | 53 bool NeedsIOSurfaceReadbackWorkaround() { |
| 84 #if defined(OS_MACOSX) | 54 #if defined(OS_MACOSX) |
| 85 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, | 55 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, |
| 86 // but it doesn't seem to hurt. | 56 // but it doesn't seem to hurt. |
| 87 return true; | 57 return true; |
| 88 #else | 58 #else |
| 89 return false; | 59 return false; |
| 90 #endif | 60 #endif |
| 91 } | 61 } |
| 92 | 62 |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 460 |
| 491 available_sync_queries_.push_back(pending_sync_queries_.take_front()); | 461 available_sync_queries_.push_back(pending_sync_queries_.take_front()); |
| 492 } | 462 } |
| 493 | 463 |
| 494 current_sync_query_ = available_sync_queries_.empty() | 464 current_sync_query_ = available_sync_queries_.empty() |
| 495 ? make_scoped_ptr(new SyncQuery(gl_)) | 465 ? make_scoped_ptr(new SyncQuery(gl_)) |
| 496 : available_sync_queries_.take_front(); | 466 : available_sync_queries_.take_front(); |
| 497 | 467 |
| 498 read_lock_fence = current_sync_query_->Begin(); | 468 read_lock_fence = current_sync_query_->Begin(); |
| 499 } else { | 469 } else { |
| 500 read_lock_fence = make_scoped_refptr(new FallbackFence(gl_)); | 470 read_lock_fence = |
| 471 make_scoped_refptr(new ResourceProvider::SynchronousFence(gl_)); |
| 501 } | 472 } |
| 502 resource_provider_->SetReadLockFence(read_lock_fence.get()); | 473 resource_provider_->SetReadLockFence(read_lock_fence.get()); |
| 503 | 474 |
| 504 if (frame->device_viewport_rect.IsEmpty()) | 475 if (frame->device_viewport_rect.IsEmpty()) |
| 505 return; | 476 return; |
| 506 | 477 |
| 507 // Insert WaitSyncPointCHROMIUM on quad resources prior to drawing the frame, | 478 // Insert WaitSyncPointCHROMIUM on quad resources prior to drawing the frame, |
| 508 // so that drawing can proceed without GL context switching interruptions. | 479 // so that drawing can proceed without GL context switching interruptions. |
| 509 DrawQuad::ResourceIteratorCallback wait_on_resource_syncpoints_callback = | 480 DrawQuad::ResourceIteratorCallback wait_on_resource_syncpoints_callback = |
| 510 base::Bind(&WaitOnResourceSyncPoints, resource_provider_); | 481 base::Bind(&WaitOnResourceSyncPoints, resource_provider_); |
| (...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3366 context_support_->ScheduleOverlayPlane( | 3337 context_support_->ScheduleOverlayPlane( |
| 3367 overlay.plane_z_order, | 3338 overlay.plane_z_order, |
| 3368 overlay.transform, | 3339 overlay.transform, |
| 3369 pending_overlay_resources_.back()->texture_id(), | 3340 pending_overlay_resources_.back()->texture_id(), |
| 3370 overlay.display_rect, | 3341 overlay.display_rect, |
| 3371 overlay.uv_rect); | 3342 overlay.uv_rect); |
| 3372 } | 3343 } |
| 3373 } | 3344 } |
| 3374 | 3345 |
| 3375 } // namespace cc | 3346 } // namespace cc |
| OLD | NEW |