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

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

Issue 11360066: cc: Remove WebCore rect use from the compositor, except within Region. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Signs 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 | Annotate | Revision Log
« no previous file with comments | « cc/stubs/int_rect.h ('k') | cc/tiled_layer.cc » ('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 "FloatRect.h"
10 #include "Region.h" 9 #include "Region.h"
11 #include "cc/draw_quad.h" 10 #include "cc/draw_quad.h"
12 #include "cc/math_util.h" 11 #include "cc/math_util.h"
13 #include "cc/render_pass.h" 12 #include "cc/render_pass.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
16 #include "ui/gfx/point_conversions.h" 15 #include "ui/gfx/point_conversions.h"
17 #include "ui/gfx/rect_conversions.h" 16 #include "ui/gfx/rect_conversions.h"
18 #include "ui/gfx/size_conversions.h" 17 #include "ui/gfx/size_conversions.h"
19 18
20 namespace LayerTestCommon { 19 namespace LayerTestCommon {
21 20
22 // Align with expected and actual output 21 // Align with expected and actual output
23 const char* quadString = " Quad: "; 22 const char* quadString = " Quad: ";
24 23
25 bool canRectFBeSafelyRoundedToRect(const gfx::RectF& r) 24 bool canRectFBeSafelyRoundedToRect(const gfx::RectF& r)
26 { 25 {
27 // Ensure that range of float values is not beyond integer range. 26 // Ensure that range of float values is not beyond integer range.
28 if (!cc::FloatRect(r).isExpressibleAsIntRect()) 27 if (!r.IsExpressibleAsRect())
29 return false; 28 return false;
30 29
31 // Ensure that the values are actually integers. 30 // Ensure that the values are actually integers.
32 if (gfx::ToFlooredPoint(r.origin()) == r.origin() 31 if (gfx::ToFlooredPoint(r.origin()) == r.origin() && gfx::ToFlooredSize(r.si ze()) == r.size())
33 && gfx::ToFlooredSize(r.size()) == r.size())
34 return true; 32 return true;
35 33
36 return false; 34 return false;
37 } 35 }
38 36
39 void verifyQuadsExactlyCoverRect(const cc::QuadList& quads, 37 void verifyQuadsExactlyCoverRect(const cc::QuadList& quads,
40 const gfx::Rect& rect) { 38 const gfx::Rect& rect) {
41 cc::Region remaining = rect; 39 cc::Region remaining = rect;
42 40
43 for (size_t i = 0; i < quads.size(); ++i) { 41 for (size_t i = 0; i < quads.size(); ++i) {
44 cc::DrawQuad* quad = quads[i]; 42 cc::DrawQuad* quad = quads[i];
45 gfx::RectF quadRectF = cc::MathUtil::mapClippedRect(quad->sharedQuadStat e()->quadTransform, gfx::RectF(quad->quadRect())); 43 gfx::RectF quadRectF = cc::MathUtil::mapClippedRect(quad->sharedQuadStat e()->quadTransform, gfx::RectF(quad->quadRect()));
46 44
47 // Before testing for exact coverage in the integer world, assert that r ounding 45 // Before testing for exact coverage in the integer world, assert that r ounding
48 // will not round the rect incorrectly. 46 // will not round the rect incorrectly.
49 ASSERT_TRUE(canRectFBeSafelyRoundedToRect(quadRectF)); 47 ASSERT_TRUE(canRectFBeSafelyRoundedToRect(quadRectF));
50 48
51 gfx::Rect quadRect = gfx::ToEnclosingRect(quadRectF); 49 gfx::Rect quadRect = gfx::ToEnclosingRect(quadRectF);
52 50
53 EXPECT_TRUE(rect.Contains(quadRect)) << quadString << i; 51 EXPECT_TRUE(rect.Contains(quadRect)) << quadString << i;
54 EXPECT_TRUE(remaining.Contains(quadRect)) << quadString << i; 52 EXPECT_TRUE(remaining.Contains(quadRect)) << quadString << i;
55 remaining.Subtract(quadRect); 53 remaining.Subtract(quadRect);
56 } 54 }
57 55
58 EXPECT_TRUE(remaining.IsEmpty()); 56 EXPECT_TRUE(remaining.IsEmpty());
59 } 57 }
60 58
61 } // namespace LayerTestCommon 59 } // namespace LayerTestCommon
OLDNEW
« no previous file with comments | « cc/stubs/int_rect.h ('k') | cc/tiled_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698