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) { | |
352 layer_tree_host_->UpdateClientAnimations(time); | |
353 } | |
354 | |
355 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { | 341 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { |
356 layer_tree_host_->SetNeedsDisplayOnAllLayers(); | 342 layer_tree_host_->SetNeedsDisplayOnAllLayers(); |
357 } | 343 } |
358 | 344 |
359 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { | 345 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { |
360 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); | 346 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); |
361 current.rasterize_only_visible_content = true; | 347 current.rasterize_only_visible_content = true; |
362 layer_tree_host_->SetDebugState(current); | 348 layer_tree_host_->SetDebugState(current); |
363 } | 349 } |
364 | 350 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( | 423 layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( |
438 this, shared_bitmap_manager, settings, compositor_message_loop_proxy); | 424 this, shared_bitmap_manager, settings, compositor_message_loop_proxy); |
439 } else { | 425 } else { |
440 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( | 426 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( |
441 this, this, shared_bitmap_manager, settings); | 427 this, this, shared_bitmap_manager, settings); |
442 } | 428 } |
443 DCHECK(layer_tree_host_); | 429 DCHECK(layer_tree_host_); |
444 } | 430 } |
445 | 431 |
446 void RenderWidgetCompositor::setSurfaceReady() { | 432 void RenderWidgetCompositor::setSurfaceReady() { |
447 layer_tree_host_->SetLayerTreeHostClientReady(); | 433 // In tests without a RenderThreadImpl, don't set ready as this kicks |
434 // off creating output surfaces that the test can't create. | |
435 if (RenderThreadImpl::current()) | |
436 layer_tree_host_->SetLayerTreeHostClientReady(); | |
448 } | 437 } |
449 | 438 |
450 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { | 439 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { |
451 layer_tree_host_->SetRootLayer( | 440 layer_tree_host_->SetRootLayer( |
452 static_cast<const WebLayerImpl*>(&layer)->layer()); | 441 static_cast<const WebLayerImpl*>(&layer)->layer()); |
453 } | 442 } |
454 | 443 |
455 void RenderWidgetCompositor::clearRootLayer() { | 444 void RenderWidgetCompositor::clearRootLayer() { |
456 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); | 445 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); |
457 } | 446 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 void RenderWidgetCompositor::compositeAndReadbackAsync( | 570 void RenderWidgetCompositor::compositeAndReadbackAsync( |
582 blink::WebCompositeAndReadbackAsyncCallback* callback) { | 571 blink::WebCompositeAndReadbackAsyncCallback* callback) { |
583 DCHECK(layer_tree_host_->root_layer()); | 572 DCHECK(layer_tree_host_->root_layer()); |
584 scoped_ptr<cc::CopyOutputRequest> request = | 573 scoped_ptr<cc::CopyOutputRequest> request = |
585 cc::CopyOutputRequest::CreateBitmapRequest( | 574 cc::CopyOutputRequest::CreateBitmapRequest( |
586 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); | 575 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); |
587 layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass()); | 576 layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass()); |
588 if (!threaded_) { | 577 if (!threaded_) { |
589 widget_->webwidget()->animate(0.0); | 578 widget_->webwidget()->animate(0.0); |
590 widget_->webwidget()->layout(); | 579 widget_->webwidget()->layout(); |
591 layer_tree_host_->Composite(gfx::FrameTime::Now()); | 580 layer_tree_host_->Composite(gfx::FrameTime::Now()); |
enne (OOO)
2014/06/30 22:22:08
This call was breaking in layout tests as it would
| |
592 } | 581 } |
593 } | 582 } |
594 | 583 |
595 void RenderWidgetCompositor::finishAllRendering() { | 584 void RenderWidgetCompositor::finishAllRendering() { |
596 layer_tree_host_->FinishAllRendering(); | 585 layer_tree_host_->FinishAllRendering(); |
597 } | 586 } |
598 | 587 |
599 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { | 588 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { |
600 layer_tree_host_->SetDeferCommits(defer_commits); | 589 layer_tree_host_->SetDeferCommits(defer_commits); |
601 } | 590 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 665 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
677 widget_->didCommitAndDrawCompositorFrame(); | 666 widget_->didCommitAndDrawCompositorFrame(); |
678 } | 667 } |
679 | 668 |
680 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 669 void RenderWidgetCompositor::DidCompleteSwapBuffers() { |
681 widget_->didCompleteSwapBuffers(); | 670 widget_->didCompleteSwapBuffers(); |
682 if (!threaded_) | 671 if (!threaded_) |
683 widget_->OnSwapBuffersComplete(); | 672 widget_->OnSwapBuffersComplete(); |
684 } | 673 } |
685 | 674 |
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() { | 675 void RenderWidgetCompositor::DidPostSwapBuffers() { |
696 widget_->OnSwapBuffersPosted(); | 676 widget_->OnSwapBuffersPosted(); |
697 } | 677 } |
698 | 678 |
699 void RenderWidgetCompositor::DidAbortSwapBuffers() { | 679 void RenderWidgetCompositor::DidAbortSwapBuffers() { |
700 widget_->OnSwapBuffersAborted(); | 680 widget_->OnSwapBuffersAborted(); |
701 } | 681 } |
702 | 682 |
703 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 683 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
704 cc::ContextProvider* provider = | 684 cc::ContextProvider* provider = |
705 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 685 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
706 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 686 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
707 } | 687 } |
708 | 688 |
709 } // namespace content | 689 } // namespace content |
OLD | NEW |