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

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

Issue 294163009: cc: Expand invalidation to full tile when recording is missing for the tile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pictureslow: don't change region while iterating it Created 6 years, 6 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/layers/picture_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 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 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 // Containing, but larger than tiling rect. 2195 // Containing, but larger than tiling rect.
2196 EXPECT_RECT_EQ(data.tiling_rect(), 2196 EXPECT_RECT_EQ(data.tiling_rect(),
2197 data.ExpandRectToTileBoundsWithBorders( 2197 data.ExpandRectToTileBoundsWithBorders(
2198 gfx::Rect(origin, gfx::Size(100, 100)))); 2198 gfx::Rect(origin, gfx::Size(100, 100))));
2199 2199
2200 // Non-intersecting with tiling rect. 2200 // Non-intersecting with tiling rect.
2201 gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100); 2201 gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100);
2202 EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect())); 2202 EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect()));
2203 EXPECT_RECT_EQ(gfx::Rect(), 2203 EXPECT_RECT_EQ(gfx::Rect(),
2204 data.ExpandRectToTileBoundsWithBorders(non_intersect)); 2204 data.ExpandRectToTileBoundsWithBorders(non_intersect));
2205
2206 TilingData data2(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(32, 64)), true);
2207
2208 // Inside other tile border texels doesn't include other tiles.
2209 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
2210 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
2211 gfx::Rect inner_rect_result(data2.TileBoundsWithBorder(1, 1));
2212 gfx::Rect expanded = data2.ExpandRectToTileBoundsWithBorders(inner_rect_src);
2213 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
2214 }
2215
2216 TEST_P(TilingDataTest, ExpandRectToTileBounds) {
2217 gfx::Point origin = GetParam();
2218 TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true);
2219
2220 // Small rect at origin rounds up to tile 0, 0.
2221 gfx::Rect at_origin_src(origin, gfx::Size(1, 1));
2222 gfx::Rect at_origin_result(data.TileBounds(0, 0));
2223 EXPECT_NE(at_origin_src, at_origin_result);
2224 EXPECT_RECT_EQ(at_origin_result, data.ExpandRectToTileBounds(at_origin_src));
2225
2226 // Arbitrary internal rect.
2227 gfx::Rect rect_src(origin.x() + 6, origin.y() + 6, 1, 3);
2228 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
2229 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4)
2230 gfx::Rect rect_result(
2231 gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(3, 4)));
2232 EXPECT_NE(rect_src, rect_result);
2233 EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBounds(rect_src));
2234
2235 // On tile bounds rounds up to next tile (since border overlaps).
2236 gfx::Rect border_rect_src(
2237 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
2238 gfx::Rect border_rect_result(
2239 gfx::UnionRects(data.TileBounds(0, 1), data.TileBounds(4, 5)));
2240 EXPECT_RECT_EQ(border_rect_result,
2241 data.ExpandRectToTileBounds(border_rect_src));
2242
2243 // Equal to tiling rect.
2244 EXPECT_RECT_EQ(data.tiling_rect(),
2245 data.ExpandRectToTileBounds(data.tiling_rect()));
2246
2247 // Containing, but larger than tiling rect.
2248 EXPECT_RECT_EQ(
2249 data.tiling_rect(),
2250 data.ExpandRectToTileBounds(gfx::Rect(origin, gfx::Size(100, 100))));
2251
2252 // Non-intersecting with tiling rect.
2253 gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100);
2254 EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect()));
2255 EXPECT_RECT_EQ(gfx::Rect(), data.ExpandRectToTileBounds(non_intersect));
2256
2257 TilingData data2(gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(32, 64)), true);
2258
2259 // Inside other tile border texels doesn't include other tiles.
2260 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
2261 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
2262 gfx::Rect inner_rect_result(data2.TileBounds(1, 1));
2263 gfx::Rect expanded = data2.ExpandRectToTileBounds(inner_rect_src);
2264 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
2205 } 2265 }
2206 2266
2207 TEST_P(TilingDataTest, Assignment) { 2267 TEST_P(TilingDataTest, Assignment) {
2208 gfx::Point origin = GetParam(); 2268 gfx::Point origin = GetParam();
2209 2269
2210 { 2270 {
2211 TilingData source( 2271 TilingData source(
2212 gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(16, 32)), true); 2272 gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(16, 32)), true);
2213 TilingData dest = source; 2273 TilingData dest = source;
2214 EXPECT_EQ(source.border_texels(), dest.border_texels()); 2274 EXPECT_EQ(source.border_texels(), dest.border_texels());
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 TilingDataTest, 3550 TilingDataTest,
3491 ::testing::Values(gfx::Point(42, 17), 3551 ::testing::Values(gfx::Point(42, 17),
3492 gfx::Point(0, 0), 3552 gfx::Point(0, 0),
3493 gfx::Point(-8, 15), 3553 gfx::Point(-8, 15),
3494 gfx::Point(-12, 4), 3554 gfx::Point(-12, 4),
3495 gfx::Point(-16, -35), 3555 gfx::Point(-16, -35),
3496 gfx::Point(-10000, -15000))); 3556 gfx::Point(-10000, -15000)));
3497 } // namespace 3557 } // namespace
3498 3558
3499 } // namespace cc 3559 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/tiling_data.cc ('k') | cc/layers/picture_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698