Improve parsing manifest for FSP API.
[chromium-blink-merge.git] / content / test / web_layer_tree_view_impl_for_testing.cc
blob6d4122056f7a9415d2bb9e90112978c98ce7be9b
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
3 // found in the LICENSE file.
5 #include "content/test/web_layer_tree_view_impl_for_testing.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/synchronization/lock.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "cc/base/switches.h"
12 #include "cc/blink/web_layer_impl.h"
13 #include "cc/input/input_handler.h"
14 #include "cc/layers/layer.h"
15 #include "cc/scheduler/begin_frame_source.h"
16 #include "cc/test/pixel_test_output_surface.h"
17 #include "cc/test/test_context_provider.h"
18 #include "cc/trees/layer_tree_host.h"
19 #include "content/test/test_blink_web_unit_test_support.h"
20 #include "third_party/WebKit/public/platform/Platform.h"
21 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
22 #include "third_party/WebKit/public/platform/WebLayer.h"
23 #include "third_party/WebKit/public/platform/WebLayerTreeView.h"
24 #include "third_party/WebKit/public/platform/WebSize.h"
25 #include "ui/gfx/frame_time.h"
27 using blink::WebColor;
28 using blink::WebGraphicsContext3D;
29 using blink::WebRect;
30 using blink::WebSize;
32 namespace content {
34 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting() {}
36 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {}
38 void WebLayerTreeViewImplForTesting::Initialize() {
39 cc::LayerTreeSettings settings;
41 // For web contents, layer transforms should scale up the contents of layers
42 // to keep content always crisp when possible.
43 settings.layer_transforms_should_scale_layer_contents = true;
45 // Accelerated animations are enabled for unit tests.
46 settings.accelerated_animation_enabled = true;
47 cc::LayerTreeHost::InitParams params;
48 params.client = this;
49 params.settings = &settings;
50 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
51 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params);
52 DCHECK(layer_tree_host_);
55 void WebLayerTreeViewImplForTesting::setRootLayer(
56 const blink::WebLayer& root) {
57 layer_tree_host_->SetRootLayer(
58 static_cast<const cc_blink::WebLayerImpl*>(&root)->layer());
61 void WebLayerTreeViewImplForTesting::clearRootLayer() {
62 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>());
65 void WebLayerTreeViewImplForTesting::setViewportSize(
66 const WebSize& unused_deprecated,
67 const WebSize& device_viewport_size) {
68 layer_tree_host_->SetViewportSize(device_viewport_size);
71 void WebLayerTreeViewImplForTesting::setViewportSize(
72 const WebSize& device_viewport_size) {
73 layer_tree_host_->SetViewportSize(device_viewport_size);
76 WebSize WebLayerTreeViewImplForTesting::layoutViewportSize() const {
77 return layer_tree_host_->device_viewport_size();
80 WebSize WebLayerTreeViewImplForTesting::deviceViewportSize() const {
81 return layer_tree_host_->device_viewport_size();
84 void WebLayerTreeViewImplForTesting::setDeviceScaleFactor(
85 float device_scale_factor) {
86 layer_tree_host_->SetDeviceScaleFactor(device_scale_factor);
89 float WebLayerTreeViewImplForTesting::deviceScaleFactor() const {
90 return layer_tree_host_->device_scale_factor();
93 void WebLayerTreeViewImplForTesting::setBackgroundColor(WebColor color) {
94 layer_tree_host_->set_background_color(color);
97 void WebLayerTreeViewImplForTesting::setHasTransparentBackground(
98 bool transparent) {
99 layer_tree_host_->set_has_transparent_background(transparent);
102 void WebLayerTreeViewImplForTesting::setVisible(bool visible) {
103 layer_tree_host_->SetVisible(visible);
106 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits(
107 float page_scale_factor,
108 float minimum,
109 float maximum) {
110 layer_tree_host_->SetPageScaleFactorAndLimits(
111 page_scale_factor, minimum, maximum);
114 void WebLayerTreeViewImplForTesting::startPageScaleAnimation(
115 const blink::WebPoint& scroll,
116 bool use_anchor,
117 float new_page_scale,
118 double duration_sec) {}
120 void WebLayerTreeViewImplForTesting::setNeedsAnimate() {
121 layer_tree_host_->SetNeedsAnimate();
124 bool WebLayerTreeViewImplForTesting::commitRequested() const {
125 return layer_tree_host_->CommitRequested();
128 void WebLayerTreeViewImplForTesting::didStopFlinging() {}
130 void WebLayerTreeViewImplForTesting::finishAllRendering() {
131 layer_tree_host_->FinishAllRendering();
134 void WebLayerTreeViewImplForTesting::setDeferCommits(bool defer_commits) {
135 layer_tree_host_->SetDeferCommits(defer_commits);
138 void WebLayerTreeViewImplForTesting::Layout() {
141 void WebLayerTreeViewImplForTesting::ApplyViewportDeltas(
142 const gfx::Vector2dF& inner_delta,
143 const gfx::Vector2dF& outer_delta,
144 const gfx::Vector2dF& elastic_overscroll_delta,
145 float page_scale,
146 float top_controls_delta) {
149 void WebLayerTreeViewImplForTesting::ApplyViewportDeltas(
150 const gfx::Vector2d& scroll_delta,
151 float page_scale,
152 float top_controls_delta) {}
154 void WebLayerTreeViewImplForTesting::RequestNewOutputSurface() {
155 bool flipped_output_surface = false;
156 layer_tree_host_->SetOutputSurface(
157 make_scoped_ptr(new cc::PixelTestOutputSurface(
158 cc::TestContextProvider::Create(), flipped_output_surface)));
161 void WebLayerTreeViewImplForTesting::DidFailToInitializeOutputSurface() {
162 RequestNewOutputSurface();
165 void WebLayerTreeViewImplForTesting::registerViewportLayers(
166 const blink::WebLayer* overscrollElasticityLayer,
167 const blink::WebLayer* pageScaleLayer,
168 const blink::WebLayer* innerViewportScrollLayer,
169 const blink::WebLayer* outerViewportScrollLayer) {
170 layer_tree_host_->RegisterViewportLayers(
171 // The scroll elasticity layer will only exist when using pinch virtual
172 // viewports.
173 overscrollElasticityLayer
174 ? static_cast<const cc_blink::WebLayerImpl*>(
175 overscrollElasticityLayer)->layer()
176 : NULL,
177 static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(),
178 static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer)
179 ->layer(),
180 // The outer viewport layer will only exist when using pinch virtual
181 // viewports.
182 outerViewportScrollLayer
183 ? static_cast<const cc_blink::WebLayerImpl*>(outerViewportScrollLayer)
184 ->layer()
185 : NULL);
188 void WebLayerTreeViewImplForTesting::clearViewportLayers() {
189 layer_tree_host_->RegisterViewportLayers(scoped_refptr<cc::Layer>(),
190 scoped_refptr<cc::Layer>(),
191 scoped_refptr<cc::Layer>(),
192 scoped_refptr<cc::Layer>());
195 void WebLayerTreeViewImplForTesting::registerSelection(
196 const blink::WebSelection& selection) {
199 void WebLayerTreeViewImplForTesting::clearSelection() {
202 } // namespace content