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