| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 scoped_refptr<DisplayItemList> display_list = | 89 scoped_refptr<DisplayItemList> display_list = |
| 90 content_layer_client.PaintContentsToDisplayList( | 90 content_layer_client.PaintContentsToDisplayList( |
| 91 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 91 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 92 | 92 |
| 93 DiscardableImageMap image_map; | 93 DiscardableImageMap image_map; |
| 94 { | 94 { |
| 95 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 95 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 96 visible_rect.size()); | 96 visible_rect.size()); |
| 97 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 97 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 98 } | 98 } |
| 99 | 99 |
| 100 for (int y = 0; y < 4; ++y) { | 100 for (int y = 0; y < 4; ++y) { |
| 101 for (int x = 0; x < 4; ++x) { | 101 for (int x = 0; x < 4; ++x) { |
| 102 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 102 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 103 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); | 103 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); |
| 104 if ((x + y) & 1) { | 104 if ((x + y) & 1) { |
| 105 EXPECT_EQ(1u, images.size()) << x << " " << y; | 105 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 106 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 106 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " |
| 107 << y; | 107 << y; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 scoped_refptr<DisplayItemList> display_list = | 162 scoped_refptr<DisplayItemList> display_list = |
| 163 content_layer_client.PaintContentsToDisplayList( | 163 content_layer_client.PaintContentsToDisplayList( |
| 164 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 164 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 165 | 165 |
| 166 DiscardableImageMap image_map; | 166 DiscardableImageMap image_map; |
| 167 { | 167 { |
| 168 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 168 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 169 layer_size); | 169 layer_size); |
| 170 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 170 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 171 } | 171 } |
| 172 | 172 |
| 173 for (int y = 0; y < 4; ++y) { | 173 for (int y = 0; y < 4; ++y) { |
| 174 for (int x = 0; x < 4; ++x) { | 174 for (int x = 0; x < 4; ++x) { |
| 175 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 175 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 176 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); | 176 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); |
| 177 if ((x + y) & 1) { | 177 if ((x + y) & 1) { |
| 178 EXPECT_EQ(1u, images.size()) << x << " " << y; | 178 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 179 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 179 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " |
| 180 << y; | 180 << y; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 256 } |
| 257 | 257 |
| 258 scoped_refptr<DisplayItemList> display_list = | 258 scoped_refptr<DisplayItemList> display_list = |
| 259 content_layer_client.PaintContentsToDisplayList( | 259 content_layer_client.PaintContentsToDisplayList( |
| 260 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 260 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 261 | 261 |
| 262 DiscardableImageMap image_map; | 262 DiscardableImageMap image_map; |
| 263 { | 263 { |
| 264 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 264 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 265 visible_rect.size()); | 265 visible_rect.size()); |
| 266 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 266 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 267 } | 267 } |
| 268 | 268 |
| 269 for (int y = 0; y < 4; ++y) { | 269 for (int y = 0; y < 4; ++y) { |
| 270 for (int x = 0; x < 4; ++x) { | 270 for (int x = 0; x < 4; ++x) { |
| 271 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( | 271 std::vector<PositionDrawImage> images = GetDiscardableImagesInRect( |
| 272 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); | 272 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); |
| 273 if ((x + y) & 1) { | 273 if ((x + y) & 1) { |
| 274 EXPECT_EQ(1u, images.size()) << x << " " << y; | 274 EXPECT_EQ(1u, images.size()) << x << " " << y; |
| 275 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 275 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " |
| 276 << y; | 276 << y; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 295 paint); | 295 paint); |
| 296 | 296 |
| 297 scoped_refptr<DisplayItemList> display_list = | 297 scoped_refptr<DisplayItemList> display_list = |
| 298 content_layer_client.PaintContentsToDisplayList( | 298 content_layer_client.PaintContentsToDisplayList( |
| 299 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 299 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 300 | 300 |
| 301 DiscardableImageMap image_map; | 301 DiscardableImageMap image_map; |
| 302 { | 302 { |
| 303 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, | 303 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map, |
| 304 visible_rect.size()); | 304 visible_rect.size()); |
| 305 display_list->Raster(generator.canvas(), nullptr, visible_rect, 1.f); | 305 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
| 306 } | 306 } |
| 307 std::vector<PositionDrawImage> images = | 307 std::vector<PositionDrawImage> images = |
| 308 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); | 308 GetDiscardableImagesInRect(image_map, gfx::Rect(0, 0, 1, 1)); |
| 309 EXPECT_EQ(1u, images.size()); | 309 EXPECT_EQ(1u, images.size()); |
| 310 EXPECT_TRUE(images[0].image == discardable_image); | 310 EXPECT_TRUE(images[0].image == discardable_image); |
| 311 EXPECT_EQ(gfx::Rect(0, 0, 2048, 2048), images[0].image_rect); | 311 EXPECT_EQ(gfx::Rect(0, 0, 2048, 2048), images[0].image_rect); |
| 312 } | 312 } |
| 313 | 313 |
| 314 TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) { | 314 TEST_F(DiscardableImageMapTest, PaintDestroyedWhileImageIsDrawn) { |
| 315 gfx::Rect visible_rect(2048, 2048); | 315 gfx::Rect visible_rect(2048, 2048); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 images = GetDiscardableImagesInRect(image_map, gfx::Rect(999, 999, 1, 1)); | 452 images = GetDiscardableImagesInRect(image_map, gfx::Rect(999, 999, 1, 1)); |
| 453 EXPECT_EQ(1u, images.size()); | 453 EXPECT_EQ(1u, images.size()); |
| 454 EXPECT_EQ(gfx::Rect(950, 951, 50, 49), images[0].image_rect); | 454 EXPECT_EQ(gfx::Rect(950, 951, 50, 49), images[0].image_rect); |
| 455 | 455 |
| 456 images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1)); | 456 images = GetDiscardableImagesInRect(image_map, gfx::Rect(0, 500, 1, 1)); |
| 457 EXPECT_EQ(1u, images.size()); | 457 EXPECT_EQ(1u, images.size()); |
| 458 EXPECT_EQ(gfx::Rect(0, 500, 1000, 100), images[0].image_rect); | 458 EXPECT_EQ(gfx::Rect(0, 500, 1000, 100), images[0].image_rect); |
| 459 } | 459 } |
| 460 | 460 |
| 461 } // namespace cc | 461 } // namespace cc |
| OLD | NEW |