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

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

Issue 385123006: cc: Use ExpandRectIgnoringBordersToTileBoundsWithBordersEmpty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « cc/base/tiling_data.cc ('k') | cc/resources/picture_layer_tiling.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 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 <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
(...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 EXPECT_EQ(gfx::Size(5, 5), data.max_texture_size()); 2126 EXPECT_EQ(gfx::Size(5, 5), data.max_texture_size());
2127 EXPECT_EQ(5, data.num_tiles_x()); 2127 EXPECT_EQ(5, data.num_tiles_x());
2128 EXPECT_EQ(10, data.num_tiles_y()); 2128 EXPECT_EQ(10, data.num_tiles_y());
2129 2129
2130 data.SetMaxTextureSize(gfx::Size(8, 5)); 2130 data.SetMaxTextureSize(gfx::Size(8, 5));
2131 EXPECT_EQ(gfx::Size(8, 5), data.max_texture_size()); 2131 EXPECT_EQ(gfx::Size(8, 5), data.max_texture_size());
2132 EXPECT_EQ(3, data.num_tiles_x()); 2132 EXPECT_EQ(3, data.num_tiles_x());
2133 EXPECT_EQ(10, data.num_tiles_y()); 2133 EXPECT_EQ(10, data.num_tiles_y());
2134 } 2134 }
2135 2135
2136 TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBordersEmpty) { 2136 TEST_P(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsWithBordersEmpty) {
2137 gfx::Point origin = GetParam(); 2137 gfx::Point origin = GetParam();
2138 TilingData empty_total_size( 2138 TilingData empty_total_size(
2139 gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(8, 8)), true); 2139 gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(8, 8)), true);
2140 EXPECT_RECT_EQ( 2140 EXPECT_RECT_EQ(
2141 gfx::Rect(), 2141 gfx::Rect(),
2142 empty_total_size.ExpandRectToTileBoundsWithBorders(gfx::Rect())); 2142 empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
2143 EXPECT_RECT_EQ(gfx::Rect(), 2143 gfx::Rect()));
2144 empty_total_size.ExpandRectToTileBoundsWithBorders( 2144 EXPECT_RECT_EQ(
2145 gfx::Rect(100, 100, 100, 100))); 2145 gfx::Rect(),
2146 EXPECT_RECT_EQ(gfx::Rect(), 2146 empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
2147 empty_total_size.ExpandRectToTileBoundsWithBorders( 2147 gfx::Rect(100, 100, 100, 100)));
2148 gfx::Rect(0, 0, 100, 100))); 2148 EXPECT_RECT_EQ(
2149 gfx::Rect(),
2150 empty_total_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
2151 gfx::Rect(0, 0, 100, 100)));
2149 2152
2150 TilingData empty_max_texture_size( 2153 TilingData empty_max_texture_size(
2151 gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(0, 0)), true); 2154 gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(0, 0)), true);
2152 EXPECT_RECT_EQ( 2155 EXPECT_RECT_EQ(
2153 gfx::Rect(), 2156 gfx::Rect(),
2154 empty_max_texture_size.ExpandRectToTileBoundsWithBorders(gfx::Rect())); 2157 empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
2155 EXPECT_RECT_EQ(gfx::Rect(), 2158 gfx::Rect()));
2156 empty_max_texture_size.ExpandRectToTileBoundsWithBorders( 2159 EXPECT_RECT_EQ(
2157 gfx::Rect(100, 100, 100, 100))); 2160 gfx::Rect(),
2158 EXPECT_RECT_EQ(gfx::Rect(), 2161 empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
2159 empty_max_texture_size.ExpandRectToTileBoundsWithBorders( 2162 gfx::Rect(100, 100, 100, 100)));
2160 gfx::Rect(0, 0, 100, 100))); 2163 EXPECT_RECT_EQ(
2164 gfx::Rect(),
2165 empty_max_texture_size.ExpandRectIgnoringBordersToTileBoundsWithBorders(
2166 gfx::Rect(0, 0, 100, 100)));
2161 } 2167 }
2162 2168
2163 TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBorders) { 2169 TEST_P(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsWithBorders) {
2164 gfx::Point origin = GetParam(); 2170 gfx::Point origin = GetParam();
2165 TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true); 2171 TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true);
2166 2172
2167 // Small rect at origin rounds up to tile 0, 0. 2173 // Small rect at origin rounds up to tile 0, 0.
2168 gfx::Rect at_origin_src(origin, gfx::Size(1, 1)); 2174 gfx::Rect at_origin_src(origin, gfx::Size(1, 1));
2169 gfx::Rect at_origin_result(data.TileBoundsWithBorder(0, 0)); 2175 gfx::Rect at_origin_result(data.TileBoundsWithBorder(0, 0));
2170 EXPECT_NE(at_origin_src, at_origin_result); 2176 EXPECT_NE(at_origin_src, at_origin_result);
2171 EXPECT_RECT_EQ(at_origin_result, 2177 EXPECT_RECT_EQ(
2172 data.ExpandRectToTileBoundsWithBorders(at_origin_src)); 2178 at_origin_result,
2179 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(at_origin_src));
2173 2180
2174 // Arbitrary internal rect. 2181 // Arbitrary internal rect.
2175 gfx::Rect rect_src(origin.x() + 6, origin.y() + 6, 1, 3); 2182 gfx::Rect rect_src(origin.x() + 6, origin.y() + 6, 1, 3);
2176 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4) 2183 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
2177 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4) 2184 // Tile 2, 3 => gfx::Rect(4, 6, 4, 4)
2178 gfx::Rect rect_result(gfx::UnionRects(data.TileBoundsWithBorder(2, 2), 2185 gfx::Rect rect_result(gfx::UnionRects(data.TileBoundsWithBorder(2, 2),
2179 data.TileBoundsWithBorder(3, 4))); 2186 data.TileBoundsWithBorder(2, 3)));
2180 EXPECT_NE(rect_src, rect_result); 2187 EXPECT_NE(rect_src, rect_result);
2181 EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBoundsWithBorders(rect_src)); 2188 EXPECT_RECT_EQ(
2189 rect_result,
2190 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(rect_src));
2182 2191
2183 // On tile bounds rounds up to next tile (since border overlaps). 2192 // On tile bounds does not round up to next tile (ignores the border).
2184 gfx::Rect border_rect_src( 2193 gfx::Rect border_rect_src(
2185 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4))); 2194 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
2186 gfx::Rect border_rect_result(gfx::UnionRects( 2195 gfx::Rect border_rect_result(gfx::UnionRects(
2187 data.TileBoundsWithBorder(0, 1), data.TileBoundsWithBorder(4, 5))); 2196 data.TileBoundsWithBorder(1, 2), data.TileBoundsWithBorder(3, 4)));
2188 EXPECT_RECT_EQ(border_rect_result, 2197 EXPECT_RECT_EQ(
2189 data.ExpandRectToTileBoundsWithBorders(border_rect_src)); 2198 border_rect_result,
2199 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(border_rect_src));
2190 2200
2191 // Equal to tiling rect. 2201 // Equal to tiling rect.
2192 EXPECT_RECT_EQ(data.tiling_rect(), 2202 EXPECT_RECT_EQ(data.tiling_rect(),
2193 data.ExpandRectToTileBoundsWithBorders(data.tiling_rect())); 2203 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(
2204 data.tiling_rect()));
2194 2205
2195 // Containing, but larger than tiling rect. 2206 // Containing, but larger than tiling rect.
2196 EXPECT_RECT_EQ(data.tiling_rect(), 2207 EXPECT_RECT_EQ(data.tiling_rect(),
2197 data.ExpandRectToTileBoundsWithBorders( 2208 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(
2198 gfx::Rect(origin, gfx::Size(100, 100)))); 2209 gfx::Rect(origin, gfx::Size(100, 100))));
2199 2210
2200 // Non-intersecting with tiling rect. 2211 // Non-intersecting with tiling rect.
2201 gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100); 2212 gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100);
2202 EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect())); 2213 EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect()));
2203 EXPECT_RECT_EQ(gfx::Rect(), 2214 EXPECT_RECT_EQ(
2204 data.ExpandRectToTileBoundsWithBorders(non_intersect)); 2215 gfx::Rect(),
2216 data.ExpandRectIgnoringBordersToTileBoundsWithBorders(non_intersect));
2205 2217
2206 TilingData data2(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(32, 64)), true); 2218 TilingData data2(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(32, 64)), true);
2207 2219
2208 // Inside other tile border texels doesn't include other tiles. 2220 // Inside other tile border texels doesn't include other tiles.
2209 gfx::Rect inner_rect_src(data2.TileBounds(1, 1)); 2221 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
2210 inner_rect_src.Inset(data2.border_texels(), data.border_texels()); 2222 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
2211 gfx::Rect inner_rect_result(data2.TileBoundsWithBorder(1, 1)); 2223 gfx::Rect inner_rect_result(data2.TileBoundsWithBorder(1, 1));
2212 gfx::Rect expanded = data2.ExpandRectToTileBoundsWithBorders(inner_rect_src); 2224 gfx::Rect expanded =
2225 data2.ExpandRectIgnoringBordersToTileBoundsWithBorders(inner_rect_src);
2213 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString()); 2226 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
2214 } 2227 }
2215 2228
2216 TEST_P(TilingDataTest, ExpandRectToTileBounds) { 2229 TEST_P(TilingDataTest, ExpandRectToTileBounds) {
2217 gfx::Point origin = GetParam(); 2230 gfx::Point origin = GetParam();
2218 TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true); 2231 TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true);
2219 2232
2220 // Small rect at origin rounds up to tile 0, 0. 2233 // Small rect at origin rounds up to tile 0, 0.
2221 gfx::Rect at_origin_src(origin, gfx::Size(1, 1)); 2234 gfx::Rect at_origin_src(origin, gfx::Size(1, 1));
2222 gfx::Rect at_origin_result(data.TileBounds(0, 0)); 2235 gfx::Rect at_origin_result(data.TileBounds(0, 0));
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 TilingDataTest, 3563 TilingDataTest,
3551 ::testing::Values(gfx::Point(42, 17), 3564 ::testing::Values(gfx::Point(42, 17),
3552 gfx::Point(0, 0), 3565 gfx::Point(0, 0),
3553 gfx::Point(-8, 15), 3566 gfx::Point(-8, 15),
3554 gfx::Point(-12, 4), 3567 gfx::Point(-12, 4),
3555 gfx::Point(-16, -35), 3568 gfx::Point(-16, -35),
3556 gfx::Point(-10000, -15000))); 3569 gfx::Point(-10000, -15000)));
3557 } // namespace 3570 } // namespace
3558 3571
3559 } // namespace cc 3572 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/tiling_data.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698