| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 | 6 |
| 7 #include "cc/test/layer_test_common.h" | 7 #include "cc/test/layer_test_common.h" |
| 8 | 8 |
| 9 #include "FloatRect.h" |
| 9 #include "Region.h" | 10 #include "Region.h" |
| 10 #include "cc/draw_quad.h" | 11 #include "cc/draw_quad.h" |
| 11 #include "cc/math_util.h" | 12 #include "cc/math_util.h" |
| 12 #include "cc/render_pass.h" | 13 #include "cc/render_pass.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 15 #include "ui/gfx/point_conversions.h" | 16 #include "ui/gfx/point_conversions.h" |
| 16 #include "ui/gfx/rect_conversions.h" | 17 #include "ui/gfx/rect_conversions.h" |
| 17 #include "ui/gfx/size_conversions.h" | 18 #include "ui/gfx/size_conversions.h" |
| 18 | 19 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 // Ensure that the values are actually integers. | 31 // Ensure that the values are actually integers. |
| 31 if (gfx::ToFlooredPoint(r.origin()) == r.origin() | 32 if (gfx::ToFlooredPoint(r.origin()) == r.origin() |
| 32 && gfx::ToFlooredSize(r.size()) == r.size()) | 33 && gfx::ToFlooredSize(r.size()) == r.size()) |
| 33 return true; | 34 return true; |
| 34 | 35 |
| 35 return false; | 36 return false; |
| 36 } | 37 } |
| 37 | 38 |
| 38 void verifyQuadsExactlyCoverRect(const cc::QuadList& quads, | 39 void verifyQuadsExactlyCoverRect(const cc::QuadList& quads, |
| 39 const gfx::Rect& rect) { | 40 const gfx::Rect& rect) { |
| 40 cc::Region remaining = cc::IntRect(rect); | 41 cc::Region remaining = rect; |
| 41 | 42 |
| 42 for (size_t i = 0; i < quads.size(); ++i) { | 43 for (size_t i = 0; i < quads.size(); ++i) { |
| 43 cc::DrawQuad* quad = quads[i]; | 44 cc::DrawQuad* quad = quads[i]; |
| 44 gfx::RectF quadRectF = cc::MathUtil::mapClippedRect(quad->sharedQuadStat
e()->quadTransform, gfx::RectF(quad->quadRect())); | 45 gfx::RectF quadRectF = cc::MathUtil::mapClippedRect(quad->sharedQuadStat
e()->quadTransform, gfx::RectF(quad->quadRect())); |
| 45 | 46 |
| 46 // Before testing for exact coverage in the integer world, assert that r
ounding | 47 // Before testing for exact coverage in the integer world, assert that r
ounding |
| 47 // will not round the rect incorrectly. | 48 // will not round the rect incorrectly. |
| 48 ASSERT_TRUE(canRectFBeSafelyRoundedToRect(quadRectF)); | 49 ASSERT_TRUE(canRectFBeSafelyRoundedToRect(quadRectF)); |
| 49 | 50 |
| 50 gfx::Rect quadRect = gfx::ToEnclosingRect(quadRectF); | 51 gfx::Rect quadRect = gfx::ToEnclosingRect(quadRectF); |
| 51 | 52 |
| 52 EXPECT_TRUE(rect.Contains(quadRect)) << quadString << i; | 53 EXPECT_TRUE(rect.Contains(quadRect)) << quadString << i; |
| 53 EXPECT_TRUE(remaining.contains(cc::IntRect(quadRect))) << quadString <<
i; | 54 EXPECT_TRUE(remaining.Contains(quadRect)) << quadString << i; |
| 54 remaining.subtract(cc::IntRect(quadRect)); | 55 remaining.Subtract(quadRect); |
| 55 } | 56 } |
| 56 | 57 |
| 57 EXPECT_TRUE(remaining.isEmpty()); | 58 EXPECT_TRUE(remaining.IsEmpty()); |
| 58 } | 59 } |
| 59 | 60 |
| 60 } // namespace LayerTestCommon | 61 } // namespace LayerTestCommon |
| OLD | NEW |