| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/playback/discardable_image_map.h" | 5 #include "cc/playback/discardable_image_map.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 for (int y = 0; y < 4; ++y) { | 101 for (int y = 0; y < 4; ++y) { |
| 102 for (int x = 0; x < 4; ++x) { | 102 for (int x = 0; x < 4; ++x) { |
| 103 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 103 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 104 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); | 104 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); |
| 105 if ((x + y) & 1) { | 105 if ((x + y) & 1) { |
| 106 EXPECT_EQ(1u, images.size()) << x << " " << y; | 106 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 107 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 107 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " |
| 108 << y; | 108 << y; |
| 109 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), | 109 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), |
| 110 images[0].image_rect); | 110 images[0].image_rect); |
| 111 EXPECT_EQ(Region(images[0].image_rect), |
| 112 image_map.GetRegionForImage(images[0].image->uniqueID())); |
| 111 } else { | 113 } else { |
| 112 EXPECT_EQ(0u, images.size()) << x << " " << y; | 114 EXPECT_EQ(0u, images.size()) << x << " " << y; |
| 113 } | 115 } |
| 114 } | 116 } |
| 115 } | 117 } |
| 116 | 118 |
| 117 // Capture 4 pixel refs. | 119 // Capture 4 pixel refs. |
| 118 std::vector<PositionDrawImage> images = | 120 std::vector<PositionDrawImage> images = |
| 119 GetDiscardableImagesInRect(image_map, gfx::Rect(512, 512, 2048, 2048)); | 121 GetDiscardableImagesInRect(image_map, gfx::Rect(512, 512, 2048, 2048)); |
| 120 EXPECT_EQ(4u, images.size()); | 122 EXPECT_EQ(4u, images.size()); |
| 123 |
| 121 EXPECT_TRUE(images[0].image == discardable_image[1][2]); | 124 EXPECT_TRUE(images[0].image == discardable_image[1][2]); |
| 122 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), images[0].image_rect); | 125 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), images[0].image_rect); |
| 126 EXPECT_EQ(Region(images[0].image_rect), |
| 127 image_map.GetRegionForImage(images[0].image->uniqueID())); |
| 128 |
| 123 EXPECT_TRUE(images[1].image == discardable_image[2][1]); | 129 EXPECT_TRUE(images[1].image == discardable_image[2][1]); |
| 124 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), images[1].image_rect); | 130 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), images[1].image_rect); |
| 131 EXPECT_EQ(Region(images[1].image_rect), |
| 132 image_map.GetRegionForImage(images[1].image->uniqueID())); |
| 133 |
| 125 EXPECT_TRUE(images[2].image == discardable_image[2][3]); | 134 EXPECT_TRUE(images[2].image == discardable_image[2][3]); |
| 126 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500), | 135 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500), |
| 127 images[2].image_rect); | 136 images[2].image_rect); |
| 137 EXPECT_EQ(Region(images[2].image_rect), |
| 138 image_map.GetRegionForImage(images[2].image->uniqueID())); |
| 139 |
| 128 EXPECT_TRUE(images[3].image == discardable_image[3][2]); | 140 EXPECT_TRUE(images[3].image == discardable_image[3][2]); |
| 129 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), | 141 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), |
| 130 images[3].image_rect); | 142 images[3].image_rect); |
| 143 EXPECT_EQ(Region(images[3].image_rect), |
| 144 image_map.GetRegionForImage(images[3].image->uniqueID())); |
| 131 } | 145 } |
| 132 | 146 |
| 133 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectNonZeroLayer) { | 147 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectNonZeroLayer) { |
| 134 gfx::Rect visible_rect(1024, 0, 2048, 2048); | 148 gfx::Rect visible_rect(1024, 0, 2048, 2048); |
| 135 // Make sure visible rect fits into the layer size. | 149 // Make sure visible rect fits into the layer size. |
| 136 gfx::Size layer_size(visible_rect.right(), visible_rect.bottom()); | 150 gfx::Size layer_size(visible_rect.right(), visible_rect.bottom()); |
| 137 FakeContentLayerClient content_layer_client; | 151 FakeContentLayerClient content_layer_client; |
| 138 content_layer_client.set_bounds(layer_size); | 152 content_layer_client.set_bounds(layer_size); |
| 139 | 153 |
| 140 // Discardable pixel refs are found in the following grids: | 154 // Discardable pixel refs are found in the following grids: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 for (int y = 0; y < 4; ++y) { | 188 for (int y = 0; y < 4; ++y) { |
| 175 for (int x = 0; x < 4; ++x) { | 189 for (int x = 0; x < 4; ++x) { |
| 176 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 190 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 177 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); | 191 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); |
| 178 if ((x + y) & 1) { | 192 if ((x + y) & 1) { |
| 179 EXPECT_EQ(1u, images.size()) << x << " " << y; | 193 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 180 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 194 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " |
| 181 << y; | 195 << y; |
| 182 EXPECT_EQ(gfx::Rect(1024 + x * 512 + 6, y * 512 + 6, 500, 500), | 196 EXPECT_EQ(gfx::Rect(1024 + x * 512 + 6, y * 512 + 6, 500, 500), |
| 183 images[0].image_rect); | 197 images[0].image_rect); |
| 198 EXPECT_EQ(Region(images[0].image_rect), |
| 199 image_map.GetRegionForImage(images[0].image->uniqueID())); |
| 184 } else { | 200 } else { |
| 185 EXPECT_EQ(0u, images.size()) << x << " " << y; | 201 EXPECT_EQ(0u, images.size()) << x << " " << y; |
| 186 } | 202 } |
| 187 } | 203 } |
| 188 } | 204 } |
| 189 // Capture 4 pixel refs. | 205 // Capture 4 pixel refs. |
| 190 { | 206 { |
| 191 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 207 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 192 image_map, gfx::Rect(1024 + 512, 512, 2048, 2048)); | 208 image_map, gfx::Rect(1024 + 512, 512, 2048, 2048)); |
| 193 EXPECT_EQ(4u, images.size()); | 209 EXPECT_EQ(4u, images.size()); |
| 210 |
| 194 EXPECT_TRUE(images[0].image == discardable_image[1][2]); | 211 EXPECT_TRUE(images[0].image == discardable_image[1][2]); |
| 195 EXPECT_EQ(gfx::Rect(1024 + 2 * 512 + 6, 512 + 6, 500, 500), | 212 EXPECT_EQ(gfx::Rect(1024 + 2 * 512 + 6, 512 + 6, 500, 500), |
| 196 images[0].image_rect); | 213 images[0].image_rect); |
| 214 EXPECT_EQ(Region(images[0].image_rect), |
| 215 image_map.GetRegionForImage(images[0].image->uniqueID())); |
| 216 |
| 197 EXPECT_TRUE(images[1].image == discardable_image[2][1]); | 217 EXPECT_TRUE(images[1].image == discardable_image[2][1]); |
| 198 EXPECT_EQ(gfx::Rect(1024 + 512 + 6, 2 * 512 + 6, 500, 500), | 218 EXPECT_EQ(gfx::Rect(1024 + 512 + 6, 2 * 512 + 6, 500, 500), |
| 199 images[1].image_rect); | 219 images[1].image_rect); |
| 220 EXPECT_EQ(Region(images[1].image_rect), |
| 221 image_map.GetRegionForImage(images[1].image->uniqueID())); |
| 222 |
| 200 EXPECT_TRUE(images[2].image == discardable_image[2][3]); | 223 EXPECT_TRUE(images[2].image == discardable_image[2][3]); |
| 201 EXPECT_EQ(gfx::Rect(1024 + 3 * 512 + 6, 2 * 512 + 6, 500, 500), | 224 EXPECT_EQ(gfx::Rect(1024 + 3 * 512 + 6, 2 * 512 + 6, 500, 500), |
| 202 images[2].image_rect); | 225 images[2].image_rect); |
| 226 EXPECT_EQ(Region(images[2].image_rect), |
| 227 image_map.GetRegionForImage(images[2].image->uniqueID())); |
| 228 |
| 203 EXPECT_TRUE(images[3].image == discardable_image[3][2]); | 229 EXPECT_TRUE(images[3].image == discardable_image[3][2]); |
| 204 EXPECT_EQ(gfx::Rect(1024 + 2 * 512 + 6, 3 * 512 + 6, 500, 500), | 230 EXPECT_EQ(gfx::Rect(1024 + 2 * 512 + 6, 3 * 512 + 6, 500, 500), |
| 205 images[3].image_rect); | 231 images[3].image_rect); |
| 232 EXPECT_EQ(Region(images[3].image_rect), |
| 233 image_map.GetRegionForImage(images[3].image->uniqueID())); |
| 206 } | 234 } |
| 207 | 235 |
| 208 // Non intersecting rects | 236 // Non intersecting rects |
| 209 { | 237 { |
| 210 std::vector<PositionDrawImage> images = | 238 std::vector<PositionDrawImage> images = |
| 211 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1000, 1000)); | 239 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1000, 1000)); |
| 212 EXPECT_EQ(0u, images.size()); | 240 EXPECT_EQ(0u, images.size()); |
| 213 } | 241 } |
| 214 { | 242 { |
| 215 std::vector<PositionDrawImage> images = | 243 std::vector<PositionDrawImage> images = |
| 216 GetDiscardableImagesInRect(image_map, gfx::Rect(3500, 0, 1000, 1000)); | 244 GetDiscardableImagesInRect(image_map, gfx::Rect(3500, 0, 1000, 1000)); |
| 217 EXPECT_EQ(0u, images.size()); | 245 EXPECT_EQ(0u, images.size()); |
| 218 } | 246 } |
| 219 { | 247 { |
| 220 std::vector<PositionDrawImage> images = | 248 std::vector<PositionDrawImage> images = |
| 221 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 1100, 1000, 1000)); | 249 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 1100, 1000, 1000)); |
| 222 EXPECT_EQ(0u, images.size()); | 250 EXPECT_EQ(0u, images.size()); |
| 223 } | 251 } |
| 224 { | 252 { |
| 225 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 253 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 226 image_map, gfx::Rect(3500, 1100, 1000, 1000)); | 254 image_map, gfx::Rect(3500, 1100, 1000, 1000)); |
| 227 EXPECT_EQ(0u, images.size()); | 255 EXPECT_EQ(0u, images.size()); |
| 228 } | 256 } |
| 257 |
| 258 // Image not present in the list. |
| 259 { |
| 260 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(500, 500)); |
| 261 EXPECT_EQ(Region(), image_map.GetRegionForImage(image->uniqueID())); |
| 262 } |
| 229 } | 263 } |
| 230 | 264 |
| 231 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectOnePixelQuery) { | 265 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectOnePixelQuery) { |
| 232 gfx::Rect visible_rect(2048, 2048); | 266 gfx::Rect visible_rect(2048, 2048); |
| 233 FakeContentLayerClient content_layer_client; | 267 FakeContentLayerClient content_layer_client; |
| 234 content_layer_client.set_bounds(visible_rect.size()); | 268 content_layer_client.set_bounds(visible_rect.size()); |
| 235 | 269 |
| 236 // Discardable pixel refs are found in the following grids: | 270 // Discardable pixel refs are found in the following grids: |
| 237 // |---|---|---|---| | 271 // |---|---|---|---| |
| 238 // | | x | | x | | 272 // | | x | | x | |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 for (int y = 0; y < 4; ++y) { | 304 for (int y = 0; y < 4; ++y) { |
| 271 for (int x = 0; x < 4; ++x) { | 305 for (int x = 0; x < 4; ++x) { |
| 272 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 306 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 273 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); | 307 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); |
| 274 if ((x + y) & 1) { | 308 if ((x + y) & 1) { |
| 275 EXPECT_EQ(1u, images.size()) << x << " " << y; | 309 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 276 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 310 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " |
| 277 << y; | 311 << y; |
| 278 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), | 312 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), |
| 279 images[0].image_rect); | 313 images[0].image_rect); |
| 314 EXPECT_EQ(Region(images[0].image_rect), |
| 315 image_map.GetRegionForImage(images[0].image->uniqueID())); |
| 280 } else { | 316 } else { |
| 281 EXPECT_EQ(0u, images.size()) << x << " " << y; | 317 EXPECT_EQ(0u, images.size()) << x << " " << y; |
| 282 } | 318 } |
| 283 } | 319 } |
| 284 } | 320 } |
| 285 } | 321 } |
| 286 | 322 |
| 287 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMassiveImage) { | 323 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMassiveImage) { |
| 288 gfx::Rect visible_rect(2048, 2048); | 324 gfx::Rect visible_rect(2048, 2048); |
| 289 FakeContentLayerClient content_layer_client; | 325 FakeContentLayerClient content_layer_client; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 303 { | 339 { |
| 304 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 340 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 305 visible_rect.size()); | 341 visible_rect.size()); |
| 306 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); | 342 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 307 } | 343 } |
| 308 std::vector<PositionDrawImage> images = | 344 std::vector<PositionDrawImage> images = |
| 309 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); | 345 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); |
| 310 EXPECT_EQ(1u, images.size()); | 346 EXPECT_EQ(1u, images.size()); |
| 311 EXPECT_TRUE(images[0].image == discardable_image); | 347 EXPECT_TRUE(images[0].image == discardable_image); |
| 312 EXPECT_EQ(gfx::Rect(0, 0, 2048, 2048), images[0].image_rect); | 348 EXPECT_EQ(gfx::Rect(0, 0, 2048, 2048), images[0].image_rect); |
| 349 EXPECT_EQ(Region(images[0].image_rect), |
| 350 image_map.GetRegionForImage(images[0].image->uniqueID())); |
| 313 } | 351 } |
| 314 | 352 |
| 315 TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) { | 353 TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) { |
| 316 gfx::Rect visible_rect(2048, 2048); | 354 gfx::Rect visible_rect(2048, 2048); |
| 317 FakeContentLayerClient content_layer_client; | 355 FakeContentLayerClient content_layer_client; |
| 318 content_layer_client.set_bounds(visible_rect.size()); | 356 content_layer_client.set_bounds(visible_rect.size()); |
| 319 | 357 |
| 320 sk_sp<SkImage> discardable_image = CreateDiscardableImage(gfx::Size(10, 10)); | 358 sk_sp<SkImage> discardable_image = CreateDiscardableImage(gfx::Size(10, 10)); |
| 321 | 359 |
| 322 DiscardableImageMap image_map; | 360 DiscardableImageMap image_map; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 { | 396 { |
| 359 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 397 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 360 visible_rect.size()); | 398 visible_rect.size()); |
| 361 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 399 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); |
| 362 } | 400 } |
| 363 std::vector<PositionDrawImage> images = | 401 std::vector<PositionDrawImage> images = |
| 364 GetDiscardableImagesInRect(image_map, gfx::Rect(42, 42, 1, 1)); | 402 GetDiscardableImagesInRect(image_map, gfx::Rect(42, 42, 1, 1)); |
| 365 EXPECT_EQ(1u, images.size()); | 403 EXPECT_EQ(1u, images.size()); |
| 366 EXPECT_TRUE(images[0].image == discardable_image); | 404 EXPECT_TRUE(images[0].image == discardable_image); |
| 367 EXPECT_EQ(gfx::Rect(42, 42, 2006, 2006), images[0].image_rect); | 405 EXPECT_EQ(gfx::Rect(42, 42, 2006, 2006), images[0].image_rect); |
| 406 EXPECT_EQ(Region(images[0].image_rect), |
| 407 image_map.GetRegionForImage(images[0].image->uniqueID())); |
| 368 } | 408 } |
| 369 | 409 |
| 370 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImageMaxLayer) { | 410 TEST_F(DiscardableImageMapTest, GetDiscardableImagesInRectMaxImageMaxLayer) { |
| 371 // At large values of integer x, x != static_cast<int>(static_cast<float>(x)). | 411 // At large values of integer x, x != static_cast<int>(static_cast<float>(x)). |
| 372 // So, make sure the dimension can be converted back and forth for the | 412 // So, make sure the dimension can be converted back and forth for the |
| 373 // purposes of the unittest. Also, at near max int values, Skia seems to skip | 413 // purposes of the unittest. Also, at near max int values, Skia seems to skip |
| 374 // some draw calls, so we subtract 64 since we only care about "really large" | 414 // some draw calls, so we subtract 64 since we only care about "really large" |
| 375 // values, not necessarily max int values. | 415 // values, not necessarily max int values. |
| 376 int dimension = static_cast<int>( | 416 int dimension = static_cast<int>( |
| 377 static_cast<float>(std::numeric_limits<int>::max() - 64)); | 417 static_cast<float>(std::numeric_limits<int>::max() - 64)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 392 scoped_refptr<DisplayItemList> display_list = | 432 scoped_refptr<DisplayItemList> display_list = |
| 393 content_layer_client.PaintContentsToDisplayList( | 433 content_layer_client.PaintContentsToDisplayList( |
| 394 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 434 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 395 | 435 |
| 396 DiscardableImageMap image_map; | 436 DiscardableImageMap image_map; |
| 397 { | 437 { |
| 398 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 438 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 399 visible_rect.size()); | 439 visible_rect.size()); |
| 400 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 440 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); |
| 401 } | 441 } |
| 442 |
| 443 EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), |
| 444 image_map.GetRegionForImage(discardable_image->uniqueID())); |
| 445 |
| 402 std::vector<PositionDrawImage> images = | 446 std::vector<PositionDrawImage> images = |
| 403 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); | 447 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); |
| 404 EXPECT_EQ(1u, images.size()); | 448 EXPECT_EQ(1u, images.size()); |
| 405 EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), images[0].image_rect); | 449 EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), images[0].image_rect); |
| 406 | 450 |
| 407 images = GetDiscardableImagesInRect(image_map, gfx::Rect(10000, 0, 1, 1)); | 451 images = GetDiscardableImagesInRect(image_map, gfx::Rect(10000, 0, 1, 1)); |
| 408 EXPECT_EQ(2u, images.size()); | 452 EXPECT_EQ(2u, images.size()); |
| 409 EXPECT_EQ(gfx::Rect(10000, 0, dimension - 10000, dimension), | 453 EXPECT_EQ(gfx::Rect(10000, 0, dimension - 10000, dimension), |
| 410 images[1].image_rect); | 454 images[1].image_rect); |
| 411 EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), images[0].image_rect); | 455 EXPECT_EQ(gfx::Rect(0, 0, dimension, dimension), images[0].image_rect); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 EXPECT_EQ(1u, images.size()); | 499 EXPECT_EQ(1u, images.size()); |
| 456 EXPECT_EQ(gfx::Rect(0, 0, 90, 89), images[0].image_rect); | 500 EXPECT_EQ(gfx::Rect(0, 0, 90, 89), images[0].image_rect); |
| 457 | 501 |
| 458 images = GetDiscardableImagesInRect(image_map, gfx::Rect(999, 999, 1, 1)); | 502 images = GetDiscardableImagesInRect(image_map, gfx::Rect(999, 999, 1, 1)); |
| 459 EXPECT_EQ(1u, images.size()); | 503 EXPECT_EQ(1u, images.size()); |
| 460 EXPECT_EQ(gfx::Rect(950, 951, 50, 49), images[0].image_rect); | 504 EXPECT_EQ(gfx::Rect(950, 951, 50, 49), images[0].image_rect); |
| 461 | 505 |
| 462 images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1)); | 506 images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1)); |
| 463 EXPECT_EQ(1u, images.size()); | 507 EXPECT_EQ(1u, images.size()); |
| 464 EXPECT_EQ(gfx::Rect(0, 500, 1000, 100), images[0].image_rect); | 508 EXPECT_EQ(gfx::Rect(0, 500, 1000, 100), images[0].image_rect); |
| 509 |
| 510 Region discardable_image_region; |
| 511 discardable_image_region.Union(gfx::Rect(0, 0, 90, 89)); |
| 512 discardable_image_region.Union(gfx::Rect(950, 951, 50, 49)); |
| 513 EXPECT_EQ(discardable_image_region, |
| 514 image_map.GetRegionForImage(discardable_image->uniqueID())); |
| 515 |
| 516 EXPECT_EQ(Region(gfx::Rect(0, 500, 1000, 100)), |
| 517 image_map.GetRegionForImage(long_discardable_image->uniqueID())); |
| 465 } | 518 } |
| 466 | 519 |
| 467 } // namespace cc | 520 } // namespace cc |
| OLD | NEW |