| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 namespace cc { | 58 namespace cc { |
| 59 class Layer; | 59 class Layer; |
| 60 } | 60 } |
| 61 | 61 |
| 62 using blink::WebBeginFrameArgs; | 62 using blink::WebBeginFrameArgs; |
| 63 using blink::WebFloatPoint; | 63 using blink::WebFloatPoint; |
| 64 using blink::WebRect; | 64 using blink::WebRect; |
| 65 using blink::WebSelectionBound; | 65 using blink::WebSelectionBound; |
| 66 using blink::WebSize; | 66 using blink::WebSize; |
| 67 using blink::WebTopControlsState; |
| 67 | 68 |
| 68 namespace content { | 69 namespace content { |
| 69 namespace { | 70 namespace { |
| 70 | 71 |
| 71 bool GetSwitchValueAsInt(const base::CommandLine& command_line, | 72 bool GetSwitchValueAsInt(const base::CommandLine& command_line, |
| 72 const std::string& switch_string, | 73 const std::string& switch_string, |
| 73 int min_value, | 74 int min_value, |
| 74 int max_value, | 75 int max_value, |
| 75 int* result) { | 76 int* result) { |
| 76 std::string string_value = command_line.GetSwitchValueASCII(switch_string); | 77 std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 int numTiles = (display_width * display_height) / (256 * 256); | 149 int numTiles = (display_width * display_height) / (256 * 256); |
| 149 if (numTiles > 16) | 150 if (numTiles > 16) |
| 150 default_tile_size = 384; | 151 default_tile_size = 384; |
| 151 if (numTiles >= 40) | 152 if (numTiles >= 40) |
| 152 default_tile_size = 512; | 153 default_tile_size = 512; |
| 153 } | 154 } |
| 154 #endif | 155 #endif |
| 155 return gfx::Size(default_tile_size, default_tile_size); | 156 return gfx::Size(default_tile_size, default_tile_size); |
| 156 } | 157 } |
| 157 | 158 |
| 159 // Check cc::TopControlsState, and blink::WebTopControlsState |
| 160 // are kept in sync. |
| 161 static_assert(int(blink::WebTopControlsBoth) == int(cc::BOTH), |
| 162 "mismatching enums: BOTH"); |
| 163 static_assert(int(blink::WebTopControlsHidden) == int(cc::HIDDEN), |
| 164 "mismatching enums: HIDDEN"); |
| 165 static_assert(int(blink::WebTopControlsShown) == int(cc::SHOWN), |
| 166 "mismatching enums: SHOWN"); |
| 167 |
| 168 static cc::TopControlsState ConvertTopControlsState( |
| 169 WebTopControlsState state) { |
| 170 return static_cast<cc::TopControlsState>(state); |
| 171 } |
| 172 |
| 158 } // namespace | 173 } // namespace |
| 159 | 174 |
| 160 // static | 175 // static |
| 161 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( | 176 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( |
| 162 RenderWidget* widget, | 177 RenderWidget* widget, |
| 163 CompositorDependencies* compositor_deps) { | 178 CompositorDependencies* compositor_deps) { |
| 164 scoped_ptr<RenderWidgetCompositor> compositor( | 179 scoped_ptr<RenderWidgetCompositor> compositor( |
| 165 new RenderWidgetCompositor(widget, compositor_deps)); | 180 new RenderWidgetCompositor(widget, compositor_deps)); |
| 166 compositor->Initialize(); | 181 compositor->Initialize(); |
| 167 return compositor; | 182 return compositor; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { | 484 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { |
| 470 layer_tree_host_->SetNeedsDisplayOnAllLayers(); | 485 layer_tree_host_->SetNeedsDisplayOnAllLayers(); |
| 471 } | 486 } |
| 472 | 487 |
| 473 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { | 488 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { |
| 474 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); | 489 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); |
| 475 current.rasterize_only_visible_content = true; | 490 current.rasterize_only_visible_content = true; |
| 476 layer_tree_host_->SetDebugState(current); | 491 layer_tree_host_->SetDebugState(current); |
| 477 } | 492 } |
| 478 | 493 |
| 479 void RenderWidgetCompositor::UpdateTopControlsState( | |
| 480 cc::TopControlsState constraints, | |
| 481 cc::TopControlsState current, | |
| 482 bool animate) { | |
| 483 layer_tree_host_->UpdateTopControlsState(constraints, | |
| 484 current, | |
| 485 animate); | |
| 486 } | |
| 487 | |
| 488 void RenderWidgetCompositor::SetTopControlsShrinkBlinkSize(bool shrink) { | |
| 489 layer_tree_host_->SetTopControlsShrinkBlinkSize(shrink); | |
| 490 } | |
| 491 | |
| 492 void RenderWidgetCompositor::SetTopControlsHeight(float height) { | |
| 493 layer_tree_host_->SetTopControlsHeight(height); | |
| 494 } | |
| 495 | |
| 496 void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) { | 494 void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) { |
| 497 layer_tree_host_->SetNeedsRedrawRect(damage_rect); | 495 layer_tree_host_->SetNeedsRedrawRect(damage_rect); |
| 498 } | 496 } |
| 499 | 497 |
| 500 void RenderWidgetCompositor::SetNeedsForcedRedraw() { | 498 void RenderWidgetCompositor::SetNeedsForcedRedraw() { |
| 501 layer_tree_host_->SetNextCommitForcesRedraw(); | 499 layer_tree_host_->SetNextCommitForcesRedraw(); |
| 502 setNeedsAnimate(); | 500 setNeedsAnimate(); |
| 503 } | 501 } |
| 504 | 502 |
| 505 scoped_ptr<cc::SwapPromiseMonitor> | 503 scoped_ptr<cc::SwapPromiseMonitor> |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } | 753 } |
| 756 | 754 |
| 757 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { | 755 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { |
| 758 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); | 756 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); |
| 759 debug_state.show_touch_event_handler_rects = show; | 757 debug_state.show_touch_event_handler_rects = show; |
| 760 debug_state.show_wheel_event_handler_rects = show; | 758 debug_state.show_wheel_event_handler_rects = show; |
| 761 debug_state.show_non_fast_scrollable_rects = show; | 759 debug_state.show_non_fast_scrollable_rects = show; |
| 762 layer_tree_host_->SetDebugState(debug_state); | 760 layer_tree_host_->SetDebugState(debug_state); |
| 763 } | 761 } |
| 764 | 762 |
| 763 void RenderWidgetCompositor::updateTopControlsState( |
| 764 WebTopControlsState constraints, |
| 765 WebTopControlsState current, |
| 766 bool animate) { |
| 767 layer_tree_host_->UpdateTopControlsState(ConvertTopControlsState(constraints), |
| 768 ConvertTopControlsState(current), |
| 769 animate); |
| 770 } |
| 771 |
| 772 void RenderWidgetCompositor::setTopControlsHeight(float height, bool shrink) { |
| 773 layer_tree_host_->SetTopControlsHeight(height, shrink); |
| 774 } |
| 775 |
| 765 void RenderWidgetCompositor::setTopControlsContentOffset(float offset) { | 776 void RenderWidgetCompositor::setTopControlsContentOffset(float offset) { |
| 766 setTopControlsShownRatio(offset); | 777 setTopControlsShownRatio(offset); |
| 767 } | 778 } |
| 768 | 779 |
| 769 void RenderWidgetCompositor::setTopControlsShownRatio(float ratio) { | 780 void RenderWidgetCompositor::setTopControlsShownRatio(float ratio) { |
| 770 layer_tree_host_->SetTopControlsShownRatio(ratio); | 781 layer_tree_host_->SetTopControlsShownRatio(ratio); |
| 771 } | 782 } |
| 772 | 783 |
| 773 void RenderWidgetCompositor::WillBeginMainFrame() { | 784 void RenderWidgetCompositor::WillBeginMainFrame() { |
| 774 widget_->willBeginCompositorFrame(); | 785 widget_->willBeginCompositorFrame(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 widget_->OnSwapBuffersAborted(); | 908 widget_->OnSwapBuffersAborted(); |
| 898 } | 909 } |
| 899 | 910 |
| 900 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 911 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
| 901 cc::ContextProvider* provider = | 912 cc::ContextProvider* provider = |
| 902 compositor_deps_->GetSharedMainThreadContextProvider(); | 913 compositor_deps_->GetSharedMainThreadContextProvider(); |
| 903 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 914 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
| 904 } | 915 } |
| 905 | 916 |
| 906 } // namespace content | 917 } // namespace content |
| OLD | NEW |