OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/PaintChunker.h" | 5 #include "platform/graphics/paint/PaintChunker.h" |
6 | 6 |
7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 using testing::ElementsAre; | 11 using testing::ElementsAre; |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 namespace { | 14 namespace { |
15 | 15 |
16 // TODO(crbug.com/629946): The tests fail mysteriously on some Windows debug | 16 // TODO(crbug.com/629946): The tests fail mysteriously on some Windows debug |
17 // bots. | 17 // bots. |
18 #if defined(NDEBUG) || !OS(WIN) | 18 #if defined(NDEBUG) || !OS(WIN) |
19 | 19 |
20 static PaintChunkProperties rootPaintChunkProperties() { | 20 TransformPaintPropertyNode* dummyRootTransform() { |
| 21 DEFINE_STATIC_REF(TransformPaintPropertyNode, rootTransform, |
| 22 (TransformPaintPropertyNode::create( |
| 23 nullptr, TransformationMatrix(), FloatPoint3D()))); |
| 24 return rootTransform; |
| 25 } |
| 26 |
| 27 ClipPaintPropertyNode* dummyRootClip() { |
| 28 DEFINE_STATIC_REF(ClipPaintPropertyNode, rootClip, |
| 29 (ClipPaintPropertyNode::create( |
| 30 nullptr, dummyRootTransform(), |
| 31 FloatRoundedRect(LayoutRect::infiniteIntRect())))); |
| 32 return rootClip; |
| 33 } |
| 34 |
| 35 EffectPaintPropertyNode* dummyRootEffect() { |
| 36 DEFINE_STATIC_REF(EffectPaintPropertyNode, rootEffect, |
| 37 (EffectPaintPropertyNode::create(nullptr, dummyRootTransform
(), dummyRootClip(), 1.0, CompositorFilterOperations()))); |
| 38 return rootEffect; |
| 39 } |
| 40 |
| 41 PaintChunkProperties rootPaintChunkProperties() { |
21 return PaintChunkProperties(); | 42 return PaintChunkProperties(); |
22 } | 43 } |
23 | 44 |
24 class PaintChunkerTest : public testing::Test { | 45 class PaintChunkerTest : public testing::Test { |
25 protected: | 46 protected: |
26 void SetUp() override { | 47 void SetUp() override { |
27 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 48 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
28 } | 49 } |
29 | 50 |
30 void TearDown() override { m_featuresBackup.restore(); } | 51 void TearDown() override { m_featuresBackup.restore(); } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 PaintChunkProperties simpleTransform; | 162 PaintChunkProperties simpleTransform; |
142 simpleTransform.transform = TransformPaintPropertyNode::create( | 163 simpleTransform.transform = TransformPaintPropertyNode::create( |
143 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); | 164 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); |
144 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 165 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
145 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 166 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 167 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
147 | 168 |
148 PaintChunkProperties simpleTransformAndEffect; | 169 PaintChunkProperties simpleTransformAndEffect; |
149 simpleTransformAndEffect.transform = simpleTransform.transform; | 170 simpleTransformAndEffect.transform = simpleTransform.transform; |
150 simpleTransformAndEffect.effect = | 171 simpleTransformAndEffect.effect = |
151 EffectPaintPropertyNode::create(nullptr, 0.5f); | 172 EffectPaintPropertyNode::create(dummyRootEffect(), dummyRootTransform(), d
ummyRootClip(), 0.5f, CompositorFilterOperations()); |
152 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); | 173 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); |
153 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 174 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
154 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 175 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
155 | 176 |
156 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; | 177 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; |
157 simpleTransformAndEffectWithUpdatedTransform.transform = | 178 simpleTransformAndEffectWithUpdatedTransform.transform = |
158 TransformPaintPropertyNode::create(nullptr, | 179 TransformPaintPropertyNode::create(nullptr, |
159 TransformationMatrix(1, 1, 0, 0, 0, 0), | 180 TransformationMatrix(1, 1, 0, 0, 0, 0), |
160 FloatPoint3D(9, 8, 7)); | 181 FloatPoint3D(9, 8, 7)); |
161 simpleTransformAndEffectWithUpdatedTransform.effect = | 182 simpleTransformAndEffectWithUpdatedTransform.effect = |
162 EffectPaintPropertyNode::create( | 183 EffectPaintPropertyNode::create( |
163 nullptr, simpleTransformAndEffect.effect->opacity()); | 184 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), simpleTransf
ormAndEffect.effect->opacity(), CompositorFilterOperations()); |
164 chunker.updateCurrentPaintChunkProperties( | 185 chunker.updateCurrentPaintChunkProperties( |
165 nullptr, simpleTransformAndEffectWithUpdatedTransform); | 186 nullptr, simpleTransformAndEffectWithUpdatedTransform); |
166 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 187 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
167 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 188 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
168 | 189 |
169 // Test that going back to a previous chunk property still creates a new | 190 // Test that going back to a previous chunk property still creates a new |
170 // chunk. | 191 // chunk. |
171 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); | 192 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); |
172 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 193 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
173 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 194 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 PaintChunk(2, 4, nullptr, simpleTransform), | 361 PaintChunk(2, 4, nullptr, simpleTransform), |
341 PaintChunk(4, 5, nullptr, simpleTransform), | 362 PaintChunk(4, 5, nullptr, simpleTransform), |
342 PaintChunk(5, 6, nullptr, simpleTransform), | 363 PaintChunk(5, 6, nullptr, simpleTransform), |
343 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); | 364 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); |
344 } | 365 } |
345 | 366 |
346 #endif | 367 #endif |
347 | 368 |
348 } // namespace | 369 } // namespace |
349 } // namespace blink | 370 } // namespace blink |
OLD | NEW |