Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: cc/test/layer_test_common.cc

Issue 11017044: Remove root layer specialness in calculateDrawTransforms (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added assertion that rounding does not affect exact coverage testing Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | cc/test/layer_tree_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/draw_quad.h" 9 #include "cc/draw_quad.h"
10 #include "cc/math_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace LayerTestCommon { 13 namespace LayerTestCommon {
13 14
14 // Align with expected and actual output 15 // Align with expected and actual output
15 const char* quadString = " Quad: "; 16 const char* quadString = " Quad: ";
16 17
18 bool floatRectCanBeSafelyRoundedToIntRect(const cc::FloatRect& r)
19 {
20 // Ensure that range of float values is not beyond integer range.
21 if (!r.isExpressibleAsIntRect())
22 return false;
23
24 // Ensure that the values are actually integers.
25 if (floorf(r.x()) == r.x()
26 && floorf(r.y()) == r.y()
27 && floorf(r.width()) == r.width()
28 && floorf(r.height()) == r.height())
29 return true;
30
31 return false;
32 }
33
17 void verifyQuadsExactlyCoverRect(const cc::QuadList& quads, 34 void verifyQuadsExactlyCoverRect(const cc::QuadList& quads,
18 const cc::IntRect& rect) { 35 const cc::IntRect& rect) {
19 cc::Region remaining(rect); 36 cc::Region remaining(rect);
20 37
21 for (size_t i = 0; i < quads.size(); ++i) { 38 for (size_t i = 0; i < quads.size(); ++i) {
22 cc::DrawQuad* quad = quads[i]; 39 cc::DrawQuad* quad = quads[i];
23 cc::IntRect quadRect = cc::IntRect(quad->quadRect()); 40 cc::FloatRect floatQuadRect = cc::MathUtil::mapClippedRect(quad->sharedQ uadState()->quadTransform, cc::FloatRect(quad->quadRect()));
41
42 // Before testing for exact coverage in the integer world, assert that r ounding
43 // will not round the rect incorrectly.
44 ASSERT_TRUE(floatRectCanBeSafelyRoundedToIntRect(floatQuadRect));
45
46 cc::IntRect quadRect = enclosingIntRect(floatQuadRect);
24 47
25 EXPECT_TRUE(rect.contains(quadRect)) << quadString << i; 48 EXPECT_TRUE(rect.contains(quadRect)) << quadString << i;
26 EXPECT_TRUE(remaining.contains(quadRect)) << quadString << i; 49 EXPECT_TRUE(remaining.contains(quadRect)) << quadString << i;
27 remaining.subtract(cc::Region(quadRect)); 50 remaining.subtract(cc::Region(quadRect));
28 } 51 }
29 52
30 EXPECT_TRUE(remaining.isEmpty()); 53 EXPECT_TRUE(remaining.isEmpty());
31 } 54 }
32 55
33 } // namespace LayerTestCommon 56 } // namespace LayerTestCommon
OLDNEW
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | cc/test/layer_tree_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698