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 15 matching lines...) Expand all Loading... |
26 #include "cc/output/begin_frame_args.h" | 26 #include "cc/output/begin_frame_args.h" |
27 #include "cc/output/copy_output_request.h" | 27 #include "cc/output/copy_output_request.h" |
28 #include "cc/output/copy_output_result.h" | 28 #include "cc/output/copy_output_result.h" |
29 #include "cc/resources/single_release_callback.h" | 29 #include "cc/resources/single_release_callback.h" |
30 #include "cc/trees/layer_tree_host.h" | 30 #include "cc/trees/layer_tree_host.h" |
31 #include "content/child/child_gpu_memory_buffer_manager.h" | 31 #include "content/child/child_gpu_memory_buffer_manager.h" |
32 #include "content/child/child_shared_bitmap_manager.h" | 32 #include "content/child/child_shared_bitmap_manager.h" |
33 #include "content/common/content_switches_internal.h" | 33 #include "content/common/content_switches_internal.h" |
34 #include "content/common/gpu/client/context_provider_command_buffer.h" | 34 #include "content/common/gpu/client/context_provider_command_buffer.h" |
35 #include "content/public/common/content_switches.h" | 35 #include "content/public/common/content_switches.h" |
| 36 #include "content/renderer/gpu/compositor_external_begin_frame_source.h" |
36 #include "content/renderer/input/input_handler_manager.h" | 37 #include "content/renderer/input/input_handler_manager.h" |
37 #include "content/renderer/render_thread_impl.h" | 38 #include "content/renderer/render_thread_impl.h" |
38 #include "gpu/command_buffer/client/gles2_interface.h" | 39 #include "gpu/command_buffer/client/gles2_interface.h" |
39 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" | 40 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" |
40 #include "third_party/WebKit/public/platform/WebSelectionBound.h" | 41 #include "third_party/WebKit/public/platform/WebSelectionBound.h" |
41 #include "third_party/WebKit/public/platform/WebSize.h" | 42 #include "third_party/WebKit/public/platform/WebSize.h" |
42 #include "third_party/WebKit/public/web/WebKit.h" | 43 #include "third_party/WebKit/public/web/WebKit.h" |
43 #include "third_party/WebKit/public/web/WebWidget.h" | 44 #include "third_party/WebKit/public/web/WebWidget.h" |
44 #include "ui/gfx/frame_time.h" | 45 #include "ui/gfx/frame_time.h" |
45 #include "ui/gl/gl_switches.h" | 46 #include "ui/gl/gl_switches.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = NULL; | 528 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = NULL; |
528 // render_thread may be NULL in tests. | 529 // render_thread may be NULL in tests. |
529 if (render_thread) { | 530 if (render_thread) { |
530 compositor_message_loop_proxy = | 531 compositor_message_loop_proxy = |
531 render_thread->compositor_message_loop_proxy(); | 532 render_thread->compositor_message_loop_proxy(); |
532 shared_bitmap_manager = render_thread->shared_bitmap_manager(); | 533 shared_bitmap_manager = render_thread->shared_bitmap_manager(); |
533 gpu_memory_buffer_manager = render_thread->gpu_memory_buffer_manager(); | 534 gpu_memory_buffer_manager = render_thread->gpu_memory_buffer_manager(); |
534 main_thread_compositor_task_runner = | 535 main_thread_compositor_task_runner = |
535 render_thread->main_thread_compositor_task_runner(); | 536 render_thread->main_thread_compositor_task_runner(); |
536 } | 537 } |
| 538 scoped_ptr<cc::BeginFrameSource> external_begin_frame_source; |
| 539 #if defined(OS_ANDROID) |
| 540 if (SynchronousCompositorFactory* factory = |
| 541 SynchronousCompositorFactory::GetInstance()) { |
| 542 DCHECK(settings.begin_frame_scheduling_enabled); |
| 543 external_begin_frame_source = |
| 544 factory->CreateExternalBeginFrameSource(widget_->routing_id()); |
| 545 } |
| 546 #endif |
| 547 if (render_thread && |
| 548 !external_begin_frame_source.get() && |
| 549 settings.begin_frame_scheduling_enabled) { |
| 550 external_begin_frame_source.reset(new CompositorExternalBeginFrameSource( |
| 551 widget_->routing_id())); |
| 552 } |
537 if (compositor_message_loop_proxy.get()) { | 553 if (compositor_message_loop_proxy.get()) { |
538 layer_tree_host_ = | 554 layer_tree_host_ = |
539 cc::LayerTreeHost::CreateThreaded(this, | 555 cc::LayerTreeHost::CreateThreaded(this, |
540 shared_bitmap_manager, | 556 shared_bitmap_manager, |
541 gpu_memory_buffer_manager, | 557 gpu_memory_buffer_manager, |
542 settings, | 558 settings, |
543 main_thread_compositor_task_runner, | 559 main_thread_compositor_task_runner, |
544 compositor_message_loop_proxy); | 560 compositor_message_loop_proxy, |
| 561 external_begin_frame_source.Pass()); |
545 } else { | 562 } else { |
546 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( | 563 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( |
547 this, | 564 this, |
548 this, | 565 this, |
549 shared_bitmap_manager, | 566 shared_bitmap_manager, |
550 gpu_memory_buffer_manager, | 567 gpu_memory_buffer_manager, |
551 settings, | 568 settings, |
552 main_thread_compositor_task_runner); | 569 main_thread_compositor_task_runner, |
| 570 external_begin_frame_source.Pass()); |
553 } | 571 } |
554 DCHECK(layer_tree_host_); | 572 DCHECK(layer_tree_host_); |
555 } | 573 } |
556 | 574 |
557 void RenderWidgetCompositor::setSurfaceReady() { | 575 void RenderWidgetCompositor::setSurfaceReady() { |
558 // In tests without a RenderThreadImpl, don't set ready as this kicks | 576 // In tests without a RenderThreadImpl, don't set ready as this kicks |
559 // off creating output surfaces that the test can't create. | 577 // off creating output surfaces that the test can't create. |
560 if (RenderThreadImpl::current()) | 578 if (RenderThreadImpl::current()) |
561 layer_tree_host_->SetLayerTreeHostClientReady(); | 579 layer_tree_host_->SetLayerTreeHostClientReady(); |
562 } | 580 } |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 widget_->OnSwapBuffersAborted(); | 889 widget_->OnSwapBuffersAborted(); |
872 } | 890 } |
873 | 891 |
874 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 892 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
875 cc::ContextProvider* provider = | 893 cc::ContextProvider* provider = |
876 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 894 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
877 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 895 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
878 } | 896 } |
879 | 897 |
880 } // namespace content | 898 } // namespace content |
OLD | NEW |