| 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 "core/paint/PaintInfo.h" | 5 #include "core/paint/PaintInfo.h" |
| 6 | 6 |
| 7 #include "platform/graphics/paint/PaintController.h" | 7 #include "platform/graphics/paint/PaintController.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(IntRect(0, 0, 1, 1))); | 27 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(IntRect(0, 0, 1, 1))); |
| 28 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(51, 51, 1, 1)))
; | 28 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(51, 51, 1, 1)))
; |
| 29 } | 29 } |
| 30 | 30 |
| 31 TEST_F(PaintInfoTest, intersectsCullRectWithLayoutRect) | 31 TEST_F(PaintInfoTest, intersectsCullRectWithLayoutRect) |
| 32 { | 32 { |
| 33 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 50), PaintPhaseSelfBlockBac
kgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); | 33 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 50), PaintPhaseSelfBlockBac
kgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); |
| 34 | 34 |
| 35 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(LayoutRect(0, 0, 1, 1)))
; | 35 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(LayoutRect(0, 0, 1, 1)))
; |
| 36 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(LayoutRect(0.1, 0.1, 0.1
, 0.1))); | 36 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(LayoutRect(LayoutUnit(0.
1), LayoutUnit(0.1), LayoutUnit(0.1), LayoutUnit(0.1)))); |
| 37 } | 37 } |
| 38 | 38 |
| 39 TEST_F(PaintInfoTest, intersectsCullRectWithTransform) | 39 TEST_F(PaintInfoTest, intersectsCullRectWithTransform) |
| 40 { | 40 { |
| 41 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 50), PaintPhaseSelfBlockBac
kgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); | 41 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 50), PaintPhaseSelfBlockBac
kgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); |
| 42 AffineTransform transform; | 42 AffineTransform transform; |
| 43 transform.translate(-2, -2); | 43 transform.translate(-2, -2); |
| 44 | 44 |
| 45 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(transform, IntRect(51, 5
1, 1, 1))); | 45 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(transform, IntRect(51, 5
1, 1, 1))); |
| 46 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(52, 52, 1, 1)))
; | 46 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(52, 52, 1, 1)))
; |
| 47 } | 47 } |
| 48 | 48 |
| 49 TEST_F(PaintInfoTest, updateCullRect) | 49 TEST_F(PaintInfoTest, updateCullRect) |
| 50 { | 50 { |
| 51 PaintInfo paintInfo(m_context, IntRect(1, 1, 50, 50), PaintPhaseSelfBlockBac
kgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); | 51 PaintInfo paintInfo(m_context, IntRect(1, 1, 50, 50), PaintPhaseSelfBlockBac
kgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); |
| 52 AffineTransform transform; | 52 AffineTransform transform; |
| 53 transform.translate(1, 1); | 53 transform.translate(1, 1); |
| 54 paintInfo.updateCullRect(transform); | 54 paintInfo.updateCullRect(transform); |
| 55 | 55 |
| 56 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(IntRect(0, 0, 1, 1))); | 56 EXPECT_TRUE(paintInfo.cullRect().intersectsCullRect(IntRect(0, 0, 1, 1))); |
| 57 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(51, 51, 1, 1)))
; | 57 EXPECT_FALSE(paintInfo.cullRect().intersectsCullRect(IntRect(51, 51, 1, 1)))
; |
| 58 } | 58 } |
| 59 | 59 |
| 60 TEST_F(PaintInfoTest, intersectsVerticalRange) | 60 TEST_F(PaintInfoTest, intersectsVerticalRange) |
| 61 { | 61 { |
| 62 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 100), PaintPhaseSelfBlockBa
ckgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); | 62 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 100), PaintPhaseSelfBlockBa
ckgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); |
| 63 | 63 |
| 64 EXPECT_TRUE(paintInfo.cullRect().intersectsVerticalRange(0, 1)); | 64 EXPECT_TRUE(paintInfo.cullRect().intersectsVerticalRange(LayoutUnit(0), Layo
utUnit(1))); |
| 65 EXPECT_FALSE(paintInfo.cullRect().intersectsVerticalRange(100, 101)); | 65 EXPECT_FALSE(paintInfo.cullRect().intersectsVerticalRange(LayoutUnit(100), L
ayoutUnit(101))); |
| 66 } | 66 } |
| 67 | 67 |
| 68 TEST_F(PaintInfoTest, intersectsHorizontalRange) | 68 TEST_F(PaintInfoTest, intersectsHorizontalRange) |
| 69 { | 69 { |
| 70 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 100), PaintPhaseSelfBlockBa
ckgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); | 70 PaintInfo paintInfo(m_context, IntRect(0, 0, 50, 100), PaintPhaseSelfBlockBa
ckgroundOnly, GlobalPaintNormalPhase, PaintLayerNoFlag); |
| 71 | 71 |
| 72 EXPECT_TRUE(paintInfo.cullRect().intersectsHorizontalRange(0, 1)); | 72 EXPECT_TRUE(paintInfo.cullRect().intersectsHorizontalRange(LayoutUnit(0), La
youtUnit(1))); |
| 73 EXPECT_FALSE(paintInfo.cullRect().intersectsHorizontalRange(50, 51)); | 73 EXPECT_FALSE(paintInfo.cullRect().intersectsHorizontalRange(LayoutUnit(50),
LayoutUnit(51))); |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace blink | 76 } // namespace blink |
| OLD | NEW |