OLD | NEW |
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/LayoutView.h" | 6 #include "core/layout/LayoutView.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/WebUnitTestSupport.h" | 17 #include "public/platform/WebUnitTestSupport.h" |
17 #include "public/web/WebSettings.h" | 18 #include "public/web/WebSettings.h" |
18 #include "public/web/WebViewClient.h" | 19 #include "public/web/WebViewClient.h" |
19 #include "web/WebLocalFrameImpl.h" | 20 #include "web/WebLocalFrameImpl.h" |
20 #include "web/WebViewImpl.h" | 21 #include "web/WebViewImpl.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 navigateTo(m_baseURL + "compositor-proxy-basic.html"); | 127 navigateTo(m_baseURL + "compositor-proxy-basic.html"); |
127 | 128 |
128 forceFullCompositingUpdate(); | 129 forceFullCompositingUpdate(); |
129 | 130 |
130 Document* document = frame()->document(); | 131 Document* document = frame()->document(); |
131 | 132 |
132 Element* tallElement = document->getElementById("tall"); | 133 Element* tallElement = document->getElementById("tall"); |
133 WebLayer* tallLayer = webLayerFromElement(tallElement); | 134 WebLayer* tallLayer = webLayerFromElement(tallElement); |
134 EXPECT_TRUE(!tallLayer); | 135 EXPECT_TRUE(!tallLayer); |
135 | 136 |
136 Element* proxiedElement = document->getElementById("proxied"); | 137 Element* proxiedElement = document->getElementById("proxied-transform"); |
137 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement); | 138 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement); |
138 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP
roperty::kTransform); | 139 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP
roperty::kTransform); |
139 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutabl
eProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorMutab
leProperty::kOpacity)); | 140 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutabl
eProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorMutab
leProperty::kOpacity)); |
140 EXPECT_NE(0UL, proxiedLayer->elementId()); | 141 EXPECT_NE(0UL, proxiedLayer->elementId()); |
141 | 142 |
142 Element* scrollElement = document->getElementById("proxied-scroller"); | 143 Element* scrollElement = document->getElementById("proxied-scroller"); |
143 WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement); | 144 WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement); |
144 EXPECT_TRUE(scrollLayer->compositorMutableProperties() & (CompositorMutableP
roperty::kScrollLeft | CompositorMutableProperty::kScrollTop)); | 145 EXPECT_TRUE(scrollLayer->compositorMutableProperties() & (CompositorMutableP
roperty::kScrollLeft | CompositorMutableProperty::kScrollTop)); |
145 EXPECT_FALSE(scrollLayer->compositorMutableProperties() & (CompositorMutable
Property::kTransform | CompositorMutableProperty::kOpacity)); | 146 EXPECT_FALSE(scrollLayer->compositorMutableProperties() & (CompositorMutable
Property::kTransform | CompositorMutableProperty::kOpacity)); |
146 EXPECT_NE(0UL, scrollLayer->elementId()); | 147 EXPECT_NE(0UL, scrollLayer->elementId()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 Element* scrollElement = document->getElementById("proxied-scroller"); | 204 Element* scrollElement = document->getElementById("proxied-scroller"); |
204 WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement); | 205 WebLayer* scrollLayer = scrollingWebLayerFromElement(scrollElement); |
205 EXPECT_FALSE(!!scrollLayer->compositorMutableProperties()); | 206 EXPECT_FALSE(!!scrollLayer->compositorMutableProperties()); |
206 EXPECT_EQ(0UL, scrollLayer->elementId()); | 207 EXPECT_EQ(0UL, scrollLayer->elementId()); |
207 | 208 |
208 WebLayer* rootScrollLayer = getRootScrollLayer(); | 209 WebLayer* rootScrollLayer = getRootScrollLayer(); |
209 EXPECT_FALSE(!!rootScrollLayer->compositorMutableProperties()); | 210 EXPECT_FALSE(!!rootScrollLayer->compositorMutableProperties()); |
210 EXPECT_EQ(0UL, rootScrollLayer->elementId()); | 211 EXPECT_EQ(0UL, rootScrollLayer->elementId()); |
211 } | 212 } |
212 | 213 |
| 214 TEST_F(CompositorWorkerTest, applyingMutationsMultipleElements) |
| 215 { |
| 216 registerMockedHttpURLLoad("compositor-proxy-basic.html"); |
| 217 navigateTo(m_baseURL + "compositor-proxy-basic.html"); |
| 218 |
| 219 Document* document = frame()->document(); |
| 220 |
| 221 { |
| 222 forceFullCompositingUpdate(); |
| 223 |
| 224 Element* proxiedElement = document->getElementById("proxied-transform"); |
| 225 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement); |
| 226 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMuta
bleProperty::kTransform); |
| 227 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMu
tableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorM
utableProperty::kOpacity)); |
| 228 uint64_t elementId = proxiedLayer->elementId(); |
| 229 EXPECT_NE(0UL, elementId); |
| 230 |
| 231 TransformationMatrix transformMatrix(11, 12, 13, 14, 21, 22, 23, 24, 31,
32, 33, 34, 41, 42, 43, 44); |
| 232 CompositorMutation mutation; |
| 233 mutation.setTransform(TransformationMatrix::toSkMatrix44(transformMatrix
)); |
| 234 |
| 235 proxiedElement->updateFromCompositorMutation(mutation); |
| 236 |
| 237 forceFullCompositingUpdate(); |
| 238 const String& cssValue = document->domWindow()->getComputedStyle(proxied
Element, String())->getPropertyValueInternal(CSSPropertyTransform); |
| 239 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41,
42, 43, 44)", cssValue); |
| 240 } |
| 241 { |
| 242 Element* proxiedElement = document->getElementById("proxied-opacity"); |
| 243 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement); |
| 244 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMuta
bleProperty::kOpacity); |
| 245 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMu
tableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop | CompositorM
utableProperty::kTransform)); |
| 246 uint64_t elementId = proxiedLayer->elementId(); |
| 247 EXPECT_NE(0UL, elementId); |
| 248 |
| 249 CompositorMutation mutation; |
| 250 mutation.setOpacity(0.5); |
| 251 |
| 252 proxiedElement->updateFromCompositorMutation(mutation); |
| 253 |
| 254 forceFullCompositingUpdate(); |
| 255 const String& cssValue = document->domWindow()->getComputedStyle(proxied
Element, String())->getPropertyValueInternal(CSSPropertyOpacity); |
| 256 EXPECT_EQ("0.5", cssValue); |
| 257 } |
| 258 } |
| 259 |
| 260 TEST_F(CompositorWorkerTest, applyingMutationsMultipleProperties) |
| 261 { |
| 262 registerMockedHttpURLLoad("compositor-proxy-basic.html"); |
| 263 navigateTo(m_baseURL + "compositor-proxy-basic.html"); |
| 264 |
| 265 Document* document = frame()->document(); |
| 266 |
| 267 forceFullCompositingUpdate(); |
| 268 |
| 269 Element* proxiedElement = document->getElementById("proxied-transform-and-op
acity"); |
| 270 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement); |
| 271 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP
roperty::kTransform); |
| 272 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP
roperty::kOpacity); |
| 273 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutabl
eProperty::kScrollLeft | CompositorMutableProperty::kScrollTop)); |
| 274 uint64_t elementId = proxiedLayer->elementId(); |
| 275 EXPECT_NE(0UL, elementId); |
| 276 |
| 277 TransformationMatrix transformMatrix(11, 12, 13, 14, 21, 22, 23, 24, 31, 32,
33, 34, 41, 42, 43, 44); |
| 278 OwnPtr<CompositorMutation> mutation = adoptPtr(new CompositorMutation); |
| 279 mutation->setTransform(TransformationMatrix::toSkMatrix44(transformMatrix)); |
| 280 mutation->setOpacity(0.5); |
| 281 |
| 282 proxiedElement->updateFromCompositorMutation(*mutation); |
| 283 { |
| 284 const String& transformValue = document->domWindow()->getComputedStyle(
proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform); |
| 285 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41,
42, 43, 44)", transformValue); |
| 286 |
| 287 const String& opacityValue = document->domWindow()->getComputedStyle(pro
xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); |
| 288 EXPECT_EQ("0.5", opacityValue); |
| 289 } |
| 290 |
| 291 // Verify that updating one property does not impact others |
| 292 mutation = adoptPtr(new CompositorMutation); |
| 293 mutation->setOpacity(0.8); |
| 294 |
| 295 proxiedElement->updateFromCompositorMutation(*mutation); |
| 296 { |
| 297 const String& transformValue = document->domWindow()->getComputedStyle(
proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform); |
| 298 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41,
42, 43, 44)", transformValue); |
| 299 |
| 300 const String& opacityValue = document->domWindow()->getComputedStyle(pro
xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); |
| 301 EXPECT_EQ("0.8", opacityValue); |
| 302 } |
| 303 } |
| 304 |
213 } // namespace blink | 305 } // namespace blink |
OLD | NEW |