[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
thakis | 11b4bbc | 2016-10-04 17:35:35 | [diff] [blame] | 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
| 14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 16 | * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE |
| 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 23 | * DAMAGE. |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 24 | */ |
| 25 | |
[email protected] | 49f8882 | 2013-12-06 12:31:11 | [diff] [blame] | 26 | #include "platform/graphics/GraphicsLayer.h" |
[email protected] | 407b51d | 2013-05-30 22:16:04 | [diff] [blame] | 27 | |
yutak | cad69d6c | 2017-04-06 09:06:03 | [diff] [blame] | 28 | #include <memory> |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 29 | #include "platform/animation/CompositorAnimation.h" |
| 30 | #include "platform/animation/CompositorAnimationClient.h" |
loyso | ffcf86c | 2016-12-19 07:14:39 | [diff] [blame] | 31 | #include "platform/animation/CompositorAnimationHost.h" |
loyso | 26f3c55 | 2016-02-10 23:54:34 | [diff] [blame] | 32 | #include "platform/animation/CompositorAnimationTimeline.h" |
| 33 | #include "platform/animation/CompositorFloatAnimationCurve.h" |
Yi Gu | 3904dc2 | 2018-02-15 18:35:24 | [diff] [blame] | 34 | #include "platform/animation/CompositorKeyframeModel.h" |
loyso | 8247b0d | 2016-06-14 11:35:33 | [diff] [blame] | 35 | #include "platform/animation/CompositorTargetProperty.h" |
vollick | ef2ae92 | 2016-06-29 17:54:27 | [diff] [blame] | 36 | #include "platform/graphics/CompositorElementId.h" |
Xianzhu Wang | 297ee9e | 2018-02-16 20:24:12 | [diff] [blame] | 37 | #include "platform/graphics/paint/PaintControllerTest.h" |
Xianzhu Wang | dfc9840 | 2018-02-14 00:12:27 | [diff] [blame] | 38 | #include "platform/graphics/paint/PropertyTreeState.h" |
Xianzhu Wang | 297ee9e | 2018-02-16 20:24:12 | [diff] [blame] | 39 | #include "platform/graphics/paint/ScopedPaintChunkProperties.h" |
Walter Korman | a167bd8 | 2017-08-09 15:24:29 | [diff] [blame] | 40 | #include "platform/graphics/test/FakeScrollableArea.h" |
skyostil | d80c41e | 2017-04-25 18:35:36 | [diff] [blame] | 41 | #include "platform/scheduler/child/web_scheduler.h" |
[email protected] | 49f8882 | 2013-12-06 12:31:11 | [diff] [blame] | 42 | #include "platform/scroll/ScrollableArea.h" |
wkorman | 070bb4a | 2016-04-01 19:58:47 | [diff] [blame] | 43 | #include "platform/testing/FakeGraphicsLayer.h" |
wkorman | 098f4a8 | 2016-04-06 01:22:39 | [diff] [blame] | 44 | #include "platform/testing/FakeGraphicsLayerClient.h" |
Xianzhu Wang | 297ee9e | 2018-02-16 20:24:12 | [diff] [blame] | 45 | #include "platform/testing/PaintTestConfigurations.h" |
loyso | cde77907 | 2016-03-31 06:44:28 | [diff] [blame] | 46 | #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
[email protected] | e72ce8b | 2013-10-27 14:41:10 | [diff] [blame] | 47 | #include "platform/transforms/Matrix3DTransformOperation.h" |
| 48 | #include "platform/transforms/RotateTransformOperation.h" |
| 49 | #include "platform/transforms/TranslateTransformOperation.h" |
yutak | cad69d6c | 2017-04-06 09:06:03 | [diff] [blame] | 50 | #include "platform/wtf/PtrUtil.h" |
[email protected] | 8555b53 | 2013-06-01 08:11:53 | [diff] [blame] | 51 | #include "public/platform/Platform.h" |
| 52 | #include "public/platform/WebCompositorSupport.h" |
[email protected] | 8555b53 | 2013-06-01 08:11:53 | [diff] [blame] | 53 | #include "public/platform/WebLayer.h" |
| 54 | #include "public/platform/WebLayerTreeView.h" |
jbroman | cd5c59c | 2017-01-20 17:27:33 | [diff] [blame] | 55 | #include "public/platform/WebThread.h" |
tkent | ce24c28 | 2015-11-18 15:52:17 | [diff] [blame] | 56 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 57 | |
[email protected] | 247956b | 2015-06-12 05:51:06 | [diff] [blame] | 58 | namespace blink { |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 59 | |
Xianzhu Wang | 297ee9e | 2018-02-16 20:24:12 | [diff] [blame] | 60 | class GraphicsLayerTest : public ::testing::Test, |
| 61 | public PaintTestConfigurations { |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 62 | public: |
| 63 | GraphicsLayerTest() { |
Xianzhu Wang | 3e9396d | 2018-02-05 19:51:53 | [diff] [blame] | 64 | clip_layer_ = WTF::WrapUnique(new FakeGraphicsLayer(client_)); |
| 65 | scroll_elasticity_layer_ = WTF::WrapUnique(new FakeGraphicsLayer(client_)); |
| 66 | page_scale_layer_ = WTF::WrapUnique(new FakeGraphicsLayer(client_)); |
| 67 | graphics_layer_ = WTF::WrapUnique(new FakeGraphicsLayer(client_)); |
Xianzhu Wang | d6c6e08 | 2017-10-14 01:01:47 | [diff] [blame] | 68 | graphics_layer_->SetDrawsContent(true); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 69 | clip_layer_->AddChild(scroll_elasticity_layer_.get()); |
Philip Rogers | d9e5ffd | 2017-06-16 00:10:53 | [diff] [blame] | 70 | scroll_elasticity_layer_->AddChild(page_scale_layer_.get()); |
| 71 | page_scale_layer_->AddChild(graphics_layer_.get()); |
pdr | bbfd882 | 2017-06-27 22:44:52 | [diff] [blame] | 72 | graphics_layer_->PlatformLayer()->SetScrollable( |
| 73 | clip_layer_->PlatformLayer()->Bounds()); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 74 | platform_layer_ = graphics_layer_->PlatformLayer(); |
| 75 | layer_tree_view_ = WTF::WrapUnique(new WebLayerTreeViewImplForTesting); |
hs1217.lee | 94e9d9c | 2017-04-12 02:26:21 | [diff] [blame] | 76 | DCHECK(layer_tree_view_); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 77 | layer_tree_view_->SetRootLayer(*clip_layer_->PlatformLayer()); |
Chandan Padhi | 198800bd1 | 2017-07-07 08:15:07 | [diff] [blame] | 78 | WebLayerTreeView::ViewportLayers viewport_layers; |
| 79 | viewport_layers.overscroll_elasticity = |
| 80 | scroll_elasticity_layer_->PlatformLayer(); |
| 81 | viewport_layers.page_scale = page_scale_layer_->PlatformLayer(); |
| 82 | viewport_layers.inner_viewport_container = clip_layer_->PlatformLayer(); |
| 83 | viewport_layers.inner_viewport_scroll = graphics_layer_->PlatformLayer(); |
| 84 | layer_tree_view_->RegisterViewportLayers(viewport_layers); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 85 | layer_tree_view_->SetViewportSize(WebSize(1, 1)); |
Xianzhu Wang | dfc9840 | 2018-02-14 00:12:27 | [diff] [blame] | 86 | |
| 87 | if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) { |
| 88 | graphics_layer_->SetLayerState( |
| 89 | PropertyTreeState(PropertyTreeState::Root()), IntPoint()); |
| 90 | } |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 91 | } |
[email protected] | b3f4f96 | 2012-06-08 18:41:47 | [diff] [blame] | 92 | |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 93 | ~GraphicsLayerTest() override { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 94 | graphics_layer_.reset(); |
| 95 | layer_tree_view_.reset(); |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 96 | } |
[email protected] | b3f4f96 | 2012-06-08 18:41:47 | [diff] [blame] | 97 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 98 | WebLayerTreeView* LayerTreeView() { return layer_tree_view_.get(); } |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 99 | |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 100 | protected: |
Xianzhu Wang | d6c6e08 | 2017-10-14 01:01:47 | [diff] [blame] | 101 | bool PaintWithoutCommit(GraphicsLayer& layer, const IntRect* interest_rect) { |
| 102 | return layer.PaintWithoutCommit(interest_rect); |
| 103 | } |
| 104 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 105 | WebLayer* platform_layer_; |
| 106 | std::unique_ptr<FakeGraphicsLayer> graphics_layer_; |
Philip Rogers | d9e5ffd | 2017-06-16 00:10:53 | [diff] [blame] | 107 | std::unique_ptr<FakeGraphicsLayer> page_scale_layer_; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 108 | std::unique_ptr<FakeGraphicsLayer> scroll_elasticity_layer_; |
| 109 | std::unique_ptr<FakeGraphicsLayer> clip_layer_; |
Xianzhu Wang | d6c6e08 | 2017-10-14 01:01:47 | [diff] [blame] | 110 | FakeGraphicsLayerClient client_; |
[email protected] | b3f4f96 | 2012-06-08 18:41:47 | [diff] [blame] | 111 | |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 112 | private: |
Sadrul Habib Chowdhury | e23c056 | 2017-08-09 22:05:29 | [diff] [blame] | 113 | std::unique_ptr<WebLayerTreeViewImplForTesting> layer_tree_view_; |
[email protected] | b3f4f96 | 2012-06-08 18:41:47 | [diff] [blame] | 114 | }; |
| 115 | |
Xianzhu Wang | 297ee9e | 2018-02-16 20:24:12 | [diff] [blame] | 116 | INSTANTIATE_TEST_CASE_P(All, |
| 117 | GraphicsLayerTest, |
| 118 | ::testing::Values(0, kSlimmingPaintV175)); |
| 119 | |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 120 | class AnimationForTesting : public CompositorAnimationClient { |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 121 | public: |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 122 | AnimationForTesting() { |
| 123 | compositor_animation_ = CompositorAnimation::Create(); |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 124 | } |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 125 | |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 126 | CompositorAnimation* GetCompositorAnimation() const override { |
| 127 | return compositor_animation_.get(); |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 128 | } |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 129 | |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 130 | std::unique_ptr<CompositorAnimation> compositor_animation_; |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 131 | }; |
| 132 | |
Xianzhu Wang | 297ee9e | 2018-02-16 20:24:12 | [diff] [blame] | 133 | TEST_P(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 134 | ASSERT_FALSE(platform_layer_->HasTickingAnimationForTesting()); |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 135 | |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 136 | std::unique_ptr<CompositorFloatAnimationCurve> curve = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 137 | CompositorFloatAnimationCurve::Create(); |
| 138 | curve->AddKeyframe( |
| 139 | CompositorFloatKeyframe(0.0, 0.0, |
| 140 | *CubicBezierTimingFunction::Preset( |
| 141 | CubicBezierTimingFunction::EaseType::EASE))); |
Yi Gu | 3904dc2 | 2018-02-15 18:35:24 | [diff] [blame] | 142 | std::unique_ptr<CompositorKeyframeModel> float_keyframe_model( |
| 143 | CompositorKeyframeModel::Create(*curve, CompositorTargetProperty::OPACITY, |
| 144 | 0, 0)); |
| 145 | int keyframe_model_id = float_keyframe_model->Id(); |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 146 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 147 | std::unique_ptr<CompositorAnimationTimeline> compositor_timeline = |
| 148 | CompositorAnimationTimeline::Create(); |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 149 | AnimationForTesting animation; |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 150 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 151 | CompositorAnimationHost host(LayerTreeView()->CompositorAnimationHost()); |
loyso | ffcf86c | 2016-12-19 07:14:39 | [diff] [blame] | 152 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 153 | host.AddTimeline(*compositor_timeline); |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 154 | compositor_timeline->AnimationAttached(animation); |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 155 | |
chrishtr | c3daf27 | 2017-05-11 11:08:02 | [diff] [blame] | 156 | platform_layer_->SetElementId(CompositorElementId(platform_layer_->Id())); |
vollick | ef2ae92 | 2016-06-29 17:54:27 | [diff] [blame] | 157 | |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 158 | animation.GetCompositorAnimation()->AttachElement( |
| 159 | platform_layer_->GetElementId()); |
| 160 | ASSERT_TRUE(animation.GetCompositorAnimation()->IsElementAttached()); |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 161 | |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 162 | animation.GetCompositorAnimation()->AddKeyframeModel( |
| 163 | std::move(float_keyframe_model)); |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 164 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 165 | ASSERT_TRUE(platform_layer_->HasTickingAnimationForTesting()); |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 166 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 167 | graphics_layer_->SetShouldFlattenTransform(false); |
[email protected] | 2b74e88 | 2012-05-11 18:04:15 | [diff] [blame] | 168 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 169 | platform_layer_ = graphics_layer_->PlatformLayer(); |
| 170 | ASSERT_TRUE(platform_layer_); |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 171 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 172 | ASSERT_TRUE(platform_layer_->HasTickingAnimationForTesting()); |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 173 | animation.GetCompositorAnimation()->RemoveKeyframeModel(keyframe_model_id); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 174 | ASSERT_FALSE(platform_layer_->HasTickingAnimationForTesting()); |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 175 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 176 | graphics_layer_->SetShouldFlattenTransform(true); |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 177 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 178 | platform_layer_ = graphics_layer_->PlatformLayer(); |
| 179 | ASSERT_TRUE(platform_layer_); |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 180 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 181 | ASSERT_FALSE(platform_layer_->HasTickingAnimationForTesting()); |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 182 | |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 183 | animation.GetCompositorAnimation()->DetachElement(); |
| 184 | ASSERT_FALSE(animation.GetCompositorAnimation()->IsElementAttached()); |
loyso | 2c1247e2 | 2015-11-08 01:26:58 | [diff] [blame] | 185 | |
Yi Gu | aa830ff | 2018-02-22 03:09:11 | [diff] [blame^] | 186 | compositor_timeline->AnimationDestroyed(animation); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 187 | host.RemoveTimeline(*compositor_timeline.get()); |
[email protected] | b3f4f96 | 2012-06-08 18:41:47 | [diff] [blame] | 188 | } |
| 189 | |
Xianzhu Wang | 297ee9e | 2018-02-16 20:24:12 | [diff] [blame] | 190 | TEST_P(GraphicsLayerTest, Paint) { |
Xianzhu Wang | d6c6e08 | 2017-10-14 01:01:47 | [diff] [blame] | 191 | IntRect interest_rect(1, 2, 3, 4); |
| 192 | EXPECT_TRUE(PaintWithoutCommit(*graphics_layer_, &interest_rect)); |
| 193 | graphics_layer_->GetPaintController().CommitNewDisplayItems(); |
| 194 | |
| 195 | client_.SetNeedsRepaint(true); |
| 196 | EXPECT_TRUE(PaintWithoutCommit(*graphics_layer_, &interest_rect)); |
| 197 | graphics_layer_->GetPaintController().CommitNewDisplayItems(); |
| 198 | |
| 199 | client_.SetNeedsRepaint(false); |
| 200 | EXPECT_FALSE(PaintWithoutCommit(*graphics_layer_, &interest_rect)); |
| 201 | |
| 202 | interest_rect.Move(IntSize(10, 20)); |
| 203 | EXPECT_TRUE(PaintWithoutCommit(*graphics_layer_, &interest_rect)); |
| 204 | graphics_layer_->GetPaintController().CommitNewDisplayItems(); |
| 205 | EXPECT_FALSE(PaintWithoutCommit(*graphics_layer_, &interest_rect)); |
| 206 | |
| 207 | graphics_layer_->SetNeedsDisplay(); |
| 208 | EXPECT_TRUE(PaintWithoutCommit(*graphics_layer_, &interest_rect)); |
| 209 | graphics_layer_->GetPaintController().CommitNewDisplayItems(); |
| 210 | EXPECT_FALSE(PaintWithoutCommit(*graphics_layer_, &interest_rect)); |
| 211 | } |
| 212 | |
Xianzhu Wang | 297ee9e | 2018-02-16 20:24:12 | [diff] [blame] | 213 | TEST_P(GraphicsLayerTest, PaintRecursively) { |
| 214 | if (!RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) |
| 215 | return; |
| 216 | |
| 217 | IntRect interest_rect(1, 2, 3, 4); |
| 218 | auto transform_root = TransformPaintPropertyNode::Root(); |
| 219 | auto transform1 = TransformPaintPropertyNode::Create( |
| 220 | transform_root, TransformationMatrix().Translate(10, 20), FloatPoint3D()); |
| 221 | auto transform2 = TransformPaintPropertyNode::Create( |
| 222 | transform1, TransformationMatrix().Scale(2), FloatPoint3D()); |
| 223 | |
| 224 | client_.SetPainter([&](const GraphicsLayer* layer, GraphicsContext& context, |
| 225 | GraphicsLayerPaintingPhase, const IntRect&) { |
| 226 | { |
| 227 | ScopedPaintChunkProperties properties( |
| 228 | context.GetPaintController(), transform1, *layer, kBackgroundType); |
| 229 | PaintControllerTestBase::DrawRect(context, *layer, kBackgroundType, |
| 230 | interest_rect); |
| 231 | } |
| 232 | { |
| 233 | ScopedPaintChunkProperties properties( |
| 234 | context.GetPaintController(), transform2, *layer, kForegroundType); |
| 235 | PaintControllerTestBase::DrawRect(context, *layer, kForegroundType, |
| 236 | interest_rect); |
| 237 | } |
| 238 | }); |
| 239 | |
| 240 | transform1->Update(transform_root, TransformationMatrix().Translate(20, 30), |
| 241 | FloatPoint3D()); |
| 242 | EXPECT_TRUE(transform1->Changed(*transform_root)); |
| 243 | EXPECT_TRUE(transform2->Changed(*transform_root)); |
| 244 | client_.SetNeedsRepaint(true); |
| 245 | graphics_layer_->PaintRecursively(); |
| 246 | |
| 247 | EXPECT_FALSE(transform1->Changed(*transform_root)); |
| 248 | EXPECT_FALSE(transform2->Changed(*transform_root)); |
| 249 | } |
| 250 | |
Blink Reformat | 1c8e1a77 | 2016-10-01 00:25:32 | [diff] [blame] | 251 | } // namespace blink |