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

Side by Side Diff: cc/base/tiling_data_unittest.cc

Issue 142863008: Revert of [#7] Pass gfx structs by const ref (gfx::Size) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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/base/tiling_data.cc ('k') | cc/layers/delegated_renderer_layer.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/tiling_data.h" 5 #include "cc/base/tiling_data.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "cc/test/geometry_test_utils.h" 9 #include "cc/test/geometry_test_utils.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace cc { 12 namespace cc {
13 namespace { 13 namespace {
14 14
15 int NumTiles( 15 int NumTiles(
16 const gfx::Size& max_texture_size, 16 gfx::Size max_texture_size,
17 const gfx::Size& total_size, 17 gfx::Size total_size,
18 bool has_border_texels) { 18 bool has_border_texels) {
19 TilingData tiling(max_texture_size, total_size, has_border_texels); 19 TilingData tiling(max_texture_size, total_size, has_border_texels);
20 int num_tiles = tiling.num_tiles_x() * tiling.num_tiles_y(); 20 int num_tiles = tiling.num_tiles_x() * tiling.num_tiles_y();
21 21
22 // Assert no overflow. 22 // Assert no overflow.
23 EXPECT_GE(num_tiles, 0); 23 EXPECT_GE(num_tiles, 0);
24 if (num_tiles > 0) 24 if (num_tiles > 0)
25 EXPECT_EQ(num_tiles / tiling.num_tiles_x(), tiling.num_tiles_y()); 25 EXPECT_EQ(num_tiles / tiling.num_tiles_x(), tiling.num_tiles_y());
26 26
27 return num_tiles; 27 return num_tiles;
28 } 28 }
29 29
30 int XIndex( 30 int XIndex(
31 const gfx::Size& max_texture_size, 31 gfx::Size max_texture_size,
32 const gfx::Size& total_size, 32 gfx::Size total_size,
33 bool has_border_texels, 33 bool has_border_texels,
34 int x_coord) { 34 int x_coord) {
35 TilingData tiling(max_texture_size, total_size, has_border_texels); 35 TilingData tiling(max_texture_size, total_size, has_border_texels);
36 return tiling.TileXIndexFromSrcCoord(x_coord); 36 return tiling.TileXIndexFromSrcCoord(x_coord);
37 } 37 }
38 38
39 int YIndex( 39 int YIndex(
40 const gfx::Size& max_texture_size, 40 gfx::Size max_texture_size,
41 const gfx::Size& total_size, 41 gfx::Size total_size,
42 bool has_border_texels, 42 bool has_border_texels,
43 int y_coord) { 43 int y_coord) {
44 TilingData tiling(max_texture_size, total_size, has_border_texels); 44 TilingData tiling(max_texture_size, total_size, has_border_texels);
45 return tiling.TileYIndexFromSrcCoord(y_coord); 45 return tiling.TileYIndexFromSrcCoord(y_coord);
46 } 46 }
47 47
48 int MinBorderXIndex( 48 int MinBorderXIndex(
49 const gfx::Size& max_texture_size, 49 gfx::Size max_texture_size,
50 const gfx::Size& total_size, 50 gfx::Size total_size,
51 bool has_border_texels, 51 bool has_border_texels,
52 int x_coord) { 52 int x_coord) {
53 TilingData tiling(max_texture_size, total_size, has_border_texels); 53 TilingData tiling(max_texture_size, total_size, has_border_texels);
54 return tiling.FirstBorderTileXIndexFromSrcCoord(x_coord); 54 return tiling.FirstBorderTileXIndexFromSrcCoord(x_coord);
55 } 55 }
56 56
57 int MinBorderYIndex( 57 int MinBorderYIndex(
58 const gfx::Size& max_texture_size, 58 gfx::Size max_texture_size,
59 const gfx::Size& total_size, 59 gfx::Size total_size,
60 bool has_border_texels, 60 bool has_border_texels,
61 int y_coord) { 61 int y_coord) {
62 TilingData tiling(max_texture_size, total_size, has_border_texels); 62 TilingData tiling(max_texture_size, total_size, has_border_texels);
63 return tiling.FirstBorderTileYIndexFromSrcCoord(y_coord); 63 return tiling.FirstBorderTileYIndexFromSrcCoord(y_coord);
64 } 64 }
65 65
66 int MaxBorderXIndex( 66 int MaxBorderXIndex(
67 const gfx::Size& max_texture_size, 67 gfx::Size max_texture_size,
68 const gfx::Size& total_size, 68 gfx::Size total_size,
69 bool has_border_texels, 69 bool has_border_texels,
70 int x_coord) { 70 int x_coord) {
71 TilingData tiling(max_texture_size, total_size, has_border_texels); 71 TilingData tiling(max_texture_size, total_size, has_border_texels);
72 return tiling.LastBorderTileXIndexFromSrcCoord(x_coord); 72 return tiling.LastBorderTileXIndexFromSrcCoord(x_coord);
73 } 73 }
74 74
75 int MaxBorderYIndex( 75 int MaxBorderYIndex(
76 const gfx::Size& max_texture_size, 76 gfx::Size max_texture_size,
77 const gfx::Size& total_size, 77 gfx::Size total_size,
78 bool has_border_texels, 78 bool has_border_texels,
79 int y_coord) { 79 int y_coord) {
80 TilingData tiling(max_texture_size, total_size, has_border_texels); 80 TilingData tiling(max_texture_size, total_size, has_border_texels);
81 return tiling.LastBorderTileYIndexFromSrcCoord(y_coord); 81 return tiling.LastBorderTileYIndexFromSrcCoord(y_coord);
82 } 82 }
83 83
84 int PosX( 84 int PosX(
85 const gfx::Size& max_texture_size, 85 gfx::Size max_texture_size,
86 const gfx::Size& total_size, 86 gfx::Size total_size,
87 bool has_border_texels, 87 bool has_border_texels,
88 int x_index) { 88 int x_index) {
89 TilingData tiling(max_texture_size, total_size, has_border_texels); 89 TilingData tiling(max_texture_size, total_size, has_border_texels);
90 return tiling.TilePositionX(x_index); 90 return tiling.TilePositionX(x_index);
91 } 91 }
92 92
93 int PosY( 93 int PosY(
94 const gfx::Size& max_texture_size, 94 gfx::Size max_texture_size,
95 const gfx::Size& total_size, 95 gfx::Size total_size,
96 bool has_border_texels, 96 bool has_border_texels,
97 int y_index) { 97 int y_index) {
98 TilingData tiling(max_texture_size, total_size, has_border_texels); 98 TilingData tiling(max_texture_size, total_size, has_border_texels);
99 return tiling.TilePositionY(y_index); 99 return tiling.TilePositionY(y_index);
100 } 100 }
101 101
102 int SizeX( 102 int SizeX(
103 const gfx::Size& max_texture_size, 103 gfx::Size max_texture_size,
104 const gfx::Size& total_size, 104 gfx::Size total_size,
105 bool has_border_texels, 105 bool has_border_texels,
106 int x_index) { 106 int x_index) {
107 TilingData tiling(max_texture_size, total_size, has_border_texels); 107 TilingData tiling(max_texture_size, total_size, has_border_texels);
108 return tiling.TileSizeX(x_index); 108 return tiling.TileSizeX(x_index);
109 } 109 }
110 110
111 int SizeY( 111 int SizeY(
112 const gfx::Size& max_texture_size, 112 gfx::Size max_texture_size,
113 const gfx::Size& total_size, 113 gfx::Size total_size,
114 bool has_border_texels, 114 bool has_border_texels,
115 int y_index) { 115 int y_index) {
116 TilingData tiling(max_texture_size, total_size, has_border_texels); 116 TilingData tiling(max_texture_size, total_size, has_border_texels);
117 return tiling.TileSizeY(y_index); 117 return tiling.TileSizeY(y_index);
118 } 118 }
119 119
120 TEST(TilingDataTest, NumTiles_NoTiling) { 120 TEST(TilingDataTest, NumTiles_NoTiling) {
121 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(16, 16), false)); 121 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(16, 16), false));
122 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(15, 15), true)); 122 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(15, 15), true));
123 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(16, 16), true)); 123 EXPECT_EQ(1, NumTiles(gfx::Size(16, 16), gfx::Size(16, 16), true));
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0); 1162 TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0);
1163 } 1163 }
1164 1164
1165 TEST(TilingDataTest, DifferenceIteratorNoTiles) { 1165 TEST(TilingDataTest, DifferenceIteratorNoTiles) {
1166 TilingData data(gfx::Size(100, 100), gfx::Size(), false); 1166 TilingData data(gfx::Size(100, 100), gfx::Size(), false);
1167 TestDiff(data, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 5, 5), 0); 1167 TestDiff(data, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 5, 5), 0);
1168 } 1168 }
1169 1169
1170 } // namespace 1170 } // namespace
1171 } // namespace cc 1171 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/tiling_data.cc ('k') | cc/layers/delegated_renderer_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698