Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp

Issue 1956853002: [SPv2] Build trivial cc property trees in PaintArtifactCompositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "base/thread_task_runner_handle.h"
7 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/trees/layer_tree_host.h"
11 #include "cc/trees/layer_tree_settings.h"
8 #include "platform/RuntimeEnabledFeatures.h" 12 #include "platform/RuntimeEnabledFeatures.h"
9 #include "platform/graphics/paint/PaintArtifact.h" 13 #include "platform/graphics/paint/PaintArtifact.h"
10 #include "platform/testing/PictureMatchers.h" 14 #include "platform/testing/PictureMatchers.h"
11 #include "platform/testing/TestPaintArtifact.h" 15 #include "platform/testing/TestPaintArtifact.h"
16 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
12 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
14 19
15 namespace blink { 20 namespace blink {
16 namespace { 21 namespace {
17 22
18 using ::testing::Pointee; 23 using ::testing::Pointee;
19 24
20 gfx::Transform translation(SkMScalar x, SkMScalar y) 25 gfx::Transform translation(SkMScalar x, SkMScalar y)
21 { 26 {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 artifact.chunk(PaintChunkProperties()) 347 artifact.chunk(PaintChunkProperties())
343 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); 348 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer);
344 update(artifact.build()); 349 update(artifact.build());
345 350
346 ASSERT_EQ(1u, rootLayer()->children().size()); 351 ASSERT_EQ(1u, rootLayer()->children().size());
347 EXPECT_EQ(layer, rootLayer()->child_at(0)); 352 EXPECT_EQ(layer, rootLayer()->child_at(0));
348 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); 353 EXPECT_EQ(gfx::Size(400, 300), layer->bounds());
349 EXPECT_EQ(translation(50, 100), layer->transform()); 354 EXPECT_EQ(translation(50, 100), layer->transform());
350 } 355 }
351 356
357 // Similar to the above, but for the path where we build cc property trees
358 // directly. This will eventually supersede the above.
359
360 class PaintArtifactCompositorTestWithPropertyTrees : public PaintArtifactComposi torTest {
361 protected:
362 PaintArtifactCompositorTestWithPropertyTrees()
363 : m_taskRunner(new base::TestSimpleTaskRunner)
364 , m_taskRunnerHandle(m_taskRunner)
365 {
366 }
367
368 void SetUp() override
369 {
370 PaintArtifactCompositorTest::SetUp();
371
372 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default LayerTreeSettings();
373 settings.use_layer_lists = true;
374 m_webLayerTreeView = adoptPtr(new WebLayerTreeViewImplForTesting(setting s));
375 m_webLayerTreeView->setRootLayer(*getPaintArtifactCompositor().getWebLay er());
376 }
377
378 const cc::PropertyTrees& propertyTrees()
379 {
380 return *m_webLayerTreeView->layerTreeHost()->property_trees();
381 }
382
383 void update(const PaintArtifact& artifact)
384 {
385 PaintArtifactCompositorTest::update(artifact);
386 m_webLayerTreeView->layerTreeHost()->UpdateLayers();
ajuma 2016/05/06 20:33:35 Try calling LayoutAndUpdateLayers instead to see i
jbroman 2016/05/07 05:37:57 Done, thanks. I also have to set up enough extra
387 }
388
389 private:
390 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner;
391 base::ThreadTaskRunnerHandle m_taskRunnerHandle;
392 OwnPtr<WebLayerTreeViewImplForTesting> m_webLayerTreeView;
393 };
394
395 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact)
396 {
397 PaintArtifact emptyArtifact;
398 update(emptyArtifact);
399 EXPECT_TRUE(rootLayer()->children().empty());
400 }
401
402 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset)
403 {
404 TestPaintArtifact artifact;
405 artifact.chunk(PaintChunkProperties())
406 .rectDrawing(FloatRect(50, -50, 100, 100), Color::white);
407 update(artifact.build());
408
409 ASSERT_EQ(1u, rootLayer()->children().size());
410 const cc::Layer* child = rootLayer()->child_at(0);
411 EXPECT_THAT(child->GetPicture(),
412 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white)));
413 EXPECT_EQ(translation(50, -50), child->screen_space_transform());
414 EXPECT_EQ(gfx::Size(100, 100), child->bounds());
415 }
416
352 } // namespace 417 } // namespace
353 } // namespace blink 418 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698