| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/layout/compositing/CompositedLayerMapping.h" | 6 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 7 | 7 |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/layout/LayoutBoxModelObject.h" | 9 #include "core/layout/LayoutBoxModelObject.h" |
| 10 #include "core/layout/LayoutTestHelper.h" | 10 #include "core/layout/LayoutTestHelper.h" |
| 11 #include "core/paint/PaintLayer.h" | 11 #include "core/paint/PaintLayer.h" |
| 12 #include <gtest/gtest.h> | 12 #include <gtest/gtest.h> |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class CompositedLayerMappingTest : public RenderingTest { | 16 class CompositedLayerMappingTest : public RenderingTest { |
| 17 public: | 17 public: |
| 18 CompositedLayerMappingTest() | 18 CompositedLayerMappingTest() |
| 19 : m_originalSlimmingPaintSynchronizedPaintingEnabled(RuntimeEnabledFeatu
res::slimmingPaintSynchronizedPaintingEnabled()) { } | 19 : m_originalSlimmingPaintSynchronizedPaintingEnabled(RuntimeEnabledFeatu
res::slimmingPaintSynchronizedPaintingEnabled()) { } |
| 20 | 20 |
| 21 protected: | 21 protected: |
| 22 IntRect computeInterestRect(const GraphicsLayer* graphicsLayer, LayoutObject
* owningLayoutObject) | 22 IntRect computeInterestRect(const GraphicsLayer* graphicsLayer, LayoutObject
* owningLayoutObject) |
| 23 { | 23 { |
| 24 return CompositedLayerMapping::computeInterestRect(graphicsLayer, owning
LayoutObject); | 24 return CompositedLayerMapping::computeInterestRect(graphicsLayer, owning
LayoutObject); |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool interestRectChangedEnoughToRepaint(const IntRect& previousInterestRect,
const IntRect& newInterestRect, const IntSize& layerSize) |
| 28 { |
| 29 return CompositedLayerMapping::interestRectChangedEnoughToRepaint(previo
usInterestRect, newInterestRect, layerSize); |
| 30 } |
| 31 |
| 27 private: | 32 private: |
| 28 void SetUp() override | 33 void SetUp() override |
| 29 { | 34 { |
| 30 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true
); | 35 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true
); |
| 31 | 36 |
| 32 RenderingTest::SetUp(); | 37 RenderingTest::SetUp(); |
| 33 enableCompositing(); | 38 enableCompositing(); |
| 34 GraphicsLayer::setDrawDebugRedFillForTesting(false); | 39 GraphicsLayer::setDrawDebugRedFillForTesting(false); |
| 35 } | 40 } |
| 36 | 41 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 "<div id='target' style='width: 10000px; height: 10000px; will-change: t
ransform'></div></div>"); | 201 "<div id='target' style='width: 10000px; height: 10000px; will-change: t
ransform'></div></div>"); |
| 197 | 202 |
| 198 document().view()->updateAllLifecyclePhases(); | 203 document().view()->updateAllLifecyclePhases(); |
| 199 Element* element = document().getElementById("target"); | 204 Element* element = document().getElementById("target"); |
| 200 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); | 205 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
| 201 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); | 206 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); |
| 202 // Offscreen layers are painted as usual. | 207 // Offscreen layers are painted as usual. |
| 203 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 4001, 4001), computeInterestRect(p
aintLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); | 208 EXPECT_TRUE(checkRectsEqual(IntRect(0, 0, 4001, 4001), computeInterestRect(p
aintLayer->graphicsLayerBacking(), paintLayer->layoutObject()))); |
| 204 } | 209 } |
| 205 | 210 |
| 211 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintEmpty) |
| 212 { |
| 213 IntSize layerSize(1000, 1000); |
| 214 // Both empty means there is nothing to do. |
| 215 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(), IntRect(), layerS
ize)); |
| 216 // Going from empty to non-empty means we must re-record because it could be
the first frame after construction or Clear. |
| 217 EXPECT_TRUE(interestRectChangedEnoughToRepaint(IntRect(), IntRect(0, 0, 1, 1
), layerSize)); |
| 218 // Going from non-empty to empty is not special-cased. |
| 219 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(0, 0, 1, 1), IntRect
(), layerSize)); |
| 220 } |
| 221 |
| 222 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintNotBigEnoug
h) |
| 223 { |
| 224 IntSize layerSize(1000, 1000); |
| 225 IntRect previousInterestRect(100, 100, 100, 100); |
| 226 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, IntRec
t(100, 100, 90, 90), layerSize)); |
| 227 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, IntRec
t(100, 100, 100, 100), layerSize)); |
| 228 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, IntRec
t(1, 1, 200, 200), layerSize)); |
| 229 } |
| 230 |
| 231 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintNotBigEnoug
hButNewAreaTouchesEdge) |
| 232 { |
| 233 IntSize layerSize(500, 500); |
| 234 IntRect previousInterestRect(100, 100, 100, 100); |
| 235 // Top edge. |
| 236 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, IntRect
(100, 0, 100, 200), layerSize)); |
| 237 // Left edge. |
| 238 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, IntRect
(0, 100, 200, 100), layerSize)); |
| 239 // Bottom edge. |
| 240 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, IntRect
(100, 100, 100, 400), layerSize)); |
| 241 // Right edge. |
| 242 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, IntRect
(100, 100, 400, 100), layerSize)); |
| 243 } |
| 244 |
| 245 // Verifies that having a current viewport that touches a layer edge does not |
| 246 // force re-recording. |
| 247 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintCurrentView
portTouchesEdge) |
| 248 { |
| 249 IntSize layerSize(500, 500); |
| 250 IntRect newInterestRect(100, 100, 300, 300); |
| 251 // Top edge. |
| 252 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(100, 0, 100, 100), n
ewInterestRect, layerSize)); |
| 253 // Left edge. |
| 254 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(0, 100, 100, 100), n
ewInterestRect, layerSize)); |
| 255 // Bottom edge. |
| 256 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(300, 400, 100, 100),
newInterestRect, layerSize)); |
| 257 // Right edge. |
| 258 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(400, 300, 100, 100),
newInterestRect, layerSize)); |
| 259 } |
| 260 |
| 261 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintScrollScena
rios) |
| 262 { |
| 263 IntSize layerSize(1000, 1000); |
| 264 IntRect previousInterestRect(100, 100, 100, 100); |
| 265 IntRect newInterestRect(previousInterestRect); |
| 266 newInterestRect.move(512, 0); |
| 267 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, newInt
erestRect, layerSize)); |
| 268 newInterestRect.move(0, 512); |
| 269 EXPECT_FALSE(interestRectChangedEnoughToRepaint(previousInterestRect, newInt
erestRect, layerSize)); |
| 270 newInterestRect.move(1, 0); |
| 271 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, newInte
restRect, layerSize)); |
| 272 newInterestRect.move(-1, 1); |
| 273 EXPECT_TRUE(interestRectChangedEnoughToRepaint(previousInterestRect, newInte
restRect, layerSize)); |
| 274 } |
| 275 |
| 206 } // namespace blink | 276 } // namespace blink |
| OLD | NEW |