| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #if defined(OS_ANDROID) | 10 #if defined(OS_ANDROID) |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 #endif | 316 #endif |
| 317 | 317 |
| 318 compositor->Initialize(settings); | 318 compositor->Initialize(settings); |
| 319 | 319 |
| 320 return compositor.Pass(); | 320 return compositor.Pass(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, | 323 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, |
| 324 bool threaded) | 324 bool threaded) |
| 325 : threaded_(threaded), | 325 : threaded_(threaded), |
| 326 suppress_schedule_composite_(false), | |
| 327 widget_(widget) { | 326 widget_(widget) { |
| 328 } | 327 } |
| 329 | 328 |
| 330 RenderWidgetCompositor::~RenderWidgetCompositor() {} | 329 RenderWidgetCompositor::~RenderWidgetCompositor() {} |
| 331 | 330 |
| 332 const base::WeakPtr<cc::InputHandler>& | 331 const base::WeakPtr<cc::InputHandler>& |
| 333 RenderWidgetCompositor::GetInputHandler() { | 332 RenderWidgetCompositor::GetInputHandler() { |
| 334 return layer_tree_host_->GetInputHandler(); | 333 return layer_tree_host_->GetInputHandler(); |
| 335 } | 334 } |
| 336 | 335 |
| 337 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { | 336 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { |
| 338 if (suppress_schedule_composite_ == suppress) | 337 layer_tree_host_->SetDeferCommits(suppress); |
| 339 return; | |
| 340 | |
| 341 if (suppress) | |
| 342 TRACE_EVENT_ASYNC_BEGIN0("gpu", | |
| 343 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); | |
| 344 else | |
| 345 TRACE_EVENT_ASYNC_END0("gpu", | |
| 346 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); | |
| 347 suppress_schedule_composite_ = suppress; | |
| 348 } | 338 } |
| 349 | 339 |
| 350 bool RenderWidgetCompositor::BeginMainFrameRequested() const { | 340 bool RenderWidgetCompositor::BeginMainFrameRequested() const { |
| 351 return layer_tree_host_->BeginMainFrameRequested(); | 341 return layer_tree_host_->BeginMainFrameRequested(); |
| 352 } | 342 } |
| 353 | 343 |
| 354 void RenderWidgetCompositor::UpdateAnimations(base::TimeTicks time) { | 344 void RenderWidgetCompositor::UpdateAnimations(base::TimeTicks time) { |
| 355 layer_tree_host_->UpdateClientAnimations(time); | 345 layer_tree_host_->UpdateClientAnimations(time); |
| 356 } | 346 } |
| 357 | 347 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 669 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
| 680 widget_->didCommitAndDrawCompositorFrame(); | 670 widget_->didCommitAndDrawCompositorFrame(); |
| 681 } | 671 } |
| 682 | 672 |
| 683 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 673 void RenderWidgetCompositor::DidCompleteSwapBuffers() { |
| 684 widget_->didCompleteSwapBuffers(); | 674 widget_->didCompleteSwapBuffers(); |
| 685 if (!threaded_) | 675 if (!threaded_) |
| 686 widget_->OnSwapBuffersComplete(); | 676 widget_->OnSwapBuffersComplete(); |
| 687 } | 677 } |
| 688 | 678 |
| 689 void RenderWidgetCompositor::ScheduleComposite() { | |
| 690 if (!suppress_schedule_composite_) | |
| 691 widget_->scheduleComposite(); | |
| 692 } | |
| 693 | |
| 694 void RenderWidgetCompositor::ScheduleAnimation() { | |
| 695 widget_->scheduleAnimation(); | |
| 696 } | |
| 697 | |
| 698 void RenderWidgetCompositor::DidPostSwapBuffers() { | 679 void RenderWidgetCompositor::DidPostSwapBuffers() { |
| 699 widget_->OnSwapBuffersPosted(); | 680 widget_->OnSwapBuffersPosted(); |
| 700 } | 681 } |
| 701 | 682 |
| 702 void RenderWidgetCompositor::DidAbortSwapBuffers() { | 683 void RenderWidgetCompositor::DidAbortSwapBuffers() { |
| 703 widget_->OnSwapBuffersAborted(); | 684 widget_->OnSwapBuffersAborted(); |
| 704 } | 685 } |
| 705 | 686 |
| 706 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 687 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
| 707 cc::ContextProvider* provider = | 688 cc::ContextProvider* provider = |
| 708 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 689 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
| 709 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 690 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
| 710 } | 691 } |
| 711 | 692 |
| 712 bool RenderWidgetCompositor::usesGpuRasterization() { | 693 bool RenderWidgetCompositor::usesGpuRasterization() { |
| 713 return layer_tree_host_->UseGpuRasterization(); | 694 return layer_tree_host_->UseGpuRasterization(); |
| 714 } | 695 } |
| 715 | 696 |
| 716 } // namespace content | 697 } // namespace content |
| OLD | NEW |