Chromium Code Reviews| 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 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 #endif | 313 #endif |
| 314 | 314 |
| 315 compositor->Initialize(settings); | 315 compositor->Initialize(settings); |
| 316 | 316 |
| 317 return compositor.Pass(); | 317 return compositor.Pass(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, | 320 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, |
| 321 bool threaded) | 321 bool threaded) |
| 322 : threaded_(threaded), | 322 : threaded_(threaded), |
| 323 suppress_schedule_composite_(false), | |
| 324 widget_(widget) { | 323 widget_(widget) { |
| 325 } | 324 } |
| 326 | 325 |
| 327 RenderWidgetCompositor::~RenderWidgetCompositor() {} | 326 RenderWidgetCompositor::~RenderWidgetCompositor() {} |
| 328 | 327 |
| 329 const base::WeakPtr<cc::InputHandler>& | 328 const base::WeakPtr<cc::InputHandler>& |
| 330 RenderWidgetCompositor::GetInputHandler() { | 329 RenderWidgetCompositor::GetInputHandler() { |
| 331 return layer_tree_host_->GetInputHandler(); | 330 return layer_tree_host_->GetInputHandler(); |
| 332 } | 331 } |
| 333 | 332 |
| 334 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { | 333 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { |
| 335 if (suppress_schedule_composite_ == suppress) | 334 layer_tree_host_->SetDeferCommits(suppress); |
| 336 return; | |
| 337 | |
| 338 if (suppress) | |
| 339 TRACE_EVENT_ASYNC_BEGIN0("gpu", | |
| 340 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); | |
| 341 else | |
| 342 TRACE_EVENT_ASYNC_END0("gpu", | |
| 343 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); | |
| 344 suppress_schedule_composite_ = suppress; | |
| 345 } | 335 } |
| 346 | 336 |
| 347 bool RenderWidgetCompositor::BeginMainFrameRequested() const { | 337 bool RenderWidgetCompositor::BeginMainFrameRequested() const { |
| 348 return layer_tree_host_->BeginMainFrameRequested(); | 338 return layer_tree_host_->BeginMainFrameRequested(); |
| 349 } | 339 } |
| 350 | 340 |
| 351 void RenderWidgetCompositor::UpdateAnimations(base::TimeTicks time) { | 341 void RenderWidgetCompositor::UpdateAnimations(base::TimeTicks time) { |
| 352 layer_tree_host_->UpdateClientAnimations(time); | 342 layer_tree_host_->UpdateClientAnimations(time); |
| 353 } | 343 } |
| 354 | 344 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( | 427 layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( |
| 438 this, shared_bitmap_manager, settings, compositor_message_loop_proxy); | 428 this, shared_bitmap_manager, settings, compositor_message_loop_proxy); |
| 439 } else { | 429 } else { |
| 440 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( | 430 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( |
| 441 this, this, shared_bitmap_manager, settings); | 431 this, this, shared_bitmap_manager, settings); |
| 442 } | 432 } |
| 443 DCHECK(layer_tree_host_); | 433 DCHECK(layer_tree_host_); |
| 444 } | 434 } |
| 445 | 435 |
| 446 void RenderWidgetCompositor::setSurfaceReady() { | 436 void RenderWidgetCompositor::setSurfaceReady() { |
| 447 layer_tree_host_->SetLayerTreeHostClientReady(); | 437 // In tests without a RenderThreadImpl, don't set ready as this kicks |
| 438 // off creating output surfaces that the test can't create. | |
| 439 if (RenderThreadImpl::current()) | |
|
enne (OOO)
2014/06/27 19:16:51
This is the fix for browser tests. By not setting
| |
| 440 layer_tree_host_->SetLayerTreeHostClientReady(); | |
| 448 } | 441 } |
| 449 | 442 |
| 450 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { | 443 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { |
| 451 layer_tree_host_->SetRootLayer( | 444 layer_tree_host_->SetRootLayer( |
| 452 static_cast<const WebLayerImpl*>(&layer)->layer()); | 445 static_cast<const WebLayerImpl*>(&layer)->layer()); |
| 453 } | 446 } |
| 454 | 447 |
| 455 void RenderWidgetCompositor::clearRootLayer() { | 448 void RenderWidgetCompositor::clearRootLayer() { |
| 456 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); | 449 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); |
| 457 } | 450 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 669 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
| 677 widget_->didCommitAndDrawCompositorFrame(); | 670 widget_->didCommitAndDrawCompositorFrame(); |
| 678 } | 671 } |
| 679 | 672 |
| 680 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 673 void RenderWidgetCompositor::DidCompleteSwapBuffers() { |
| 681 widget_->didCompleteSwapBuffers(); | 674 widget_->didCompleteSwapBuffers(); |
| 682 if (!threaded_) | 675 if (!threaded_) |
| 683 widget_->OnSwapBuffersComplete(); | 676 widget_->OnSwapBuffersComplete(); |
| 684 } | 677 } |
| 685 | 678 |
| 686 void RenderWidgetCompositor::ScheduleComposite() { | |
| 687 if (!suppress_schedule_composite_) | |
| 688 widget_->scheduleComposite(); | |
| 689 } | |
| 690 | |
| 691 void RenderWidgetCompositor::ScheduleAnimation() { | |
| 692 widget_->scheduleAnimation(); | |
| 693 } | |
| 694 | |
| 695 void RenderWidgetCompositor::DidPostSwapBuffers() { | 679 void RenderWidgetCompositor::DidPostSwapBuffers() { |
| 696 widget_->OnSwapBuffersPosted(); | 680 widget_->OnSwapBuffersPosted(); |
| 697 } | 681 } |
| 698 | 682 |
| 699 void RenderWidgetCompositor::DidAbortSwapBuffers() { | 683 void RenderWidgetCompositor::DidAbortSwapBuffers() { |
| 700 widget_->OnSwapBuffersAborted(); | 684 widget_->OnSwapBuffersAborted(); |
| 701 } | 685 } |
| 702 | 686 |
| 703 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 687 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
| 704 cc::ContextProvider* provider = | 688 cc::ContextProvider* provider = |
| 705 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 689 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
| 706 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 690 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
| 707 } | 691 } |
| 708 | 692 |
| 709 } // namespace content | 693 } // namespace content |
| OLD | NEW |