| 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/CachedDisplayItem.h" | 9 #include "platform/graphics/paint/CachedDisplayItem.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/DrawingDisplayItem.h" | 12 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 13 #include "platform/graphics/paint/DrawingRecorder.h" | 13 #include "platform/graphics/paint/DrawingRecorder.h" |
| 14 #include "platform/graphics/paint/SubsequenceRecorder.h" | 14 #include "platform/graphics/paint/SubsequenceRecorder.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class PaintControllerTest : public ::testing::Test { | 19 class PaintControllerTest : public ::testing::Test { |
| 20 public: | 20 public: |
| 21 PaintControllerTest() | 21 PaintControllerTest() |
| 22 : m_paintController(PaintController::create()) | 22 : m_paintController(PaintController::create()) |
| 23 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } | 23 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
| 24 | 24 |
| 25 IntRect visualRect(const PaintArtifact& paintArtifact, unsigned index) | 25 IntRect visualRect(const PaintArtifact& paintArtifact, unsigned index) |
| 26 { | 26 { |
| 27 return paintArtifact.displayItemList().visualRect(index); | 27 return paintArtifact.getDisplayItemList().visualRect(index); |
| 28 } | 28 } |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 PaintController& paintController() { return *m_paintController; } | 31 PaintController& getPaintController() { return *m_paintController; } |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 void TearDown() override | 34 void TearDown() override |
| 35 { | 35 { |
| 36 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); | 36 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
| 37 } | 37 } |
| 38 | 38 |
| 39 OwnPtr<PaintController> m_paintController; | 39 OwnPtr<PaintController> m_paintController; |
| 40 bool m_originalSlimmingPaintV2Enabled; | 40 bool m_originalSlimmingPaintV2Enabled; |
| 41 }; | 41 }; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 void drawClippedRect(GraphicsContext& context, const TestDisplayItemClient& clie
nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect&
bound) | 99 void drawClippedRect(GraphicsContext& context, const TestDisplayItemClient& clie
nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect&
bound) |
| 100 { | 100 { |
| 101 ClipRecorder clipRecorder(context, client, clipType, LayoutRect(1, 1, 9, 9))
; | 101 ClipRecorder clipRecorder(context, client, clipType, LayoutRect(1, 1, 9, 9))
; |
| 102 drawRect(context, client, drawingType, bound); | 102 drawRect(context, client, drawingType, bound); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_F(PaintControllerTest, NestedRecorders) | 105 TEST_F(PaintControllerTest, NestedRecorders) |
| 106 { | 106 { |
| 107 GraphicsContext context(paintController()); | 107 GraphicsContext context(getPaintController()); |
| 108 | 108 |
| 109 TestDisplayItemClient client("client"); | 109 TestDisplayItemClient client("client"); |
| 110 | 110 |
| 111 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect(
100, 100, 200, 200)); | 111 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect(
100, 100, 200, 200)); |
| 112 paintController().commitNewDisplayItems(); | 112 getPaintController().commitNewDisplayItems(); |
| 113 | 113 |
| 114 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 3, | 114 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 115 TestDisplayItem(client, clipType), | 115 TestDisplayItem(client, clipType), |
| 116 TestDisplayItem(client, backgroundDrawingType), | 116 TestDisplayItem(client, backgroundDrawingType), |
| 117 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType))); | 117 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType))); |
| 118 } | 118 } |
| 119 | 119 |
| 120 TEST_F(PaintControllerTest, UpdateBasic) | 120 TEST_F(PaintControllerTest, UpdateBasic) |
| 121 { | 121 { |
| 122 TestDisplayItemClient first("first"); | 122 TestDisplayItemClient first("first"); |
| 123 TestDisplayItemClient second("second"); | 123 TestDisplayItemClient second("second"); |
| 124 GraphicsContext context(paintController()); | 124 GraphicsContext context(getPaintController()); |
| 125 | 125 |
| 126 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300
)); | 126 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300
)); |
| 127 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20
0)); | 127 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20
0)); |
| 128 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300
)); | 128 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300
)); |
| 129 paintController().commitNewDisplayItems(); | 129 getPaintController().commitNewDisplayItems(); |
| 130 | 130 |
| 131 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 3, | 131 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 132 TestDisplayItem(first, backgroundDrawingType), | 132 TestDisplayItem(first, backgroundDrawingType), |
| 133 TestDisplayItem(second, backgroundDrawingType), | 133 TestDisplayItem(second, backgroundDrawingType), |
| 134 TestDisplayItem(first, foregroundDrawingType)); | 134 TestDisplayItem(first, foregroundDrawingType)); |
| 135 | 135 |
| 136 paintController().invalidate(second); | 136 getPaintController().invalidate(second); |
| 137 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300
)); | 137 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300
)); |
| 138 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300
)); | 138 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300
)); |
| 139 paintController().commitNewDisplayItems(); | 139 getPaintController().commitNewDisplayItems(); |
| 140 | 140 |
| 141 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 141 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 142 TestDisplayItem(first, backgroundDrawingType), | 142 TestDisplayItem(first, backgroundDrawingType), |
| 143 TestDisplayItem(first, foregroundDrawingType)); | 143 TestDisplayItem(first, foregroundDrawingType)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 TEST_F(PaintControllerTest, UpdateSwapOrder) | 146 TEST_F(PaintControllerTest, UpdateSwapOrder) |
| 147 { | 147 { |
| 148 TestDisplayItemClient first("first"); | 148 TestDisplayItemClient first("first"); |
| 149 TestDisplayItemClient second("second"); | 149 TestDisplayItemClient second("second"); |
| 150 TestDisplayItemClient unaffected("unaffected"); | 150 TestDisplayItemClient unaffected("unaffected"); |
| 151 GraphicsContext context(paintController()); | 151 GraphicsContext context(getPaintController()); |
| 152 | 152 |
| 153 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 153 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 154 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 154 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 155 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); | 155 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 156 paintController().commitNewDisplayItems(); | 156 getPaintController().commitNewDisplayItems(); |
| 157 | 157 |
| 158 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 3, | 158 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 159 TestDisplayItem(first, backgroundDrawingType), | 159 TestDisplayItem(first, backgroundDrawingType), |
| 160 TestDisplayItem(second, backgroundDrawingType), | 160 TestDisplayItem(second, backgroundDrawingType), |
| 161 TestDisplayItem(unaffected, backgroundDrawingType)); | 161 TestDisplayItem(unaffected, backgroundDrawingType)); |
| 162 | 162 |
| 163 paintController().invalidate(second); | 163 getPaintController().invalidate(second); |
| 164 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 164 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 165 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 165 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 166 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); | 166 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10,
10)); |
| 167 paintController().commitNewDisplayItems(); | 167 getPaintController().commitNewDisplayItems(); |
| 168 | 168 |
| 169 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 3, | 169 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 170 TestDisplayItem(second, backgroundDrawingType), | 170 TestDisplayItem(second, backgroundDrawingType), |
| 171 TestDisplayItem(first, backgroundDrawingType), | 171 TestDisplayItem(first, backgroundDrawingType), |
| 172 TestDisplayItem(unaffected, backgroundDrawingType)); | 172 TestDisplayItem(unaffected, backgroundDrawingType)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 TEST_F(PaintControllerTest, UpdateNewItemInMiddle) | 175 TEST_F(PaintControllerTest, UpdateNewItemInMiddle) |
| 176 { | 176 { |
| 177 TestDisplayItemClient first("first"); | 177 TestDisplayItemClient first("first"); |
| 178 TestDisplayItemClient second("second"); | 178 TestDisplayItemClient second("second"); |
| 179 TestDisplayItemClient third("third"); | 179 TestDisplayItemClient third("third"); |
| 180 GraphicsContext context(paintController()); | 180 GraphicsContext context(getPaintController()); |
| 181 | 181 |
| 182 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 182 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 183 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 183 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 184 paintController().commitNewDisplayItems(); | 184 getPaintController().commitNewDisplayItems(); |
| 185 | 185 |
| 186 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 186 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 187 TestDisplayItem(first, backgroundDrawingType), | 187 TestDisplayItem(first, backgroundDrawingType), |
| 188 TestDisplayItem(second, backgroundDrawingType)); | 188 TestDisplayItem(second, backgroundDrawingType)); |
| 189 | 189 |
| 190 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 190 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 191 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50)
); | 191 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50)
); |
| 192 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 192 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 193 paintController().commitNewDisplayItems(); | 193 getPaintController().commitNewDisplayItems(); |
| 194 | 194 |
| 195 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 3, | 195 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 196 TestDisplayItem(first, backgroundDrawingType), | 196 TestDisplayItem(first, backgroundDrawingType), |
| 197 TestDisplayItem(third, backgroundDrawingType), | 197 TestDisplayItem(third, backgroundDrawingType), |
| 198 TestDisplayItem(second, backgroundDrawingType)); | 198 TestDisplayItem(second, backgroundDrawingType)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 TEST_F(PaintControllerTest, UpdateInvalidationWithPhases) | 201 TEST_F(PaintControllerTest, UpdateInvalidationWithPhases) |
| 202 { | 202 { |
| 203 TestDisplayItemClient first("first"); | 203 TestDisplayItemClient first("first"); |
| 204 TestDisplayItemClient second("second"); | 204 TestDisplayItemClient second("second"); |
| 205 TestDisplayItemClient third("third"); | 205 TestDisplayItemClient third("third"); |
| 206 GraphicsContext context(paintController()); | 206 GraphicsContext context(getPaintController()); |
| 207 | 207 |
| 208 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 208 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 209 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 209 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 210 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50))
; | 210 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50))
; |
| 211 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); | 211 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 212 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); | 212 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 213 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50))
; | 213 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50))
; |
| 214 paintController().commitNewDisplayItems(); | 214 getPaintController().commitNewDisplayItems(); |
| 215 | 215 |
| 216 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 6, | 216 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 217 TestDisplayItem(first, backgroundDrawingType), | 217 TestDisplayItem(first, backgroundDrawingType), |
| 218 TestDisplayItem(second, backgroundDrawingType), | 218 TestDisplayItem(second, backgroundDrawingType), |
| 219 TestDisplayItem(third, backgroundDrawingType), | 219 TestDisplayItem(third, backgroundDrawingType), |
| 220 TestDisplayItem(first, foregroundDrawingType), | 220 TestDisplayItem(first, foregroundDrawingType), |
| 221 TestDisplayItem(second, foregroundDrawingType), | 221 TestDisplayItem(second, foregroundDrawingType), |
| 222 TestDisplayItem(third, foregroundDrawingType)); | 222 TestDisplayItem(third, foregroundDrawingType)); |
| 223 | 223 |
| 224 paintController().invalidate(second); | 224 getPaintController().invalidate(second); |
| 225 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); | 225 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 226 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); | 226 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 227 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50))
; | 227 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50))
; |
| 228 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); | 228 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100
)); |
| 229 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); | 229 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200
)); |
| 230 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50))
; | 230 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50))
; |
| 231 paintController().commitNewDisplayItems(); | 231 getPaintController().commitNewDisplayItems(); |
| 232 | 232 |
| 233 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 6, | 233 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 234 TestDisplayItem(first, backgroundDrawingType), | 234 TestDisplayItem(first, backgroundDrawingType), |
| 235 TestDisplayItem(second, backgroundDrawingType), | 235 TestDisplayItem(second, backgroundDrawingType), |
| 236 TestDisplayItem(third, backgroundDrawingType), | 236 TestDisplayItem(third, backgroundDrawingType), |
| 237 TestDisplayItem(first, foregroundDrawingType), | 237 TestDisplayItem(first, foregroundDrawingType), |
| 238 TestDisplayItem(second, foregroundDrawingType), | 238 TestDisplayItem(second, foregroundDrawingType), |
| 239 TestDisplayItem(third, foregroundDrawingType)); | 239 TestDisplayItem(third, foregroundDrawingType)); |
| 240 } | 240 } |
| 241 | 241 |
| 242 TEST_F(PaintControllerTest, UpdateAddFirstOverlap) | 242 TEST_F(PaintControllerTest, UpdateAddFirstOverlap) |
| 243 { | 243 { |
| 244 TestDisplayItemClient first("first"); | 244 TestDisplayItemClient first("first"); |
| 245 TestDisplayItemClient second("second"); | 245 TestDisplayItemClient second("second"); |
| 246 GraphicsContext context(paintController()); | 246 GraphicsContext context(getPaintController()); |
| 247 | 247 |
| 248 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); | 248 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 249 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); | 249 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 250 paintController().commitNewDisplayItems(); | 250 getPaintController().commitNewDisplayItems(); |
| 251 | 251 |
| 252 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 252 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 253 TestDisplayItem(second, backgroundDrawingType), | 253 TestDisplayItem(second, backgroundDrawingType), |
| 254 TestDisplayItem(second, foregroundDrawingType)); | 254 TestDisplayItem(second, foregroundDrawingType)); |
| 255 | 255 |
| 256 paintController().invalidate(first); | 256 getPaintController().invalidate(first); |
| 257 paintController().invalidate(second); | 257 getPaintController().invalidate(second); |
| 258 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 258 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 259 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); | 259 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 260 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); | 260 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 261 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); | 261 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 262 paintController().commitNewDisplayItems(); | 262 getPaintController().commitNewDisplayItems(); |
| 263 | 263 |
| 264 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 4, | 264 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 265 TestDisplayItem(first, backgroundDrawingType), | 265 TestDisplayItem(first, backgroundDrawingType), |
| 266 TestDisplayItem(first, foregroundDrawingType), | 266 TestDisplayItem(first, foregroundDrawingType), |
| 267 TestDisplayItem(second, backgroundDrawingType), | 267 TestDisplayItem(second, backgroundDrawingType), |
| 268 TestDisplayItem(second, foregroundDrawingType)); | 268 TestDisplayItem(second, foregroundDrawingType)); |
| 269 | 269 |
| 270 paintController().invalidate(first); | 270 getPaintController().invalidate(first); |
| 271 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); | 271 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 272 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); | 272 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 273 paintController().commitNewDisplayItems(); | 273 getPaintController().commitNewDisplayItems(); |
| 274 | 274 |
| 275 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 275 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 276 TestDisplayItem(second, backgroundDrawingType), | 276 TestDisplayItem(second, backgroundDrawingType), |
| 277 TestDisplayItem(second, foregroundDrawingType)); | 277 TestDisplayItem(second, foregroundDrawingType)); |
| 278 } | 278 } |
| 279 | 279 |
| 280 TEST_F(PaintControllerTest, UpdateAddLastOverlap) | 280 TEST_F(PaintControllerTest, UpdateAddLastOverlap) |
| 281 { | 281 { |
| 282 TestDisplayItemClient first("first"); | 282 TestDisplayItemClient first("first"); |
| 283 TestDisplayItemClient second("second"); | 283 TestDisplayItemClient second("second"); |
| 284 GraphicsContext context(paintController()); | 284 GraphicsContext context(getPaintController()); |
| 285 | 285 |
| 286 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 286 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 287 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); | 287 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 288 paintController().commitNewDisplayItems(); | 288 getPaintController().commitNewDisplayItems(); |
| 289 | 289 |
| 290 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 290 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 291 TestDisplayItem(first, backgroundDrawingType), | 291 TestDisplayItem(first, backgroundDrawingType), |
| 292 TestDisplayItem(first, foregroundDrawingType)); | 292 TestDisplayItem(first, foregroundDrawingType)); |
| 293 | 293 |
| 294 paintController().invalidate(first); | 294 getPaintController().invalidate(first); |
| 295 paintController().invalidate(second); | 295 getPaintController().invalidate(second); |
| 296 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 296 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 297 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); | 297 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 298 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); | 298 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 299 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); | 299 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50)
); |
| 300 paintController().commitNewDisplayItems(); | 300 getPaintController().commitNewDisplayItems(); |
| 301 | 301 |
| 302 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 4, | 302 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 303 TestDisplayItem(first, backgroundDrawingType), | 303 TestDisplayItem(first, backgroundDrawingType), |
| 304 TestDisplayItem(first, foregroundDrawingType), | 304 TestDisplayItem(first, foregroundDrawingType), |
| 305 TestDisplayItem(second, backgroundDrawingType), | 305 TestDisplayItem(second, backgroundDrawingType), |
| 306 TestDisplayItem(second, foregroundDrawingType)); | 306 TestDisplayItem(second, foregroundDrawingType)); |
| 307 | 307 |
| 308 paintController().invalidate(first); | 308 getPaintController().invalidate(first); |
| 309 paintController().invalidate(second); | 309 getPaintController().invalidate(second); |
| 310 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 310 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 311 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); | 311 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 312 paintController().commitNewDisplayItems(); | 312 getPaintController().commitNewDisplayItems(); |
| 313 | 313 |
| 314 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 314 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 315 TestDisplayItem(first, backgroundDrawingType), | 315 TestDisplayItem(first, backgroundDrawingType), |
| 316 TestDisplayItem(first, foregroundDrawingType)); | 316 TestDisplayItem(first, foregroundDrawingType)); |
| 317 } | 317 } |
| 318 | 318 |
| 319 TEST_F(PaintControllerTest, UpdateClip) | 319 TEST_F(PaintControllerTest, UpdateClip) |
| 320 { | 320 { |
| 321 TestDisplayItemClient first("first"); | 321 TestDisplayItemClient first("first"); |
| 322 TestDisplayItemClient second("second"); | 322 TestDisplayItemClient second("second"); |
| 323 GraphicsContext context(paintController()); | 323 GraphicsContext context(getPaintController()); |
| 324 | 324 |
| 325 { | 325 { |
| 326 ClipRecorder clipRecorder(context, first, clipType, LayoutRect(1, 1, 2,
2)); | 326 ClipRecorder clipRecorder(context, first, clipType, LayoutRect(1, 1, 2,
2)); |
| 327 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150,
150)); | 327 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150,
150)); |
| 328 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150
, 150)); | 328 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150
, 150)); |
| 329 } | 329 } |
| 330 paintController().commitNewDisplayItems(); | 330 getPaintController().commitNewDisplayItems(); |
| 331 | 331 |
| 332 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 4, | 332 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 333 TestDisplayItem(first, clipType), | 333 TestDisplayItem(first, clipType), |
| 334 TestDisplayItem(first, backgroundDrawingType), | 334 TestDisplayItem(first, backgroundDrawingType), |
| 335 TestDisplayItem(second, backgroundDrawingType), | 335 TestDisplayItem(second, backgroundDrawingType), |
| 336 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); | 336 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); |
| 337 | 337 |
| 338 paintController().invalidate(first); | 338 getPaintController().invalidate(first); |
| 339 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 339 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 340 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15
0)); | 340 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15
0)); |
| 341 paintController().commitNewDisplayItems(); | 341 getPaintController().commitNewDisplayItems(); |
| 342 | 342 |
| 343 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 343 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 344 TestDisplayItem(first, backgroundDrawingType), | 344 TestDisplayItem(first, backgroundDrawingType), |
| 345 TestDisplayItem(second, backgroundDrawingType)); | 345 TestDisplayItem(second, backgroundDrawingType)); |
| 346 | 346 |
| 347 paintController().invalidate(second); | 347 getPaintController().invalidate(second); |
| 348 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 348 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 349 { | 349 { |
| 350 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2,
2)); | 350 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2,
2)); |
| 351 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150
, 150)); | 351 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150
, 150)); |
| 352 } | 352 } |
| 353 paintController().commitNewDisplayItems(); | 353 getPaintController().commitNewDisplayItems(); |
| 354 | 354 |
| 355 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 4, | 355 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 356 TestDisplayItem(first, backgroundDrawingType), | 356 TestDisplayItem(first, backgroundDrawingType), |
| 357 TestDisplayItem(second, clipType), | 357 TestDisplayItem(second, clipType), |
| 358 TestDisplayItem(second, backgroundDrawingType), | 358 TestDisplayItem(second, backgroundDrawingType), |
| 359 TestDisplayItem(second, DisplayItem::clipTypeToEndClipType(clipType))); | 359 TestDisplayItem(second, DisplayItem::clipTypeToEndClipType(clipType))); |
| 360 } | 360 } |
| 361 | 361 |
| 362 TEST_F(PaintControllerTest, CachedDisplayItems) | 362 TEST_F(PaintControllerTest, CachedDisplayItems) |
| 363 { | 363 { |
| 364 TestDisplayItemClient first("first"); | 364 TestDisplayItemClient first("first"); |
| 365 TestDisplayItemClient second("second"); | 365 TestDisplayItemClient second("second"); |
| 366 GraphicsContext context(paintController()); | 366 GraphicsContext context(getPaintController()); |
| 367 | 367 |
| 368 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 368 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 369 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15
0)); | 369 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15
0)); |
| 370 paintController().commitNewDisplayItems(); | 370 getPaintController().commitNewDisplayItems(); |
| 371 | 371 |
| 372 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 372 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 373 TestDisplayItem(first, backgroundDrawingType), | 373 TestDisplayItem(first, backgroundDrawingType), |
| 374 TestDisplayItem(second, backgroundDrawingType)); | 374 TestDisplayItem(second, backgroundDrawingType)); |
| 375 EXPECT_TRUE(paintController().clientCacheIsValid(first)); | 375 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); |
| 376 EXPECT_TRUE(paintController().clientCacheIsValid(second)); | 376 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); |
| 377 const SkPicture* firstPicture = static_cast<const DrawingDisplayItem&>(paint
Controller().displayItemList()[0]).picture(); | 377 const SkPicture* firstPicture = static_cast<const DrawingDisplayItem&>(getPa
intController().getDisplayItemList()[0]).picture(); |
| 378 const SkPicture* secondPicture = static_cast<const DrawingDisplayItem&>(pain
tController().displayItemList()[1]).picture(); | 378 const SkPicture* secondPicture = static_cast<const DrawingDisplayItem&>(getP
aintController().getDisplayItemList()[1]).picture(); |
| 379 | 379 |
| 380 paintController().invalidate(first); | 380 getPaintController().invalidate(first); |
| 381 EXPECT_FALSE(paintController().clientCacheIsValid(first)); | 381 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); |
| 382 EXPECT_TRUE(paintController().clientCacheIsValid(second)); | 382 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); |
| 383 | 383 |
| 384 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); | 384 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150
)); |
| 385 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15
0)); | 385 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15
0)); |
| 386 paintController().commitNewDisplayItems(); | 386 getPaintController().commitNewDisplayItems(); |
| 387 | 387 |
| 388 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 388 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 389 TestDisplayItem(first, backgroundDrawingType), | 389 TestDisplayItem(first, backgroundDrawingType), |
| 390 TestDisplayItem(second, backgroundDrawingType)); | 390 TestDisplayItem(second, backgroundDrawingType)); |
| 391 // The first display item should be updated. | 391 // The first display item should be updated. |
| 392 EXPECT_NE(firstPicture, static_cast<const DrawingDisplayItem&>(paintControll
er().displayItemList()[0]).picture()); | 392 EXPECT_NE(firstPicture, static_cast<const DrawingDisplayItem&>(getPaintContr
oller().getDisplayItemList()[0]).picture()); |
| 393 // The second display item should be cached. | 393 // The second display item should be cached. |
| 394 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(paintControl
ler().displayItemList()[1]).picture()); | 394 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaintCont
roller().getDisplayItemList()[1]).picture()); |
| 395 EXPECT_TRUE(paintController().clientCacheIsValid(first)); | 395 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); |
| 396 EXPECT_TRUE(paintController().clientCacheIsValid(second)); | 396 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); |
| 397 | 397 |
| 398 paintController().invalidateAll(); | 398 getPaintController().invalidateAll(); |
| 399 EXPECT_FALSE(paintController().clientCacheIsValid(first)); | 399 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); |
| 400 EXPECT_FALSE(paintController().clientCacheIsValid(second)); | 400 EXPECT_FALSE(getPaintController().clientCacheIsValid(second)); |
| 401 } | 401 } |
| 402 | 402 |
| 403 TEST_F(PaintControllerTest, ComplexUpdateSwapOrder) | 403 TEST_F(PaintControllerTest, ComplexUpdateSwapOrder) |
| 404 { | 404 { |
| 405 TestDisplayItemClient container1("container1"); | 405 TestDisplayItemClient container1("container1"); |
| 406 TestDisplayItemClient content1("content1"); | 406 TestDisplayItemClient content1("content1"); |
| 407 TestDisplayItemClient container2("container2"); | 407 TestDisplayItemClient container2("container2"); |
| 408 TestDisplayItemClient content2("content2"); | 408 TestDisplayItemClient content2("content2"); |
| 409 GraphicsContext context(paintController()); | 409 GraphicsContext context(getPaintController()); |
| 410 | 410 |
| 411 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); | 411 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 412 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); | 412 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 413 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); | 413 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 414 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); | 414 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 415 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); | 415 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 416 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); | 416 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 417 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2
00)); | 417 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 418 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100
, 100)); | 418 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 419 paintController().commitNewDisplayItems(); | 419 getPaintController().commitNewDisplayItems(); |
| 420 | 420 |
| 421 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 8, | 421 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, |
| 422 TestDisplayItem(container1, backgroundDrawingType), | 422 TestDisplayItem(container1, backgroundDrawingType), |
| 423 TestDisplayItem(content1, backgroundDrawingType), | 423 TestDisplayItem(content1, backgroundDrawingType), |
| 424 TestDisplayItem(content1, foregroundDrawingType), | 424 TestDisplayItem(content1, foregroundDrawingType), |
| 425 TestDisplayItem(container1, foregroundDrawingType), | 425 TestDisplayItem(container1, foregroundDrawingType), |
| 426 TestDisplayItem(container2, backgroundDrawingType), | 426 TestDisplayItem(container2, backgroundDrawingType), |
| 427 TestDisplayItem(content2, backgroundDrawingType), | 427 TestDisplayItem(content2, backgroundDrawingType), |
| 428 TestDisplayItem(content2, foregroundDrawingType), | 428 TestDisplayItem(content2, foregroundDrawingType), |
| 429 TestDisplayItem(container2, foregroundDrawingType)); | 429 TestDisplayItem(container2, foregroundDrawingType)); |
| 430 | 430 |
| 431 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. | 431 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. |
| 432 paintController().invalidate(container1); | 432 getPaintController().invalidate(container1); |
| 433 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); | 433 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 434 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); | 434 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 435 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2
00)); | 435 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 436 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100
, 100)); | 436 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 437 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); | 437 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 438 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); | 438 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 439 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); | 439 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 440 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); | 440 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 441 paintController().commitNewDisplayItems(); | 441 getPaintController().commitNewDisplayItems(); |
| 442 | 442 |
| 443 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 8, | 443 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, |
| 444 TestDisplayItem(container2, backgroundDrawingType), | 444 TestDisplayItem(container2, backgroundDrawingType), |
| 445 TestDisplayItem(content2, backgroundDrawingType), | 445 TestDisplayItem(content2, backgroundDrawingType), |
| 446 TestDisplayItem(content2, foregroundDrawingType), | 446 TestDisplayItem(content2, foregroundDrawingType), |
| 447 TestDisplayItem(container2, foregroundDrawingType), | 447 TestDisplayItem(container2, foregroundDrawingType), |
| 448 TestDisplayItem(container1, backgroundDrawingType), | 448 TestDisplayItem(container1, backgroundDrawingType), |
| 449 TestDisplayItem(content1, backgroundDrawingType), | 449 TestDisplayItem(content1, backgroundDrawingType), |
| 450 TestDisplayItem(content1, foregroundDrawingType), | 450 TestDisplayItem(content1, foregroundDrawingType), |
| 451 TestDisplayItem(container1, foregroundDrawingType)); | 451 TestDisplayItem(container1, foregroundDrawingType)); |
| 452 } | 452 } |
| 453 | 453 |
| 454 TEST_F(PaintControllerTest, CachedSubsequenceSwapOrder) | 454 TEST_F(PaintControllerTest, CachedSubsequenceSwapOrder) |
| 455 { | 455 { |
| 456 TestDisplayItemClient container1("container1"); | 456 TestDisplayItemClient container1("container1"); |
| 457 TestDisplayItemClient content1("content1"); | 457 TestDisplayItemClient content1("content1"); |
| 458 TestDisplayItemClient container2("container2"); | 458 TestDisplayItemClient container2("container2"); |
| 459 TestDisplayItemClient content2("content2"); | 459 TestDisplayItemClient content2("content2"); |
| 460 GraphicsContext context(paintController()); | 460 GraphicsContext context(getPaintController()); |
| 461 | 461 |
| 462 { | 462 { |
| 463 SubsequenceRecorder r(context, container1); | 463 SubsequenceRecorder r(context, container1); |
| 464 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100,
100, 100)); | 464 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100,
100, 100)); |
| 465 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5
0, 200)); | 465 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5
0, 200)); |
| 466 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 5
0, 200)); | 466 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 5
0, 200)); |
| 467 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); | 467 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); |
| 468 } | 468 } |
| 469 { | 469 { |
| 470 SubsequenceRecorder r(context, container2); | 470 SubsequenceRecorder r(context, container2); |
| 471 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200,
100, 100)); | 471 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200,
100, 100)); |
| 472 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5
0, 200)); | 472 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5
0, 200)); |
| 473 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5
0, 200)); | 473 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5
0, 200)); |
| 474 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200,
100, 100)); | 474 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200,
100, 100)); |
| 475 } | 475 } |
| 476 paintController().commitNewDisplayItems(); | 476 getPaintController().commitNewDisplayItems(); |
| 477 | 477 |
| 478 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 12, | 478 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 12, |
| 479 TestDisplayItem(container1, DisplayItem::Subsequence), | 479 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 480 TestDisplayItem(container1, backgroundDrawingType), | 480 TestDisplayItem(container1, backgroundDrawingType), |
| 481 TestDisplayItem(content1, backgroundDrawingType), | 481 TestDisplayItem(content1, backgroundDrawingType), |
| 482 TestDisplayItem(content1, foregroundDrawingType), | 482 TestDisplayItem(content1, foregroundDrawingType), |
| 483 TestDisplayItem(container1, foregroundDrawingType), | 483 TestDisplayItem(container1, foregroundDrawingType), |
| 484 TestDisplayItem(container1, DisplayItem::EndSubsequence), | 484 TestDisplayItem(container1, DisplayItem::EndSubsequence), |
| 485 | 485 |
| 486 TestDisplayItem(container2, DisplayItem::Subsequence), | 486 TestDisplayItem(container2, DisplayItem::Subsequence), |
| 487 TestDisplayItem(container2, backgroundDrawingType), | 487 TestDisplayItem(container2, backgroundDrawingType), |
| 488 TestDisplayItem(content2, backgroundDrawingType), | 488 TestDisplayItem(content2, backgroundDrawingType), |
| 489 TestDisplayItem(content2, foregroundDrawingType), | 489 TestDisplayItem(content2, foregroundDrawingType), |
| 490 TestDisplayItem(container2, foregroundDrawingType), | 490 TestDisplayItem(container2, foregroundDrawingType), |
| 491 TestDisplayItem(container2, DisplayItem::EndSubsequence)); | 491 TestDisplayItem(container2, DisplayItem::EndSubsequence)); |
| 492 | 492 |
| 493 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. | 493 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. |
| 494 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer2)); | 494 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer2)); |
| 495 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer1)); | 495 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer1)); |
| 496 | 496 |
| 497 EXPECT_DISPLAY_LIST(paintController().newDisplayItemList(), 2, | 497 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 2, |
| 498 TestDisplayItem(container2, DisplayItem::CachedSubsequence), | 498 TestDisplayItem(container2, DisplayItem::CachedSubsequence), |
| 499 TestDisplayItem(container1, DisplayItem::CachedSubsequence)); | 499 TestDisplayItem(container1, DisplayItem::CachedSubsequence)); |
| 500 | 500 |
| 501 paintController().commitNewDisplayItems(); | 501 getPaintController().commitNewDisplayItems(); |
| 502 | 502 |
| 503 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 12, | 503 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 12, |
| 504 TestDisplayItem(container2, DisplayItem::Subsequence), | 504 TestDisplayItem(container2, DisplayItem::Subsequence), |
| 505 TestDisplayItem(container2, backgroundDrawingType), | 505 TestDisplayItem(container2, backgroundDrawingType), |
| 506 TestDisplayItem(content2, backgroundDrawingType), | 506 TestDisplayItem(content2, backgroundDrawingType), |
| 507 TestDisplayItem(content2, foregroundDrawingType), | 507 TestDisplayItem(content2, foregroundDrawingType), |
| 508 TestDisplayItem(container2, foregroundDrawingType), | 508 TestDisplayItem(container2, foregroundDrawingType), |
| 509 TestDisplayItem(container2, DisplayItem::EndSubsequence), | 509 TestDisplayItem(container2, DisplayItem::EndSubsequence), |
| 510 | 510 |
| 511 TestDisplayItem(container1, DisplayItem::Subsequence), | 511 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 512 TestDisplayItem(container1, backgroundDrawingType), | 512 TestDisplayItem(container1, backgroundDrawingType), |
| 513 TestDisplayItem(content1, backgroundDrawingType), | 513 TestDisplayItem(content1, backgroundDrawingType), |
| 514 TestDisplayItem(content1, foregroundDrawingType), | 514 TestDisplayItem(content1, foregroundDrawingType), |
| 515 TestDisplayItem(container1, foregroundDrawingType), | 515 TestDisplayItem(container1, foregroundDrawingType), |
| 516 TestDisplayItem(container1, DisplayItem::EndSubsequence)); | 516 TestDisplayItem(container1, DisplayItem::EndSubsequence)); |
| 517 } | 517 } |
| 518 | 518 |
| 519 TEST_F(PaintControllerTest, OutOfOrderNoCrash) | 519 TEST_F(PaintControllerTest, OutOfOrderNoCrash) |
| 520 { | 520 { |
| 521 TestDisplayItemClient client("client"); | 521 TestDisplayItemClient client("client"); |
| 522 GraphicsContext context(paintController()); | 522 GraphicsContext context(getPaintController()); |
| 523 | 523 |
| 524 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; | 524 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; |
| 525 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 1); | 525 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 1); |
| 526 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 2); | 526 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 2); |
| 527 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 3); | 527 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 3); |
| 528 | 528 |
| 529 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); | 529 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); |
| 530 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); | 530 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); |
| 531 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); | 531 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); |
| 532 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); | 532 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); |
| 533 | 533 |
| 534 paintController().commitNewDisplayItems(); | 534 getPaintController().commitNewDisplayItems(); |
| 535 | 535 |
| 536 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); | 536 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); |
| 537 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); | 537 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); |
| 538 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); | 538 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); |
| 539 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); | 539 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); |
| 540 | 540 |
| 541 paintController().commitNewDisplayItems(); | 541 getPaintController().commitNewDisplayItems(); |
| 542 } | 542 } |
| 543 | 543 |
| 544 TEST_F(PaintControllerTest, CachedNestedSubsequenceUpdate) | 544 TEST_F(PaintControllerTest, CachedNestedSubsequenceUpdate) |
| 545 { | 545 { |
| 546 TestDisplayItemClient container1("container1"); | 546 TestDisplayItemClient container1("container1"); |
| 547 TestDisplayItemClient content1("content1"); | 547 TestDisplayItemClient content1("content1"); |
| 548 TestDisplayItemClient container2("container2"); | 548 TestDisplayItemClient container2("container2"); |
| 549 TestDisplayItemClient content2("content2"); | 549 TestDisplayItemClient content2("content2"); |
| 550 GraphicsContext context(paintController()); | 550 GraphicsContext context(getPaintController()); |
| 551 | 551 |
| 552 { | 552 { |
| 553 SubsequenceRecorder r(context, container1); | 553 SubsequenceRecorder r(context, container1); |
| 554 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100,
100, 100)); | 554 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100,
100, 100)); |
| 555 { | 555 { |
| 556 SubsequenceRecorder r(context, content1); | 556 SubsequenceRecorder r(context, content1); |
| 557 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10
0, 50, 200)); | 557 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10
0, 50, 200)); |
| 558 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10
0, 50, 200)); | 558 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10
0, 50, 200)); |
| 559 } | 559 } |
| 560 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); | 560 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); |
| 561 } | 561 } |
| 562 { | 562 { |
| 563 SubsequenceRecorder r(context, container2); | 563 SubsequenceRecorder r(context, container2); |
| 564 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200,
100, 100)); | 564 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200,
100, 100)); |
| 565 { | 565 { |
| 566 SubsequenceRecorder r(context, content2); | 566 SubsequenceRecorder r(context, content2); |
| 567 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20
0, 50, 200)); | 567 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20
0, 50, 200)); |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 paintController().commitNewDisplayItems(); | 570 getPaintController().commitNewDisplayItems(); |
| 571 | 571 |
| 572 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 14, | 572 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 14, |
| 573 TestDisplayItem(container1, DisplayItem::Subsequence), | 573 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 574 TestDisplayItem(container1, backgroundDrawingType), | 574 TestDisplayItem(container1, backgroundDrawingType), |
| 575 TestDisplayItem(content1, DisplayItem::Subsequence), | 575 TestDisplayItem(content1, DisplayItem::Subsequence), |
| 576 TestDisplayItem(content1, backgroundDrawingType), | 576 TestDisplayItem(content1, backgroundDrawingType), |
| 577 TestDisplayItem(content1, foregroundDrawingType), | 577 TestDisplayItem(content1, foregroundDrawingType), |
| 578 TestDisplayItem(content1, DisplayItem::EndSubsequence), | 578 TestDisplayItem(content1, DisplayItem::EndSubsequence), |
| 579 TestDisplayItem(container1, foregroundDrawingType), | 579 TestDisplayItem(container1, foregroundDrawingType), |
| 580 TestDisplayItem(container1, DisplayItem::EndSubsequence), | 580 TestDisplayItem(container1, DisplayItem::EndSubsequence), |
| 581 | 581 |
| 582 TestDisplayItem(container2, DisplayItem::Subsequence), | 582 TestDisplayItem(container2, DisplayItem::Subsequence), |
| 583 TestDisplayItem(container2, backgroundDrawingType), | 583 TestDisplayItem(container2, backgroundDrawingType), |
| 584 TestDisplayItem(content2, DisplayItem::Subsequence), | 584 TestDisplayItem(content2, DisplayItem::Subsequence), |
| 585 TestDisplayItem(content2, backgroundDrawingType), | 585 TestDisplayItem(content2, backgroundDrawingType), |
| 586 TestDisplayItem(content2, DisplayItem::EndSubsequence), | 586 TestDisplayItem(content2, DisplayItem::EndSubsequence), |
| 587 TestDisplayItem(container2, DisplayItem::EndSubsequence)); | 587 TestDisplayItem(container2, DisplayItem::EndSubsequence)); |
| 588 | 588 |
| 589 // Invalidate container1 but not content1. | 589 // Invalidate container1 but not content1. |
| 590 paintController().invalidate(container1); | 590 getPaintController().invalidate(container1); |
| 591 | 591 |
| 592 // Container2 itself now becomes empty (but still has the 'content2' child), | 592 // Container2 itself now becomes empty (but still has the 'content2' child), |
| 593 // and chooses not to output subsequence info. | 593 // and chooses not to output subsequence info. |
| 594 | 594 |
| 595 paintController().invalidate(container2); | 595 getPaintController().invalidate(container2); |
| 596 paintController().invalidate(content2); | 596 getPaintController().invalidate(content2); |
| 597 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co
ntainer2)); | 597 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co
ntainer2)); |
| 598 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co
ntent2)); | 598 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co
ntent2)); |
| 599 // Content2 now outputs foreground only. | 599 // Content2 now outputs foreground only. |
| 600 { | 600 { |
| 601 SubsequenceRecorder r(context, content2); | 601 SubsequenceRecorder r(context, content2); |
| 602 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5
0, 200)); | 602 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5
0, 200)); |
| 603 } | 603 } |
| 604 // Repaint container1 with foreground only. | 604 // Repaint container1 with foreground only. |
| 605 { | 605 { |
| 606 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context
, container1)); | 606 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context
, container1)); |
| 607 SubsequenceRecorder r(context, container1); | 607 SubsequenceRecorder r(context, container1); |
| 608 // Use cached subsequence of content1. | 608 // Use cached subsequence of content1. |
| 609 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context,
content1)); | 609 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context,
content1)); |
| 610 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); | 610 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100,
100, 100)); |
| 611 } | 611 } |
| 612 EXPECT_DISPLAY_LIST(paintController().newDisplayItemList(), 7, | 612 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 7, |
| 613 TestDisplayItem(content2, DisplayItem::Subsequence), | 613 TestDisplayItem(content2, DisplayItem::Subsequence), |
| 614 TestDisplayItem(content2, foregroundDrawingType), | 614 TestDisplayItem(content2, foregroundDrawingType), |
| 615 TestDisplayItem(content2, DisplayItem::EndSubsequence), | 615 TestDisplayItem(content2, DisplayItem::EndSubsequence), |
| 616 TestDisplayItem(container1, DisplayItem::Subsequence), | 616 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 617 TestDisplayItem(content1, DisplayItem::CachedSubsequence), | 617 TestDisplayItem(content1, DisplayItem::CachedSubsequence), |
| 618 TestDisplayItem(container1, foregroundDrawingType), | 618 TestDisplayItem(container1, foregroundDrawingType), |
| 619 TestDisplayItem(container1, DisplayItem::EndSubsequence)); | 619 TestDisplayItem(container1, DisplayItem::EndSubsequence)); |
| 620 | 620 |
| 621 paintController().commitNewDisplayItems(); | 621 getPaintController().commitNewDisplayItems(); |
| 622 | 622 |
| 623 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 10, | 623 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 10, |
| 624 TestDisplayItem(content2, DisplayItem::Subsequence), | 624 TestDisplayItem(content2, DisplayItem::Subsequence), |
| 625 TestDisplayItem(content2, foregroundDrawingType), | 625 TestDisplayItem(content2, foregroundDrawingType), |
| 626 TestDisplayItem(content2, DisplayItem::EndSubsequence), | 626 TestDisplayItem(content2, DisplayItem::EndSubsequence), |
| 627 | 627 |
| 628 TestDisplayItem(container1, DisplayItem::Subsequence), | 628 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 629 TestDisplayItem(content1, DisplayItem::Subsequence), | 629 TestDisplayItem(content1, DisplayItem::Subsequence), |
| 630 TestDisplayItem(content1, backgroundDrawingType), | 630 TestDisplayItem(content1, backgroundDrawingType), |
| 631 TestDisplayItem(content1, foregroundDrawingType), | 631 TestDisplayItem(content1, foregroundDrawingType), |
| 632 TestDisplayItem(content1, DisplayItem::EndSubsequence), | 632 TestDisplayItem(content1, DisplayItem::EndSubsequence), |
| 633 TestDisplayItem(container1, foregroundDrawingType), | 633 TestDisplayItem(container1, foregroundDrawingType), |
| 634 TestDisplayItem(container1, DisplayItem::EndSubsequence)); | 634 TestDisplayItem(container1, DisplayItem::EndSubsequence)); |
| 635 } | 635 } |
| 636 | 636 |
| 637 TEST_F(PaintControllerTest, Scope) | 637 TEST_F(PaintControllerTest, Scope) |
| 638 { | 638 { |
| 639 TestDisplayItemClient multicol("multicol"); | 639 TestDisplayItemClient multicol("multicol"); |
| 640 TestDisplayItemClient content("content"); | 640 TestDisplayItemClient content("content"); |
| 641 GraphicsContext context(paintController()); | 641 GraphicsContext context(getPaintController()); |
| 642 | 642 |
| 643 FloatRect rect1(100, 100, 50, 50); | 643 FloatRect rect1(100, 100, 50, 50); |
| 644 FloatRect rect2(150, 100, 50, 50); | 644 FloatRect rect2(150, 100, 50, 50); |
| 645 FloatRect rect3(200, 100, 50, 50); | 645 FloatRect rect3(200, 100, 50, 50); |
| 646 | 646 |
| 647 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100,
100)); | 647 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100,
100)); |
| 648 | 648 |
| 649 paintController().beginScope(); | 649 getPaintController().beginScope(); |
| 650 drawRect(context, content, foregroundDrawingType, rect1); | 650 drawRect(context, content, foregroundDrawingType, rect1); |
| 651 paintController().endScope(); | 651 getPaintController().endScope(); |
| 652 | 652 |
| 653 paintController().beginScope(); | 653 getPaintController().beginScope(); |
| 654 drawRect(context, content, foregroundDrawingType, rect2); | 654 drawRect(context, content, foregroundDrawingType, rect2); |
| 655 paintController().endScope(); | 655 getPaintController().endScope(); |
| 656 paintController().commitNewDisplayItems(); | 656 getPaintController().commitNewDisplayItems(); |
| 657 | 657 |
| 658 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 3, | 658 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 659 TestDisplayItem(multicol, backgroundDrawingType), | 659 TestDisplayItem(multicol, backgroundDrawingType), |
| 660 TestDisplayItem(content, foregroundDrawingType), | 660 TestDisplayItem(content, foregroundDrawingType), |
| 661 TestDisplayItem(content, foregroundDrawingType)); | 661 TestDisplayItem(content, foregroundDrawingType)); |
| 662 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(pa
intController().displayItemList()[1]).picture(); | 662 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge
tPaintController().getDisplayItemList()[1]).picture(); |
| 663 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(pa
intController().displayItemList()[2]).picture(); | 663 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge
tPaintController().getDisplayItemList()[2]).picture(); |
| 664 EXPECT_NE(picture1, picture2); | 664 EXPECT_NE(picture1, picture2); |
| 665 | 665 |
| 666 // Draw again with nothing invalidated. | 666 // Draw again with nothing invalidated. |
| 667 EXPECT_TRUE(paintController().clientCacheIsValid(multicol)); | 667 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol)); |
| 668 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100,
100)); | 668 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100,
100)); |
| 669 paintController().beginScope(); | 669 getPaintController().beginScope(); |
| 670 drawRect(context, content, foregroundDrawingType, rect1); | 670 drawRect(context, content, foregroundDrawingType, rect1); |
| 671 paintController().endScope(); | 671 getPaintController().endScope(); |
| 672 | 672 |
| 673 paintController().beginScope(); | 673 getPaintController().beginScope(); |
| 674 drawRect(context, content, foregroundDrawingType, rect2); | 674 drawRect(context, content, foregroundDrawingType, rect2); |
| 675 paintController().endScope(); | 675 getPaintController().endScope(); |
| 676 | 676 |
| 677 EXPECT_DISPLAY_LIST(paintController().newDisplayItemList(), 3, | 677 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 3, |
| 678 TestDisplayItem(multicol, DisplayItem::drawingTypeToCachedDrawingType(ba
ckgroundDrawingType)), | 678 TestDisplayItem(multicol, DisplayItem::drawingTypeToCachedDrawingType(ba
ckgroundDrawingType)), |
| 679 TestDisplayItem(content, foregroundDrawingType), | 679 TestDisplayItem(content, foregroundDrawingType), |
| 680 TestDisplayItem(content, foregroundDrawingType)); | 680 TestDisplayItem(content, foregroundDrawingType)); |
| 681 | 681 |
| 682 paintController().commitNewDisplayItems(); | 682 getPaintController().commitNewDisplayItems(); |
| 683 | 683 |
| 684 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 3, | 684 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 685 TestDisplayItem(multicol, backgroundDrawingType), | 685 TestDisplayItem(multicol, backgroundDrawingType), |
| 686 TestDisplayItem(content, foregroundDrawingType), | 686 TestDisplayItem(content, foregroundDrawingType), |
| 687 TestDisplayItem(content, foregroundDrawingType)); | 687 TestDisplayItem(content, foregroundDrawingType)); |
| 688 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(paintController()
.displayItemList()[1]).picture()); | 688 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[1]).picture()); |
| 689 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(paintController()
.displayItemList()[2]).picture()); | 689 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[2]).picture()); |
| 690 | 690 |
| 691 // Now the multicol becomes 3 columns and repaints. | 691 // Now the multicol becomes 3 columns and repaints. |
| 692 paintController().invalidate(multicol); | 692 getPaintController().invalidate(multicol); |
| 693 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100,
100)); | 693 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100,
100)); |
| 694 | 694 |
| 695 paintController().beginScope(); | 695 getPaintController().beginScope(); |
| 696 drawRect(context, content, foregroundDrawingType, rect1); | 696 drawRect(context, content, foregroundDrawingType, rect1); |
| 697 paintController().endScope(); | 697 getPaintController().endScope(); |
| 698 | 698 |
| 699 paintController().beginScope(); | 699 getPaintController().beginScope(); |
| 700 drawRect(context, content, foregroundDrawingType, rect2); | 700 drawRect(context, content, foregroundDrawingType, rect2); |
| 701 paintController().endScope(); | 701 getPaintController().endScope(); |
| 702 | 702 |
| 703 paintController().beginScope(); | 703 getPaintController().beginScope(); |
| 704 drawRect(context, content, foregroundDrawingType, rect3); | 704 drawRect(context, content, foregroundDrawingType, rect3); |
| 705 paintController().endScope(); | 705 getPaintController().endScope(); |
| 706 | 706 |
| 707 // We should repaint everything on invalidation of the scope container. | 707 // We should repaint everything on invalidation of the scope container. |
| 708 EXPECT_DISPLAY_LIST(paintController().newDisplayItemList(), 4, | 708 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, |
| 709 TestDisplayItem(multicol, backgroundDrawingType), | 709 TestDisplayItem(multicol, backgroundDrawingType), |
| 710 TestDisplayItem(content, foregroundDrawingType), | 710 TestDisplayItem(content, foregroundDrawingType), |
| 711 TestDisplayItem(content, foregroundDrawingType), | 711 TestDisplayItem(content, foregroundDrawingType), |
| 712 TestDisplayItem(content, foregroundDrawingType)); | 712 TestDisplayItem(content, foregroundDrawingType)); |
| 713 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(paintController()
.newDisplayItemList()[1]).picture()); | 713 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().newDisplayItemList()[1]).picture()); |
| 714 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(paintController()
.newDisplayItemList()[2]).picture()); | 714 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().newDisplayItemList()[2]).picture()); |
| 715 | 715 |
| 716 paintController().commitNewDisplayItems(); | 716 getPaintController().commitNewDisplayItems(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 TEST_F(PaintControllerTest, OptimizeNoopPairs) | 719 TEST_F(PaintControllerTest, OptimizeNoopPairs) |
| 720 { | 720 { |
| 721 TestDisplayItemClient first("first"); | 721 TestDisplayItemClient first("first"); |
| 722 TestDisplayItemClient second("second"); | 722 TestDisplayItemClient second("second"); |
| 723 TestDisplayItemClient third("third"); | 723 TestDisplayItemClient third("third"); |
| 724 | 724 |
| 725 GraphicsContext context(paintController()); | 725 GraphicsContext context(getPaintController()); |
| 726 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 726 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 727 { | 727 { |
| 728 ClipPathRecorder clipRecorder(context, second, Path()); | 728 ClipPathRecorder clipRecorder(context, second, Path()); |
| 729 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); | 729 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); |
| 730 } | 730 } |
| 731 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 731 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 732 | 732 |
| 733 paintController().commitNewDisplayItems(); | 733 getPaintController().commitNewDisplayItems(); |
| 734 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 5, | 734 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 5, |
| 735 TestDisplayItem(first, backgroundDrawingType), | 735 TestDisplayItem(first, backgroundDrawingType), |
| 736 TestDisplayItem(second, DisplayItem::BeginClipPath), | 736 TestDisplayItem(second, DisplayItem::BeginClipPath), |
| 737 TestDisplayItem(second, backgroundDrawingType), | 737 TestDisplayItem(second, backgroundDrawingType), |
| 738 TestDisplayItem(second, DisplayItem::EndClipPath), | 738 TestDisplayItem(second, DisplayItem::EndClipPath), |
| 739 TestDisplayItem(third, backgroundDrawingType)); | 739 TestDisplayItem(third, backgroundDrawingType)); |
| 740 | 740 |
| 741 paintController().invalidate(second); | 741 getPaintController().invalidate(second); |
| 742 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 742 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 743 { | 743 { |
| 744 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2,
2)); | 744 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2,
2)); |
| 745 // Do not draw anything for second. | 745 // Do not draw anything for second. |
| 746 } | 746 } |
| 747 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 747 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 748 paintController().commitNewDisplayItems(); | 748 getPaintController().commitNewDisplayItems(); |
| 749 | 749 |
| 750 // Empty clips should have been optimized out. | 750 // Empty clips should have been optimized out. |
| 751 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 751 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 752 TestDisplayItem(first, backgroundDrawingType), | 752 TestDisplayItem(first, backgroundDrawingType), |
| 753 TestDisplayItem(third, backgroundDrawingType)); | 753 TestDisplayItem(third, backgroundDrawingType)); |
| 754 | 754 |
| 755 paintController().invalidate(second); | 755 getPaintController().invalidate(second); |
| 756 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 756 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 757 { | 757 { |
| 758 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2,
2)); | 758 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2,
2)); |
| 759 { | 759 { |
| 760 ClipPathRecorder clipPathRecorder(context, second, Path()); | 760 ClipPathRecorder clipPathRecorder(context, second, Path()); |
| 761 // Do not draw anything for second. | 761 // Do not draw anything for second. |
| 762 } | 762 } |
| 763 } | 763 } |
| 764 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 764 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 765 paintController().commitNewDisplayItems(); | 765 getPaintController().commitNewDisplayItems(); |
| 766 | 766 |
| 767 // Empty clips should have been optimized out. | 767 // Empty clips should have been optimized out. |
| 768 EXPECT_DISPLAY_LIST(paintController().displayItemList(), 2, | 768 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
| 769 TestDisplayItem(first, backgroundDrawingType), | 769 TestDisplayItem(first, backgroundDrawingType), |
| 770 TestDisplayItem(third, backgroundDrawingType)); | 770 TestDisplayItem(third, backgroundDrawingType)); |
| 771 } | 771 } |
| 772 | 772 |
| 773 TEST_F(PaintControllerTest, SmallPaintControllerHasOnePaintChunk) | 773 TEST_F(PaintControllerTest, SmallPaintControllerHasOnePaintChunk) |
| 774 { | 774 { |
| 775 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 775 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 776 TestDisplayItemClient client("test client"); | 776 TestDisplayItemClient client("test client"); |
| 777 | 777 |
| 778 GraphicsContext context(paintController()); | 778 GraphicsContext context(getPaintController()); |
| 779 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 779 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 780 | 780 |
| 781 paintController().commitNewDisplayItems(); | 781 getPaintController().commitNewDisplayItems(); |
| 782 const auto& paintChunks = paintController().paintChunks(); | 782 const auto& paintChunks = getPaintController().paintChunks(); |
| 783 ASSERT_EQ(1u, paintChunks.size()); | 783 ASSERT_EQ(1u, paintChunks.size()); |
| 784 EXPECT_EQ(0u, paintChunks[0].beginIndex); | 784 EXPECT_EQ(0u, paintChunks[0].beginIndex); |
| 785 EXPECT_EQ(1u, paintChunks[0].endIndex); | 785 EXPECT_EQ(1u, paintChunks[0].endIndex); |
| 786 } | 786 } |
| 787 | 787 |
| 788 #define EXPECT_RECT_EQ(expected, actual) \ | 788 #define EXPECT_RECT_EQ(expected, actual) \ |
| 789 do { \ | 789 do { \ |
| 790 const IntRect& actualRect = actual; \ | 790 const IntRect& actualRect = actual; \ |
| 791 EXPECT_EQ(expected.x(), actualRect.x()); \ | 791 EXPECT_EQ(expected.x(), actualRect.x()); \ |
| 792 EXPECT_EQ(expected.y(), actualRect.y()); \ | 792 EXPECT_EQ(expected.y(), actualRect.y()); \ |
| 793 EXPECT_EQ(expected.width(), actualRect.width()); \ | 793 EXPECT_EQ(expected.width(), actualRect.width()); \ |
| 794 EXPECT_EQ(expected.height(), actualRect.height()); \ | 794 EXPECT_EQ(expected.height(), actualRect.height()); \ |
| 795 } while (false) | 795 } while (false) |
| 796 | 796 |
| 797 TEST_F(PaintControllerTest, PaintArtifactWithVisualRects) | 797 TEST_F(PaintControllerTest, PaintArtifactWithVisualRects) |
| 798 { | 798 { |
| 799 TestDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 799 TestDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 800 | 800 |
| 801 GraphicsContext context(paintController()); | 801 GraphicsContext context(getPaintController()); |
| 802 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 802 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 803 | 803 |
| 804 paintController().commitNewDisplayItems(LayoutSize(20, 30)); | 804 getPaintController().commitNewDisplayItems(LayoutSize(20, 30)); |
| 805 const auto& paintArtifact = paintController().paintArtifact(); | 805 const auto& paintArtifact = getPaintController().paintArtifact(); |
| 806 ASSERT_EQ(1u, paintArtifact.displayItemList().size()); | 806 ASSERT_EQ(1u, paintArtifact.getDisplayItemList().size()); |
| 807 EXPECT_RECT_EQ(IntRect(-20, -30, 200, 100), visualRect(paintArtifact, 0)); | 807 EXPECT_RECT_EQ(IntRect(-20, -30, 200, 100), visualRect(paintArtifact, 0)); |
| 808 } | 808 } |
| 809 | 809 |
| 810 } // namespace blink | 810 } // namespace blink |
| OLD | NEW |