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 IntSize& layerSize, const IntR ect& previousInterestRect, const IntRect& newInterestRect) | |
28 { | |
29 return CompositedLayerMapping::interestRectChangedEnoughToRepaint(layerS ize, previousInterestRect, newInterestRect); | |
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, InterestRectChangedEnoughToRepaint) | |
chrishtr
2015/10/29 16:34:42
Please copy the exact tests from here:
https://co
Xianzhu
2015/10/29 17:17:27
Done.
| |
212 { | |
213 IntSize layerSize(2000, 2000); | |
214 EXPECT_FALSE(interestRectChangedEnoughToRepaint(layerSize, IntRect(), IntRec t())); | |
215 EXPECT_TRUE(interestRectChangedEnoughToRepaint(layerSize, IntRect(), IntRect (0, 0, 100, 100))); | |
216 EXPECT_FALSE(interestRectChangedEnoughToRepaint(layerSize, IntRect(100, 100, 100, 100), IntRect(100, 100, 50, 50))); | |
217 EXPECT_FALSE(interestRectChangedEnoughToRepaint(layerSize, IntRect(100, 100, 100, 100), IntRect(50, 50, 500, 500))); | |
218 EXPECT_TRUE(interestRectChangedEnoughToRepaint(layerSize, IntRect(100, 100, 100, 100), IntRect(50, 50, 800, 600))); | |
219 EXPECT_TRUE(interestRectChangedEnoughToRepaint(layerSize, IntRect(100, 100, 100, 100), IntRect(0, 0, 200, 200))); | |
220 EXPECT_TRUE(interestRectChangedEnoughToRepaint(layerSize, IntRect(1000, 1000 , 900, 900), IntRect(1000, 1000, 1000, 1000))); | |
221 } | |
222 | |
206 } // namespace blink | 223 } // namespace blink |
OLD | NEW |