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/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/CompositorMutation.h" |
12 #include "platform/graphics/GraphicsLayer.h" | 12 #include "platform/graphics/GraphicsLayer.h" |
13 #include "platform/testing/URLTestHelpers.h" | 13 #include "platform/testing/URLTestHelpers.h" |
14 #include "public/platform/Platform.h" | 14 #include "public/platform/Platform.h" |
15 #include "public/platform/WebLayer.h" | 15 #include "public/platform/WebLayer.h" |
16 #include "public/platform/WebLayerTreeView.h" | 16 #include "public/platform/WebLayerTreeView.h" |
17 #include "public/platform/WebURLLoaderMockFactory.h" | 17 #include "public/platform/WebURLLoaderMockFactory.h" |
18 #include "public/web/WebCache.h" | 18 #include "public/web/WebCache.h" |
19 #include "public/web/WebSettings.h" | 19 #include "public/web/WebSettings.h" |
20 #include "public/web/WebViewClient.h" | 20 #include "public/web/WebViewClient.h" |
21 #include "web/WebLocalFrameImpl.h" | 21 #include "web/WebLocalFrameImpl.h" |
22 #include "web/WebViewImpl.h" | 22 #include "web/WebViewImpl.h" |
23 #include "web/tests/FrameTestHelpers.h" | 23 #include "web/tests/FrameTestHelpers.h" |
| 24 #include "wtf/PtrUtil.h" |
24 #include <gtest/gtest.h> | 25 #include <gtest/gtest.h> |
| 26 #include <memory> |
25 | 27 |
26 namespace blink { | 28 namespace blink { |
27 | 29 |
28 class CompositorWorkerTest : public testing::Test { | 30 class CompositorWorkerTest : public testing::Test { |
29 public: | 31 public: |
30 CompositorWorkerTest() | 32 CompositorWorkerTest() |
31 : m_baseURL("http://www.test.com/") | 33 : m_baseURL("http://www.test.com/") |
32 { | 34 { |
33 RuntimeEnabledFeatures::setCompositorWorkerEnabled(true); | 35 RuntimeEnabledFeatures::setCompositorWorkerEnabled(true); |
34 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, &confi
gureSettings); | 36 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, &confi
gureSettings); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 272 |
271 Element* proxiedElement = document->getElementById("proxied-transform-and-op
acity"); | 273 Element* proxiedElement = document->getElementById("proxied-transform-and-op
acity"); |
272 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement); | 274 WebLayer* proxiedLayer = webLayerFromElement(proxiedElement); |
273 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP
roperty::kTransform); | 275 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP
roperty::kTransform); |
274 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP
roperty::kOpacity); | 276 EXPECT_TRUE(proxiedLayer->compositorMutableProperties() & CompositorMutableP
roperty::kOpacity); |
275 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutabl
eProperty::kScrollLeft | CompositorMutableProperty::kScrollTop)); | 277 EXPECT_FALSE(proxiedLayer->compositorMutableProperties() & (CompositorMutabl
eProperty::kScrollLeft | CompositorMutableProperty::kScrollTop)); |
276 uint64_t elementId = proxiedLayer->elementId(); | 278 uint64_t elementId = proxiedLayer->elementId(); |
277 EXPECT_NE(0UL, elementId); | 279 EXPECT_NE(0UL, elementId); |
278 | 280 |
279 TransformationMatrix transformMatrix(11, 12, 13, 14, 21, 22, 23, 24, 31, 32,
33, 34, 41, 42, 43, 44); | 281 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); | 282 std::unique_ptr<CompositorMutation> mutation = wrapUnique(new CompositorMuta
tion); |
281 mutation->setTransform(TransformationMatrix::toSkMatrix44(transformMatrix)); | 283 mutation->setTransform(TransformationMatrix::toSkMatrix44(transformMatrix)); |
282 mutation->setOpacity(0.5); | 284 mutation->setOpacity(0.5); |
283 | 285 |
284 proxiedElement->updateFromCompositorMutation(*mutation); | 286 proxiedElement->updateFromCompositorMutation(*mutation); |
285 { | 287 { |
286 const String& transformValue = document->domWindow()->getComputedStyle(
proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform); | 288 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); | 289 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41,
42, 43, 44)", transformValue); |
288 | 290 |
289 const String& opacityValue = document->domWindow()->getComputedStyle(pro
xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); | 291 const String& opacityValue = document->domWindow()->getComputedStyle(pro
xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); |
290 EXPECT_EQ("0.5", opacityValue); | 292 EXPECT_EQ("0.5", opacityValue); |
291 } | 293 } |
292 | 294 |
293 // Verify that updating one property does not impact others | 295 // Verify that updating one property does not impact others |
294 mutation = adoptPtr(new CompositorMutation); | 296 mutation = wrapUnique(new CompositorMutation); |
295 mutation->setOpacity(0.8); | 297 mutation->setOpacity(0.8); |
296 | 298 |
297 proxiedElement->updateFromCompositorMutation(*mutation); | 299 proxiedElement->updateFromCompositorMutation(*mutation); |
298 { | 300 { |
299 const String& transformValue = document->domWindow()->getComputedStyle(
proxiedElement, String())->getPropertyValueInternal(CSSPropertyTransform); | 301 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); | 302 EXPECT_EQ("matrix3d(11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41,
42, 43, 44)", transformValue); |
301 | 303 |
302 const String& opacityValue = document->domWindow()->getComputedStyle(pro
xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); | 304 const String& opacityValue = document->domWindow()->getComputedStyle(pro
xiedElement, String())->getPropertyValueInternal(CSSPropertyOpacity); |
303 EXPECT_EQ("0.8", opacityValue); | 305 EXPECT_EQ("0.8", opacityValue); |
304 } | 306 } |
305 } | 307 } |
306 | 308 |
307 } // namespace blink | 309 } // namespace blink |
OLD | NEW |