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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 | 56 |
57 namespace cc { | 57 namespace cc { |
58 class Layer; | 58 class Layer; |
59 } | 59 } |
60 | 60 |
61 using blink::WebBeginFrameArgs; | 61 using blink::WebBeginFrameArgs; |
62 using blink::WebFloatPoint; | 62 using blink::WebFloatPoint; |
63 using blink::WebRect; | 63 using blink::WebRect; |
64 using blink::WebSelectionBound; | 64 using blink::WebSelectionBound; |
65 using blink::WebSize; | 65 using blink::WebSize; |
66 using blink::WebTopControlsState; | |
66 | 67 |
67 namespace content { | 68 namespace content { |
68 namespace { | 69 namespace { |
69 | 70 |
70 bool GetSwitchValueAsInt(const base::CommandLine& command_line, | 71 bool GetSwitchValueAsInt(const base::CommandLine& command_line, |
71 const std::string& switch_string, | 72 const std::string& switch_string, |
72 int min_value, | 73 int min_value, |
73 int max_value, | 74 int max_value, |
74 int* result) { | 75 int* result) { |
75 std::string string_value = command_line.GetSwitchValueASCII(switch_string); | 76 std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 int numTiles = (display_width * display_height) / (256 * 256); | 148 int numTiles = (display_width * display_height) / (256 * 256); |
148 if (numTiles > 16) | 149 if (numTiles > 16) |
149 default_tile_size = 384; | 150 default_tile_size = 384; |
150 if (numTiles >= 40) | 151 if (numTiles >= 40) |
151 default_tile_size = 512; | 152 default_tile_size = 512; |
152 } | 153 } |
153 #endif | 154 #endif |
154 return gfx::Size(default_tile_size, default_tile_size); | 155 return gfx::Size(default_tile_size, default_tile_size); |
155 } | 156 } |
156 | 157 |
158 // Check cc::TopControlsState, and blink::WebTopControlsState | |
159 // are kept in sync. | |
160 static_assert(int(blink::WebTopControlsBoth) == int(cc::BOTH), | |
161 "mismatching enums: BOTH"); | |
162 static_assert(int(blink::WebTopControlsHidden) == int(cc::HIDDEN), | |
163 "mismatching enums: HIDDEN"); | |
164 static_assert(int(blink::WebTopControlsShown) == int(cc::SHOWN), | |
165 "mismatching enums: SHOWN"); | |
166 | |
167 static cc::TopControlsState ConvertTopControlsState( | |
no sievers
2015/02/19 19:51:37
nit: don't need static here since you are in the a
| |
168 WebTopControlsState state) { | |
169 return static_cast<cc::TopControlsState>(state); | |
170 } | |
171 | |
157 } // namespace | 172 } // namespace |
158 | 173 |
159 // static | 174 // static |
160 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( | 175 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( |
161 RenderWidget* widget, | 176 RenderWidget* widget, |
162 CompositorDependencies* compositor_deps) { | 177 CompositorDependencies* compositor_deps) { |
163 scoped_ptr<RenderWidgetCompositor> compositor( | 178 scoped_ptr<RenderWidgetCompositor> compositor( |
164 new RenderWidgetCompositor(widget, compositor_deps)); | 179 new RenderWidgetCompositor(widget, compositor_deps)); |
165 compositor->Initialize(); | 180 compositor->Initialize(); |
166 return compositor; | 181 return compositor; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { | 474 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { |
460 layer_tree_host_->SetNeedsDisplayOnAllLayers(); | 475 layer_tree_host_->SetNeedsDisplayOnAllLayers(); |
461 } | 476 } |
462 | 477 |
463 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { | 478 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { |
464 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); | 479 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); |
465 current.rasterize_only_visible_content = true; | 480 current.rasterize_only_visible_content = true; |
466 layer_tree_host_->SetDebugState(current); | 481 layer_tree_host_->SetDebugState(current); |
467 } | 482 } |
468 | 483 |
469 void RenderWidgetCompositor::UpdateTopControlsState( | |
470 cc::TopControlsState constraints, | |
471 cc::TopControlsState current, | |
472 bool animate) { | |
473 layer_tree_host_->UpdateTopControlsState(constraints, | |
474 current, | |
475 animate); | |
476 } | |
477 | |
478 void RenderWidgetCompositor::SetTopControlsShrinkBlinkSize(bool shrink) { | |
479 layer_tree_host_->SetTopControlsShrinkBlinkSize(shrink); | |
480 } | |
481 | |
482 void RenderWidgetCompositor::SetTopControlsHeight(float height) { | |
483 layer_tree_host_->SetTopControlsHeight(height); | |
484 } | |
485 | |
486 void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) { | 484 void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) { |
487 layer_tree_host_->SetNeedsRedrawRect(damage_rect); | 485 layer_tree_host_->SetNeedsRedrawRect(damage_rect); |
488 } | 486 } |
489 | 487 |
490 void RenderWidgetCompositor::SetNeedsForcedRedraw() { | 488 void RenderWidgetCompositor::SetNeedsForcedRedraw() { |
491 layer_tree_host_->SetNextCommitForcesRedraw(); | 489 layer_tree_host_->SetNextCommitForcesRedraw(); |
492 setNeedsAnimate(); | 490 setNeedsAnimate(); |
493 } | 491 } |
494 | 492 |
495 scoped_ptr<cc::SwapPromiseMonitor> | 493 scoped_ptr<cc::SwapPromiseMonitor> |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 } | 739 } |
742 | 740 |
743 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { | 741 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { |
744 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); | 742 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); |
745 debug_state.show_touch_event_handler_rects = show; | 743 debug_state.show_touch_event_handler_rects = show; |
746 debug_state.show_wheel_event_handler_rects = show; | 744 debug_state.show_wheel_event_handler_rects = show; |
747 debug_state.show_non_fast_scrollable_rects = show; | 745 debug_state.show_non_fast_scrollable_rects = show; |
748 layer_tree_host_->SetDebugState(debug_state); | 746 layer_tree_host_->SetDebugState(debug_state); |
749 } | 747 } |
750 | 748 |
749 void RenderWidgetCompositor::updateTopControlsState( | |
750 WebTopControlsState constraints, | |
751 WebTopControlsState current, | |
752 bool animate) { | |
753 layer_tree_host_->UpdateTopControlsState(ConvertTopControlsState(constraints), | |
754 ConvertTopControlsState(current), | |
755 animate); | |
756 } | |
757 | |
758 void RenderWidgetCompositor::setTopControlsHeight(float height, bool shrink) { | |
759 layer_tree_host_->SetTopControlsHeight(height, shrink); | |
no sievers
2015/02/19 19:51:37
nit: indent
| |
760 } | |
761 | |
751 void RenderWidgetCompositor::setTopControlsContentOffset(float offset) { | 762 void RenderWidgetCompositor::setTopControlsContentOffset(float offset) { |
752 setTopControlsShownRatio(offset); | 763 setTopControlsShownRatio(offset); |
753 } | 764 } |
754 | 765 |
755 void RenderWidgetCompositor::setTopControlsShownRatio(float ratio) { | 766 void RenderWidgetCompositor::setTopControlsShownRatio(float ratio) { |
756 layer_tree_host_->SetTopControlsShownRatio(ratio); | 767 layer_tree_host_->SetTopControlsShownRatio(ratio); |
757 } | 768 } |
758 | 769 |
759 void RenderWidgetCompositor::WillBeginMainFrame() { | 770 void RenderWidgetCompositor::WillBeginMainFrame() { |
760 widget_->willBeginCompositorFrame(); | 771 widget_->willBeginCompositorFrame(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
879 widget_->OnSwapBuffersAborted(); | 890 widget_->OnSwapBuffersAborted(); |
880 } | 891 } |
881 | 892 |
882 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 893 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
883 cc::ContextProvider* provider = | 894 cc::ContextProvider* provider = |
884 compositor_deps_->GetSharedMainThreadContextProvider(); | 895 compositor_deps_->GetSharedMainThreadContextProvider(); |
885 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 896 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
886 } | 897 } |
887 | 898 |
888 } // namespace content | 899 } // namespace content |
OLD | NEW |