Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/Source/web/tests/CompositorWorkerTest.cpp

Issue 1602343002: compositor-worker: cc->blink mutation plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor-worker-ian-patch
Patch Set: Merge master + s/scoped_ptr/unique_ptr/ Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/frame/FrameView.h" 5 #include "core/frame/FrameView.h"
6 #include "core/layout/api/LayoutViewItem.h" 6 #include "core/layout/api/LayoutViewItem.h"
7 #include "core/layout/compositing/CompositedLayerMapping.h" 7 #include "core/layout/compositing/CompositedLayerMapping.h"
8 #include "core/layout/compositing/PaintLayerCompositor.h" 8 #include "core/layout/compositing/PaintLayerCompositor.h"
9 #include "core/page/Page.h" 9 #include "core/page/Page.h"
10 #include "platform/graphics/CompositorMutableProperties.h" 10 #include "platform/graphics/CompositorMutableProperties.h"
11 #include "platform/graphics/CompositorMutation.h"
11 #include "platform/graphics/GraphicsLayer.h" 12 #include "platform/graphics/GraphicsLayer.h"
12 #include "platform/testing/URLTestHelpers.h" 13 #include "platform/testing/URLTestHelpers.h"
13 #include "public/platform/Platform.h" 14 #include "public/platform/Platform.h"
14 #include "public/platform/WebLayer.h" 15 #include "public/platform/WebLayer.h"
15 #include "public/platform/WebLayerTreeView.h" 16 #include "public/platform/WebLayerTreeView.h"
16 #include "public/platform/WebURLLoaderMockFactory.h" 17 #include "public/platform/WebURLLoaderMockFactory.h"
17 #include "public/web/WebCache.h" 18 #include "public/web/WebCache.h"
18 #include "public/web/WebSettings.h" 19 #include "public/web/WebSettings.h"
19 #include "public/web/WebViewClient.h" 20 #include "public/web/WebViewClient.h"
20 #include "web/WebLocalFrameImpl.h" 21 #include "web/WebLocalFrameImpl.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 navigateTo(m_baseURL + "compositor-proxy-basic.html"); 129 navigateTo(m_baseURL + "compositor-proxy-basic.html");
129 130
130 forceFullCompositingUpdate(); 131 forceFullCompositingUpdate();
131 132
132 Document* document = frame()->document(); 133 Document* document = frame()->document();
133 134
134 Element* tallElement = document->getElementById("tall"); 135 Element* tallElement = document->getElementById("tall");
135 WebLayer* tallLayer = webLayerFromElement(tallElement); 136 WebLayer* tallLayer = webLayerFromElement(tallElement);
136 EXPECT_TRUE(!tallLayer); 137 EXPECT_TRUE(!tallLayer);
137 138
138 Element* proxiedElement = document->getElementById("proxied"); 139 Element* proxiedElement = document->getElementById("proxied-transform");
139 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement); 140 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement);
140 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP roperty::kTransform); 141 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP roperty::kTransform);
141 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutabl eProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorMutab leProperty::kOpacity)); 142 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutabl eProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorMutab leProperty::kOpacity));
142 EXPECT_NE(0UL, proxiedLayer->elementId()); 143 EXPECT_NE(0UL, proxiedLayer->elementId());
143 144
144 Element* scrollElement = document->getElementById("proxied-scroller"); 145 Element* scrollElement = document->getElementById("proxied-scroller");
145 WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement); 146 WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement);
146 EXPECT_TRUE(scrollLayer->compositorMutableProperties() & (CompositorMutableP roperty::kScrollLeft | CompositorMutableProperty::kScrollTop)); 147 EXPECT_TRUE(scrollLayer->compositorMutableProperties() & (CompositorMutableP roperty::kScrollLeft | CompositorMutableProperty::kScrollTop));
147 EXPECT_FALSE(scrollLayer->compositorMutableProperties() & (CompositorMutable Property::kTransform | CompositorMutableProperty::kOpacity)); 148 EXPECT_FALSE(scrollLayer->compositorMutableProperties() & (CompositorMutable Property::kTransform | CompositorMutableProperty::kOpacity));
148 EXPECT_NE(0UL, scrollLayer->elementId()); 149 EXPECT_NE(0UL, scrollLayer->elementId());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 Element* scrollElement = document->getElementById("proxied-scroller"); 206 Element* scrollElement = document->getElementById("proxied-scroller");
206 WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement); 207 WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement);
207 EXPECT_FALSE(!!scrollLayer->compositorMutableProperties()); 208 EXPECT_FALSE(!!scrollLayer->compositorMutableProperties());
208 EXPECT_EQ(0UL, scrollLayer->elementId()); 209 EXPECT_EQ(0UL, scrollLayer->elementId());
209 210
210 WebLayer* rootScrollLayer = getRootScrollLayer(); 211 WebLayer* rootScrollLayer = getRootScrollLayer();
211 EXPECT_FALSE(!!rootScrollLayer->compositorMutableProperties()); 212 EXPECT_FALSE(!!rootScrollLayer->compositorMutableProperties());
212 EXPECT_EQ(0UL, rootScrollLayer->elementId()); 213 EXPECT_EQ(0UL, rootScrollLayer->elementId());
213 } 214 }
214 215
216 TEST_F(CompositorWorkerTest, applyingMutationsMultipleElements)
217 {
218 registerMockedHttpURLLoad("compositor-proxy-basic.html");
219 navigateTo(m_baseURL + "compositor-proxy-basic.html");
220
221 Document* document = frame()->document();
222
223 {
224 forceFullCompositingUpdate();
225
226 Element* proxiedElement = document->getElementById("proxied-transform");
227 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement);
228 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMuta bleProperty::kTransform);
229 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMu tableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorM utableProperty::kOpacity));
230 uint64_t elementId = proxiedLayer->elementId();
231 EXPECT_NE(0UL, elementId);
232
233 TransformationMatrix transformMatrix(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44);
234 CompositorMutation mutation;
235 mutation.setTransform(TransformationMatrix::toSkMatrix44(transformMatrix ));
236
237 proxiedElement->updateFromCompositorMutation(mutation);
238
239 forceFullCompositingUpdate();
240 const String& cssValue = document->domWindow()->getComputedStyle(proxied Element, String())->getPropertyValueInternal(CSSPropertyTransform);
241 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44)", cssValue);
242 }
243 {
244 Element* proxiedElement = document->getElementById("proxied-opacity");
245 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement);
246 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMuta bleProperty::kOpacity);
247 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMu tableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorM utableProperty::kTransform));
248 uint64_t elementId = proxiedLayer->elementId();
249 EXPECT_NE(0UL, elementId);
250
251 CompositorMutation mutation;
252 mutation.setOpacity(0.5);
253
254 proxiedElement->updateFromCompositorMutation(mutation);
255
256 forceFullCompositingUpdate();
257 const String& cssValue = document->domWindow()->getComputedStyle(proxied Element, String())->getPropertyValueInternal(CSSPropertyOpacity);
258 EXPECT_EQ("0.5", cssValue);
259 }
260 }
261
262 TEST_F(CompositorWorkerTest, applyingMutationsMultipleProperties)
263 {
264 registerMockedHttpURLLoad("compositor-proxy-basic.html");
265 navigateTo(m_baseURL + "compositor-proxy-basic.html");
266
267 Document* document = frame()->document();
268
269 forceFullCompositingUpdate();
270
271 Element* proxiedElement = document->getElementById("proxied-transform-and-op acity");
272 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement);
273 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP roperty::kTransform);
274 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP roperty::kOpacity);
275 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutabl eProperty::kScrollLeft | CompositorMutableProperty::kScrollTop));
276 uint64_t elementId = proxiedLayer->elementId();
277 EXPECT_NE(0UL, elementId);
278
279 TransformationMatrix transformMatrix(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44);
280 OwnPtr<CompositorMutation> mutation = adoptPtr(new CompositorMutation);
281 mutation->setTransform(TransformationMatrix::toSkMatrix44(transformMatrix));
282 mutation->setOpacity(0.5);
283
284 proxiedElement->updateFromCompositorMutation(*mutation);
285 {
286 const String& transformValue = document->domWindow()->getComputedStyle( proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform);
287 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44)", transformValue);
288
289 const String& opacityValue = document->domWindow()->getComputedStyle(pro xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity);
290 EXPECT_EQ("0.5", opacityValue);
291 }
292
293 // Verify that updating one property does not impact others
294 mutation = adoptPtr(new CompositorMutation);
295 mutation->setOpacity(0.8);
296
297 proxiedElement->updateFromCompositorMutation(*mutation);
298 {
299 const String& transformValue = document->domWindow()->getComputedStyle( proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform);
300 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44)", transformValue);
301
302 const String& opacityValue = document->domWindow()->getComputedStyle(pro xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity);
303 EXPECT_EQ("0.8", opacityValue);
304 }
305 }
306
215 } // namespace blink 307 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698