| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    1 // Copyright 2016 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 "platform/graphics/paint/GeometryMapper.h" |    5 #include "platform/graphics/paint/GeometryMapper.h" | 
|    6  |    6  | 
|    7 #include "platform/geometry/GeometryTestHelpers.h" |    7 #include "platform/geometry/GeometryTestHelpers.h" | 
|    8 #include "platform/geometry/LayoutRect.h" |    8 #include "platform/geometry/LayoutRect.h" | 
 |    9 #include "platform/graphics/BoxReflection.h" | 
 |   10 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 
|    9 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |   11 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 
|   10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |   12 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 
|   11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |   13 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 
|   12 #include "platform/testing/PaintPropertyTestHelpers.h" |   14 #include "platform/testing/PaintPropertyTestHelpers.h" | 
|   13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |   15 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 
|   14 #include "testing/gtest/include/gtest/gtest.h" |   16 #include "testing/gtest/include/gtest/gtest.h" | 
|   15  |   17  | 
|   16 namespace blink { |   18 namespace blink { | 
|   17  |   19  | 
|   18 class GeometryMapperTest : public ::testing::Test, |   20 class GeometryMapperTest : public ::testing::Test, | 
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  692             lowestCommonAncestor(childOfChild2.get(), child1.get())); |  694             lowestCommonAncestor(childOfChild2.get(), child1.get())); | 
|  693   EXPECT_EQ(rootPropertyTreeState().transform(), |  695   EXPECT_EQ(rootPropertyTreeState().transform(), | 
|  694             lowestCommonAncestor(childOfChild2.get(), |  696             lowestCommonAncestor(childOfChild2.get(), | 
|  695                                  rootPropertyTreeState().transform())); |  697                                  rootPropertyTreeState().transform())); | 
|  696   EXPECT_EQ(child2, lowestCommonAncestor(childOfChild2.get(), child2.get())); |  698   EXPECT_EQ(child2, lowestCommonAncestor(childOfChild2.get(), child2.get())); | 
|  697  |  699  | 
|  698   EXPECT_EQ(rootPropertyTreeState().transform(), |  700   EXPECT_EQ(rootPropertyTreeState().transform(), | 
|  699             lowestCommonAncestor(child1.get(), child2.get())); |  701             lowestCommonAncestor(child1.get(), child2.get())); | 
|  700 } |  702 } | 
|  701  |  703  | 
 |  704 TEST_F(GeometryMapperTest, FilterWithClipsAndTransforms) { | 
 |  705   RefPtr<TransformPaintPropertyNode> transformAboveEffect = | 
 |  706       TransformPaintPropertyNode::create(rootPropertyTreeState().transform(), | 
 |  707                                          TransformationMatrix().scale(3), | 
 |  708                                          FloatPoint3D()); | 
 |  709   RefPtr<TransformPaintPropertyNode> transformBelowEffect = | 
 |  710       TransformPaintPropertyNode::create(transformAboveEffect, | 
 |  711                                          TransformationMatrix().scale(2), | 
 |  712                                          FloatPoint3D()); | 
 |  713  | 
 |  714   // This clip is between transformAboveEffect and the effect. | 
 |  715   RefPtr<ClipPaintPropertyNode> clipAboveEffect = ClipPaintPropertyNode::create( | 
 |  716       rootPropertyTreeState().clip(), transformAboveEffect, | 
 |  717       FloatRoundedRect(-100, -100, 200, 200)); | 
 |  718   // This clip is between the effect and transformBelowEffect. | 
 |  719   RefPtr<ClipPaintPropertyNode> clipBelowEffect = | 
 |  720       ClipPaintPropertyNode::create(clipAboveEffect, transformAboveEffect, | 
 |  721                                     FloatRoundedRect(10, 10, 200, 200)); | 
 |  722  | 
 |  723   CompositorFilterOperations filters; | 
 |  724   filters.appendBlurFilter(20); | 
 |  725   RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | 
 |  726       rootPropertyTreeState().effect(), transformAboveEffect, clipAboveEffect, | 
 |  727       filters, 1.0, SkBlendMode::kSrcOver); | 
 |  728  | 
 |  729   PropertyTreeState localState(transformBelowEffect.get(), | 
 |  730                                clipBelowEffect.get(), effect.get()); | 
 |  731  | 
 |  732   FloatRect input(0, 0, 50, 50); | 
 |  733   // 1. transformBelowEffect | 
 |  734   FloatRect output = transformBelowEffect->matrix().mapRect(input); | 
 |  735   // 2. clipBelowEffect | 
 |  736   output.intersect(clipBelowEffect->clipRect().rect()); | 
 |  737   EXPECT_EQ(FloatRect(10, 10, 90, 90), output); | 
 |  738   // 3. effect (the outset is 3 times of blur amount). | 
 |  739   output = filters.mapRect(output); | 
 |  740   EXPECT_EQ(FloatRect(-50, -50, 210, 210), output); | 
 |  741   // 4. clipAboveEffect | 
 |  742   output.intersect(clipAboveEffect->clipRect().rect()); | 
 |  743   EXPECT_EQ(FloatRect(-50, -50, 150, 150), output); | 
 |  744   // 5. transformAboveEffect | 
 |  745   output = transformAboveEffect->matrix().mapRect(output); | 
 |  746   EXPECT_EQ(FloatRect(-150, -150, 450, 450), output); | 
 |  747  | 
 |  748   bool hasRadius = false; | 
 |  749   CHECK_MAPPINGS( | 
 |  750       input, output, FloatRect(0, 0, 300, 300), | 
 |  751       transformAboveEffect->matrix() * transformBelowEffect->matrix(), | 
 |  752       FloatRect(30, 30, 270, 270), localState, rootPropertyTreeState(), | 
 |  753       hasRadius); | 
 |  754 } | 
 |  755  | 
 |  756 TEST_F(GeometryMapperTest, ReflectionWithPaintOffset) { | 
 |  757   CompositorFilterOperations filters; | 
 |  758   filters.appendReferenceFilter(SkiaImageFilterBuilder::buildBoxReflectFilter( | 
 |  759       BoxReflection(BoxReflection::HorizontalReflection, 0), nullptr)); | 
 |  760   RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | 
 |  761       rootPropertyTreeState().effect(), rootPropertyTreeState().transform(), | 
 |  762       rootPropertyTreeState().clip(), filters, 1.0, SkBlendMode::kSrcOver, | 
 |  763       CompositingReasonNone, CompositorElementId(), FloatPoint(100, 100)); | 
 |  764  | 
 |  765   PropertyTreeState localState = rootPropertyTreeState(); | 
 |  766   localState.setEffect(effect); | 
 |  767  | 
 |  768   FloatRect input(100, 100, 50, 50); | 
 |  769   // Reflection is at (50, 100, 50, 50). | 
 |  770   FloatRect output(50, 100, 100, 50); | 
 |  771  | 
 |  772   bool hasRadius = false; | 
 |  773   CHECK_MAPPINGS(input, output, input, TransformationMatrix(), | 
 |  774                  ClipPaintPropertyNode::root()->clipRect().rect(), localState, | 
 |  775                  rootPropertyTreeState(), hasRadius); | 
 |  776 } | 
 |  777  | 
|  702 }  // namespace blink |  778 }  // namespace blink | 
| OLD | NEW |