OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/raster/raster_source.h" | 5 #include "cc/raster/raster_source.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Discardable pixel refs are found in the following cells: | 200 // Discardable pixel refs are found in the following cells: |
201 // |---|---| | 201 // |---|---| |
202 // | x | x | | 202 // | x | x | |
203 // |---|---| | 203 // |---|---| |
204 // | | x | | 204 // | | x | |
205 // |---|---| | 205 // |---|---| |
206 recording_source->add_draw_image(discardable_image[0][0], gfx::Point(0, 0)); | 206 recording_source->add_draw_image(discardable_image[0][0], gfx::Point(0, 0)); |
207 recording_source->add_draw_image(discardable_image[0][1], gfx::Point(260, 0)); | 207 recording_source->add_draw_image(discardable_image[0][1], gfx::Point(260, 0)); |
208 recording_source->add_draw_image(discardable_image[1][1], | 208 recording_source->add_draw_image(discardable_image[1][1], |
209 gfx::Point(260, 260)); | 209 gfx::Point(260, 260)); |
210 recording_source->SetGenerateDiscardableImagesMetadata(true); | |
211 recording_source->Rerecord(); | 210 recording_source->Rerecord(); |
212 | 211 |
213 scoped_refptr<RasterSource> raster = | 212 scoped_refptr<RasterSource> raster = |
214 RasterSource::CreateFromRecordingSource(recording_source.get(), false); | 213 RasterSource::CreateFromRecordingSource(recording_source.get(), false); |
215 | 214 |
216 // Tile sized iterators. These should find only one pixel ref. | 215 // Tile sized iterators. These should find only one pixel ref. |
217 { | 216 { |
218 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB(); | 217 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB(); |
219 std::vector<DrawImage> images; | 218 std::vector<DrawImage> images; |
220 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 256, 256), 1.f, | 219 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 256, 256), 1.f, |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 // 3. Draw 4x4 green rects into every corner. | 585 // 3. Draw 4x4 green rects into every corner. |
587 flags.setColor(SK_ColorGREEN); | 586 flags.setColor(SK_ColorGREEN); |
588 recording_source->add_draw_rect_with_flags(gfx::Rect(0, 0, 4, 4), flags); | 587 recording_source->add_draw_rect_with_flags(gfx::Rect(0, 0, 4, 4), flags); |
589 recording_source->add_draw_rect_with_flags( | 588 recording_source->add_draw_rect_with_flags( |
590 gfx::Rect(size.width() - 4, 0, 4, 4), flags); | 589 gfx::Rect(size.width() - 4, 0, 4, 4), flags); |
591 recording_source->add_draw_rect_with_flags( | 590 recording_source->add_draw_rect_with_flags( |
592 gfx::Rect(0, size.height() - 4, 4, 4), flags); | 591 gfx::Rect(0, size.height() - 4, 4, 4), flags); |
593 recording_source->add_draw_rect_with_flags( | 592 recording_source->add_draw_rect_with_flags( |
594 gfx::Rect(size.width() - 4, size.height() - 4, 4, 4), flags); | 593 gfx::Rect(size.width() - 4, size.height() - 4, 4, 4), flags); |
595 | 594 |
596 recording_source->SetGenerateDiscardableImagesMetadata(true); | |
597 recording_source->Rerecord(); | 595 recording_source->Rerecord(); |
598 | 596 |
599 bool can_use_lcd = true; | 597 bool can_use_lcd = true; |
600 scoped_refptr<RasterSource> raster_source = | 598 scoped_refptr<RasterSource> raster_source = |
601 recording_source->CreateRasterSource(can_use_lcd); | 599 recording_source->CreateRasterSource(can_use_lcd); |
602 SoftwareImageDecodeCache controller( | 600 SoftwareImageDecodeCache controller( |
603 ResourceFormat::RGBA_8888, | 601 ResourceFormat::RGBA_8888, |
604 LayerTreeSettings().decoded_image_working_set_budget_bytes); | 602 LayerTreeSettings().decoded_image_working_set_budget_bytes); |
605 raster_source->set_image_decode_cache(&controller); | 603 raster_source->set_image_decode_cache(&controller); |
606 | 604 |
(...skipping 14 matching lines...) Expand all Loading... |
621 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); | 619 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); |
622 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); | 620 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); |
623 for (int x = 0; x < 49; ++x) | 621 for (int x = 0; x < 49; ++x) |
624 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); | 622 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); |
625 for (int y = 0; y < 24; ++y) | 623 for (int y = 0; y < 24; ++y) |
626 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); | 624 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); |
627 } | 625 } |
628 | 626 |
629 } // namespace | 627 } // namespace |
630 } // namespace cc | 628 } // namespace cc |
OLD | NEW |