| 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 "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 recording_source.SetGenerateDiscardableImagesMetadata(true); | 89 recording_source.SetGenerateDiscardableImagesMetadata(true); |
| 90 recording_source.UpdateAndExpandInvalidation( | 90 recording_source.UpdateAndExpandInvalidation( |
| 91 &content_layer_client, &invalidation, visible_rect.size(), visible_rect, | 91 &content_layer_client, &invalidation, visible_rect.size(), visible_rect, |
| 92 1, DisplayListRecordingSource::RECORD_NORMALLY); | 92 1, DisplayListRecordingSource::RECORD_NORMALLY); |
| 93 DisplayItemList* display_list = recording_source.display_list(); | 93 DisplayItemList* display_list = recording_source.display_list(); |
| 94 | 94 |
| 95 DiscardableImageMap image_map; | 95 DiscardableImageMap image_map; |
| 96 { | 96 { |
| 97 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 97 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 98 visible_rect.size()); | 98 visible_rect.size()); |
| 99 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 99 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 100 } | 100 } |
| 101 | 101 |
| 102 for (int y = 0; y < 4; ++y) { | 102 for (int y = 0; y < 4; ++y) { |
| 103 for (int x = 0; x < 4; ++x) { | 103 for (int x = 0; x < 4; ++x) { |
| 104 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 104 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 105 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); | 105 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); |
| 106 if ((x + y) & 1) { | 106 if ((x + y) & 1) { |
| 107 EXPECT_EQ(1u, images.size()) << x << " " << y; | 107 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 108 EXPECT_TRUE(images[0].image == discardable_image[y][x].get()) | 108 EXPECT_TRUE(images[0].image == discardable_image[y][x].get()) |
| 109 << x << " " << y; | 109 << x << " " << y; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 recording_source.SetGenerateDiscardableImagesMetadata(true); | 166 recording_source.SetGenerateDiscardableImagesMetadata(true); |
| 167 recording_source.UpdateAndExpandInvalidation( | 167 recording_source.UpdateAndExpandInvalidation( |
| 168 &content_layer_client, &invalidation, layer_size, visible_rect, 1, | 168 &content_layer_client, &invalidation, layer_size, visible_rect, 1, |
| 169 DisplayListRecordingSource::RECORD_NORMALLY); | 169 DisplayListRecordingSource::RECORD_NORMALLY); |
| 170 DisplayItemList* display_list = recording_source.display_list(); | 170 DisplayItemList* display_list = recording_source.display_list(); |
| 171 | 171 |
| 172 DiscardableImageMap image_map; | 172 DiscardableImageMap image_map; |
| 173 { | 173 { |
| 174 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 174 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 175 layer_size); | 175 layer_size); |
| 176 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 176 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 177 } | 177 } |
| 178 | 178 |
| 179 for (int y = 0; y < 4; ++y) { | 179 for (int y = 0; y < 4; ++y) { |
| 180 for (int x = 0; x < 4; ++x) { | 180 for (int x = 0; x < 4; ++x) { |
| 181 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 181 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 182 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); | 182 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); |
| 183 if ((x + y) & 1) { | 183 if ((x + y) & 1) { |
| 184 EXPECT_EQ(1u, images.size()) << x << " " << y; | 184 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 185 EXPECT_TRUE(images[0].image == discardable_image[y][x].get()) | 185 EXPECT_TRUE(images[0].image == discardable_image[y][x].get()) |
| 186 << x << " " << y; | 186 << x << " " << y; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 recording_source.SetGenerateDiscardableImagesMetadata(true); | 266 recording_source.SetGenerateDiscardableImagesMetadata(true); |
| 267 recording_source.UpdateAndExpandInvalidation( | 267 recording_source.UpdateAndExpandInvalidation( |
| 268 &content_layer_client, &invalidation, visible_rect.size(), visible_rect, | 268 &content_layer_client, &invalidation, visible_rect.size(), visible_rect, |
| 269 1, DisplayListRecordingSource::RECORD_NORMALLY); | 269 1, DisplayListRecordingSource::RECORD_NORMALLY); |
| 270 DisplayItemList* display_list = recording_source.display_list(); | 270 DisplayItemList* display_list = recording_source.display_list(); |
| 271 | 271 |
| 272 DiscardableImageMap image_map; | 272 DiscardableImageMap image_map; |
| 273 { | 273 { |
| 274 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 274 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 275 visible_rect.size()); | 275 visible_rect.size()); |
| 276 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 276 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 277 } | 277 } |
| 278 | 278 |
| 279 for (int y = 0; y < 4; ++y) { | 279 for (int y = 0; y < 4; ++y) { |
| 280 for (int x = 0; x < 4; ++x) { | 280 for (int x = 0; x < 4; ++x) { |
| 281 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 281 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 282 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); | 282 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); |
| 283 if ((x + y) & 1) { | 283 if ((x + y) & 1) { |
| 284 EXPECT_EQ(1u, images.size()) << x << " " << y; | 284 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 285 EXPECT_TRUE(images[0].image == discardable_image[y][x].get()) | 285 EXPECT_TRUE(images[0].image == discardable_image[y][x].get()) |
| 286 << x << " " << y; | 286 << x << " " << y; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 309 recording_source.SetGenerateDiscardableImagesMetadata(true); | 309 recording_source.SetGenerateDiscardableImagesMetadata(true); |
| 310 recording_source.UpdateAndExpandInvalidation( | 310 recording_source.UpdateAndExpandInvalidation( |
| 311 &content_layer_client, &invalidation, visible_rect.size(), visible_rect, | 311 &content_layer_client, &invalidation, visible_rect.size(), visible_rect, |
| 312 1, DisplayListRecordingSource::RECORD_NORMALLY); | 312 1, DisplayListRecordingSource::RECORD_NORMALLY); |
| 313 DisplayItemList* display_list = recording_source.display_list(); | 313 DisplayItemList* display_list = recording_source.display_list(); |
| 314 | 314 |
| 315 DiscardableImageMap image_map; | 315 DiscardableImageMap image_map; |
| 316 { | 316 { |
| 317 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 317 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 318 visible_rect.size()); | 318 visible_rect.size()); |
| 319 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 319 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 320 } | 320 } |
| 321 std::vector<PositionDrawImage> images = | 321 std::vector<PositionDrawImage> images = |
| 322 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); | 322 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); |
| 323 EXPECT_EQ(1u, images.size()); | 323 EXPECT_EQ(1u, images.size()); |
| 324 EXPECT_TRUE(images[0].image == discardable_image.get()); | 324 EXPECT_TRUE(images[0].image == discardable_image.get()); |
| 325 EXPECT_EQ(gfx::Rect(0, 0, 1 << 25, 1 << 25), images[0].image_rect); | 325 EXPECT_EQ(gfx::Rect(0, 0, 1 << 25, 1 << 25), images[0].image_rect); |
| 326 } | 326 } |
| 327 | 327 |
| 328 TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) { | 328 TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) { |
| 329 gfx::Rect visible_rect(2048, 2048); | 329 gfx::Rect visible_rect(2048, 2048); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 346 generator.canvas()->restore(); | 346 generator.canvas()->restore(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 std::vector<PositionDrawImage> images = | 349 std::vector<PositionDrawImage> images = |
| 350 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); | 350 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); |
| 351 EXPECT_EQ(1u, images.size()); | 351 EXPECT_EQ(1u, images.size()); |
| 352 EXPECT_TRUE(images[0].image == discardable_image.get()); | 352 EXPECT_TRUE(images[0].image == discardable_image.get()); |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace cc | 355 } // namespace cc |
| OLD | NEW |