Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
| 6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
| 10 #include "platform/graphics/paint/ClipPathRecorder.h" | 10 #include "platform/graphics/paint/ClipPathRecorder.h" |
| 11 #include "platform/graphics/paint/ClipRecorder.h" | 11 #include "platform/graphics/paint/ClipRecorder.h" |
| 12 #include "platform/graphics/paint/CompositingRecorder.h" | 12 #include "platform/graphics/paint/CompositingRecorder.h" |
| 13 #include "platform/graphics/paint/DrawingDisplayItem.h" | 13 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 14 #include "platform/graphics/paint/DrawingRecorder.h" | 14 #include "platform/graphics/paint/DrawingRecorder.h" |
| 15 #include "platform/graphics/paint/SubsequenceRecorder.h" | 15 #include "platform/graphics/paint/SubsequenceRecorder.h" |
| 16 #include "platform/testing/FakeDisplayItemClient.h" | 16 #include "platform/testing/FakeDisplayItemClient.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include <memory> | 19 #include <memory> |
| 19 | 20 |
| 21 using testing::UnorderedElementsAre; | |
| 22 | |
| 20 namespace blink { | 23 namespace blink { |
| 21 | 24 |
| 22 class PaintControllerTestBase : public testing::Test { | 25 class PaintControllerTestBase : public testing::Test { |
| 23 public: | 26 public: |
| 24 PaintControllerTestBase() | 27 PaintControllerTestBase() |
| 25 : m_paintController(PaintController::create()) { } | 28 : m_paintController(PaintController::create()) { } |
| 26 | 29 |
| 27 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index) | 30 IntRect visualRect(const PaintArtifact& paintArtifact, size_t index) |
| 28 { | 31 { |
| 29 return paintArtifact.getDisplayItemList().visualRect(index); | 32 return paintArtifact.getDisplayItemList().visualRect(index); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 IntRect rect(0, 0, 10, 10); | 94 IntRect rect(0, 0, 10, 10); |
| 92 context.drawRect(rect); | 95 context.drawRect(rect); |
| 93 } | 96 } |
| 94 | 97 |
| 95 void drawClippedRect(GraphicsContext& context, const FakeDisplayItemClient& clie nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect& bound) | 98 void drawClippedRect(GraphicsContext& context, const FakeDisplayItemClient& clie nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect& bound) |
| 96 { | 99 { |
| 97 ClipRecorder clipRecorder(context, client, clipType, IntRect(1, 1, 9, 9)); | 100 ClipRecorder clipRecorder(context, client, clipType, IntRect(1, 1, 9, 9)); |
| 98 drawRect(context, client, drawingType, bound); | 101 drawRect(context, client, drawingType, bound); |
| 99 } | 102 } |
| 100 | 103 |
| 104 enum TestConfigurations { | |
| 105 SPv1, | |
| 106 SPv2, | |
| 101 #if DCHECK_IS_ON() | 107 #if DCHECK_IS_ON() |
| 108 UnderInvalidationCheckingSPv1, | |
| 109 UnderInvalidationCheckingSPv2, | |
| 110 #endif | |
| 111 }; | |
| 112 | |
| 102 // Tests using this class will be tested with under-invalidation-checking enable d and disabled. | 113 // Tests using this class will be tested with under-invalidation-checking enable d and disabled. |
| 103 class PaintControllerTest : public PaintControllerTestBase, public testing::With ParamInterface<bool> { | 114 class PaintControllerTest : public PaintControllerTestBase, public testing::With ParamInterface<TestConfigurations> { |
| 115 public: | |
| 116 PaintControllerTest() | |
| 117 : m_rootPaintPropertyClient("root") | |
| 118 , m_rootPaintChunkId(m_rootPaintPropertyClient, DisplayItem::Uninitializ edType) | |
| 119 { } | |
| 120 | |
| 104 protected: | 121 protected: |
| 105 void SetUp() override | 122 void SetUp() override |
| 106 { | 123 { |
| 107 if (GetParam()) | 124 switch (GetParam()) { |
| 125 case SPv1: | |
| 126 break; | |
| 127 case SPv2: | |
| 128 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | |
| 129 break; | |
| 130 #if DCHECK_IS_ON() | |
| 131 case UnderInvalidationCheckingSPv1: | |
| 108 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEna bled(true); | 132 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEna bled(true); |
| 133 break; | |
| 134 case UnderInvalidationCheckingSPv2: | |
| 135 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | |
| 136 RuntimeEnabledFeatures::setSlimmingPaintUnderInvalidationCheckingEna bled(true); | |
| 137 break; | |
| 138 #endif | |
| 139 } | |
| 109 } | 140 } |
| 141 | |
| 142 FakeDisplayItemClient m_rootPaintPropertyClient; | |
| 143 PaintChunk::Id m_rootPaintChunkId; | |
| 110 }; | 144 }; |
| 111 | 145 |
| 112 INSTANTIATE_TEST_CASE_P(All, PaintControllerTest, ::testing::Bool()); | 146 #if DCHECK_IS_ON() |
| 113 #define TEST_F_OR_P TEST_P | 147 INSTANTIATE_TEST_CASE_P(All, PaintControllerTest, ::testing::Values(SPv1, SPv2, UnderInvalidationCheckingSPv1, UnderInvalidationCheckingSPv2)); |
| 114 #else | 148 #else |
| 115 // Under-invalidation checking is only available when DCHECK_IS_ON(). | 149 INSTANTIATE_TEST_CASE_P(All, PaintControllerTest, ::testing::Values(SPv1, SPv2)) ; |
| 116 using PaintControllerTest = PaintControllerTestBase; | |
| 117 #define TEST_F_OR_P TEST_F | |
| 118 #endif | 150 #endif |
| 119 | 151 |
| 120 TEST_F_OR_P(PaintControllerTest, NestedRecorders) | 152 TEST_P(PaintControllerTest, NestedRecorders) |
| 121 { | 153 { |
| 122 GraphicsContext context(getPaintController()); | 154 GraphicsContext context(getPaintController()); |
| 123 | 155 FakeDisplayItemClient client("client", LayoutRect(100, 100, 200, 200)); |
| 124 FakeDisplayItemClient client("client"); | 156 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 157 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 125 | 158 |
| 126 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect( 100, 100, 200, 200)); | 159 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect( 100, 100, 200, 200)); |
| 127 getPaintController().commitNewDisplayItems(); | 160 getPaintController().commitNewDisplayItems(); |
| 128 | 161 |
| 129 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 162 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 130 TestDisplayItem(client, clipType), | 163 TestDisplayItem(client, clipType), |
| 131 TestDisplayItem(client, backgroundDrawingType), | 164 TestDisplayItem(client, backgroundDrawingType), |
| 132 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType))); | 165 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType))); |
| 166 | |
| 167 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 168 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 169 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 170 FloatRect(LayoutRect::infiniteIntRect()))); | |
| 171 } | |
| 133 } | 172 } |
| 134 | 173 |
| 135 TEST_F_OR_P(PaintControllerTest, UpdateBasic) | 174 TEST_P(PaintControllerTest, UpdateBasic) |
| 136 { | 175 { |
| 137 FakeDisplayItemClient first("first"); | 176 FakeDisplayItemClient first("first", LayoutRect(100, 100, 300, 300)); |
| 138 FakeDisplayItemClient second("second"); | 177 FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); |
| 139 GraphicsContext context(getPaintController()); | 178 GraphicsContext context(getPaintController()); |
| 179 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 180 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 140 | 181 |
| 141 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); | 182 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); |
| 142 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0)); | 183 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0)); |
| 143 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); | 184 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); |
| 144 | 185 |
| 145 EXPECT_EQ(0, numCachedNewItems()); | 186 EXPECT_EQ(0, numCachedNewItems()); |
| 146 | 187 |
| 147 getPaintController().commitNewDisplayItems(); | 188 getPaintController().commitNewDisplayItems(); |
| 148 | 189 |
| 149 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 190 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 150 TestDisplayItem(first, backgroundDrawingType), | 191 TestDisplayItem(first, backgroundDrawingType), |
| 151 TestDisplayItem(second, backgroundDrawingType), | 192 TestDisplayItem(second, backgroundDrawingType), |
| 152 TestDisplayItem(first, foregroundDrawingType)); | 193 TestDisplayItem(first, foregroundDrawingType)); |
| 153 | 194 |
| 195 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 196 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 197 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 198 FloatRect(LayoutRect::infiniteIntRect()))); | |
| 199 | |
| 200 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 201 } | |
| 202 | |
| 154 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); | 203 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); |
| 155 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); | 204 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); |
| 156 | 205 |
| 157 EXPECT_EQ(2, numCachedNewItems()); | 206 EXPECT_EQ(2, numCachedNewItems()); |
| 158 #if DCHECK_IS_ON() | 207 #if DCHECK_IS_ON() |
| 159 EXPECT_EQ(2, numSequentialMatches()); | 208 EXPECT_EQ(2, numSequentialMatches()); |
| 160 EXPECT_EQ(0, numOutOfOrderMatches()); | 209 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 161 EXPECT_EQ(1, numIndexedItems()); | 210 EXPECT_EQ(1, numIndexedItems()); |
| 162 #endif | 211 #endif |
| 163 | 212 |
| 164 getPaintController().commitNewDisplayItems(); | 213 getPaintController().commitNewDisplayItems(); |
| 165 | 214 |
| 166 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 215 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 167 TestDisplayItem(first, backgroundDrawingType), | 216 TestDisplayItem(first, backgroundDrawingType), |
| 168 TestDisplayItem(first, foregroundDrawingType)); | 217 TestDisplayItem(first, foregroundDrawingType)); |
| 218 | |
| 219 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 220 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 221 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 222 FloatRect(100, 100, 200, 200))); // |second| disappeared from the ch unk. | |
| 223 } | |
| 169 } | 224 } |
| 170 | 225 |
| 171 TEST_F_OR_P(PaintControllerTest, UpdateSwapOrder) | 226 TEST_P(PaintControllerTest, UpdateSwapOrder) |
| 172 { | 227 { |
| 173 FakeDisplayItemClient first("first"); | 228 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); |
| 174 FakeDisplayItemClient second("second"); | 229 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); |
| 175 FakeDisplayItemClient unaffected("unaffected"); | 230 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)) ; |
| 176 GraphicsContext context(getPaintController()); | 231 GraphicsContext context(getPaintController()); |
| 232 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 233 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 177 | 234 |
| 178 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); | 235 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 179 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); | 236 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 180 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); | 237 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 181 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); | 238 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 182 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); | 239 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); |
| 183 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10)); | 240 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10)); |
| 184 getPaintController().commitNewDisplayItems(); | 241 getPaintController().commitNewDisplayItems(); |
| 242 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 243 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 185 | 244 |
| 186 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, | 245 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 187 TestDisplayItem(first, backgroundDrawingType), | 246 TestDisplayItem(first, backgroundDrawingType), |
| 188 TestDisplayItem(first, foregroundDrawingType), | 247 TestDisplayItem(first, foregroundDrawingType), |
| 189 TestDisplayItem(second, backgroundDrawingType), | 248 TestDisplayItem(second, backgroundDrawingType), |
| 190 TestDisplayItem(second, foregroundDrawingType), | 249 TestDisplayItem(second, foregroundDrawingType), |
| 191 TestDisplayItem(unaffected, backgroundDrawingType), | 250 TestDisplayItem(unaffected, backgroundDrawingType), |
| 192 TestDisplayItem(unaffected, foregroundDrawingType)); | 251 TestDisplayItem(unaffected, foregroundDrawingType)); |
| 193 | 252 |
| 194 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); | 253 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 207 | 266 |
| 208 getPaintController().commitNewDisplayItems(); | 267 getPaintController().commitNewDisplayItems(); |
| 209 | 268 |
| 210 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, | 269 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 211 TestDisplayItem(second, backgroundDrawingType), | 270 TestDisplayItem(second, backgroundDrawingType), |
| 212 TestDisplayItem(second, foregroundDrawingType), | 271 TestDisplayItem(second, foregroundDrawingType), |
| 213 TestDisplayItem(first, backgroundDrawingType), | 272 TestDisplayItem(first, backgroundDrawingType), |
| 214 TestDisplayItem(first, foregroundDrawingType), | 273 TestDisplayItem(first, foregroundDrawingType), |
| 215 TestDisplayItem(unaffected, backgroundDrawingType), | 274 TestDisplayItem(unaffected, backgroundDrawingType), |
| 216 TestDisplayItem(unaffected, foregroundDrawingType)); | 275 TestDisplayItem(unaffected, foregroundDrawingType)); |
| 276 | |
| 277 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 278 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 279 // TODO(wangxianzhu): In real world we invalidate clients with reordered display items. | |
| 280 // Need to support raster invalidation for recordered display items with out invalidating clients. | |
| 281 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre()); | |
| 282 } | |
| 217 } | 283 } |
| 218 | 284 |
| 219 TEST_F_OR_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) | 285 TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) |
| 220 { | 286 { |
| 221 FakeDisplayItemClient first("first"); | 287 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); |
| 222 FakeDisplayItemClient second("second"); | 288 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); |
| 223 FakeDisplayItemClient unaffected("unaffected"); | 289 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)) ; |
| 224 GraphicsContext context(getPaintController()); | 290 GraphicsContext context(getPaintController()); |
| 291 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 292 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 225 | 293 |
| 226 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); | 294 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 227 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); | 295 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 228 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); | 296 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 229 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); | 297 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 230 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); | 298 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); |
| 231 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10)); | 299 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10)); |
| 232 getPaintController().commitNewDisplayItems(); | 300 getPaintController().commitNewDisplayItems(); |
| 233 | 301 |
| 234 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, | 302 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 235 TestDisplayItem(first, backgroundDrawingType), | 303 TestDisplayItem(first, backgroundDrawingType), |
| 236 TestDisplayItem(first, foregroundDrawingType), | 304 TestDisplayItem(first, foregroundDrawingType), |
| 237 TestDisplayItem(second, backgroundDrawingType), | 305 TestDisplayItem(second, backgroundDrawingType), |
| 238 TestDisplayItem(second, foregroundDrawingType), | 306 TestDisplayItem(second, foregroundDrawingType), |
| 239 TestDisplayItem(unaffected, backgroundDrawingType), | 307 TestDisplayItem(unaffected, backgroundDrawingType), |
| 240 TestDisplayItem(unaffected, foregroundDrawingType)); | 308 TestDisplayItem(unaffected, foregroundDrawingType)); |
| 241 | 309 |
| 310 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 311 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 312 | |
| 242 first.setDisplayItemsUncached(); | 313 first.setDisplayItemsUncached(); |
| 243 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); | 314 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 244 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); | 315 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 245 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); | 316 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 246 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); | 317 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 247 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); | 318 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); |
| 248 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10)); | 319 drawRect(context, unaffected, foregroundDrawingType, FloatRect(300, 300, 10, 10)); |
| 249 | 320 |
| 250 EXPECT_EQ(4, numCachedNewItems()); | 321 EXPECT_EQ(4, numCachedNewItems()); |
| 251 #if DCHECK_IS_ON() | 322 #if DCHECK_IS_ON() |
| 252 EXPECT_EQ(4, numSequentialMatches()); // second, unaffected | 323 EXPECT_EQ(4, numSequentialMatches()); // second, unaffected |
| 253 EXPECT_EQ(0, numOutOfOrderMatches()); | 324 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 254 EXPECT_EQ(2, numIndexedItems()); | 325 EXPECT_EQ(2, numIndexedItems()); |
| 255 #endif | 326 #endif |
| 256 | 327 |
| 257 getPaintController().commitNewDisplayItems(); | 328 getPaintController().commitNewDisplayItems(); |
| 258 | 329 |
| 259 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, | 330 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 260 TestDisplayItem(second, backgroundDrawingType), | 331 TestDisplayItem(second, backgroundDrawingType), |
| 261 TestDisplayItem(second, foregroundDrawingType), | 332 TestDisplayItem(second, foregroundDrawingType), |
| 262 TestDisplayItem(first, backgroundDrawingType), | 333 TestDisplayItem(first, backgroundDrawingType), |
| 263 TestDisplayItem(first, foregroundDrawingType), | 334 TestDisplayItem(first, foregroundDrawingType), |
| 264 TestDisplayItem(unaffected, backgroundDrawingType), | 335 TestDisplayItem(unaffected, backgroundDrawingType), |
| 265 TestDisplayItem(unaffected, foregroundDrawingType)); | 336 TestDisplayItem(unaffected, foregroundDrawingType)); |
| 337 | |
| 338 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 339 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 340 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 341 FloatRect(100, 100, 100, 100), // Old bounds of |first|. | |
| 342 FloatRect(100, 100, 100, 100))); // New bounds of |first|. | |
| 343 } | |
| 266 } | 344 } |
| 267 | 345 |
| 268 TEST_F_OR_P(PaintControllerTest, UpdateNewItemInMiddle) | 346 TEST_P(PaintControllerTest, UpdateNewItemInMiddle) |
| 269 { | 347 { |
| 270 FakeDisplayItemClient first("first"); | 348 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); |
| 271 FakeDisplayItemClient second("second"); | 349 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); |
| 272 FakeDisplayItemClient third("third"); | 350 FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50)); |
| 273 GraphicsContext context(getPaintController()); | 351 GraphicsContext context(getPaintController()); |
| 352 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 353 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 274 | 354 |
| 275 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); | 355 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 276 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); | 356 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 277 getPaintController().commitNewDisplayItems(); | 357 getPaintController().commitNewDisplayItems(); |
| 278 | 358 |
| 279 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 359 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 280 TestDisplayItem(first, backgroundDrawingType), | 360 TestDisplayItem(first, backgroundDrawingType), |
| 281 TestDisplayItem(second, backgroundDrawingType)); | 361 TestDisplayItem(second, backgroundDrawingType)); |
| 282 | 362 |
| 363 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 364 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 365 | |
| 283 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); | 366 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 284 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50) ); | 367 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50) ); |
| 285 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); | 368 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 286 | 369 |
| 287 EXPECT_EQ(2, numCachedNewItems()); | 370 EXPECT_EQ(2, numCachedNewItems()); |
| 288 #if DCHECK_IS_ON() | 371 #if DCHECK_IS_ON() |
| 289 EXPECT_EQ(2, numSequentialMatches()); // first, second | 372 EXPECT_EQ(2, numSequentialMatches()); // first, second |
| 290 EXPECT_EQ(0, numOutOfOrderMatches()); | 373 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 291 EXPECT_EQ(0, numIndexedItems()); | 374 EXPECT_EQ(0, numIndexedItems()); |
| 292 #endif | 375 #endif |
| 293 | 376 |
| 294 getPaintController().commitNewDisplayItems(); | 377 getPaintController().commitNewDisplayItems(); |
| 295 | 378 |
| 296 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 379 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 297 TestDisplayItem(first, backgroundDrawingType), | 380 TestDisplayItem(first, backgroundDrawingType), |
| 298 TestDisplayItem(third, backgroundDrawingType), | 381 TestDisplayItem(third, backgroundDrawingType), |
| 299 TestDisplayItem(second, backgroundDrawingType)); | 382 TestDisplayItem(second, backgroundDrawingType)); |
| 383 | |
| 384 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 385 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 386 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 387 FloatRect(125, 100, 200, 50))); // |third| newly appeared in the chu nk. | |
| 388 } | |
| 300 } | 389 } |
| 301 | 390 |
| 302 TEST_F_OR_P(PaintControllerTest, UpdateInvalidationWithPhases) | 391 TEST_P(PaintControllerTest, UpdateInvalidationWithPhases) |
| 303 { | 392 { |
| 304 FakeDisplayItemClient first("first"); | 393 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); |
| 305 FakeDisplayItemClient second("second"); | 394 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); |
| 306 FakeDisplayItemClient third("third"); | 395 FakeDisplayItemClient third("third", LayoutRect(300, 100, 50, 50)); |
| 307 GraphicsContext context(getPaintController()); | 396 GraphicsContext context(getPaintController()); |
| 397 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 398 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 308 | 399 |
| 309 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); | 400 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 310 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); | 401 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 311 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ; | 402 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ; |
| 312 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); | 403 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 313 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); | 404 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 314 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ; | 405 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ; |
| 315 getPaintController().commitNewDisplayItems(); | 406 getPaintController().commitNewDisplayItems(); |
| 316 | 407 |
| 317 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, | 408 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 318 TestDisplayItem(first, backgroundDrawingType), | 409 TestDisplayItem(first, backgroundDrawingType), |
| 319 TestDisplayItem(second, backgroundDrawingType), | 410 TestDisplayItem(second, backgroundDrawingType), |
| 320 TestDisplayItem(third, backgroundDrawingType), | 411 TestDisplayItem(third, backgroundDrawingType), |
| 321 TestDisplayItem(first, foregroundDrawingType), | 412 TestDisplayItem(first, foregroundDrawingType), |
| 322 TestDisplayItem(second, foregroundDrawingType), | 413 TestDisplayItem(second, foregroundDrawingType), |
| 323 TestDisplayItem(third, foregroundDrawingType)); | 414 TestDisplayItem(third, foregroundDrawingType)); |
| 324 | 415 |
| 416 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 417 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 418 | |
| 325 second.setDisplayItemsUncached(); | 419 second.setDisplayItemsUncached(); |
| 326 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); | 420 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 327 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); | 421 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 328 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ; | 422 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ; |
| 329 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); | 423 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); |
| 330 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); | 424 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); |
| 331 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ; | 425 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ; |
| 332 | 426 |
| 333 EXPECT_EQ(4, numCachedNewItems()); | 427 EXPECT_EQ(4, numCachedNewItems()); |
| 334 #if DCHECK_IS_ON() | 428 #if DCHECK_IS_ON() |
| 335 EXPECT_EQ(4, numSequentialMatches()); | 429 EXPECT_EQ(4, numSequentialMatches()); |
| 336 EXPECT_EQ(0, numOutOfOrderMatches()); | 430 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 337 EXPECT_EQ(2, numIndexedItems()); | 431 EXPECT_EQ(2, numIndexedItems()); |
| 338 #endif | 432 #endif |
| 339 | 433 |
| 340 getPaintController().commitNewDisplayItems(); | 434 getPaintController().commitNewDisplayItems(); |
| 341 | 435 |
| 342 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, | 436 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 343 TestDisplayItem(first, backgroundDrawingType), | 437 TestDisplayItem(first, backgroundDrawingType), |
| 344 TestDisplayItem(second, backgroundDrawingType), | 438 TestDisplayItem(second, backgroundDrawingType), |
| 345 TestDisplayItem(third, backgroundDrawingType), | 439 TestDisplayItem(third, backgroundDrawingType), |
| 346 TestDisplayItem(first, foregroundDrawingType), | 440 TestDisplayItem(first, foregroundDrawingType), |
| 347 TestDisplayItem(second, foregroundDrawingType), | 441 TestDisplayItem(second, foregroundDrawingType), |
| 348 TestDisplayItem(third, foregroundDrawingType)); | 442 TestDisplayItem(third, foregroundDrawingType)); |
| 443 | |
| 444 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 445 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 446 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 447 FloatRect(100, 100, 50, 200), // Old bounds of |second|. | |
| 448 FloatRect(100, 100, 50, 200))); // New bounds of |second|. | |
| 449 } | |
| 349 } | 450 } |
| 350 | 451 |
| 351 TEST_F_OR_P(PaintControllerTest, UpdateAddFirstOverlap) | 452 TEST_P(PaintControllerTest, UpdateAddFirstOverlap) |
| 352 { | 453 { |
| 353 FakeDisplayItemClient first("first"); | 454 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); |
| 354 FakeDisplayItemClient second("second"); | 455 FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); |
| 355 GraphicsContext context(getPaintController()); | 456 GraphicsContext context(getPaintController()); |
| 457 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 458 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 356 | 459 |
| 357 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); | 460 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); |
| 358 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); | 461 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); |
| 359 getPaintController().commitNewDisplayItems(); | 462 getPaintController().commitNewDisplayItems(); |
| 360 | 463 |
| 361 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 464 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 362 TestDisplayItem(second, backgroundDrawingType), | 465 TestDisplayItem(second, backgroundDrawingType), |
| 363 TestDisplayItem(second, foregroundDrawingType)); | 466 TestDisplayItem(second, foregroundDrawingType)); |
| 364 | 467 |
| 468 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 469 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 470 | |
| 365 first.setDisplayItemsUncached(); | 471 first.setDisplayItemsUncached(); |
| 366 second.setDisplayItemsUncached(); | 472 second.setDisplayItemsUncached(); |
| 473 second.setVisualRect(LayoutRect(150, 150, 100, 100)); | |
| 367 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); | 474 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 368 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); | 475 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 369 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); | 476 drawRect(context, second, backgroundDrawingType, FloatRect(150, 150, 100, 10 0)); |
| 370 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); | 477 drawRect(context, second, foregroundDrawingType, FloatRect(150, 150, 100, 10 0)); |
| 371 EXPECT_EQ(0, numCachedNewItems()); | 478 EXPECT_EQ(0, numCachedNewItems()); |
| 372 getPaintController().commitNewDisplayItems(); | 479 getPaintController().commitNewDisplayItems(); |
| 373 | 480 |
| 374 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, | 481 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 375 TestDisplayItem(first, backgroundDrawingType), | 482 TestDisplayItem(first, backgroundDrawingType), |
| 376 TestDisplayItem(first, foregroundDrawingType), | 483 TestDisplayItem(first, foregroundDrawingType), |
| 377 TestDisplayItem(second, backgroundDrawingType), | 484 TestDisplayItem(second, backgroundDrawingType), |
| 378 TestDisplayItem(second, foregroundDrawingType)); | 485 TestDisplayItem(second, foregroundDrawingType)); |
| 379 | 486 |
| 380 first.setDisplayItemsUncached(); | 487 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 381 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); | 488 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
| 382 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); | 489 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( |
| 490 FloatRect(100, 100, 150, 150), // |first| newly appeared in the chun k. | |
| 491 FloatRect(200, 200, 50, 50), // Old bounds of |second|. | |
| 492 FloatRect(150, 150, 100, 100))); // New bounds of |second|. | |
| 493 | |
| 494 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 495 } | |
| 496 | |
| 497 drawRect(context, second, backgroundDrawingType, FloatRect(150, 150, 100, 10 0)); | |
| 498 drawRect(context, second, foregroundDrawingType, FloatRect(150, 150, 100, 10 0)); | |
| 383 | 499 |
| 384 EXPECT_EQ(2, numCachedNewItems()); | 500 EXPECT_EQ(2, numCachedNewItems()); |
| 385 #if DCHECK_IS_ON() | 501 #if DCHECK_IS_ON() |
| 386 EXPECT_EQ(2, numSequentialMatches()); | 502 EXPECT_EQ(2, numSequentialMatches()); |
| 387 EXPECT_EQ(0, numOutOfOrderMatches()); | 503 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 388 EXPECT_EQ(2, numIndexedItems()); | 504 EXPECT_EQ(2, numIndexedItems()); |
| 389 #endif | 505 #endif |
| 390 | 506 |
| 391 getPaintController().commitNewDisplayItems(); | 507 getPaintController().commitNewDisplayItems(); |
| 392 | 508 |
| 393 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 509 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 394 TestDisplayItem(second, backgroundDrawingType), | 510 TestDisplayItem(second, backgroundDrawingType), |
| 395 TestDisplayItem(second, foregroundDrawingType)); | 511 TestDisplayItem(second, foregroundDrawingType)); |
| 512 | |
| 513 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 514 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 515 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 516 FloatRect(100, 100, 150, 150))); // |first| disappeared from the chu nk. | |
| 517 } | |
| 396 } | 518 } |
| 397 | 519 |
| 398 TEST_F_OR_P(PaintControllerTest, UpdateAddLastOverlap) | 520 TEST_P(PaintControllerTest, UpdateAddLastOverlap) |
| 399 { | 521 { |
| 400 FakeDisplayItemClient first("first"); | 522 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); |
| 401 FakeDisplayItemClient second("second"); | 523 FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); |
| 402 GraphicsContext context(getPaintController()); | 524 GraphicsContext context(getPaintController()); |
| 525 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 526 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 403 | 527 |
| 404 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); | 528 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 405 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); | 529 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 406 getPaintController().commitNewDisplayItems(); | 530 getPaintController().commitNewDisplayItems(); |
| 407 | 531 |
| 408 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 532 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 409 TestDisplayItem(first, backgroundDrawingType), | 533 TestDisplayItem(first, backgroundDrawingType), |
| 410 TestDisplayItem(first, foregroundDrawingType)); | 534 TestDisplayItem(first, foregroundDrawingType)); |
| 411 | 535 |
| 536 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 537 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 538 | |
| 412 first.setDisplayItemsUncached(); | 539 first.setDisplayItemsUncached(); |
| 540 first.setVisualRect(LayoutRect(150, 150, 100, 100)); | |
| 413 second.setDisplayItemsUncached(); | 541 second.setDisplayItemsUncached(); |
| 414 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); | 542 drawRect(context, first, backgroundDrawingType, FloatRect(150, 150, 100, 100 )); |
| 415 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); | 543 drawRect(context, first, foregroundDrawingType, FloatRect(150, 150, 100, 100 )); |
| 416 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); | 544 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); |
| 417 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); | 545 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); |
| 418 EXPECT_EQ(0, numCachedNewItems()); | 546 EXPECT_EQ(0, numCachedNewItems()); |
| 419 getPaintController().commitNewDisplayItems(); | 547 getPaintController().commitNewDisplayItems(); |
| 420 | 548 |
| 421 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, | 549 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 422 TestDisplayItem(first, backgroundDrawingType), | 550 TestDisplayItem(first, backgroundDrawingType), |
| 423 TestDisplayItem(first, foregroundDrawingType), | 551 TestDisplayItem(first, foregroundDrawingType), |
| 424 TestDisplayItem(second, backgroundDrawingType), | 552 TestDisplayItem(second, backgroundDrawingType), |
| 425 TestDisplayItem(second, foregroundDrawingType)); | 553 TestDisplayItem(second, foregroundDrawingType)); |
| 426 | 554 |
| 555 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 556 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 557 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 558 FloatRect(100, 100, 150, 150), // Old bounds of |first|. | |
| 559 FloatRect(150, 150, 100, 100), // New bounds of |first|. | |
| 560 FloatRect(200, 200, 50, 50))); // |second| newly appeared in the chu nk. | |
| 561 | |
| 562 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 563 } | |
| 564 | |
| 427 first.setDisplayItemsUncached(); | 565 first.setDisplayItemsUncached(); |
| 566 first.setVisualRect(LayoutRect(100, 100, 150, 150)); | |
| 428 second.setDisplayItemsUncached(); | 567 second.setDisplayItemsUncached(); |
| 429 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); | 568 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 430 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); | 569 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 431 EXPECT_EQ(0, numCachedNewItems()); | 570 EXPECT_EQ(0, numCachedNewItems()); |
| 432 getPaintController().commitNewDisplayItems(); | 571 getPaintController().commitNewDisplayItems(); |
| 433 | 572 |
| 434 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 573 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 435 TestDisplayItem(first, backgroundDrawingType), | 574 TestDisplayItem(first, backgroundDrawingType), |
| 436 TestDisplayItem(first, foregroundDrawingType)); | 575 TestDisplayItem(first, foregroundDrawingType)); |
| 576 | |
| 577 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 578 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 579 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 580 FloatRect(150, 150, 100, 100), // Old bounds of |first|. | |
| 581 FloatRect(100, 100, 150, 150), // New bounds of |first|. | |
| 582 FloatRect(200, 200, 50, 50))); // |second| disappeared from the chun k. | |
| 583 } | |
| 437 } | 584 } |
| 438 | 585 |
| 439 TEST_F_OR_P(PaintControllerTest, UpdateClip) | 586 TEST_P(PaintControllerTest, UpdateClip) |
| 440 { | 587 { |
| 441 FakeDisplayItemClient first("first"); | 588 FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); |
| 442 FakeDisplayItemClient second("second"); | 589 FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); |
| 443 GraphicsContext context(getPaintController()); | 590 GraphicsContext context(getPaintController()); |
| 444 | 591 |
| 445 { | 592 { |
| 593 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 594 PaintChunk::Id id(first, clipType); | |
| 595 PaintChunkProperties properties; | |
| 596 properties.clip = ClipPaintPropertyNode::create(nullptr, nullptr, Fl oatRoundedRect(1, 1, 2, 2)); | |
| 597 getPaintController().updateCurrentPaintChunkProperties(&id, properti es); | |
| 598 } | |
| 446 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2)) ; | 599 ClipRecorder clipRecorder(context, first, clipType, IntRect(1, 1, 2, 2)) ; |
| 447 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150)); | 600 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150)); |
| 448 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150 , 150)); | 601 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200 , 200)); |
| 449 } | 602 } |
| 450 getPaintController().commitNewDisplayItems(); | 603 getPaintController().commitNewDisplayItems(); |
| 451 | 604 |
| 452 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, | 605 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 453 TestDisplayItem(first, clipType), | 606 TestDisplayItem(first, clipType), |
| 454 TestDisplayItem(first, backgroundDrawingType), | 607 TestDisplayItem(first, backgroundDrawingType), |
| 455 TestDisplayItem(second, backgroundDrawingType), | 608 TestDisplayItem(second, backgroundDrawingType), |
| 456 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); | 609 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); |
| 457 | 610 |
| 611 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 612 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 613 | |
| 458 first.setDisplayItemsUncached(); | 614 first.setDisplayItemsUncached(); |
| 459 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); | 615 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 460 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); | 616 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0)); |
| 461 | 617 |
| 462 EXPECT_EQ(1, numCachedNewItems()); | 618 EXPECT_EQ(1, numCachedNewItems()); |
| 463 #if DCHECK_IS_ON() | 619 #if DCHECK_IS_ON() |
| 464 EXPECT_EQ(1, numSequentialMatches()); | 620 EXPECT_EQ(1, numSequentialMatches()); |
| 465 EXPECT_EQ(0, numOutOfOrderMatches()); | 621 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 466 EXPECT_EQ(1, numIndexedItems()); | 622 EXPECT_EQ(1, numIndexedItems()); |
| 467 #endif | 623 #endif |
| 468 | 624 |
| 469 getPaintController().commitNewDisplayItems(); | 625 getPaintController().commitNewDisplayItems(); |
| 470 | 626 |
| 471 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 627 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 472 TestDisplayItem(first, backgroundDrawingType), | 628 TestDisplayItem(first, backgroundDrawingType), |
| 473 TestDisplayItem(second, backgroundDrawingType)); | 629 TestDisplayItem(second, backgroundDrawingType)); |
| 474 | 630 |
| 631 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 632 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 633 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 634 FloatRect(LayoutRect::infiniteIntRect()))); // This is a new chunk. | |
| 635 | |
| 636 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 637 } | |
| 638 | |
| 475 second.setDisplayItemsUncached(); | 639 second.setDisplayItemsUncached(); |
| 476 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); | 640 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 477 { | 641 { |
| 642 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 643 PaintChunk::Id id(second, clipType); | |
| 644 PaintChunkProperties properties; | |
| 645 properties.clip = ClipPaintPropertyNode::create(nullptr, nullptr, Fl oatRoundedRect(1, 1, 2, 2)); | |
| 646 getPaintController().updateCurrentPaintChunkProperties(&id, properti es); | |
| 647 } | |
| 478 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2) ); | 648 ClipRecorder clipRecorder(context, second, clipType, IntRect(1, 1, 2, 2) ); |
| 479 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150 , 150)); | 649 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200 , 200)); |
| 480 } | 650 } |
| 481 getPaintController().commitNewDisplayItems(); | 651 getPaintController().commitNewDisplayItems(); |
| 482 | 652 |
| 483 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, | 653 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 484 TestDisplayItem(first, backgroundDrawingType), | 654 TestDisplayItem(first, backgroundDrawingType), |
| 485 TestDisplayItem(second, clipType), | 655 TestDisplayItem(second, clipType), |
| 486 TestDisplayItem(second, backgroundDrawingType), | 656 TestDisplayItem(second, backgroundDrawingType), |
| 487 TestDisplayItem(second, DisplayItem::clipTypeToEndClipType(clipType))); | 657 TestDisplayItem(second, DisplayItem::clipTypeToEndClipType(clipType))); |
| 658 | |
| 659 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 660 EXPECT_EQ(2u, getPaintController().paintChunks().size()); | |
| 661 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 662 FloatRect(100, 100, 200, 200))); // |second| disappeared from the fi rst chunk. | |
| 663 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre( | |
| 664 FloatRect(LayoutRect::infiniteIntRect()))); // This is a new chunk. | |
| 665 } | |
| 488 } | 666 } |
| 489 | 667 |
| 490 TEST_F_OR_P(PaintControllerTest, CachedDisplayItems) | 668 TEST_P(PaintControllerTest, CachedDisplayItems) |
| 491 { | 669 { |
| 492 FakeDisplayItemClient first("first"); | 670 FakeDisplayItemClient first("first"); |
| 493 FakeDisplayItemClient second("second"); | 671 FakeDisplayItemClient second("second"); |
| 494 GraphicsContext context(getPaintController()); | 672 GraphicsContext context(getPaintController()); |
| 495 | 673 |
| 496 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); | 674 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); |
| 497 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); | 675 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); |
| 498 getPaintController().commitNewDisplayItems(); | 676 getPaintController().commitNewDisplayItems(); |
| 499 | 677 |
| 500 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 678 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 522 if (!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled() ) | 700 if (!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled() ) |
| 523 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint Controller().getDisplayItemList()[1]).picture()); | 701 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint Controller().getDisplayItemList()[1]).picture()); |
| 524 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); | 702 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); |
| 525 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); | 703 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); |
| 526 | 704 |
| 527 getPaintController().invalidateAll(); | 705 getPaintController().invalidateAll(); |
| 528 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); | 706 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); |
| 529 EXPECT_FALSE(getPaintController().clientCacheIsValid(second)); | 707 EXPECT_FALSE(getPaintController().clientCacheIsValid(second)); |
| 530 } | 708 } |
| 531 | 709 |
| 532 TEST_F_OR_P(PaintControllerTest, ComplexUpdateSwapOrder) | 710 TEST_P(PaintControllerTest, ComplexUpdateSwapOrder) |
| 533 { | 711 { |
| 534 FakeDisplayItemClient container1("container1"); | 712 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 )); |
| 535 FakeDisplayItemClient content1("content1"); | 713 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); |
| 536 FakeDisplayItemClient container2("container2"); | 714 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 )); |
| 537 FakeDisplayItemClient content2("content2"); | 715 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 538 GraphicsContext context(getPaintController()); | 716 GraphicsContext context(getPaintController()); |
| 717 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 718 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 539 | 719 |
| 540 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); | 720 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); |
| 541 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); | 721 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); |
| 542 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); | 722 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); |
| 543 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100)); | 723 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100)); |
| 544 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100)); | 724 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100)); |
| 545 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00)); | 725 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00)); |
| 546 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00)); | 726 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00)); |
| 547 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100)); | 727 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100)); |
| 548 getPaintController().commitNewDisplayItems(); | 728 getPaintController().commitNewDisplayItems(); |
| 549 | 729 |
| 550 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, | 730 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, |
| 551 TestDisplayItem(container1, backgroundDrawingType), | 731 TestDisplayItem(container1, backgroundDrawingType), |
| 552 TestDisplayItem(content1, backgroundDrawingType), | 732 TestDisplayItem(content1, backgroundDrawingType), |
| 553 TestDisplayItem(content1, foregroundDrawingType), | 733 TestDisplayItem(content1, foregroundDrawingType), |
| 554 TestDisplayItem(container1, foregroundDrawingType), | 734 TestDisplayItem(container1, foregroundDrawingType), |
| 555 TestDisplayItem(container2, backgroundDrawingType), | 735 TestDisplayItem(container2, backgroundDrawingType), |
| 556 TestDisplayItem(content2, backgroundDrawingType), | 736 TestDisplayItem(content2, backgroundDrawingType), |
| 557 TestDisplayItem(content2, foregroundDrawingType), | 737 TestDisplayItem(content2, foregroundDrawingType), |
| 558 TestDisplayItem(container2, foregroundDrawingType)); | 738 TestDisplayItem(container2, foregroundDrawingType)); |
| 559 | 739 |
| 740 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 741 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 742 | |
| 560 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. | 743 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. |
| 561 container1.setDisplayItemsUncached(); | 744 container1.setDisplayItemsUncached(); |
| 562 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100)); | 745 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100)); |
| 563 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00)); | 746 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00)); |
| 564 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00)); | 747 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00)); |
| 565 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100)); | 748 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100)); |
| 566 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); | 749 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); |
| 567 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); | 750 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); |
| 568 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); | 751 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); |
| 569 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100)); | 752 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100)); |
| 570 getPaintController().commitNewDisplayItems(); | 753 getPaintController().commitNewDisplayItems(); |
| 571 | 754 |
| 572 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, | 755 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, |
| 573 TestDisplayItem(container2, backgroundDrawingType), | 756 TestDisplayItem(container2, backgroundDrawingType), |
| 574 TestDisplayItem(content2, backgroundDrawingType), | 757 TestDisplayItem(content2, backgroundDrawingType), |
| 575 TestDisplayItem(content2, foregroundDrawingType), | 758 TestDisplayItem(content2, foregroundDrawingType), |
| 576 TestDisplayItem(container2, foregroundDrawingType), | 759 TestDisplayItem(container2, foregroundDrawingType), |
| 577 TestDisplayItem(container1, backgroundDrawingType), | 760 TestDisplayItem(container1, backgroundDrawingType), |
| 578 TestDisplayItem(content1, backgroundDrawingType), | 761 TestDisplayItem(content1, backgroundDrawingType), |
| 579 TestDisplayItem(content1, foregroundDrawingType), | 762 TestDisplayItem(content1, foregroundDrawingType), |
| 580 TestDisplayItem(container1, foregroundDrawingType)); | 763 TestDisplayItem(container1, foregroundDrawingType)); |
| 764 | |
| 765 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 766 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 767 // TODO(wangxianzhu): In real world we invalidate clients with reordered display items. | |
| 768 // Need to support raster invalidation for recordered display items with out invalidating clients. | |
| 769 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 770 FloatRect(100, 100, 100, 100), // Old bounds of |container1|. | |
| 771 FloatRect(100, 100, 100, 100))); // New bounds of |container1|. | |
| 772 } | |
| 581 } | 773 } |
| 582 | 774 |
| 583 TEST_F_OR_P(PaintControllerTest, CachedSubsequenceSwapOrder) | 775 TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) |
| 584 { | 776 { |
| 585 FakeDisplayItemClient container1("container1"); | 777 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 )); |
| 586 FakeDisplayItemClient content1("content1"); | 778 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); |
| 587 FakeDisplayItemClient container2("container2"); | 779 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 )); |
| 588 FakeDisplayItemClient content2("content2"); | 780 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 589 GraphicsContext context(getPaintController()); | 781 GraphicsContext context(getPaintController()); |
| 590 | 782 |
| 783 PaintChunkProperties container1Properties; | |
| 784 PaintChunkProperties container2Properties; | |
| 785 | |
| 591 { | 786 { |
| 787 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 788 PaintChunk::Id id(container1, backgroundDrawingType); | |
| 789 container1Properties.effect = EffectPaintPropertyNode::create(nullpt r, 0.5); | |
| 790 getPaintController().updateCurrentPaintChunkProperties(&id, containe r1Properties); | |
| 791 } | |
| 592 SubsequenceRecorder r(context, container1); | 792 SubsequenceRecorder r(context, container1); |
| 593 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); | 793 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); |
| 594 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5 0, 200)); | 794 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5 0, 200)); |
| 595 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 5 0, 200)); | 795 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 5 0, 200)); |
| 596 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); | 796 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); |
| 597 } | 797 } |
| 598 { | 798 { |
| 799 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 800 PaintChunk::Id id(container2, backgroundDrawingType); | |
| 801 container2Properties.effect = EffectPaintPropertyNode::create(nullpt r, 0.5); | |
| 802 getPaintController().updateCurrentPaintChunkProperties(&id, containe r2Properties); | |
| 803 } | |
| 599 SubsequenceRecorder r(context, container2); | 804 SubsequenceRecorder r(context, container2); |
| 600 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); | 805 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); |
| 601 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5 0, 200)); | 806 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5 0, 200)); |
| 602 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); | 807 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); |
| 603 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100)); | 808 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100)); |
| 604 } | 809 } |
| 605 getPaintController().commitNewDisplayItems(); | 810 getPaintController().commitNewDisplayItems(); |
| 606 | 811 |
| 607 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 12, | 812 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 12, |
| 608 TestDisplayItem(container1, DisplayItem::Subsequence), | 813 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 609 TestDisplayItem(container1, backgroundDrawingType), | 814 TestDisplayItem(container1, backgroundDrawingType), |
| 610 TestDisplayItem(content1, backgroundDrawingType), | 815 TestDisplayItem(content1, backgroundDrawingType), |
| 611 TestDisplayItem(content1, foregroundDrawingType), | 816 TestDisplayItem(content1, foregroundDrawingType), |
| 612 TestDisplayItem(container1, foregroundDrawingType), | 817 TestDisplayItem(container1, foregroundDrawingType), |
| 613 TestDisplayItem(container1, DisplayItem::EndSubsequence), | 818 TestDisplayItem(container1, DisplayItem::EndSubsequence), |
| 614 | 819 |
| 615 TestDisplayItem(container2, DisplayItem::Subsequence), | 820 TestDisplayItem(container2, DisplayItem::Subsequence), |
| 616 TestDisplayItem(container2, backgroundDrawingType), | 821 TestDisplayItem(container2, backgroundDrawingType), |
| 617 TestDisplayItem(content2, backgroundDrawingType), | 822 TestDisplayItem(content2, backgroundDrawingType), |
| 618 TestDisplayItem(content2, foregroundDrawingType), | 823 TestDisplayItem(content2, foregroundDrawingType), |
| 619 TestDisplayItem(container2, foregroundDrawingType), | 824 TestDisplayItem(container2, foregroundDrawingType), |
| 620 TestDisplayItem(container2, DisplayItem::EndSubsequence)); | 825 TestDisplayItem(container2, DisplayItem::EndSubsequence)); |
| 621 | 826 |
| 827 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 828 EXPECT_EQ(2u, getPaintController().paintChunks().size()); | |
| 829 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id); | |
| 830 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[1].id); | |
| 831 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 832 FloatRect(LayoutRect::infiniteIntRect()))); | |
| 833 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre( | |
| 834 FloatRect(LayoutRect::infiniteIntRect()))); | |
| 835 } | |
| 836 | |
| 622 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. | 837 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. |
| 623 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { | 838 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) { |
| 624 // When under-invalidation-checking is enabled, useCachedSubsequenceIfPo ssible is forced off, | 839 // When under-invalidation-checking is enabled, useCachedSubsequenceIfPo ssible is forced off, |
| 625 // and the client is expected to create the same painting as in the prev ious paint. | 840 // and the client is expected to create the same painting as in the prev ious paint. |
| 626 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container2)); | 841 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container2)); |
| 627 { | 842 { |
| 843 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 844 PaintChunk::Id id(container2, backgroundDrawingType); | |
| 845 getPaintController().updateCurrentPaintChunkProperties(&id, cont ainer2Properties); | |
| 846 } | |
| 628 SubsequenceRecorder r(context, container2); | 847 SubsequenceRecorder r(context, container2); |
| 629 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); | 848 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); |
| 630 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20 0, 50, 200)); | 849 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20 0, 50, 200)); |
| 631 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 20 0, 50, 200)); | 850 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 20 0, 50, 200)); |
| 632 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100)); | 851 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100)); |
| 633 } | 852 } |
| 634 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1)); | 853 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1)); |
| 635 { | 854 { |
| 855 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 856 PaintChunk::Id id(container1, backgroundDrawingType); | |
| 857 getPaintController().updateCurrentPaintChunkProperties(&id, cont ainer1Properties); | |
| 858 } | |
| 636 SubsequenceRecorder r(context, container1); | 859 SubsequenceRecorder r(context, container1); |
| 637 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); | 860 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); |
| 638 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); | 861 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); |
| 639 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); | 862 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); |
| 640 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); | 863 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); |
| 641 } | 864 } |
| 642 } else { | 865 } else { |
| 643 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container2)); | 866 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container2)); |
| 644 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container1)); | 867 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, container1)); |
| 645 } | 868 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 664 TestDisplayItem(container1, DisplayItem::Subsequence), | 887 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 665 TestDisplayItem(container1, backgroundDrawingType), | 888 TestDisplayItem(container1, backgroundDrawingType), |
| 666 TestDisplayItem(content1, backgroundDrawingType), | 889 TestDisplayItem(content1, backgroundDrawingType), |
| 667 TestDisplayItem(content1, foregroundDrawingType), | 890 TestDisplayItem(content1, foregroundDrawingType), |
| 668 TestDisplayItem(container1, foregroundDrawingType), | 891 TestDisplayItem(container1, foregroundDrawingType), |
| 669 TestDisplayItem(container1, DisplayItem::EndSubsequence)); | 892 TestDisplayItem(container1, DisplayItem::EndSubsequence)); |
| 670 | 893 |
| 671 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 894 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 672 DisplayItemClient::endShouldKeepAliveAllClients(); | 895 DisplayItemClient::endShouldKeepAliveAllClients(); |
| 673 #endif | 896 #endif |
| 897 | |
| 898 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 899 EXPECT_EQ(2u, getPaintController().paintChunks().size()); | |
| 900 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id); | |
| 901 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[1].id); | |
| 902 // Swapping order of chunks should not invalidate anything. | |
| 903 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre()); | |
| 904 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre()); | |
| 905 } | |
| 674 } | 906 } |
| 675 | 907 |
| 676 TEST_F_OR_P(PaintControllerTest, OutOfOrderNoCrash) | 908 TEST_P(PaintControllerTest, OutOfOrderNoCrash) |
| 677 { | 909 { |
| 678 FakeDisplayItemClient client("client"); | 910 FakeDisplayItemClient client("client"); |
| 679 GraphicsContext context(getPaintController()); | 911 GraphicsContext context(getPaintController()); |
| 680 | 912 |
| 681 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; | 913 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; |
| 682 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 1); | 914 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 1); |
| 683 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 2); | 915 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 2); |
| 684 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 3); | 916 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 3); |
| 685 | 917 |
| 686 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); | 918 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); |
| 687 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); | 919 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); |
| 688 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); | 920 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); |
| 689 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); | 921 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); |
| 690 | 922 |
| 691 getPaintController().commitNewDisplayItems(); | 923 getPaintController().commitNewDisplayItems(); |
| 692 | 924 |
| 693 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); | 925 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); |
| 694 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); | 926 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); |
| 695 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); | 927 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); |
| 696 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); | 928 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); |
| 697 | 929 |
| 698 getPaintController().commitNewDisplayItems(); | 930 getPaintController().commitNewDisplayItems(); |
| 699 } | 931 } |
| 700 | 932 |
| 701 TEST_F_OR_P(PaintControllerTest, CachedNestedSubsequenceUpdate) | 933 TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) |
| 702 { | 934 { |
| 703 FakeDisplayItemClient container1("container1"); | 935 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 )); |
| 704 FakeDisplayItemClient content1("content1"); | 936 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); |
| 705 FakeDisplayItemClient container2("container2"); | 937 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 )); |
| 706 FakeDisplayItemClient content2("content2"); | 938 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 707 GraphicsContext context(getPaintController()); | 939 GraphicsContext context(getPaintController()); |
| 708 | 940 |
| 941 PaintChunkProperties container1BackgroundProperties; | |
| 942 PaintChunkProperties content1Properties; | |
| 943 PaintChunkProperties container1ForegroundProperties; | |
| 944 PaintChunkProperties container2BackgroundProperties; | |
| 945 PaintChunkProperties content2Properties; | |
| 946 | |
| 709 { | 947 { |
| 948 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 949 PaintChunk::Id id(container1, backgroundDrawingType); | |
| 950 container1BackgroundProperties.effect = EffectPaintPropertyNode::cre ate(nullptr, 0.5); | |
| 951 getPaintController().updateCurrentPaintChunkProperties(&id, containe r1BackgroundProperties); | |
| 952 } | |
| 710 SubsequenceRecorder r(context, container1); | 953 SubsequenceRecorder r(context, container1); |
| 711 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); | 954 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); |
| 712 { | 955 { |
| 956 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 957 PaintChunk::Id id(content1, backgroundDrawingType); | |
| 958 content1Properties.effect = EffectPaintPropertyNode::create(null ptr, 0.6); | |
| 959 getPaintController().updateCurrentPaintChunkProperties(&id, cont ent1Properties); | |
| 960 } | |
| 713 SubsequenceRecorder r(context, content1); | 961 SubsequenceRecorder r(context, content1); |
| 714 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); | 962 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); |
| 715 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); | 963 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); |
| 716 } | 964 } |
| 965 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 966 PaintChunk::Id id(container1, foregroundDrawingType); | |
| 967 container1ForegroundProperties.effect = EffectPaintPropertyNode::cre ate(nullptr, 0.5); | |
| 968 getPaintController().updateCurrentPaintChunkProperties(&id, containe r1ForegroundProperties); | |
| 969 } | |
| 717 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); | 970 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); |
| 718 } | 971 } |
| 719 { | 972 { |
| 973 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 974 PaintChunk::Id id(container2, backgroundDrawingType); | |
| 975 container2BackgroundProperties.effect = EffectPaintPropertyNode::cre ate(nullptr, 0.7); | |
| 976 getPaintController().updateCurrentPaintChunkProperties(&id, containe r2BackgroundProperties); | |
| 977 } | |
| 720 SubsequenceRecorder r(context, container2); | 978 SubsequenceRecorder r(context, container2); |
| 721 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); | 979 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); |
| 722 { | 980 { |
| 981 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 982 PaintChunk::Id id(content2, backgroundDrawingType); | |
| 983 content2Properties.effect = EffectPaintPropertyNode::create(null ptr, 0.8); | |
| 984 getPaintController().updateCurrentPaintChunkProperties(&id, cont ent2Properties); | |
| 985 } | |
| 723 SubsequenceRecorder r(context, content2); | 986 SubsequenceRecorder r(context, content2); |
| 724 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20 0, 50, 200)); | 987 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20 0, 50, 200)); |
| 725 } | 988 } |
| 726 } | 989 } |
| 727 getPaintController().commitNewDisplayItems(); | 990 getPaintController().commitNewDisplayItems(); |
| 728 | 991 |
| 729 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 14, | 992 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 14, |
| 730 TestDisplayItem(container1, DisplayItem::Subsequence), | 993 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 731 TestDisplayItem(container1, backgroundDrawingType), | 994 TestDisplayItem(container1, backgroundDrawingType), |
| 732 TestDisplayItem(content1, DisplayItem::Subsequence), | 995 TestDisplayItem(content1, DisplayItem::Subsequence), |
| 733 TestDisplayItem(content1, backgroundDrawingType), | 996 TestDisplayItem(content1, backgroundDrawingType), |
| 734 TestDisplayItem(content1, foregroundDrawingType), | 997 TestDisplayItem(content1, foregroundDrawingType), |
| 735 TestDisplayItem(content1, DisplayItem::EndSubsequence), | 998 TestDisplayItem(content1, DisplayItem::EndSubsequence), |
| 736 TestDisplayItem(container1, foregroundDrawingType), | 999 TestDisplayItem(container1, foregroundDrawingType), |
| 737 TestDisplayItem(container1, DisplayItem::EndSubsequence), | 1000 TestDisplayItem(container1, DisplayItem::EndSubsequence), |
| 738 | 1001 |
| 739 TestDisplayItem(container2, DisplayItem::Subsequence), | 1002 TestDisplayItem(container2, DisplayItem::Subsequence), |
| 740 TestDisplayItem(container2, backgroundDrawingType), | 1003 TestDisplayItem(container2, backgroundDrawingType), |
| 741 TestDisplayItem(content2, DisplayItem::Subsequence), | 1004 TestDisplayItem(content2, DisplayItem::Subsequence), |
| 742 TestDisplayItem(content2, backgroundDrawingType), | 1005 TestDisplayItem(content2, backgroundDrawingType), |
| 743 TestDisplayItem(content2, DisplayItem::EndSubsequence), | 1006 TestDisplayItem(content2, DisplayItem::EndSubsequence), |
| 744 TestDisplayItem(container2, DisplayItem::EndSubsequence)); | 1007 TestDisplayItem(container2, DisplayItem::EndSubsequence)); |
| 745 | 1008 |
| 1009 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 1010 EXPECT_EQ(5u, getPaintController().paintChunks().size()); | |
| 1011 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id); | |
| 1012 EXPECT_EQ(PaintChunk::Id(content1, backgroundDrawingType), getPaintContr oller().paintChunks()[1].id); | |
| 1013 EXPECT_EQ(PaintChunk::Id(container1, foregroundDrawingType), getPaintCon troller().paintChunks()[2].id); | |
| 1014 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[3].id); | |
| 1015 EXPECT_EQ(PaintChunk::Id(content2, backgroundDrawingType), getPaintContr oller().paintChunks()[4].id); | |
| 1016 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); | |
| 1017 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); | |
| 1018 EXPECT_THAT(getPaintController().paintChunks()[2].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); | |
| 1019 EXPECT_THAT(getPaintController().paintChunks()[3].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); | |
| 1020 EXPECT_THAT(getPaintController().paintChunks()[4].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); | |
| 1021 } | |
| 1022 | |
| 746 // Invalidate container1 but not content1. | 1023 // Invalidate container1 but not content1. |
| 747 container1.setDisplayItemsUncached(); | 1024 container1.setDisplayItemsUncached(); |
| 748 | 1025 |
| 749 // Container2 itself now becomes empty (but still has the 'content2' child), | 1026 // Container2 itself now becomes empty (but still has the 'content2' child), |
| 750 // and chooses not to output subsequence info. | 1027 // and chooses not to output subsequence info. |
| 751 | 1028 |
| 752 container2.setDisplayItemsUncached(); | 1029 container2.setDisplayItemsUncached(); |
| 753 content2.setDisplayItemsUncached(); | 1030 content2.setDisplayItemsUncached(); |
| 754 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co ntainer2)); | 1031 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co ntainer2)); |
| 755 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co ntent2)); | 1032 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co ntent2)); |
| 756 // Content2 now outputs foreground only. | 1033 // Content2 now outputs foreground only. |
| 757 { | 1034 { |
| 1035 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 1036 PaintChunk::Id id(content2, foregroundDrawingType); | |
| 1037 getPaintController().updateCurrentPaintChunkProperties(&id, content2 Properties); | |
| 1038 } | |
| 758 SubsequenceRecorder r(context, content2); | 1039 SubsequenceRecorder r(context, content2); |
| 759 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); | 1040 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); |
| 760 } | 1041 } |
| 761 // Repaint container1 with foreground only. | 1042 // Repaint container1 with foreground only. |
| 762 { | 1043 { |
| 763 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1)); | 1044 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1)); |
| 764 SubsequenceRecorder r(context, container1); | 1045 SubsequenceRecorder r(context, container1); |
| 765 // Use cached subsequence of content1. | 1046 // Use cached subsequence of content1. |
| 766 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnable d()) { | 1047 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnable d()) { |
| 767 // When under-invalidation-checking is enabled, useCachedSubsequence IfPossible is forced off, | 1048 // When under-invalidation-checking is enabled, useCachedSubsequence IfPossible is forced off, |
| 768 // and the client is expected to create the same painting as in the previous paint. | 1049 // and the client is expected to create the same painting as in the previous paint. |
| 769 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, content1)); | 1050 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(con text, content1)); |
| 1051 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 1052 PaintChunk::Id id(content1, backgroundDrawingType); | |
| 1053 getPaintController().updateCurrentPaintChunkProperties(&id, cont ent1Properties); | |
| 1054 } | |
| 770 SubsequenceRecorder r(context, content1); | 1055 SubsequenceRecorder r(context, content1); |
| 771 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); | 1056 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); |
| 772 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); | 1057 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); |
| 773 } else { | 1058 } else { |
| 774 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(cont ext, content1)); | 1059 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(cont ext, content1)); |
| 775 } | 1060 } |
| 1061 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 1062 PaintChunk::Id id(container1, foregroundDrawingType); | |
| 1063 getPaintController().updateCurrentPaintChunkProperties(&id, containe r1ForegroundProperties); | |
| 1064 } | |
| 776 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); | 1065 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); |
| 777 } | 1066 } |
| 778 | 1067 |
| 779 EXPECT_EQ(4, numCachedNewItems()); | 1068 EXPECT_EQ(4, numCachedNewItems()); |
| 780 #if DCHECK_IS_ON() | 1069 #if DCHECK_IS_ON() |
| 781 EXPECT_EQ(1, numSequentialMatches()); | 1070 EXPECT_EQ(1, numSequentialMatches()); |
| 782 EXPECT_EQ(0, numOutOfOrderMatches()); | 1071 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 783 EXPECT_EQ(2, numIndexedItems()); | 1072 EXPECT_EQ(2, numIndexedItems()); |
| 784 #endif | 1073 #endif |
| 785 | 1074 |
| 786 getPaintController().commitNewDisplayItems(); | 1075 getPaintController().commitNewDisplayItems(); |
| 787 | 1076 |
| 788 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 10, | 1077 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 10, |
| 789 TestDisplayItem(content2, DisplayItem::Subsequence), | 1078 TestDisplayItem(content2, DisplayItem::Subsequence), |
| 790 TestDisplayItem(content2, foregroundDrawingType), | 1079 TestDisplayItem(content2, foregroundDrawingType), |
| 791 TestDisplayItem(content2, DisplayItem::EndSubsequence), | 1080 TestDisplayItem(content2, DisplayItem::EndSubsequence), |
| 792 | 1081 |
| 793 TestDisplayItem(container1, DisplayItem::Subsequence), | 1082 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 794 TestDisplayItem(content1, DisplayItem::Subsequence), | 1083 TestDisplayItem(content1, DisplayItem::Subsequence), |
| 795 TestDisplayItem(content1, backgroundDrawingType), | 1084 TestDisplayItem(content1, backgroundDrawingType), |
| 796 TestDisplayItem(content1, foregroundDrawingType), | 1085 TestDisplayItem(content1, foregroundDrawingType), |
| 797 TestDisplayItem(content1, DisplayItem::EndSubsequence), | 1086 TestDisplayItem(content1, DisplayItem::EndSubsequence), |
| 798 TestDisplayItem(container1, foregroundDrawingType), | 1087 TestDisplayItem(container1, foregroundDrawingType), |
| 799 TestDisplayItem(container1, DisplayItem::EndSubsequence)); | 1088 TestDisplayItem(container1, DisplayItem::EndSubsequence)); |
| 800 | 1089 |
| 1090 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 1091 EXPECT_EQ(3u, getPaintController().paintChunks().size()); | |
| 1092 EXPECT_EQ(PaintChunk::Id(content2, foregroundDrawingType), getPaintContr oller().paintChunks()[0].id); | |
| 1093 EXPECT_EQ(PaintChunk::Id(content1, backgroundDrawingType), getPaintContr oller().paintChunks()[1].id); | |
| 1094 EXPECT_EQ(PaintChunk::Id(container1, foregroundDrawingType), getPaintCon troller().paintChunks()[2].id); | |
| 1095 // This is a new chunk. | |
| 1096 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 1097 FloatRect(LayoutRect::infiniteIntRect()))); | |
| 1098 // This chunk didn't change. | |
| 1099 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre()); | |
| 1100 // |container1| is invalidated. | |
| 1101 EXPECT_THAT(getPaintController().paintChunks()[2].rasterInvalidationRect s, UnorderedElementsAre( | |
| 1102 FloatRect(100, 100, 100, 100), | |
|
chrishtr
2016/08/26 18:10:51
Old and new bounds right? If so, comment.
Xianzhu
2016/08/26 18:39:24
Done.
| |
| 1103 FloatRect(100, 100, 100, 100))); | |
| 1104 } | |
| 1105 | |
| 801 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 1106 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 802 DisplayItemClient::endShouldKeepAliveAllClients(); | 1107 DisplayItemClient::endShouldKeepAliveAllClients(); |
| 803 #endif | 1108 #endif |
| 804 } | 1109 } |
| 805 | 1110 |
| 806 TEST_F_OR_P(PaintControllerTest, SkipCache) | 1111 TEST_P(PaintControllerTest, SkipCache) |
| 807 { | 1112 { |
| 808 FakeDisplayItemClient multicol("multicol"); | 1113 FakeDisplayItemClient multicol("multicol", LayoutRect(100, 100, 200, 200)); |
| 809 FakeDisplayItemClient content("content"); | 1114 FakeDisplayItemClient content("content", LayoutRect(100, 100, 100, 100)); |
| 810 GraphicsContext context(getPaintController()); | 1115 GraphicsContext context(getPaintController()); |
| 1116 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
| 1117 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 811 | 1118 |
| 812 FloatRect rect1(100, 100, 50, 50); | 1119 FloatRect rect1(100, 100, 50, 50); |
| 813 FloatRect rect2(150, 100, 50, 50); | 1120 FloatRect rect2(150, 100, 50, 50); |
| 814 FloatRect rect3(200, 100, 50, 50); | 1121 FloatRect rect3(200, 100, 50, 50); |
| 815 | 1122 |
| 816 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); | 1123 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); |
| 817 | 1124 |
| 818 getPaintController().beginSkippingCache(); | 1125 getPaintController().beginSkippingCache(); |
| 819 drawRect(context, content, foregroundDrawingType, rect1); | 1126 drawRect(context, content, foregroundDrawingType, rect1); |
| 820 drawRect(context, content, foregroundDrawingType, rect2); | 1127 drawRect(context, content, foregroundDrawingType, rect2); |
| 821 getPaintController().endSkippingCache(); | 1128 getPaintController().endSkippingCache(); |
| 822 | 1129 |
| 823 getPaintController().commitNewDisplayItems(); | 1130 getPaintController().commitNewDisplayItems(); |
| 824 | 1131 |
| 825 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1132 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 826 TestDisplayItem(multicol, backgroundDrawingType), | 1133 TestDisplayItem(multicol, backgroundDrawingType), |
| 827 TestDisplayItem(content, foregroundDrawingType), | 1134 TestDisplayItem(content, foregroundDrawingType), |
| 828 TestDisplayItem(content, foregroundDrawingType)); | 1135 TestDisplayItem(content, foregroundDrawingType)); |
| 829 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture(); | 1136 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture(); |
| 830 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture(); | 1137 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture(); |
| 831 EXPECT_NE(picture1, picture2); | 1138 EXPECT_NE(picture1, picture2); |
| 832 | 1139 |
| 1140 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 1141 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 1142 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); | |
| 1143 | |
| 1144 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 1145 } | |
| 1146 | |
| 833 // Draw again with nothing invalidated. | 1147 // Draw again with nothing invalidated. |
| 834 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol)); | 1148 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol)); |
| 835 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); | 1149 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); |
| 836 | 1150 |
| 837 getPaintController().beginSkippingCache(); | 1151 getPaintController().beginSkippingCache(); |
| 838 drawRect(context, content, foregroundDrawingType, rect1); | 1152 drawRect(context, content, foregroundDrawingType, rect1); |
| 839 drawRect(context, content, foregroundDrawingType, rect2); | 1153 drawRect(context, content, foregroundDrawingType, rect2); |
| 840 getPaintController().endSkippingCache(); | 1154 getPaintController().endSkippingCache(); |
| 841 | 1155 |
| 842 EXPECT_EQ(1, numCachedNewItems()); | 1156 EXPECT_EQ(1, numCachedNewItems()); |
| 843 #if DCHECK_IS_ON() | 1157 #if DCHECK_IS_ON() |
| 844 EXPECT_EQ(1, numSequentialMatches()); | 1158 EXPECT_EQ(1, numSequentialMatches()); |
| 845 EXPECT_EQ(0, numOutOfOrderMatches()); | 1159 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 846 EXPECT_EQ(0, numIndexedItems()); | 1160 EXPECT_EQ(0, numIndexedItems()); |
| 847 #endif | 1161 #endif |
| 848 | 1162 |
| 849 getPaintController().commitNewDisplayItems(); | 1163 getPaintController().commitNewDisplayItems(); |
| 850 | 1164 |
| 851 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1165 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 852 TestDisplayItem(multicol, backgroundDrawingType), | 1166 TestDisplayItem(multicol, backgroundDrawingType), |
| 853 TestDisplayItem(content, foregroundDrawingType), | 1167 TestDisplayItem(content, foregroundDrawingType), |
| 854 TestDisplayItem(content, foregroundDrawingType)); | 1168 TestDisplayItem(content, foregroundDrawingType)); |
| 855 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); | 1169 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); |
| 856 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); | 1170 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); |
| 857 | 1171 |
| 1172 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 1173 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 1174 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 1175 FloatRect(100, 100, 100, 100), | |
|
chrishtr
2016/08/26 18:10:51
ditto
Xianzhu
2016/08/26 18:39:24
Done.
| |
| 1176 FloatRect(100, 100, 100, 100))); | |
| 1177 | |
| 1178 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); | |
| 1179 } | |
| 1180 | |
| 858 // Now the multicol becomes 3 columns and repaints. | 1181 // Now the multicol becomes 3 columns and repaints. |
| 859 multicol.setDisplayItemsUncached(); | 1182 multicol.setDisplayItemsUncached(); |
| 860 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100)); | 1183 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100)); |
| 861 | 1184 |
| 862 getPaintController().beginSkippingCache(); | 1185 getPaintController().beginSkippingCache(); |
| 863 drawRect(context, content, foregroundDrawingType, rect1); | 1186 drawRect(context, content, foregroundDrawingType, rect1); |
| 864 drawRect(context, content, foregroundDrawingType, rect2); | 1187 drawRect(context, content, foregroundDrawingType, rect2); |
| 865 drawRect(context, content, foregroundDrawingType, rect3); | 1188 drawRect(context, content, foregroundDrawingType, rect3); |
| 866 getPaintController().endSkippingCache(); | 1189 getPaintController().endSkippingCache(); |
| 867 | 1190 |
| 868 // We should repaint everything on invalidation of the scope container. | 1191 // We should repaint everything on invalidation of the scope container. |
| 869 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, | 1192 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, |
| 870 TestDisplayItem(multicol, backgroundDrawingType), | 1193 TestDisplayItem(multicol, backgroundDrawingType), |
| 871 TestDisplayItem(content, foregroundDrawingType), | 1194 TestDisplayItem(content, foregroundDrawingType), |
| 872 TestDisplayItem(content, foregroundDrawingType), | 1195 TestDisplayItem(content, foregroundDrawingType), |
| 873 TestDisplayItem(content, foregroundDrawingType)); | 1196 TestDisplayItem(content, foregroundDrawingType)); |
| 874 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); | 1197 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); |
| 875 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture()); | 1198 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture()); |
| 876 | 1199 |
| 877 getPaintController().commitNewDisplayItems(); | 1200 getPaintController().commitNewDisplayItems(); |
| 1201 | |
| 1202 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 1203 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | |
| 1204 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( | |
| 1205 FloatRect(100, 100, 200, 200), | |
| 1206 FloatRect(100, 100, 200, 200), | |
| 1207 FloatRect(100, 100, 100, 100), | |
| 1208 FloatRect(100, 100, 100, 100))); | |
|
Xianzhu
2016/08/26 18:39:23
Done.
| |
| 1209 } | |
| 878 } | 1210 } |
| 879 | 1211 |
| 880 TEST_F_OR_P(PaintControllerTest, PartialSkipCache) | 1212 TEST_P(PaintControllerTest, PartialSkipCache) |
| 881 { | 1213 { |
| 882 FakeDisplayItemClient content("content"); | 1214 FakeDisplayItemClient content("content"); |
| 883 GraphicsContext context(getPaintController()); | 1215 GraphicsContext context(getPaintController()); |
| 884 | 1216 |
| 885 FloatRect rect1(100, 100, 50, 50); | 1217 FloatRect rect1(100, 100, 50, 50); |
| 886 FloatRect rect2(150, 100, 50, 50); | 1218 FloatRect rect2(150, 100, 50, 50); |
| 887 FloatRect rect3(200, 100, 50, 50); | 1219 FloatRect rect3(200, 100, 50, 50); |
| 888 | 1220 |
| 889 drawRect(context, content, backgroundDrawingType, rect1); | 1221 drawRect(context, content, backgroundDrawingType, rect1); |
| 890 getPaintController().beginSkippingCache(); | 1222 getPaintController().beginSkippingCache(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 | 1257 |
| 926 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1258 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 927 TestDisplayItem(content, backgroundDrawingType), | 1259 TestDisplayItem(content, backgroundDrawingType), |
| 928 TestDisplayItem(content, foregroundDrawingType), | 1260 TestDisplayItem(content, foregroundDrawingType), |
| 929 TestDisplayItem(content, foregroundDrawingType)); | 1261 TestDisplayItem(content, foregroundDrawingType)); |
| 930 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[0]).picture()); | 1262 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[0]).picture()); |
| 931 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); | 1263 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); |
| 932 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); | 1264 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); |
| 933 } | 1265 } |
| 934 | 1266 |
| 935 TEST_F_OR_P(PaintControllerTest, OptimizeNoopPairs) | 1267 TEST_F(PaintControllerTestBase, OptimizeNoopPairs) |
| 936 { | 1268 { |
| 937 FakeDisplayItemClient first("first"); | 1269 FakeDisplayItemClient first("first"); |
| 938 FakeDisplayItemClient second("second"); | 1270 FakeDisplayItemClient second("second"); |
| 939 FakeDisplayItemClient third("third"); | 1271 FakeDisplayItemClient third("third"); |
| 940 | 1272 |
| 941 GraphicsContext context(getPaintController()); | 1273 GraphicsContext context(getPaintController()); |
| 942 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 1274 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 943 { | 1275 { |
| 944 ClipPathRecorder clipRecorder(context, second, Path()); | 1276 ClipPathRecorder clipRecorder(context, second, Path()); |
| 945 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); | 1277 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 978 } | 1310 } |
| 979 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 1311 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 980 getPaintController().commitNewDisplayItems(); | 1312 getPaintController().commitNewDisplayItems(); |
| 981 | 1313 |
| 982 // Empty clips should have been optimized out. | 1314 // Empty clips should have been optimized out. |
| 983 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 1315 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 984 TestDisplayItem(first, backgroundDrawingType), | 1316 TestDisplayItem(first, backgroundDrawingType), |
| 985 TestDisplayItem(third, backgroundDrawingType)); | 1317 TestDisplayItem(third, backgroundDrawingType)); |
| 986 } | 1318 } |
| 987 | 1319 |
| 988 TEST_F_OR_P(PaintControllerTest, SmallPaintControllerHasOnePaintChunk) | 1320 TEST_F(PaintControllerTestBase, SmallPaintControllerHasOnePaintChunk) |
| 989 { | 1321 { |
| 990 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 1322 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 991 FakeDisplayItemClient client("test client"); | 1323 FakeDisplayItemClient client("test client"); |
| 992 | 1324 |
| 993 GraphicsContext context(getPaintController()); | 1325 GraphicsContext context(getPaintController()); |
| 994 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 1326 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 995 | 1327 |
| 996 getPaintController().commitNewDisplayItems(); | 1328 getPaintController().commitNewDisplayItems(); |
| 997 const auto& paintChunks = getPaintController().paintChunks(); | 1329 const auto& paintChunks = getPaintController().paintChunks(); |
| 998 ASSERT_EQ(1u, paintChunks.size()); | 1330 ASSERT_EQ(1u, paintChunks.size()); |
| 999 EXPECT_EQ(0u, paintChunks[0].beginIndex); | 1331 EXPECT_EQ(0u, paintChunks[0].beginIndex); |
| 1000 EXPECT_EQ(1u, paintChunks[0].endIndex); | 1332 EXPECT_EQ(1u, paintChunks[0].endIndex); |
| 1001 } | 1333 } |
| 1002 | 1334 |
| 1003 #define EXPECT_RECT_EQ(expected, actual) \ | 1335 TEST_F(PaintControllerTestBase, PaintArtifactWithVisualRects) |
| 1004 do { \ | |
| 1005 const IntRect& actualRect = actual; \ | |
| 1006 EXPECT_EQ(expected.x(), actualRect.x()); \ | |
| 1007 EXPECT_EQ(expected.y(), actualRect.y()); \ | |
| 1008 EXPECT_EQ(expected.width(), actualRect.width()); \ | |
| 1009 EXPECT_EQ(expected.height(), actualRect.height()); \ | |
| 1010 } while (false) | |
| 1011 | |
| 1012 TEST_F_OR_P(PaintControllerTest, PaintArtifactWithVisualRects) | |
| 1013 { | 1336 { |
| 1014 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1337 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1015 | 1338 |
| 1016 GraphicsContext context(getPaintController()); | 1339 GraphicsContext context(getPaintController()); |
| 1017 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 1340 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 1018 | 1341 |
| 1019 getPaintController().commitNewDisplayItems(LayoutSize(20, 30)); | 1342 getPaintController().commitNewDisplayItems(LayoutSize(20, 30)); |
| 1020 const auto& paintArtifact = getPaintController().paintArtifact(); | 1343 const auto& paintArtifact = getPaintController().paintArtifact(); |
| 1021 ASSERT_EQ(1u, paintArtifact.getDisplayItemList().size()); | 1344 ASSERT_EQ(1u, paintArtifact.getDisplayItemList().size()); |
| 1022 EXPECT_RECT_EQ(IntRect(-20, -30, 200, 100), visualRect(paintArtifact, 0)); | 1345 EXPECT_EQ(IntRect(-20, -30, 200, 100), visualRect(paintArtifact, 0)); |
| 1023 } | 1346 } |
| 1024 | 1347 |
| 1025 void drawPath(GraphicsContext& context, DisplayItemClient& client, DisplayItem:: Type type, unsigned count) | 1348 void drawPath(GraphicsContext& context, DisplayItemClient& client, DisplayItem:: Type type, unsigned count) |
| 1026 { | 1349 { |
| 1027 if (DrawingRecorder::useCachedDrawingIfPossible(context, client, type)) | 1350 if (DrawingRecorder::useCachedDrawingIfPossible(context, client, type)) |
| 1028 return; | 1351 return; |
| 1029 | 1352 |
| 1030 DrawingRecorder drawingRecorder(context, client, type, FloatRect(0, 0, 100, 100)); | 1353 DrawingRecorder drawingRecorder(context, client, type, FloatRect(0, 0, 100, 100)); |
| 1031 SkPath path; | 1354 SkPath path; |
| 1032 path.moveTo(0, 0); | 1355 path.moveTo(0, 0); |
| 1033 path.lineTo(0, 100); | 1356 path.lineTo(0, 100); |
| 1034 path.lineTo(50, 50); | 1357 path.lineTo(50, 50); |
| 1035 path.lineTo(100, 100); | 1358 path.lineTo(100, 100); |
| 1036 path.lineTo(100, 0); | 1359 path.lineTo(100, 0); |
| 1037 path.close(); | 1360 path.close(); |
| 1038 SkPaint paint; | 1361 SkPaint paint; |
| 1039 paint.setAntiAlias(true); | 1362 paint.setAntiAlias(true); |
| 1040 for (unsigned i = 0; i < count; i++) | 1363 for (unsigned i = 0; i < count; i++) |
| 1041 context.drawPath(path, paint); | 1364 context.drawPath(path, paint); |
| 1042 } | 1365 } |
| 1043 | 1366 |
| 1044 TEST_F_OR_P(PaintControllerTest, IsSuitableForGpuRasterizationSinglePath) | 1367 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) |
| 1045 { | 1368 { |
| 1046 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1369 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1047 GraphicsContext context(getPaintController()); | 1370 GraphicsContext context(getPaintController()); |
| 1048 drawPath(context, client, backgroundDrawingType, 1); | 1371 drawPath(context, client, backgroundDrawingType, 1); |
| 1049 getPaintController().commitNewDisplayItems(LayoutSize()); | 1372 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 1050 EXPECT_TRUE(getPaintController().paintArtifact().isSuitableForGpuRasterizati on()); | 1373 EXPECT_TRUE(getPaintController().paintArtifact().isSuitableForGpuRasterizati on()); |
| 1051 } | 1374 } |
| 1052 | 1375 |
| 1053 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPaths) | 1376 TEST_F(PaintControllerTestBase, IsNotSuitableForGpuRasterizationSinglePictureMan yPaths) |
| 1054 { | 1377 { |
| 1055 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1378 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1056 GraphicsContext context(getPaintController()); | 1379 GraphicsContext context(getPaintController()); |
| 1057 | 1380 |
| 1058 drawPath(context, client, backgroundDrawingType, 50); | 1381 drawPath(context, client, backgroundDrawingType, 50); |
| 1059 getPaintController().commitNewDisplayItems(LayoutSize()); | 1382 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 1060 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); | 1383 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); |
| 1061 } | 1384 } |
| 1062 | 1385 |
| 1063 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationMultiplePicture sSinglePathEach) | 1386 TEST_F(PaintControllerTestBase, IsNotSuitableForGpuRasterizationMultiplePictures SinglePathEach) |
| 1064 { | 1387 { |
| 1065 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1388 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1066 GraphicsContext context(getPaintController()); | 1389 GraphicsContext context(getPaintController()); |
| 1067 getPaintController().beginSkippingCache(); | 1390 getPaintController().beginSkippingCache(); |
| 1068 | 1391 |
| 1069 for (int i = 0; i < 50; ++i) | 1392 for (int i = 0; i < 50; ++i) |
| 1070 drawPath(context, client, backgroundDrawingType, 50); | 1393 drawPath(context, client, backgroundDrawingType, 50); |
| 1071 | 1394 |
| 1072 getPaintController().endSkippingCache(); | 1395 getPaintController().endSkippingCache(); |
| 1073 getPaintController().commitNewDisplayItems(LayoutSize()); | 1396 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 1074 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); | 1397 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); |
| 1075 } | 1398 } |
| 1076 | 1399 |
| 1077 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPathsTwoPaints) | 1400 TEST_F(PaintControllerTestBase, IsNotSuitableForGpuRasterizationSinglePictureMan yPathsTwoPaints) |
| 1078 { | 1401 { |
| 1079 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1402 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1080 | 1403 |
| 1081 { | 1404 { |
| 1082 GraphicsContext context(getPaintController()); | 1405 GraphicsContext context(getPaintController()); |
| 1083 drawPath(context, client, backgroundDrawingType, 50); | 1406 drawPath(context, client, backgroundDrawingType, 50); |
| 1084 getPaintController().commitNewDisplayItems(LayoutSize()); | 1407 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 1085 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); | 1408 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); |
| 1086 } | 1409 } |
| 1087 | 1410 |
| 1088 client.setDisplayItemsUncached(); | 1411 client.setDisplayItemsUncached(); |
| 1089 | 1412 |
| 1090 { | 1413 { |
| 1091 GraphicsContext context(getPaintController()); | 1414 GraphicsContext context(getPaintController()); |
| 1092 drawPath(context, client, backgroundDrawingType, 50); | 1415 drawPath(context, client, backgroundDrawingType, 50); |
| 1093 getPaintController().commitNewDisplayItems(LayoutSize()); | 1416 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 1094 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); | 1417 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); |
| 1095 } | 1418 } |
| 1096 } | 1419 } |
| 1097 | 1420 |
| 1098 TEST_F_OR_P(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureMa nyPathsCached) | 1421 TEST_F(PaintControllerTestBase, IsNotSuitableForGpuRasterizationSinglePictureMan yPathsCached) |
| 1099 { | 1422 { |
| 1100 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1423 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1101 | 1424 |
| 1102 { | 1425 { |
| 1103 GraphicsContext context(getPaintController()); | 1426 GraphicsContext context(getPaintController()); |
| 1104 drawPath(context, client, backgroundDrawingType, 50); | 1427 drawPath(context, client, backgroundDrawingType, 50); |
| 1105 getPaintController().commitNewDisplayItems(LayoutSize()); | 1428 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 1106 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); | 1429 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); |
| 1107 } | 1430 } |
| 1108 | 1431 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1130 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer)); | 1453 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer)); |
| 1131 getPaintController().commitNewDisplayItems(LayoutSize()); | 1454 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 1132 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); | 1455 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); |
| 1133 | 1456 |
| 1134 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 1457 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 1135 DisplayItemClient::endShouldKeepAliveAllClients(); | 1458 DisplayItemClient::endShouldKeepAliveAllClients(); |
| 1136 #endif | 1459 #endif |
| 1137 } | 1460 } |
| 1138 | 1461 |
| 1139 // Temporarily disabled (pref regressions due to GPU veto stickiness: http://crb ug.com/603969). | 1462 // Temporarily disabled (pref regressions due to GPU veto stickiness: http://crb ug.com/603969). |
| 1140 TEST_F_OR_P(PaintControllerTest, DISABLED_IsNotSuitableForGpuRasterizationConcav eClipPath) | 1463 TEST_F(PaintControllerTestBase, DISABLED_IsNotSuitableForGpuRasterizationConcave ClipPath) |
| 1141 { | 1464 { |
| 1142 Path path; | 1465 Path path; |
| 1143 path.addLineTo(FloatPoint(50, 50)); | 1466 path.addLineTo(FloatPoint(50, 50)); |
| 1144 path.addLineTo(FloatPoint(100, 0)); | 1467 path.addLineTo(FloatPoint(100, 0)); |
| 1145 path.addLineTo(FloatPoint(50, 100)); | 1468 path.addLineTo(FloatPoint(50, 100)); |
| 1146 path.closeSubpath(); | 1469 path.closeSubpath(); |
| 1147 | 1470 |
| 1148 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 1471 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 1149 GraphicsContext context(getPaintController()); | 1472 GraphicsContext context(getPaintController()); |
| 1150 | 1473 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1434 } | 1757 } |
| 1435 | 1758 |
| 1436 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence ) | 1759 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence ) |
| 1437 { | 1760 { |
| 1438 testFoldCompositingDrawingInSubsequence(); | 1761 testFoldCompositingDrawingInSubsequence(); |
| 1439 } | 1762 } |
| 1440 | 1763 |
| 1441 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 1764 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
| 1442 | 1765 |
| 1443 } // namespace blink | 1766 } // namespace blink |
| OLD | NEW |