| 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/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
| 6 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/test/fake_compositor_frame_sink.h" | 10 #include "cc/test/fake_compositor_frame_sink.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 24 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include <memory> | 27 #include <memory> |
| 28 | 28 |
| 29 namespace blink { | 29 namespace blink { |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 using ::testing::Pointee; | 32 using ::testing::Pointee; |
| 33 | 33 |
| 34 PaintChunkProperties defaultPaintChunkProperties() { |
| 35 PaintChunkProperties properties; |
| 36 properties.transform = TransformPaintPropertyNode::root(); |
| 37 properties.clip = ClipPaintPropertyNode::root(); |
| 38 properties.effect = EffectPaintPropertyNode::root(); |
| 39 properties.scroll = ScrollPaintPropertyNode::root(); |
| 40 return properties; |
| 41 } |
| 42 |
| 34 gfx::Transform translation(SkMScalar x, SkMScalar y) { | 43 gfx::Transform translation(SkMScalar x, SkMScalar y) { |
| 35 gfx::Transform transform; | 44 gfx::Transform transform; |
| 36 transform.Translate(x, y); | 45 transform.Translate(x, y); |
| 37 return transform; | 46 return transform; |
| 38 } | 47 } |
| 39 | 48 |
| 40 class WebLayerTreeViewWithCompositorFrameSink | 49 class WebLayerTreeViewWithCompositorFrameSink |
| 41 : public WebLayerTreeViewImplForTesting { | 50 : public WebLayerTreeViewImplForTesting { |
| 42 public: | 51 public: |
| 43 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& settings) | 52 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& settings) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 }; | 120 }; |
| 112 | 121 |
| 113 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) { | 122 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) { |
| 114 PaintArtifact emptyArtifact; | 123 PaintArtifact emptyArtifact; |
| 115 update(emptyArtifact); | 124 update(emptyArtifact); |
| 116 EXPECT_TRUE(rootLayer()->children().empty()); | 125 EXPECT_TRUE(rootLayer()->children().empty()); |
| 117 } | 126 } |
| 118 | 127 |
| 119 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) { | 128 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) { |
| 120 TestPaintArtifact artifact; | 129 TestPaintArtifact artifact; |
| 121 artifact.chunk(PaintChunkProperties()) | 130 artifact.chunk(defaultPaintChunkProperties()) |
| 122 .rectDrawing(FloatRect(50, -50, 100, 100), Color::white); | 131 .rectDrawing(FloatRect(50, -50, 100, 100), Color::white); |
| 123 update(artifact.build()); | 132 update(artifact.build()); |
| 124 | 133 |
| 125 ASSERT_EQ(1u, contentLayerCount()); | 134 ASSERT_EQ(1u, contentLayerCount()); |
| 126 const cc::Layer* child = contentLayerAt(0); | 135 const cc::Layer* child = contentLayerAt(0); |
| 127 EXPECT_THAT(child->GetPicture(), | 136 EXPECT_THAT(child->GetPicture(), |
| 128 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 137 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| 129 EXPECT_EQ(translation(50, -50), child->screen_space_transform()); | 138 EXPECT_EQ(translation(50, -50), child->screen_space_transform()); |
| 130 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); | 139 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); |
| 131 } | 140 } |
| 132 | 141 |
| 133 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) { | 142 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) { |
| 134 // A 90 degree clockwise rotation about (100, 100). | 143 // A 90 degree clockwise rotation about (100, 100). |
| 135 RefPtr<TransformPaintPropertyNode> transform = | 144 RefPtr<TransformPaintPropertyNode> transform = |
| 136 TransformPaintPropertyNode::create(nullptr, | 145 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), |
| 137 TransformationMatrix().rotate(90), | 146 TransformationMatrix().rotate(90), |
| 138 FloatPoint3D(100, 100, 0)); | 147 FloatPoint3D(100, 100, 0)); |
| 139 | 148 |
| 140 TestPaintArtifact artifact; | 149 TestPaintArtifact artifact; |
| 141 artifact.chunk(transform, nullptr, EffectPaintPropertyNode::root()) | 150 artifact |
| 151 .chunk(transform, ClipPaintPropertyNode::root(), |
| 152 EffectPaintPropertyNode::root()) |
| 142 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 153 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 143 artifact.chunk(nullptr, nullptr, EffectPaintPropertyNode::root()) | 154 artifact |
| 155 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 156 EffectPaintPropertyNode::root()) |
| 144 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); | 157 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); |
| 145 artifact.chunk(transform, nullptr, EffectPaintPropertyNode::root()) | 158 artifact |
| 159 .chunk(transform, ClipPaintPropertyNode::root(), |
| 160 EffectPaintPropertyNode::root()) |
| 146 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 161 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
| 147 update(artifact.build()); | 162 update(artifact.build()); |
| 148 | 163 |
| 149 ASSERT_EQ(3u, contentLayerCount()); | 164 ASSERT_EQ(3u, contentLayerCount()); |
| 150 { | 165 { |
| 151 const cc::Layer* layer = contentLayerAt(0); | 166 const cc::Layer* layer = contentLayerAt(0); |
| 152 EXPECT_THAT( | 167 EXPECT_THAT( |
| 153 layer->GetPicture(), | 168 layer->GetPicture(), |
| 154 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 169 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| 155 gfx::RectF mappedRect(0, 0, 100, 100); | 170 gfx::RectF mappedRect(0, 0, 100, 100); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 170 Pointee(drawsRectangle(FloatRect(0, 0, 200, 100), Color::black))); | 185 Pointee(drawsRectangle(FloatRect(0, 0, 200, 100), Color::black))); |
| 171 gfx::RectF mappedRect(0, 0, 200, 100); | 186 gfx::RectF mappedRect(0, 0, 200, 100); |
| 172 layer->screen_space_transform().TransformRect(&mappedRect); | 187 layer->screen_space_transform().TransformRect(&mappedRect); |
| 173 EXPECT_EQ(gfx::RectF(0, 100, 100, 200), mappedRect); | 188 EXPECT_EQ(gfx::RectF(0, 100, 100, 200), mappedRect); |
| 174 } | 189 } |
| 175 } | 190 } |
| 176 | 191 |
| 177 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) { | 192 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) { |
| 178 // A translation by (5, 5) within a 2x scale about (10, 10). | 193 // A translation by (5, 5) within a 2x scale about (10, 10). |
| 179 RefPtr<TransformPaintPropertyNode> transform1 = | 194 RefPtr<TransformPaintPropertyNode> transform1 = |
| 180 TransformPaintPropertyNode::create( | 195 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), |
| 181 nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0)); | 196 TransformationMatrix().scale(2), |
| 197 FloatPoint3D(10, 10, 0)); |
| 182 RefPtr<TransformPaintPropertyNode> transform2 = | 198 RefPtr<TransformPaintPropertyNode> transform2 = |
| 183 TransformPaintPropertyNode::create( | 199 TransformPaintPropertyNode::create( |
| 184 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D()); | 200 transform1, TransformationMatrix().translate(5, 5), FloatPoint3D()); |
| 185 | 201 |
| 186 TestPaintArtifact artifact; | 202 TestPaintArtifact artifact; |
| 187 artifact.chunk(transform1, nullptr, EffectPaintPropertyNode::root()) | 203 artifact |
| 204 .chunk(transform1, ClipPaintPropertyNode::root(), |
| 205 EffectPaintPropertyNode::root()) |
| 188 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 206 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 189 artifact.chunk(transform2, nullptr, EffectPaintPropertyNode::root()) | 207 artifact |
| 208 .chunk(transform2, ClipPaintPropertyNode::root(), |
| 209 EffectPaintPropertyNode::root()) |
| 190 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 210 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
| 191 update(artifact.build()); | 211 update(artifact.build()); |
| 192 | 212 |
| 193 ASSERT_EQ(2u, contentLayerCount()); | 213 ASSERT_EQ(2u, contentLayerCount()); |
| 194 { | 214 { |
| 195 const cc::Layer* layer = contentLayerAt(0); | 215 const cc::Layer* layer = contentLayerAt(0); |
| 196 EXPECT_THAT( | 216 EXPECT_THAT( |
| 197 layer->GetPicture(), | 217 layer->GetPicture(), |
| 198 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 218 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
| 199 gfx::RectF mappedRect(0, 0, 300, 200); | 219 gfx::RectF mappedRect(0, 0, 300, 200); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 216 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, | 236 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, |
| 217 FlattensInheritedTransform) { | 237 FlattensInheritedTransform) { |
| 218 for (bool transformIsFlattened : {true, false}) { | 238 for (bool transformIsFlattened : {true, false}) { |
| 219 SCOPED_TRACE(transformIsFlattened); | 239 SCOPED_TRACE(transformIsFlattened); |
| 220 | 240 |
| 221 // The flattens_inherited_transform bit corresponds to whether the _parent_ | 241 // The flattens_inherited_transform bit corresponds to whether the _parent_ |
| 222 // transform node flattens the transform. This is because Blink's notion of | 242 // transform node flattens the transform. This is because Blink's notion of |
| 223 // flattening determines whether content within the node's local transform | 243 // flattening determines whether content within the node's local transform |
| 224 // is flattened, while cc's notion applies in the parent's coordinate space. | 244 // is flattened, while cc's notion applies in the parent's coordinate space. |
| 225 RefPtr<TransformPaintPropertyNode> transform1 = | 245 RefPtr<TransformPaintPropertyNode> transform1 = |
| 226 TransformPaintPropertyNode::create(nullptr, TransformationMatrix(), | 246 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), |
| 247 TransformationMatrix(), |
| 227 FloatPoint3D()); | 248 FloatPoint3D()); |
| 228 RefPtr<TransformPaintPropertyNode> transform2 = | 249 RefPtr<TransformPaintPropertyNode> transform2 = |
| 229 TransformPaintPropertyNode::create( | 250 TransformPaintPropertyNode::create( |
| 230 transform1, TransformationMatrix().rotate3d(0, 45, 0), | 251 transform1, TransformationMatrix().rotate3d(0, 45, 0), |
| 231 FloatPoint3D()); | 252 FloatPoint3D()); |
| 232 RefPtr<TransformPaintPropertyNode> transform3 = | 253 RefPtr<TransformPaintPropertyNode> transform3 = |
| 233 TransformPaintPropertyNode::create( | 254 TransformPaintPropertyNode::create( |
| 234 transform2, TransformationMatrix().rotate3d(0, 45, 0), | 255 transform2, TransformationMatrix().rotate3d(0, 45, 0), |
| 235 FloatPoint3D(), transformIsFlattened); | 256 FloatPoint3D(), transformIsFlattened); |
| 236 | 257 |
| 237 TestPaintArtifact artifact; | 258 TestPaintArtifact artifact; |
| 238 artifact.chunk(transform3, nullptr, nullptr) | 259 artifact |
| 260 .chunk(transform3, ClipPaintPropertyNode::root(), |
| 261 EffectPaintPropertyNode::root()) |
| 239 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 262 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 240 update(artifact.build()); | 263 update(artifact.build()); |
| 241 | 264 |
| 242 ASSERT_EQ(1u, contentLayerCount()); | 265 ASSERT_EQ(1u, contentLayerCount()); |
| 243 const cc::Layer* layer = contentLayerAt(0); | 266 const cc::Layer* layer = contentLayerAt(0); |
| 244 EXPECT_THAT( | 267 EXPECT_THAT( |
| 245 layer->GetPicture(), | 268 layer->GetPicture(), |
| 246 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 269 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
| 247 | 270 |
| 248 // The leaf transform node should flatten its inherited transform node | 271 // The leaf transform node should flatten its inherited transform node |
| (...skipping 15 matching lines...) Expand all Loading... |
| 264 if (transformIsFlattened) | 287 if (transformIsFlattened) |
| 265 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 100), rect); | 288 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 100), rect); |
| 266 else | 289 else |
| 267 EXPECT_TRUE(rect.IsEmpty()); | 290 EXPECT_TRUE(rect.IsEmpty()); |
| 268 } | 291 } |
| 269 } | 292 } |
| 270 | 293 |
| 271 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) { | 294 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) { |
| 272 // Has no 3D rendering context. | 295 // Has no 3D rendering context. |
| 273 RefPtr<TransformPaintPropertyNode> transform1 = | 296 RefPtr<TransformPaintPropertyNode> transform1 = |
| 274 TransformPaintPropertyNode::create(nullptr, TransformationMatrix(), | 297 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), |
| 298 TransformationMatrix(), |
| 275 FloatPoint3D()); | 299 FloatPoint3D()); |
| 276 // Establishes a 3D rendering context. | 300 // Establishes a 3D rendering context. |
| 277 RefPtr<TransformPaintPropertyNode> transform2 = | 301 RefPtr<TransformPaintPropertyNode> transform2 = |
| 278 TransformPaintPropertyNode::create(transform1, TransformationMatrix(), | 302 TransformPaintPropertyNode::create(transform1, TransformationMatrix(), |
| 279 FloatPoint3D(), false, 1); | 303 FloatPoint3D(), false, 1); |
| 280 // Extends the 3D rendering context of transform2. | 304 // Extends the 3D rendering context of transform2. |
| 281 RefPtr<TransformPaintPropertyNode> transform3 = | 305 RefPtr<TransformPaintPropertyNode> transform3 = |
| 282 TransformPaintPropertyNode::create(transform2, TransformationMatrix(), | 306 TransformPaintPropertyNode::create(transform2, TransformationMatrix(), |
| 283 FloatPoint3D(), false, 1); | 307 FloatPoint3D(), false, 1); |
| 284 // Establishes a 3D rendering context distinct from transform2. | 308 // Establishes a 3D rendering context distinct from transform2. |
| 285 RefPtr<TransformPaintPropertyNode> transform4 = | 309 RefPtr<TransformPaintPropertyNode> transform4 = |
| 286 TransformPaintPropertyNode::create(transform2, TransformationMatrix(), | 310 TransformPaintPropertyNode::create(transform2, TransformationMatrix(), |
| 287 FloatPoint3D(), false, 2); | 311 FloatPoint3D(), false, 2); |
| 288 | 312 |
| 289 TestPaintArtifact artifact; | 313 TestPaintArtifact artifact; |
| 290 artifact.chunk(transform1, nullptr, EffectPaintPropertyNode::root()) | 314 artifact |
| 315 .chunk(transform1, ClipPaintPropertyNode::root(), |
| 316 EffectPaintPropertyNode::root()) |
| 291 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); | 317 .rectDrawing(FloatRect(0, 0, 300, 200), Color::white); |
| 292 artifact.chunk(transform2, nullptr, EffectPaintPropertyNode::root()) | 318 artifact |
| 319 .chunk(transform2, ClipPaintPropertyNode::root(), |
| 320 EffectPaintPropertyNode::root()) |
| 293 .rectDrawing(FloatRect(0, 0, 300, 200), Color::lightGray); | 321 .rectDrawing(FloatRect(0, 0, 300, 200), Color::lightGray); |
| 294 artifact.chunk(transform3, nullptr, EffectPaintPropertyNode::root()) | 322 artifact |
| 323 .chunk(transform3, ClipPaintPropertyNode::root(), |
| 324 EffectPaintPropertyNode::root()) |
| 295 .rectDrawing(FloatRect(0, 0, 300, 200), Color::darkGray); | 325 .rectDrawing(FloatRect(0, 0, 300, 200), Color::darkGray); |
| 296 artifact.chunk(transform4, nullptr, EffectPaintPropertyNode::root()) | 326 artifact |
| 327 .chunk(transform4, ClipPaintPropertyNode::root(), |
| 328 EffectPaintPropertyNode::root()) |
| 297 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); | 329 .rectDrawing(FloatRect(0, 0, 300, 200), Color::black); |
| 298 update(artifact.build()); | 330 update(artifact.build()); |
| 299 | 331 |
| 300 ASSERT_EQ(4u, contentLayerCount()); | 332 ASSERT_EQ(4u, contentLayerCount()); |
| 301 | 333 |
| 302 // The white layer is not 3D sorted. | 334 // The white layer is not 3D sorted. |
| 303 const cc::Layer* whiteLayer = contentLayerAt(0); | 335 const cc::Layer* whiteLayer = contentLayerAt(0); |
| 304 EXPECT_THAT(whiteLayer->GetPicture(), | 336 EXPECT_THAT(whiteLayer->GetPicture(), |
| 305 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); | 337 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::white))); |
| 306 int whiteSortingContextId = transformNode(whiteLayer).sorting_context_id; | 338 int whiteSortingContextId = transformNode(whiteLayer).sorting_context_id; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 336 EXPECT_THAT(blackLayer->GetPicture(), | 368 EXPECT_THAT(blackLayer->GetPicture(), |
| 337 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); | 369 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); |
| 338 int blackSortingContextId = transformNode(blackLayer).sorting_context_id; | 370 int blackSortingContextId = transformNode(blackLayer).sorting_context_id; |
| 339 EXPECT_EQ(blackLayer->sorting_context_id(), blackSortingContextId); | 371 EXPECT_EQ(blackLayer->sorting_context_id(), blackSortingContextId); |
| 340 EXPECT_NE(0, blackSortingContextId); | 372 EXPECT_NE(0, blackSortingContextId); |
| 341 EXPECT_NE(lightGraySortingContextId, blackSortingContextId); | 373 EXPECT_NE(lightGraySortingContextId, blackSortingContextId); |
| 342 } | 374 } |
| 343 | 375 |
| 344 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip) { | 376 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip) { |
| 345 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( | 377 RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( |
| 346 nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200)); | 378 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 379 FloatRoundedRect(100, 100, 300, 200)); |
| 347 | 380 |
| 348 TestPaintArtifact artifact; | 381 TestPaintArtifact artifact; |
| 349 artifact.chunk(nullptr, clip, nullptr) | 382 artifact |
| 383 .chunk(TransformPaintPropertyNode::root(), clip, |
| 384 EffectPaintPropertyNode::root()) |
| 350 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black); | 385 .rectDrawing(FloatRect(220, 80, 300, 200), Color::black); |
| 351 update(artifact.build()); | 386 update(artifact.build()); |
| 352 | 387 |
| 353 ASSERT_EQ(1u, contentLayerCount()); | 388 ASSERT_EQ(1u, contentLayerCount()); |
| 354 const cc::Layer* layer = contentLayerAt(0); | 389 const cc::Layer* layer = contentLayerAt(0); |
| 355 EXPECT_THAT(layer->GetPicture(), | 390 EXPECT_THAT(layer->GetPicture(), |
| 356 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); | 391 Pointee(drawsRectangle(FloatRect(0, 0, 300, 200), Color::black))); |
| 357 EXPECT_EQ(translation(220, 80), layer->screen_space_transform()); | 392 EXPECT_EQ(translation(220, 80), layer->screen_space_transform()); |
| 358 | 393 |
| 359 const cc::ClipNode* clipNode = | 394 const cc::ClipNode* clipNode = |
| 360 propertyTrees().clip_tree.Node(layer->clip_tree_index()); | 395 propertyTrees().clip_tree.Node(layer->clip_tree_index()); |
| 361 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clipNode->clip_type); | 396 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clipNode->clip_type); |
| 362 EXPECT_TRUE(clipNode->layers_are_clipped); | 397 EXPECT_TRUE(clipNode->layers_are_clipped); |
| 363 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->clip); | 398 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clipNode->clip); |
| 364 } | 399 } |
| 365 | 400 |
| 366 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) { | 401 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) { |
| 367 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 402 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
| 368 nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700)); | 403 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 369 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 404 FloatRoundedRect(100, 100, 700, 700)); |
| 370 clip1, nullptr, FloatRoundedRect(200, 200, 700, 100)); | 405 RefPtr<ClipPaintPropertyNode> clip2 = |
| 406 ClipPaintPropertyNode::create(clip1, TransformPaintPropertyNode::root(), |
| 407 FloatRoundedRect(200, 200, 700, 100)); |
| 371 | 408 |
| 372 TestPaintArtifact artifact; | 409 TestPaintArtifact artifact; |
| 373 artifact.chunk(nullptr, clip1, EffectPaintPropertyNode::root()) | 410 artifact |
| 411 .chunk(TransformPaintPropertyNode::root(), clip1, |
| 412 EffectPaintPropertyNode::root()) |
| 374 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); | 413 .rectDrawing(FloatRect(300, 350, 100, 100), Color::white); |
| 375 artifact.chunk(nullptr, clip2, EffectPaintPropertyNode::root()) | 414 artifact |
| 415 .chunk(TransformPaintPropertyNode::root(), clip2, |
| 416 EffectPaintPropertyNode::root()) |
| 376 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); | 417 .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray); |
| 377 artifact.chunk(nullptr, clip1, EffectPaintPropertyNode::root()) | 418 artifact |
| 419 .chunk(TransformPaintPropertyNode::root(), clip1, |
| 420 EffectPaintPropertyNode::root()) |
| 378 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); | 421 .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray); |
| 379 artifact.chunk(nullptr, clip2, EffectPaintPropertyNode::root()) | 422 artifact |
| 423 .chunk(TransformPaintPropertyNode::root(), clip2, |
| 424 EffectPaintPropertyNode::root()) |
| 380 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); | 425 .rectDrawing(FloatRect(300, 350, 100, 100), Color::black); |
| 381 update(artifact.build()); | 426 update(artifact.build()); |
| 382 | 427 |
| 383 ASSERT_EQ(4u, contentLayerCount()); | 428 ASSERT_EQ(4u, contentLayerCount()); |
| 384 | 429 |
| 385 const cc::Layer* whiteLayer = contentLayerAt(0); | 430 const cc::Layer* whiteLayer = contentLayerAt(0); |
| 386 EXPECT_THAT(whiteLayer->GetPicture(), | 431 EXPECT_THAT(whiteLayer->GetPicture(), |
| 387 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 432 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| 388 EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform()); | 433 EXPECT_EQ(translation(300, 350), whiteLayer->screen_space_transform()); |
| 389 | 434 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 417 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, innerClip->clip_type); | 462 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, innerClip->clip_type); |
| 418 EXPECT_TRUE(innerClip->layers_are_clipped); | 463 EXPECT_TRUE(innerClip->layers_are_clipped); |
| 419 EXPECT_EQ(gfx::RectF(200, 200, 700, 100), innerClip->clip); | 464 EXPECT_EQ(gfx::RectF(200, 200, 700, 100), innerClip->clip); |
| 420 EXPECT_EQ(outerClip->id, innerClip->parent_id); | 465 EXPECT_EQ(outerClip->id, innerClip->parent_id); |
| 421 } | 466 } |
| 422 | 467 |
| 423 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) { | 468 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) { |
| 424 Vector<RefPtr<ClipPaintPropertyNode>> clips; | 469 Vector<RefPtr<ClipPaintPropertyNode>> clips; |
| 425 for (unsigned i = 1; i <= 10; i++) { | 470 for (unsigned i = 1; i <= 10; i++) { |
| 426 clips.append(ClipPaintPropertyNode::create( | 471 clips.append(ClipPaintPropertyNode::create( |
| 427 clips.isEmpty() ? nullptr : clips.last(), nullptr, | 472 clips.isEmpty() ? ClipPaintPropertyNode::root() : clips.last(), |
| 473 TransformPaintPropertyNode::root(), |
| 428 FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i))); | 474 FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i))); |
| 429 } | 475 } |
| 430 | 476 |
| 431 TestPaintArtifact artifact; | 477 TestPaintArtifact artifact; |
| 432 artifact.chunk(nullptr, clips.last(), EffectPaintPropertyNode::root()) | 478 artifact |
| 479 .chunk(TransformPaintPropertyNode::root(), clips.last(), |
| 480 EffectPaintPropertyNode::root()) |
| 433 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); | 481 .rectDrawing(FloatRect(0, 0, 200, 200), Color::white); |
| 434 update(artifact.build()); | 482 update(artifact.build()); |
| 435 | 483 |
| 436 // Check the drawing layer. | 484 // Check the drawing layer. |
| 437 ASSERT_EQ(1u, contentLayerCount()); | 485 ASSERT_EQ(1u, contentLayerCount()); |
| 438 const cc::Layer* drawingLayer = contentLayerAt(0); | 486 const cc::Layer* drawingLayer = contentLayerAt(0); |
| 439 EXPECT_THAT(drawingLayer->GetPicture(), | 487 EXPECT_THAT(drawingLayer->GetPicture(), |
| 440 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); | 488 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::white))); |
| 441 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); | 489 EXPECT_EQ(gfx::Transform(), drawingLayer->screen_space_transform()); |
| 442 | 490 |
| 443 // Check the clip nodes. | 491 // Check the clip nodes. |
| 444 const cc::ClipNode* clipNode = | 492 const cc::ClipNode* clipNode = |
| 445 propertyTrees().clip_tree.Node(drawingLayer->clip_tree_index()); | 493 propertyTrees().clip_tree.Node(drawingLayer->clip_tree_index()); |
| 446 for (auto it = clips.rbegin(); it != clips.rend(); ++it) { | 494 for (auto it = clips.rbegin(); it != clips.rend(); ++it) { |
| 447 const ClipPaintPropertyNode* paintClipNode = it->get(); | 495 const ClipPaintPropertyNode* paintClipNode = it->get(); |
| 448 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clipNode->clip_type); | 496 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clipNode->clip_type); |
| 449 EXPECT_TRUE(clipNode->layers_are_clipped); | 497 EXPECT_TRUE(clipNode->layers_are_clipped); |
| 450 EXPECT_EQ(paintClipNode->clipRect().rect(), clipNode->clip); | 498 EXPECT_EQ(paintClipNode->clipRect().rect(), clipNode->clip); |
| 451 clipNode = propertyTrees().clip_tree.Node(clipNode->parent_id); | 499 clipNode = propertyTrees().clip_tree.Node(clipNode->parent_id); |
| 452 } | 500 } |
| 453 } | 501 } |
| 454 | 502 |
| 455 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) { | 503 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) { |
| 456 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( | 504 RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create( |
| 457 nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600)); | 505 ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 506 FloatRoundedRect(0, 0, 800, 600)); |
| 458 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( | 507 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create( |
| 459 commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600)); | 508 commonClip, TransformPaintPropertyNode::root(), |
| 509 FloatRoundedRect(0, 0, 400, 600)); |
| 460 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( | 510 RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create( |
| 461 commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600)); | 511 commonClip, TransformPaintPropertyNode::root(), |
| 512 FloatRoundedRect(400, 0, 400, 600)); |
| 462 | 513 |
| 463 TestPaintArtifact artifact; | 514 TestPaintArtifact artifact; |
| 464 artifact.chunk(nullptr, clip1, EffectPaintPropertyNode::root()) | 515 artifact |
| 516 .chunk(TransformPaintPropertyNode::root(), clip1, |
| 517 EffectPaintPropertyNode::root()) |
| 465 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); | 518 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); |
| 466 artifact.chunk(nullptr, clip2, EffectPaintPropertyNode::root()) | 519 artifact |
| 520 .chunk(TransformPaintPropertyNode::root(), clip2, |
| 521 EffectPaintPropertyNode::root()) |
| 467 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); | 522 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); |
| 468 update(artifact.build()); | 523 update(artifact.build()); |
| 469 | 524 |
| 470 ASSERT_EQ(2u, contentLayerCount()); | 525 ASSERT_EQ(2u, contentLayerCount()); |
| 471 | 526 |
| 472 const cc::Layer* whiteLayer = contentLayerAt(0); | 527 const cc::Layer* whiteLayer = contentLayerAt(0); |
| 473 EXPECT_THAT(whiteLayer->GetPicture(), | 528 EXPECT_THAT(whiteLayer->GetPicture(), |
| 474 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); | 529 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); |
| 475 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); | 530 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); |
| 476 const cc::ClipNode* whiteClip = | 531 const cc::ClipNode* whiteClip = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 496 commonClipNode->clip_type); | 551 commonClipNode->clip_type); |
| 497 EXPECT_TRUE(commonClipNode->layers_are_clipped); | 552 EXPECT_TRUE(commonClipNode->layers_are_clipped); |
| 498 ASSERT_EQ(gfx::RectF(0, 0, 800, 600), commonClipNode->clip); | 553 ASSERT_EQ(gfx::RectF(0, 0, 800, 600), commonClipNode->clip); |
| 499 } | 554 } |
| 500 | 555 |
| 501 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, | 556 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, |
| 502 ForeignLayerPassesThrough) { | 557 ForeignLayerPassesThrough) { |
| 503 scoped_refptr<cc::Layer> layer = cc::Layer::Create(); | 558 scoped_refptr<cc::Layer> layer = cc::Layer::Create(); |
| 504 | 559 |
| 505 TestPaintArtifact artifact; | 560 TestPaintArtifact artifact; |
| 506 artifact.chunk(PaintChunkProperties()) | 561 artifact.chunk(defaultPaintChunkProperties()) |
| 507 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); | 562 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); |
| 508 update(artifact.build()); | 563 update(artifact.build()); |
| 509 | 564 |
| 510 ASSERT_EQ(1u, contentLayerCount()); | 565 ASSERT_EQ(1u, contentLayerCount()); |
| 511 EXPECT_EQ(layer, contentLayerAt(0)); | 566 EXPECT_EQ(layer, contentLayerAt(0)); |
| 512 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); | 567 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); |
| 513 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); | 568 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); |
| 514 } | 569 } |
| 515 | 570 |
| 516 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { | 571 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { |
| 517 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create( | 572 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create( |
| 518 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 573 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 519 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); | 574 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); |
| 520 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create( | 575 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create( |
| 521 effect1, TransformPaintPropertyNode::root(), | 576 effect1, TransformPaintPropertyNode::root(), |
| 522 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.3); | 577 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.3); |
| 523 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create( | 578 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create( |
| 524 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 579 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 525 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.2); | 580 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.2); |
| 526 | 581 |
| 527 TestPaintArtifact artifact; | 582 TestPaintArtifact artifact; |
| 528 artifact.chunk(nullptr, nullptr, effect2.get()) | 583 artifact |
| 584 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 585 effect2.get()) |
| 529 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 586 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 530 artifact.chunk(nullptr, nullptr, effect1.get()) | 587 artifact |
| 588 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 589 effect1.get()) |
| 531 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 590 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 532 artifact.chunk(nullptr, nullptr, effect3.get()) | 591 artifact |
| 592 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 593 effect3.get()) |
| 533 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 594 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 534 update(artifact.build()); | 595 update(artifact.build()); |
| 535 | 596 |
| 536 ASSERT_EQ(3u, contentLayerCount()); | 597 ASSERT_EQ(3u, contentLayerCount()); |
| 537 | 598 |
| 538 const cc::EffectTree& effectTree = propertyTrees().effect_tree; | 599 const cc::EffectTree& effectTree = propertyTrees().effect_tree; |
| 539 // Node #0 reserved for null; #1 for root render surface; #2 for | 600 // Node #0 reserved for null; #1 for root render surface; #2 for |
| 540 // EffectPaintPropertyNode::root(), plus 3 nodes for those created by | 601 // EffectPaintPropertyNode::root(), plus 3 nodes for those created by |
| 541 // this test. | 602 // this test. |
| 542 ASSERT_EQ(6u, effectTree.size()); | 603 ASSERT_EQ(5u, effectTree.size()); |
| 543 | 604 |
| 544 const cc::EffectNode& convertedDummyRootEffect = *effectTree.Node(2); | 605 const cc::EffectNode& convertedRootEffect = *effectTree.Node(1); |
| 545 EXPECT_EQ(1, convertedDummyRootEffect.parent_id); | 606 EXPECT_EQ(-1, convertedRootEffect.parent_id); |
| 546 | 607 |
| 547 const cc::EffectNode& convertedEffect1 = *effectTree.Node(3); | 608 const cc::EffectNode& convertedEffect1 = *effectTree.Node(2); |
| 548 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect1.parent_id); | 609 EXPECT_EQ(convertedRootEffect.id, convertedEffect1.parent_id); |
| 549 EXPECT_FLOAT_EQ(0.5, convertedEffect1.opacity); | 610 EXPECT_FLOAT_EQ(0.5, convertedEffect1.opacity); |
| 550 | 611 |
| 551 const cc::EffectNode& convertedEffect2 = *effectTree.Node(4); | 612 const cc::EffectNode& convertedEffect2 = *effectTree.Node(3); |
| 552 EXPECT_EQ(convertedEffect1.id, convertedEffect2.parent_id); | 613 EXPECT_EQ(convertedEffect1.id, convertedEffect2.parent_id); |
| 553 EXPECT_FLOAT_EQ(0.3, convertedEffect2.opacity); | 614 EXPECT_FLOAT_EQ(0.3, convertedEffect2.opacity); |
| 554 | 615 |
| 555 const cc::EffectNode& convertedEffect3 = *effectTree.Node(5); | 616 const cc::EffectNode& convertedEffect3 = *effectTree.Node(4); |
| 556 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); | 617 EXPECT_EQ(convertedRootEffect.id, convertedEffect3.parent_id); |
| 557 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); | 618 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); |
| 558 | 619 |
| 559 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); | 620 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); |
| 560 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); | 621 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); |
| 561 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); | 622 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); |
| 562 } | 623 } |
| 563 | 624 |
| 564 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) { | 625 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) { |
| 565 RefPtr<TransformPaintPropertyNode> scrollTranslation = | 626 RefPtr<TransformPaintPropertyNode> scrollTranslation = |
| 566 TransformPaintPropertyNode::create( | 627 TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(), |
| 567 nullptr, TransformationMatrix().translate(7, 9), FloatPoint3D()); | 628 TransformationMatrix().translate(7, 9), |
| 629 FloatPoint3D()); |
| 568 RefPtr<ScrollPaintPropertyNode> scroll = ScrollPaintPropertyNode::create( | 630 RefPtr<ScrollPaintPropertyNode> scroll = ScrollPaintPropertyNode::create( |
| 569 nullptr, scrollTranslation, IntSize(11, 13), IntSize(27, 31), true, | 631 ScrollPaintPropertyNode::root(), scrollTranslation, IntSize(11, 13), |
| 570 false); | 632 IntSize(27, 31), true, false); |
| 571 | 633 |
| 572 TestPaintArtifact artifact; | 634 TestPaintArtifact artifact; |
| 573 artifact.chunk(scrollTranslation, nullptr, nullptr, scroll) | 635 artifact |
| 636 .chunk(scrollTranslation, ClipPaintPropertyNode::root(), |
| 637 EffectPaintPropertyNode::root(), scroll) |
| 574 .rectDrawing(FloatRect(11, 13, 17, 19), Color::white); | 638 .rectDrawing(FloatRect(11, 13, 17, 19), Color::white); |
| 575 update(artifact.build()); | 639 update(artifact.build()); |
| 576 | 640 |
| 577 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; | 641 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; |
| 578 // Node #0 reserved for null; #1 for root render surface. | 642 // Node #0 reserved for null; #1 for root render surface. |
| 579 ASSERT_EQ(3u, scrollTree.size()); | 643 ASSERT_EQ(3u, scrollTree.size()); |
| 580 const cc::ScrollNode& scrollNode = *scrollTree.Node(2); | 644 const cc::ScrollNode& scrollNode = *scrollTree.Node(2); |
| 581 EXPECT_EQ(gfx::Size(11, 13), scrollNode.scroll_clip_layer_bounds); | 645 EXPECT_EQ(gfx::Size(11, 13), scrollNode.scroll_clip_layer_bounds); |
| 582 EXPECT_EQ(gfx::Size(27, 31), scrollNode.bounds); | 646 EXPECT_EQ(gfx::Size(27, 31), scrollNode.bounds); |
| 583 EXPECT_TRUE(scrollNode.user_scrollable_horizontal); | 647 EXPECT_TRUE(scrollNode.user_scrollable_horizontal); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 596 scrollNode.main_thread_scrolling_reasons); | 660 scrollNode.main_thread_scrolling_reasons); |
| 597 } | 661 } |
| 598 | 662 |
| 599 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { | 663 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { |
| 600 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | 664 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( |
| 601 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 665 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 602 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); | 666 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); |
| 603 | 667 |
| 604 RefPtr<TransformPaintPropertyNode> scrollTranslationA = | 668 RefPtr<TransformPaintPropertyNode> scrollTranslationA = |
| 605 TransformPaintPropertyNode::create( | 669 TransformPaintPropertyNode::create( |
| 606 nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D()); | 670 TransformPaintPropertyNode::root(), |
| 671 TransformationMatrix().translate(11, 13), FloatPoint3D()); |
| 607 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( | 672 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( |
| 608 nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true); | 673 ScrollPaintPropertyNode::root(), scrollTranslationA, IntSize(2, 3), |
| 674 IntSize(5, 7), false, true); |
| 609 scrollA->addMainThreadScrollingReasons( | 675 scrollA->addMainThreadScrollingReasons( |
| 610 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 676 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 611 RefPtr<TransformPaintPropertyNode> scrollTranslationB = | 677 RefPtr<TransformPaintPropertyNode> scrollTranslationB = |
| 612 TransformPaintPropertyNode::create( | 678 TransformPaintPropertyNode::create( |
| 613 scrollTranslationA, TransformationMatrix().translate(37, 41), | 679 scrollTranslationA, TransformationMatrix().translate(37, 41), |
| 614 FloatPoint3D()); | 680 FloatPoint3D()); |
| 615 RefPtr<ScrollPaintPropertyNode> scrollB = ScrollPaintPropertyNode::create( | 681 RefPtr<ScrollPaintPropertyNode> scrollB = ScrollPaintPropertyNode::create( |
| 616 scrollA, scrollTranslationB, IntSize(19, 23), IntSize(29, 31), true, | 682 scrollA, scrollTranslationB, IntSize(19, 23), IntSize(29, 31), true, |
| 617 false); | 683 false); |
| 618 TestPaintArtifact artifact; | 684 TestPaintArtifact artifact; |
| 619 artifact.chunk(scrollTranslationA, nullptr, effect, scrollA) | 685 artifact |
| 686 .chunk(scrollTranslationA, ClipPaintPropertyNode::root(), effect, scrollA) |
| 620 .rectDrawing(FloatRect(7, 11, 13, 17), Color::white); | 687 .rectDrawing(FloatRect(7, 11, 13, 17), Color::white); |
| 621 artifact.chunk(scrollTranslationB, nullptr, effect, scrollB) | 688 artifact |
| 689 .chunk(scrollTranslationB, ClipPaintPropertyNode::root(), effect, scrollB) |
| 622 .rectDrawing(FloatRect(1, 2, 3, 5), Color::white); | 690 .rectDrawing(FloatRect(1, 2, 3, 5), Color::white); |
| 623 update(artifact.build()); | 691 update(artifact.build()); |
| 624 | 692 |
| 625 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; | 693 const cc::ScrollTree& scrollTree = propertyTrees().scroll_tree; |
| 626 // Node #0 reserved for null; #1 for root render surface. | 694 // Node #0 reserved for null; #1 for root render surface. |
| 627 ASSERT_EQ(4u, scrollTree.size()); | 695 ASSERT_EQ(4u, scrollTree.size()); |
| 628 const cc::ScrollNode& scrollNodeA = *scrollTree.Node(2); | 696 const cc::ScrollNode& scrollNodeA = *scrollTree.Node(2); |
| 629 EXPECT_EQ(gfx::Size(2, 3), scrollNodeA.scroll_clip_layer_bounds); | 697 EXPECT_EQ(gfx::Size(2, 3), scrollNodeA.scroll_clip_layer_bounds); |
| 630 EXPECT_EQ(gfx::Size(5, 7), scrollNodeA.bounds); | 698 EXPECT_EQ(gfx::Size(5, 7), scrollNodeA.bounds); |
| 631 EXPECT_FALSE(scrollNodeA.user_scrollable_horizontal); | 699 EXPECT_FALSE(scrollNodeA.user_scrollable_horizontal); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 652 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); | 720 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); |
| 653 | 721 |
| 654 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & | 722 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & |
| 655 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 723 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 656 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & | 724 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & |
| 657 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 725 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 658 } | 726 } |
| 659 | 727 |
| 660 } // namespace | 728 } // namespace |
| 661 } // namespace blink | 729 } // namespace blink |
| OLD | NEW |