OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "webkit/support/web_layer_tree_view_impl_for_testing.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/strings/string_number_conversions.h" | |
9 #include "base/synchronization/lock.h" | |
10 #include "cc/base/switches.h" | |
11 #include "cc/debug/test_context_provider.h" | |
12 #include "cc/input/input_handler.h" | |
13 #include "cc/layers/layer.h" | |
14 #include "cc/output/output_surface.h" | |
15 #include "cc/trees/layer_tree_host.h" | |
16 #include "third_party/WebKit/public/platform/Platform.h" | |
17 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | |
18 #include "third_party/WebKit/public/platform/WebLayer.h" | |
19 #include "third_party/WebKit/public/platform/WebLayerTreeView.h" | |
20 #include "third_party/WebKit/public/platform/WebRenderingStats.h" | |
21 #include "third_party/WebKit/public/platform/WebSize.h" | |
22 #include "webkit/common/gpu/test_context_provider_factory.h" | |
23 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | |
24 #include "webkit/support/test_webkit_platform_support.h" | |
25 | |
26 using WebKit::WebColor; | |
27 using WebKit::WebGraphicsContext3D; | |
28 using WebKit::WebRect; | |
29 using WebKit::WebRenderingStats; | |
30 using WebKit::WebSize; | |
31 | |
32 namespace webkit { | |
33 | |
34 WebLayerTreeViewImplForTesting::WebLayerTreeViewImplForTesting() {} | |
35 | |
36 WebLayerTreeViewImplForTesting::~WebLayerTreeViewImplForTesting() {} | |
37 | |
38 bool WebLayerTreeViewImplForTesting::Initialize() { | |
39 cc::LayerTreeSettings settings; | |
40 | |
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; | |
44 | |
45 // Accelerated animations are enabled for unit tests. | |
46 settings.accelerated_animation_enabled = true; | |
47 layer_tree_host_ = cc::LayerTreeHost::Create(this, settings, NULL); | |
48 if (!layer_tree_host_) | |
49 return false; | |
50 return true; | |
51 } | |
52 | |
53 void WebLayerTreeViewImplForTesting::setSurfaceReady() { | |
54 layer_tree_host_->SetLayerTreeHostClientReady(); | |
55 } | |
56 | |
57 void WebLayerTreeViewImplForTesting::setRootLayer( | |
58 const WebKit::WebLayer& root) { | |
59 layer_tree_host_->SetRootLayer( | |
60 static_cast<const WebLayerImpl*>(&root)->layer()); | |
61 } | |
62 | |
63 void WebLayerTreeViewImplForTesting::clearRootLayer() { | |
64 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); | |
65 } | |
66 | |
67 void WebLayerTreeViewImplForTesting::setViewportSize( | |
68 const WebSize& unused_deprecated, | |
69 const WebSize& device_viewport_size) { | |
70 layer_tree_host_->SetViewportSize(device_viewport_size); | |
71 } | |
72 | |
73 WebSize WebLayerTreeViewImplForTesting::layoutViewportSize() const { | |
74 return layer_tree_host_->device_viewport_size(); | |
75 } | |
76 | |
77 WebSize WebLayerTreeViewImplForTesting::deviceViewportSize() const { | |
78 return layer_tree_host_->device_viewport_size(); | |
79 } | |
80 | |
81 void WebLayerTreeViewImplForTesting::setDeviceScaleFactor( | |
82 float device_scale_factor) { | |
83 layer_tree_host_->SetDeviceScaleFactor(device_scale_factor); | |
84 } | |
85 | |
86 float WebLayerTreeViewImplForTesting::deviceScaleFactor() const { | |
87 return layer_tree_host_->device_scale_factor(); | |
88 } | |
89 | |
90 void WebLayerTreeViewImplForTesting::setBackgroundColor(WebColor color) { | |
91 layer_tree_host_->set_background_color(color); | |
92 } | |
93 | |
94 void WebLayerTreeViewImplForTesting::setHasTransparentBackground( | |
95 bool transparent) { | |
96 layer_tree_host_->set_has_transparent_background(transparent); | |
97 } | |
98 | |
99 void WebLayerTreeViewImplForTesting::setVisible(bool visible) { | |
100 layer_tree_host_->SetVisible(visible); | |
101 } | |
102 | |
103 void WebLayerTreeViewImplForTesting::setPageScaleFactorAndLimits( | |
104 float page_scale_factor, | |
105 float minimum, | |
106 float maximum) { | |
107 layer_tree_host_->SetPageScaleFactorAndLimits( | |
108 page_scale_factor, minimum, maximum); | |
109 } | |
110 | |
111 void WebLayerTreeViewImplForTesting::startPageScaleAnimation( | |
112 const WebKit::WebPoint& scroll, | |
113 bool use_anchor, | |
114 float new_page_scale, | |
115 double duration_sec) {} | |
116 | |
117 void WebLayerTreeViewImplForTesting::setNeedsAnimate() { | |
118 layer_tree_host_->SetNeedsAnimate(); | |
119 } | |
120 | |
121 void WebLayerTreeViewImplForTesting::setNeedsRedraw() { | |
122 layer_tree_host_->SetNeedsRedraw(); | |
123 } | |
124 | |
125 bool WebLayerTreeViewImplForTesting::commitRequested() const { | |
126 return layer_tree_host_->CommitRequested(); | |
127 } | |
128 | |
129 void WebLayerTreeViewImplForTesting::composite() { | |
130 layer_tree_host_->Composite(base::TimeTicks::Now()); | |
131 } | |
132 | |
133 void WebLayerTreeViewImplForTesting::didStopFlinging() {} | |
134 | |
135 bool WebLayerTreeViewImplForTesting::compositeAndReadback( | |
136 void* pixels, const WebRect& rect_in_device_viewport) { | |
137 return layer_tree_host_->CompositeAndReadback(pixels, | |
138 rect_in_device_viewport); | |
139 } | |
140 | |
141 void WebLayerTreeViewImplForTesting::finishAllRendering() { | |
142 layer_tree_host_->FinishAllRendering(); | |
143 } | |
144 | |
145 void WebLayerTreeViewImplForTesting::setDeferCommits(bool defer_commits) { | |
146 layer_tree_host_->SetDeferCommits(defer_commits); | |
147 } | |
148 | |
149 void WebLayerTreeViewImplForTesting::renderingStats(WebRenderingStats&) const {} | |
150 | |
151 void WebLayerTreeViewImplForTesting::Layout() { | |
152 } | |
153 | |
154 void WebLayerTreeViewImplForTesting::ApplyScrollAndScale( | |
155 gfx::Vector2d scroll_delta, | |
156 float page_scale) {} | |
157 | |
158 scoped_ptr<cc::OutputSurface> | |
159 WebLayerTreeViewImplForTesting::CreateOutputSurface(bool fallback) { | |
160 return make_scoped_ptr( | |
161 new cc::OutputSurface(cc::TestContextProvider::Create())); | |
162 } | |
163 | |
164 void WebLayerTreeViewImplForTesting::ScheduleComposite() { | |
165 } | |
166 | |
167 scoped_refptr<cc::ContextProvider> | |
168 WebLayerTreeViewImplForTesting::OffscreenContextProviderForMainThread() { | |
169 return webkit::gpu::TestContextProviderFactory::GetInstance()-> | |
170 OffscreenContextProviderForMainThread(); | |
171 } | |
172 | |
173 scoped_refptr<cc::ContextProvider> | |
174 WebLayerTreeViewImplForTesting::OffscreenContextProviderForCompositorThread() { | |
175 NOTREACHED(); | |
176 return NULL; | |
177 } | |
178 | |
179 } // namespace webkit | |
OLD | NEW |