| 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 "platform/testing/WebLayerTreeViewImplForTesting.h" | 5 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| 6 | 6 |
| 7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
| 9 #include "cc/animation/animation_timeline.h" | 9 #include "cc/animation/animation_timeline.h" |
| 10 #include "cc/blink/web_layer_impl.h" | 10 #include "cc/blink/web_layer_impl.h" |
| 11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
| 12 #include "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
| 13 #include "public/platform/Platform.h" | 13 #include "public/platform/Platform.h" |
| 14 #include "public/platform/WebLayer.h" | 14 #include "public/platform/WebLayer.h" |
| 15 #include "public/platform/WebLayerTreeView.h" | 15 #include "public/platform/WebLayerTreeView.h" |
| 16 #include "public/platform/WebSize.h" | 16 #include "public/platform/WebSize.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting() | 20 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting() |
| 21 : WebLayerTreeViewImplForTesting(defaultLayerTreeSettings()) | 21 : WebLayerTreeViewImplForTesting(defaultLayerTreeSettings()) |
| 22 { | 22 { |
| 23 } | 23 } |
| 24 | 24 |
| 25 static cc::LayerTreeSettings settingsForLayerListPolicy(WebLayerTreeViewImplForT
esting::LayerListPolicy policy) |
| 26 { |
| 27 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::defaultLaye
rTreeSettings(); |
| 28 settings.use_layer_lists = policy == WebLayerTreeViewImplForTesting::UseLaye
rLists; |
| 29 return settings; |
| 30 } |
| 31 |
| 32 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting(LayerListPolicy p
olicy) |
| 33 : WebLayerTreeViewImplForTesting(settingsForLayerListPolicy(policy)) |
| 34 { |
| 35 } |
| 36 |
| 25 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting(const cc::LayerTr
eeSettings& settings) | 37 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting(const cc::LayerTr
eeSettings& settings) |
| 26 { | 38 { |
| 27 cc::LayerTreeHost::InitParams params; | 39 cc::LayerTreeHost::InitParams params; |
| 28 params.client = this; | 40 params.client = this; |
| 29 params.settings = &settings; | 41 params.settings = &settings; |
| 30 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 42 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 31 params.task_graph_runner = &m_taskGraphRunner; | 43 params.task_graph_runner = &m_taskGraphRunner; |
| 32 params.animation_host = cc::AnimationHost::CreateForTesting(cc::ThreadInstan
ce::MAIN); | 44 params.animation_host = cc::AnimationHost::CreateForTesting(cc::ThreadInstan
ce::MAIN); |
| 33 m_layerTreeHost = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 45 m_layerTreeHost = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
| 34 ASSERT(m_layerTreeHost); | 46 ASSERT(m_layerTreeHost); |
| 35 } | 47 } |
| 36 | 48 |
| 37 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {} | 49 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {} |
| 38 | 50 |
| 39 // static | 51 // static |
| 40 cc::LayerTreeSettings WebLayerTreeViewImplForTesting::defaultLayerTreeSettings() | 52 cc::LayerTreeSettings WebLayerTreeViewImplForTesting::defaultLayerTreeSettings() |
| 41 { | 53 { |
| 42 cc::LayerTreeSettings settings; | 54 cc::LayerTreeSettings settings; |
| 43 | 55 |
| 44 // For web contents, layer transforms should scale up the contents of layers | 56 // For web contents, layer transforms should scale up the contents of layers |
| 45 // to keep content always crisp when possible. | 57 // to keep content always crisp when possible. |
| 46 settings.layer_transforms_should_scale_layer_contents = true; | 58 settings.layer_transforms_should_scale_layer_contents = true; |
| 47 | 59 |
| 48 return settings; | 60 return settings; |
| 49 } | 61 } |
| 50 | 62 |
| 63 bool WebLayerTreeViewImplForTesting::hasLayer(const WebLayer& layer) |
| 64 { |
| 65 return layer.ccLayer()->layer_tree_host() == m_layerTreeHost.get(); |
| 66 } |
| 67 |
| 51 void WebLayerTreeViewImplForTesting::setRootLayer(const blink::WebLayer& root) | 68 void WebLayerTreeViewImplForTesting::setRootLayer(const blink::WebLayer& root) |
| 52 { | 69 { |
| 53 m_layerTreeHost->SetRootLayer(static_cast<const cc_blink::WebLayerImpl*>(&ro
ot)->layer()); | 70 m_layerTreeHost->SetRootLayer(static_cast<const cc_blink::WebLayerImpl*>(&ro
ot)->layer()); |
| 54 } | 71 } |
| 55 | 72 |
| 56 void WebLayerTreeViewImplForTesting::clearRootLayer() | 73 void WebLayerTreeViewImplForTesting::clearRootLayer() |
| 57 { | 74 { |
| 58 m_layerTreeHost->SetRootLayer(scoped_refptr<cc::Layer>()); | 75 m_layerTreeHost->SetRootLayer(scoped_refptr<cc::Layer>()); |
| 59 } | 76 } |
| 60 | 77 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 { | 228 { |
| 212 m_layerTreeHost->SetHaveScrollEventHandlers(haveEentHandlers); | 229 m_layerTreeHost->SetHaveScrollEventHandlers(haveEentHandlers); |
| 213 } | 230 } |
| 214 | 231 |
| 215 bool WebLayerTreeViewImplForTesting::haveScrollEventHandlers() const | 232 bool WebLayerTreeViewImplForTesting::haveScrollEventHandlers() const |
| 216 { | 233 { |
| 217 return m_layerTreeHost->have_scroll_event_handlers(); | 234 return m_layerTreeHost->have_scroll_event_handlers(); |
| 218 } | 235 } |
| 219 | 236 |
| 220 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |