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/paint/discardable_image_map.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "cc/base/region.h" | 13 #include "cc/base/region.h" |
14 #include "cc/test/fake_content_layer_client.h" | 14 #include "cc/test/fake_content_layer_client.h" |
15 #include "cc/test/fake_recording_source.h" | 15 #include "cc/test/fake_recording_source.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 visible_rect.size()); | 100 visible_rect.size()); |
101 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); | 101 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
102 } | 102 } |
103 | 103 |
104 for (int y = 0; y < 4; ++y) { | 104 for (int y = 0; y < 4; ++y) { |
105 for (int x = 0; x < 4; ++x) { | 105 for (int x = 0; x < 4; ++x) { |
106 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( | 106 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( |
107 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); | 107 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); |
108 if ((x + y) & 1) { | 108 if ((x + y) & 1) { |
109 EXPECT_EQ(1u, images.size()) << x << " " << y; | 109 EXPECT_EQ(1u, images.size()) << x << " " << y; |
110 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 110 EXPECT_TRUE(images[0].image == discardable_image[y][x]) |
111 << y; | 111 << x << " " << y; |
112 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), | 112 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), |
113 images[0].image_rect); | 113 images[0].image_rect); |
114 EXPECT_EQ(images[0].image_rect, | 114 EXPECT_EQ(images[0].image_rect, |
115 image_map.GetRectForImage(images[0].image->uniqueID())); | 115 image_map.GetRectForImage(images[0].image->uniqueID())); |
116 } else { | 116 } else { |
117 EXPECT_EQ(0u, images.size()) << x << " " << y; | 117 EXPECT_EQ(0u, images.size()) << x << " " << y; |
118 } | 118 } |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 layer_size); | 187 layer_size); |
188 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); | 188 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
189 } | 189 } |
190 | 190 |
191 for (int y = 0; y < 4; ++y) { | 191 for (int y = 0; y < 4; ++y) { |
192 for (int x = 0; x < 4; ++x) { | 192 for (int x = 0; x < 4; ++x) { |
193 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( | 193 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( |
194 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); | 194 image_map, gfx::Rect(1024 + x * 512, y * 512, 500, 500)); |
195 if ((x + y) & 1) { | 195 if ((x + y) & 1) { |
196 EXPECT_EQ(1u, images.size()) << x << " " << y; | 196 EXPECT_EQ(1u, images.size()) << x << " " << y; |
197 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 197 EXPECT_TRUE(images[0].image == discardable_image[y][x]) |
198 << y; | 198 << x << " " << y; |
199 EXPECT_EQ(gfx::Rect(1024 + x * 512 + 6, y * 512 + 6, 500, 500), | 199 EXPECT_EQ(gfx::Rect(1024 + x * 512 + 6, y * 512 + 6, 500, 500), |
200 images[0].image_rect); | 200 images[0].image_rect); |
201 EXPECT_EQ(images[0].image_rect, | 201 EXPECT_EQ(images[0].image_rect, |
202 image_map.GetRectForImage(images[0].image->uniqueID())); | 202 image_map.GetRectForImage(images[0].image->uniqueID())); |
203 } else { | 203 } else { |
204 EXPECT_EQ(0u, images.size()) << x << " " << y; | 204 EXPECT_EQ(0u, images.size()) << x << " " << y; |
205 } | 205 } |
206 } | 206 } |
207 } | 207 } |
208 // Capture 4 pixel refs. | 208 // Capture 4 pixel refs. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 visible_rect.size()); | 303 visible_rect.size()); |
304 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); | 304 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
305 } | 305 } |
306 | 306 |
307 for (int y = 0; y < 4; ++y) { | 307 for (int y = 0; y < 4; ++y) { |
308 for (int x = 0; x < 4; ++x) { | 308 for (int x = 0; x < 4; ++x) { |
309 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( | 309 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( |
310 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); | 310 image_map, gfx::Rect(x * 512 + 256, y * 512 + 256, 1, 1)); |
311 if ((x + y) & 1) { | 311 if ((x + y) & 1) { |
312 EXPECT_EQ(1u, images.size()) << x << " " << y; | 312 EXPECT_EQ(1u, images.size()) << x << " " << y; |
313 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 313 EXPECT_TRUE(images[0].image == discardable_image[y][x]) |
314 << y; | 314 << x << " " << y; |
315 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), | 315 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), |
316 images[0].image_rect); | 316 images[0].image_rect); |
317 EXPECT_EQ(images[0].image_rect, | 317 EXPECT_EQ(images[0].image_rect, |
318 image_map.GetRectForImage(images[0].image->uniqueID())); | 318 image_map.GetRectForImage(images[0].image->uniqueID())); |
319 } else { | 319 } else { |
320 EXPECT_EQ(0u, images.size()) << x << " " << y; | 320 EXPECT_EQ(0u, images.size()) << x << " " << y; |
321 } | 321 } |
322 } | 322 } |
323 } | 323 } |
324 } | 324 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 visible_rect.size()); | 588 visible_rect.size()); |
589 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); | 589 display_list->Raster(generator.canvas(), nullptr, gfx::Rect(), 1.f); |
590 } | 590 } |
591 | 591 |
592 for (int y = 0; y < 4; ++y) { | 592 for (int y = 0; y < 4; ++y) { |
593 for (int x = 0; x < 4; ++x) { | 593 for (int x = 0; x < 4; ++x) { |
594 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( | 594 std::vector<PositionScaleDrawImage> images = GetDiscardableImagesInRect( |
595 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); | 595 image_map, gfx::Rect(x * 512, y * 512, 500, 500)); |
596 if ((x + y) & 1) { | 596 if ((x + y) & 1) { |
597 EXPECT_EQ(1u, images.size()) << x << " " << y; | 597 EXPECT_EQ(1u, images.size()) << x << " " << y; |
598 EXPECT_TRUE(images[0].image == discardable_image[y][x]) << x << " " | 598 EXPECT_TRUE(images[0].image == discardable_image[y][x]) |
599 << y; | 599 << x << " " << y; |
600 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), | 600 EXPECT_EQ(gfx::Rect(x * 512 + 6, y * 512 + 6, 500, 500), |
601 images[0].image_rect); | 601 images[0].image_rect); |
602 EXPECT_EQ(std::max(x * 0.5f, kMinScale), images[0].scale.fWidth); | 602 EXPECT_EQ(std::max(x * 0.5f, kMinScale), images[0].scale.fWidth); |
603 EXPECT_EQ(std::max(y * 0.5f, kMinScale), images[0].scale.fHeight); | 603 EXPECT_EQ(std::max(y * 0.5f, kMinScale), images[0].scale.fHeight); |
604 } else { | 604 } else { |
605 EXPECT_EQ(0u, images.size()) << x << " " << y; | 605 EXPECT_EQ(0u, images.size()) << x << " " << y; |
606 } | 606 } |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
610 // Capture 4 pixel refs. | 610 // Capture 4 pixel refs. |
611 std::vector<PositionScaleDrawImage> images = | 611 std::vector<PositionScaleDrawImage> images = |
612 GetDiscardableImagesInRect(image_map, gfx::Rect(512, 512, 2048, 2048)); | 612 GetDiscardableImagesInRect(image_map, gfx::Rect(512, 512, 2048, 2048)); |
613 EXPECT_EQ(4u, images.size()); | 613 EXPECT_EQ(4u, images.size()); |
614 EXPECT_TRUE(images[0].image == discardable_image[1][2]); | 614 EXPECT_TRUE(images[0].image == discardable_image[1][2]); |
615 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), images[0].image_rect); | 615 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), images[0].image_rect); |
616 EXPECT_TRUE(images[1].image == discardable_image[2][1]); | 616 EXPECT_TRUE(images[1].image == discardable_image[2][1]); |
617 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), images[1].image_rect); | 617 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), images[1].image_rect); |
618 EXPECT_TRUE(images[2].image == discardable_image[2][3]); | 618 EXPECT_TRUE(images[2].image == discardable_image[2][3]); |
619 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500), | 619 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500), |
620 images[2].image_rect); | 620 images[2].image_rect); |
621 EXPECT_TRUE(images[3].image == discardable_image[3][2]); | 621 EXPECT_TRUE(images[3].image == discardable_image[3][2]); |
622 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), | 622 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), |
623 images[3].image_rect); | 623 images[3].image_rect); |
624 } | 624 } |
625 | 625 |
626 } // namespace cc | 626 } // namespace cc |
OLD | NEW |