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

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

Issue 240593004: cc: Fix missing compositor invalidations during resize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid assertion on empty bounds Created 6 years, 8 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) {
2137 gfx::Point origin = GetParam();
2138 TilingData empty_total_size(
2139 gfx::Size(0, 0), gfx::Rect(origin, gfx::Size(8, 8)), true);
2140 EXPECT_RECT_EQ(
2141 gfx::Rect(),
2142 empty_total_size.ExpandRectToTileBoundsWithBorders(gfx::Rect()));
2143 EXPECT_RECT_EQ(gfx::Rect(),
2144 empty_total_size.ExpandRectToTileBoundsWithBorders(
2145 gfx::Rect(100, 100, 100, 100)));
2146 EXPECT_RECT_EQ(gfx::Rect(),
2147 empty_total_size.ExpandRectToTileBoundsWithBorders(
2148 gfx::Rect(0, 0, 100, 100)));
2149
2150 TilingData empty_max_texture_size(
2151 gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(0, 0)), true);
2152 EXPECT_RECT_EQ(
2153 gfx::Rect(),
2154 empty_max_texture_size.ExpandRectToTileBoundsWithBorders(gfx::Rect()));
2155 EXPECT_RECT_EQ(gfx::Rect(),
2156 empty_max_texture_size.ExpandRectToTileBoundsWithBorders(
2157 gfx::Rect(100, 100, 100, 100)));
2158 EXPECT_RECT_EQ(gfx::Rect(),
2159 empty_max_texture_size.ExpandRectToTileBoundsWithBorders(
2160 gfx::Rect(0, 0, 100, 100)));
2161 }
2162
2163 TEST_P(TilingDataTest, ExpandRectToTileBoundsWithBorders) {
2164 gfx::Point origin = GetParam();
2165 TilingData data(gfx::Size(4, 4), gfx::Rect(origin, gfx::Size(16, 32)), true);
2166
2167 // Small rect at origin rounds up to tile 0, 0.
2168 gfx::Rect at_origin_src(origin, gfx::Size(1, 1));
2169 gfx::Rect at_origin_result(data.TileBoundsWithBorder(0, 0));
2170 EXPECT_NE(at_origin_src, at_origin_result);
2171 EXPECT_RECT_EQ(at_origin_result,
2172 data.ExpandRectToTileBoundsWithBorders(at_origin_src));
2173
2174 // Arbitrary internal rect.
2175 gfx::Rect rect_src(origin.x() + 6, origin.y() + 6, 1, 3);
2176 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
2177 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4)
2178 gfx::Rect rect_result(gfx::UnionRects(data.TileBoundsWithBorder(2, 2),
2179 data.TileBoundsWithBorder(3, 4)));
2180 EXPECT_NE(rect_src, rect_result);
2181 EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBoundsWithBorders(rect_src));
2182
2183 // On tile bounds rounds up to next tile (since border overlaps).
2184 gfx::Rect border_rect_src(
2185 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
2186 gfx::Rect border_rect_result(gfx::UnionRects(
2187 data.TileBoundsWithBorder(0, 1), data.TileBoundsWithBorder(4, 5)));
2188 EXPECT_RECT_EQ(border_rect_result,
2189 data.ExpandRectToTileBoundsWithBorders(border_rect_src));
2190
2191 // Equal to tiling rect.
2192 EXPECT_RECT_EQ(data.tiling_rect(),
2193 data.ExpandRectToTileBoundsWithBorders(data.tiling_rect()));
2194
2195 // Containing, but larger than tiling rect.
2196 EXPECT_RECT_EQ(data.tiling_rect(),
2197 data.ExpandRectToTileBoundsWithBorders(
2198 gfx::Rect(origin, gfx::Size(100, 100))));
2199
2200 // Non-intersecting with tiling rect.
2201 gfx::Rect non_intersect(origin.x() + 200, origin.y() + 200, 100, 100);
2202 EXPECT_FALSE(non_intersect.Intersects(data.tiling_rect()));
2203 EXPECT_RECT_EQ(gfx::Rect(),
2204 data.ExpandRectToTileBoundsWithBorders(non_intersect));
2205 }
2206
2136 TEST_P(TilingDataTest, Assignment) { 2207 TEST_P(TilingDataTest, Assignment) {
2137 gfx::Point origin = GetParam(); 2208 gfx::Point origin = GetParam();
2138 2209
2139 { 2210 {
2140 TilingData source( 2211 TilingData source(
2141 gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(16, 32)), true); 2212 gfx::Size(8, 8), gfx::Rect(origin, gfx::Size(16, 32)), true);
2142 TilingData dest = source; 2213 TilingData dest = source;
2143 EXPECT_EQ(source.border_texels(), dest.border_texels()); 2214 EXPECT_EQ(source.border_texels(), dest.border_texels());
2144 EXPECT_EQ(source.max_texture_size(), dest.max_texture_size()); 2215 EXPECT_EQ(source.max_texture_size(), dest.max_texture_size());
2145 EXPECT_EQ(source.num_tiles_x(), dest.num_tiles_x()); 2216 EXPECT_EQ(source.num_tiles_x(), dest.num_tiles_x());
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 TilingDataTest, 3490 TilingDataTest,
3420 ::testing::Values(gfx::Point(42, 17), 3491 ::testing::Values(gfx::Point(42, 17),
3421 gfx::Point(0, 0), 3492 gfx::Point(0, 0),
3422 gfx::Point(-8, 15), 3493 gfx::Point(-8, 15),
3423 gfx::Point(-12, 4), 3494 gfx::Point(-12, 4),
3424 gfx::Point(-16, -35), 3495 gfx::Point(-16, -35),
3425 gfx::Point(-10000, -15000))); 3496 gfx::Point(-10000, -15000)));
3426 } // namespace 3497 } // namespace
3427 3498
3428 } // namespace cc 3499 } // 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