| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/test/web_layer_tree_view_impl_for_testing.h" | 5 #include "content/test/web_layer_tree_view_impl_for_testing.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "cc/base/switches.h" | 10 #include "cc/base/switches.h" |
| 11 #include "cc/input/input_handler.h" | 11 #include "cc/input/input_handler.h" |
| 12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
| 13 #include "cc/output/output_surface.h" | 13 #include "cc/output/output_surface.h" |
| 14 #include "cc/test/test_context_provider.h" | 14 #include "cc/test/test_context_provider.h" |
| 15 #include "cc/trees/layer_tree_host.h" | 15 #include "cc/trees/layer_tree_host.h" |
| 16 #include "content/test/test_webkit_platform_support.h" | 16 #include "content/test/test_webkit_platform_support.h" |
| 17 #include "third_party/WebKit/public/platform/Platform.h" | 17 #include "third_party/WebKit/public/platform/Platform.h" |
| 18 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 18 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 19 #include "third_party/WebKit/public/platform/WebLayer.h" | 19 #include "third_party/WebKit/public/platform/WebLayer.h" |
| 20 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" | 20 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" |
| 21 #include "third_party/WebKit/public/platform/WebRenderingStats.h" | 21 #include "third_party/WebKit/public/platform/WebRenderingStats.h" |
| 22 #include "third_party/WebKit/public/platform/WebSize.h" | 22 #include "third_party/WebKit/public/platform/WebSize.h" |
| 23 #include "ui/gfx/frame_time.h" | 23 #include "ui/gfx/frame_time.h" |
| 24 #include "webkit/common/gpu/test_context_provider_factory.h" | 24 #include "webkit/common/gpu/test_context_provider_factory.h" |
| 25 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 25 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
| 26 | 26 |
| 27 using WebKit::WebColor; | 27 using blink::WebColor; |
| 28 using WebKit::WebGraphicsContext3D; | 28 using blink::WebGraphicsContext3D; |
| 29 using WebKit::WebRect; | 29 using blink::WebRect; |
| 30 using WebKit::WebRenderingStats; | 30 using blink::WebRenderingStats; |
| 31 using WebKit::WebSize; | 31 using blink::WebSize; |
| 32 | 32 |
| 33 namespace webkit { | 33 namespace webkit { |
| 34 | 34 |
| 35 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting() {} | 35 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting() {} |
| 36 | 36 |
| 37 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {} | 37 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {} |
| 38 | 38 |
| 39 bool WebLayerTreeViewImplForTesting::Initialize() { | 39 bool WebLayerTreeViewImplForTesting::Initialize() { |
| 40 cc::LayerTreeSettings settings; | 40 cc::LayerTreeSettings settings; |
| 41 | 41 |
| 42 // For web contents, layer transforms should scale up the contents of layers | 42 // For web contents, layer transforms should scale up the contents of layers |
| 43 // to keep content always crisp when possible. | 43 // to keep content always crisp when possible. |
| 44 settings.layer_transforms_should_scale_layer_contents = true; | 44 settings.layer_transforms_should_scale_layer_contents = true; |
| 45 | 45 |
| 46 // Accelerated animations are enabled for unit tests. | 46 // Accelerated animations are enabled for unit tests. |
| 47 settings.accelerated_animation_enabled = true; | 47 settings.accelerated_animation_enabled = true; |
| 48 layer_tree_host_ = cc::LayerTreeHost::Create(this, NULL, settings, NULL); | 48 layer_tree_host_ = cc::LayerTreeHost::Create(this, NULL, settings, NULL); |
| 49 if (!layer_tree_host_) | 49 if (!layer_tree_host_) |
| 50 return false; | 50 return false; |
| 51 return true; | 51 return true; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void WebLayerTreeViewImplForTesting::setSurfaceReady() { | 54 void WebLayerTreeViewImplForTesting::setSurfaceReady() { |
| 55 layer_tree_host_->SetLayerTreeHostClientReady(); | 55 layer_tree_host_->SetLayerTreeHostClientReady(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void WebLayerTreeViewImplForTesting::setRootLayer( | 58 void WebLayerTreeViewImplForTesting::setRootLayer( |
| 59 const WebKit::WebLayer& root) { | 59 const blink::WebLayer& root) { |
| 60 layer_tree_host_->SetRootLayer( | 60 layer_tree_host_->SetRootLayer( |
| 61 static_cast<const WebLayerImpl*>(&root)->layer()); | 61 static_cast<const WebLayerImpl*>(&root)->layer()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void WebLayerTreeViewImplForTesting::clearRootLayer() { | 64 void WebLayerTreeViewImplForTesting::clearRootLayer() { |
| 65 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); | 65 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void WebLayerTreeViewImplForTesting::setViewportSize( | 68 void WebLayerTreeViewImplForTesting::setViewportSize( |
| 69 const WebSize& unused_deprecated, | 69 const WebSize& unused_deprecated, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits( | 104 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits( |
| 105 float page_scale_factor, | 105 float page_scale_factor, |
| 106 float minimum, | 106 float minimum, |
| 107 float maximum) { | 107 float maximum) { |
| 108 layer_tree_host_->SetPageScaleFactorAndLimits( | 108 layer_tree_host_->SetPageScaleFactorAndLimits( |
| 109 page_scale_factor, minimum, maximum); | 109 page_scale_factor, minimum, maximum); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void WebLayerTreeViewImplForTesting::startPageScaleAnimation( | 112 void WebLayerTreeViewImplForTesting::startPageScaleAnimation( |
| 113 const WebKit::WebPoint& scroll, | 113 const blink::WebPoint& scroll, |
| 114 bool use_anchor, | 114 bool use_anchor, |
| 115 float new_page_scale, | 115 float new_page_scale, |
| 116 double duration_sec) {} | 116 double duration_sec) {} |
| 117 | 117 |
| 118 void WebLayerTreeViewImplForTesting::setNeedsAnimate() { | 118 void WebLayerTreeViewImplForTesting::setNeedsAnimate() { |
| 119 layer_tree_host_->SetNeedsAnimate(); | 119 layer_tree_host_->SetNeedsAnimate(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void WebLayerTreeViewImplForTesting::setNeedsRedraw() { | 122 void WebLayerTreeViewImplForTesting::setNeedsRedraw() { |
| 123 layer_tree_host_->SetNeedsRedraw(); | 123 layer_tree_host_->SetNeedsRedraw(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 | 167 |
| 168 scoped_refptr<cc::ContextProvider> | 168 scoped_refptr<cc::ContextProvider> |
| 169 WebLayerTreeViewImplForTesting::OffscreenContextProvider() { | 169 WebLayerTreeViewImplForTesting::OffscreenContextProvider() { |
| 170 // Unit tests only run in single threaded mode. | 170 // Unit tests only run in single threaded mode. |
| 171 return webkit::gpu::TestContextProviderFactory::GetInstance()-> | 171 return webkit::gpu::TestContextProviderFactory::GetInstance()-> |
| 172 OffscreenContextProviderForMainThread(); | 172 OffscreenContextProviderForMainThread(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace webkit | 175 } // namespace webkit |
| OLD | NEW |