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 | 9 |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
13 #include "base/time.h" | 14 #include "base/time.h" |
14 #include "cc/base/switches.h" | 15 #include "cc/base/switches.h" |
15 #include "cc/base/thread_impl.h" | 16 #include "cc/base/thread_impl.h" |
16 #include "cc/debug/layer_tree_debug_state.h" | 17 #include "cc/debug/layer_tree_debug_state.h" |
17 #include "cc/layers/layer.h" | 18 #include "cc/layers/layer.h" |
18 #include "cc/trees/layer_tree_host.h" | 19 #include "cc/trees/layer_tree_host.h" |
19 #include "content/common/gpu/client/context_provider_command_buffer.h" | 20 #include "content/common/gpu/client/context_provider_command_buffer.h" |
20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
21 #include "content/renderer/gpu/input_handler_manager.h" | 22 #include "content/renderer/gpu/input_handler_manager.h" |
22 #include "content/renderer/render_thread_impl.h" | 23 #include "content/renderer/render_thread_impl.h" |
23 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" |
25 #include "ui/gl/gl_switches.h" | 26 #include "ui/gl/gl_switches.h" |
26 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 27 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
27 #include "webkit/renderer/compositor_bindings/web_to_ccinput_handler_adapter.h" | |
28 | 28 |
29 namespace cc { | 29 namespace cc { |
30 class Layer; | 30 class Layer; |
31 } | 31 } |
32 | 32 |
33 using WebKit::WebFloatPoint; | 33 using WebKit::WebFloatPoint; |
34 using WebKit::WebSize; | 34 using WebKit::WebSize; |
35 using WebKit::WebRect; | 35 using WebKit::WebRect; |
36 | 36 |
37 namespace content { | 37 namespace content { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 return compositor.Pass(); | 283 return compositor.Pass(); |
284 } | 284 } |
285 | 285 |
286 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget) | 286 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget) |
287 : suppress_schedule_composite_(false), | 287 : suppress_schedule_composite_(false), |
288 widget_(widget) { | 288 widget_(widget) { |
289 } | 289 } |
290 | 290 |
291 RenderWidgetCompositor::~RenderWidgetCompositor() {} | 291 RenderWidgetCompositor::~RenderWidgetCompositor() {} |
292 | 292 |
| 293 const base::WeakPtr<cc::InputHandler>& |
| 294 RenderWidgetCompositor::GetInputHandler() { |
| 295 return layer_tree_host_->GetInputHandler(); |
| 296 } |
| 297 |
293 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { | 298 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { |
294 if (suppress_schedule_composite_ == suppress) | 299 if (suppress_schedule_composite_ == suppress) |
295 return; | 300 return; |
296 | 301 |
297 if (suppress) | 302 if (suppress) |
298 TRACE_EVENT_ASYNC_BEGIN0("gpu", | 303 TRACE_EVENT_ASYNC_BEGIN0("gpu", |
299 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); | 304 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); |
300 else | 305 else |
301 TRACE_EVENT_ASYNC_END0("gpu", | 306 TRACE_EVENT_ASYNC_END0("gpu", |
302 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); | 307 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 530 |
526 scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::CreateOutputSurface() { | 531 scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::CreateOutputSurface() { |
527 return widget_->CreateOutputSurface(); | 532 return widget_->CreateOutputSurface(); |
528 } | 533 } |
529 | 534 |
530 void RenderWidgetCompositor::DidInitializeOutputSurface(bool success) { | 535 void RenderWidgetCompositor::DidInitializeOutputSurface(bool success) { |
531 if (!success) | 536 if (!success) |
532 widget_->webwidget()->didExitCompositingMode(); | 537 widget_->webwidget()->didExitCompositingMode(); |
533 } | 538 } |
534 | 539 |
535 scoped_ptr<cc::InputHandlerClient> | |
536 RenderWidgetCompositor::CreateInputHandlerClient() { | |
537 scoped_ptr<cc::InputHandlerClient> ret; | |
538 scoped_ptr<WebKit::WebInputHandler> web_handler( | |
539 widget_->webwidget()->createInputHandler()); | |
540 if (web_handler) | |
541 ret = WebKit::WebToCCInputHandlerAdapter::create(web_handler.Pass()); | |
542 return ret.Pass(); | |
543 } | |
544 | |
545 void RenderWidgetCompositor::WillCommit() { | 540 void RenderWidgetCompositor::WillCommit() { |
546 widget_->InstrumentWillComposite(); | 541 widget_->InstrumentWillComposite(); |
547 } | 542 } |
548 | 543 |
549 void RenderWidgetCompositor::DidCommit() { | 544 void RenderWidgetCompositor::DidCommit() { |
550 widget_->DidCommitCompositorFrame(); | 545 widget_->DidCommitCompositorFrame(); |
551 widget_->didBecomeReadyForAdditionalInput(); | 546 widget_->didBecomeReadyForAdditionalInput(); |
552 } | 547 } |
553 | 548 |
554 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 549 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
(...skipping 14 matching lines...) Expand all Loading... |
569 return RenderThreadImpl::current()->OffscreenContextProviderForMainThread(); | 564 return RenderThreadImpl::current()->OffscreenContextProviderForMainThread(); |
570 } | 565 } |
571 | 566 |
572 scoped_refptr<cc::ContextProvider> | 567 scoped_refptr<cc::ContextProvider> |
573 RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { | 568 RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { |
574 return RenderThreadImpl::current()-> | 569 return RenderThreadImpl::current()-> |
575 OffscreenContextProviderForCompositorThread(); | 570 OffscreenContextProviderForCompositorThread(); |
576 } | 571 } |
577 | 572 |
578 } // namespace content | 573 } // namespace content |
OLD | NEW |