| 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 "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
| 9 #include "platform/graphics/paint/PaintArtifact.h" | 9 #include "platform/graphics/paint/PaintArtifact.h" |
| 10 #include "platform/testing/PictureMatchers.h" | 10 #include "platform/testing/PictureMatchers.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 gfx::Transform transform; | 22 gfx::Transform transform; |
| 23 transform.Translate(x, y); | 23 transform.Translate(x, y); |
| 24 return transform; | 24 return transform; |
| 25 } | 25 } |
| 26 | 26 |
| 27 class PaintArtifactCompositorTest : public ::testing::Test { | 27 class PaintArtifactCompositorTest : public ::testing::Test { |
| 28 protected: | 28 protected: |
| 29 void SetUp() override | 29 void SetUp() override |
| 30 { | 30 { |
| 31 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 31 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 32 m_paintArtifactCompositor.initializeIfNeeded(); | 32 |
| 33 // Delay constructing the compositor until after the feature is set. |
| 34 m_paintArtifactCompositor = adoptPtr(new PaintArtifactCompositor); |
| 33 } | 35 } |
| 34 | 36 |
| 35 void TearDown() override | 37 void TearDown() override |
| 36 { | 38 { |
| 37 m_featuresBackup.restore(); | 39 m_featuresBackup.restore(); |
| 38 } | 40 } |
| 39 | 41 |
| 40 PaintArtifactCompositor& paintArtifactCompositor() { return m_paintArtifactC
ompositor; } | 42 PaintArtifactCompositor& paintArtifactCompositor() { return *m_paintArtifact
Compositor; } |
| 41 cc::Layer* rootLayer() { return m_paintArtifactCompositor.rootLayer(); } | 43 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); } |
| 42 void update(const PaintArtifact& artifact) { m_paintArtifactCompositor.updat
e(artifact); } | 44 void update(const PaintArtifact& artifact) { m_paintArtifactCompositor->upda
te(artifact); } |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 RuntimeEnabledFeatures::Backup m_featuresBackup; | 47 RuntimeEnabledFeatures::Backup m_featuresBackup; |
| 46 PaintArtifactCompositor m_paintArtifactCompositor; | 48 OwnPtr<PaintArtifactCompositor> m_paintArtifactCompositor; |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 TEST_F(PaintArtifactCompositorTest, EmptyPaintArtifact) | 51 TEST_F(PaintArtifactCompositorTest, EmptyPaintArtifact) |
| 50 { | 52 { |
| 51 PaintArtifact emptyArtifact; | 53 PaintArtifact emptyArtifact; |
| 52 update(emptyArtifact); | 54 update(emptyArtifact); |
| 53 EXPECT_TRUE(rootLayer()->children().empty()); | 55 EXPECT_TRUE(rootLayer()->children().empty()); |
| 54 } | 56 } |
| 55 | 57 |
| 56 TEST_F(PaintArtifactCompositorTest, OneChunkWithAnOffset) | 58 TEST_F(PaintArtifactCompositorTest, OneChunkWithAnOffset) |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 ASSERT_EQ(1u, clipLayer2->children().size()); | 301 ASSERT_EQ(1u, clipLayer2->children().size()); |
| 300 cc::Layer* blackLayer = clipLayer2->child_at(0); | 302 cc::Layer* blackLayer = clipLayer2->child_at(0); |
| 301 EXPECT_THAT(blackLayer->GetPicture(), | 303 EXPECT_THAT(blackLayer->GetPicture(), |
| 302 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::black))); | 304 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::black))); |
| 303 EXPECT_EQ(translation(-400, 0), blackLayer->transform()); | 305 EXPECT_EQ(translation(-400, 0), blackLayer->transform()); |
| 304 } | 306 } |
| 305 } | 307 } |
| 306 | 308 |
| 307 } // namespace | 309 } // namespace |
| 308 } // namespace blink | 310 } // namespace blink |
| OLD | NEW |