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

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

Issue 93663004: [#2] Pass gfx structs by const ref (gfx::Rect, gfx::RectF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT, fix builds on non-linux platforms! Created 6 years, 11 months 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/test/layer_test_common.h ('k') | cc/test/layer_tree_pixel_test.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 "cc/test/layer_test_common.h" 5 #include "cc/test/layer_test_common.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/base/region.h" 8 #include "cc/base/region.h"
9 #include "cc/quads/draw_quad.h" 9 #include "cc/quads/draw_quad.h"
10 #include "cc/quads/render_pass.h" 10 #include "cc/quads/render_pass.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/gfx/point_conversions.h" 12 #include "ui/gfx/point_conversions.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/rect_conversions.h" 14 #include "ui/gfx/rect_conversions.h"
15 #include "ui/gfx/size_conversions.h" 15 #include "ui/gfx/size_conversions.h"
16 16
17 namespace cc { 17 namespace cc {
18 18
19 // Align with expected and actual output. 19 // Align with expected and actual output.
20 const char* LayerTestCommon::quad_string = " Quad: "; 20 const char* LayerTestCommon::quad_string = " Quad: ";
21 21
22 static bool CanRectFBeSafelyRoundedToRect(gfx::RectF r) { 22 static bool CanRectFBeSafelyRoundedToRect(const gfx::RectF& r) {
23 // Ensure that range of float values is not beyond integer range. 23 // Ensure that range of float values is not beyond integer range.
24 if (!r.IsExpressibleAsRect()) 24 if (!r.IsExpressibleAsRect())
25 return false; 25 return false;
26 26
27 // Ensure that the values are actually integers. 27 // Ensure that the values are actually integers.
28 if (gfx::ToFlooredPoint(r.origin()) == r.origin() && 28 if (gfx::ToFlooredPoint(r.origin()) == r.origin() &&
29 gfx::ToFlooredSize(r.size()) == r.size()) 29 gfx::ToFlooredSize(r.size()) == r.size())
30 return true; 30 return true;
31 31
32 return false; 32 return false;
33 } 33 }
34 34
35 void LayerTestCommon::VerifyQuadsExactlyCoverRect(const QuadList& quads, 35 void LayerTestCommon::VerifyQuadsExactlyCoverRect(const QuadList& quads,
36 gfx::Rect rect) { 36 const gfx::Rect& rect) {
37 Region remaining = rect; 37 Region remaining = rect;
38 38
39 for (size_t i = 0; i < quads.size(); ++i) { 39 for (size_t i = 0; i < quads.size(); ++i) {
40 DrawQuad* quad = quads[i]; 40 DrawQuad* quad = quads[i];
41 gfx::RectF quad_rectf = 41 gfx::RectF quad_rectf =
42 MathUtil::MapClippedRect(quad->quadTransform(), gfx::RectF(quad->rect)); 42 MathUtil::MapClippedRect(quad->quadTransform(), gfx::RectF(quad->rect));
43 43
44 // Before testing for exact coverage in the integer world, assert that 44 // Before testing for exact coverage in the integer world, assert that
45 // rounding will not round the rect incorrectly. 45 // rounding will not round the rect incorrectly.
46 ASSERT_TRUE(CanRectFBeSafelyRoundedToRect(quad_rectf)); 46 ASSERT_TRUE(CanRectFBeSafelyRoundedToRect(quad_rectf));
47 47
48 gfx::Rect quad_rect = gfx::ToEnclosingRect(quad_rectf); 48 gfx::Rect quad_rect = gfx::ToEnclosingRect(quad_rectf);
49 49
50 EXPECT_TRUE(rect.Contains(quad_rect)) << quad_string << i; 50 EXPECT_TRUE(rect.Contains(quad_rect)) << quad_string << i;
51 EXPECT_TRUE(remaining.Contains(quad_rect)) << quad_string << i; 51 EXPECT_TRUE(remaining.Contains(quad_rect)) << quad_string << i;
52 remaining.Subtract(quad_rect); 52 remaining.Subtract(quad_rect);
53 } 53 }
54 54
55 EXPECT_TRUE(remaining.IsEmpty()); 55 EXPECT_TRUE(remaining.IsEmpty());
56 } 56 }
57 57
58 } // namespace cc 58 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_test_common.h ('k') | cc/test/layer_tree_pixel_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698