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() { |
pdr.
2016/10/22 03:58:37
Potential followup: WDYT of adding a superclass th
trchen
2016/10/24 21:53:20
I'm thinking to move the static root nodes to Sour
| |
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( | |
38 nullptr, dummyRootTransform(), dummyRootClip(), | |
39 CompositorFilterOperations(), 1.0))); | |
40 return rootEffect; | |
41 } | |
42 | |
43 PaintChunkProperties rootPaintChunkProperties() { | |
21 return PaintChunkProperties(); | 44 return PaintChunkProperties(); |
22 } | 45 } |
23 | 46 |
24 class PaintChunkerTest : public testing::Test { | 47 class PaintChunkerTest : public testing::Test { |
25 protected: | 48 protected: |
26 void SetUp() override { | 49 void SetUp() override { |
27 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 50 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
28 } | 51 } |
29 | 52 |
30 void TearDown() override { m_featuresBackup.restore(); } | 53 void TearDown() override { m_featuresBackup.restore(); } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 | 163 |
141 PaintChunkProperties simpleTransform; | 164 PaintChunkProperties simpleTransform; |
142 simpleTransform.transform = TransformPaintPropertyNode::create( | 165 simpleTransform.transform = TransformPaintPropertyNode::create( |
143 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); | 166 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); |
144 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 167 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); |
145 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 168 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 169 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
147 | 170 |
148 PaintChunkProperties simpleTransformAndEffect; | 171 PaintChunkProperties simpleTransformAndEffect; |
149 simpleTransformAndEffect.transform = simpleTransform.transform; | 172 simpleTransformAndEffect.transform = simpleTransform.transform; |
150 simpleTransformAndEffect.effect = | 173 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create( |
151 EffectPaintPropertyNode::create(nullptr, 0.5f); | 174 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
175 CompositorFilterOperations(), 0.5f); | |
152 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); | 176 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); |
153 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 177 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
154 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 178 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
155 | 179 |
156 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; | 180 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; |
157 simpleTransformAndEffectWithUpdatedTransform.transform = | 181 simpleTransformAndEffectWithUpdatedTransform.transform = |
158 TransformPaintPropertyNode::create(nullptr, | 182 TransformPaintPropertyNode::create(nullptr, |
159 TransformationMatrix(1, 1, 0, 0, 0, 0), | 183 TransformationMatrix(1, 1, 0, 0, 0, 0), |
160 FloatPoint3D(9, 8, 7)); | 184 FloatPoint3D(9, 8, 7)); |
161 simpleTransformAndEffectWithUpdatedTransform.effect = | 185 simpleTransformAndEffectWithUpdatedTransform.effect = |
162 EffectPaintPropertyNode::create( | 186 EffectPaintPropertyNode::create( |
163 nullptr, simpleTransformAndEffect.effect->opacity()); | 187 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
188 CompositorFilterOperations(), | |
189 simpleTransformAndEffect.effect->opacity()); | |
164 chunker.updateCurrentPaintChunkProperties( | 190 chunker.updateCurrentPaintChunkProperties( |
165 nullptr, simpleTransformAndEffectWithUpdatedTransform); | 191 nullptr, simpleTransformAndEffectWithUpdatedTransform); |
166 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 192 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
167 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 193 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
168 | 194 |
169 // Test that going back to a previous chunk property still creates a new | 195 // Test that going back to a previous chunk property still creates a new |
170 // chunk. | 196 // chunk. |
171 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); | 197 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); |
172 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 198 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
173 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 199 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 PaintChunk(2, 4, nullptr, simpleTransform), | 366 PaintChunk(2, 4, nullptr, simpleTransform), |
341 PaintChunk(4, 5, nullptr, simpleTransform), | 367 PaintChunk(4, 5, nullptr, simpleTransform), |
342 PaintChunk(5, 6, nullptr, simpleTransform), | 368 PaintChunk(5, 6, nullptr, simpleTransform), |
343 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); | 369 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); |
344 } | 370 } |
345 | 371 |
346 #endif | 372 #endif |
347 | 373 |
348 } // namespace | 374 } // namespace |
349 } // namespace blink | 375 } // namespace blink |
OLD | NEW |