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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "cc/test/fake_picture_pile_impl.h" | 6 #include "cc/test/fake_picture_pile_impl.h" |
7 #include "cc/test/fake_rendering_stats_instrumentation.h" | 7 #include "cc/test/fake_rendering_stats_instrumentation.h" |
8 #include "cc/test/skia_common.h" | 8 #include "cc/test/skia_common.h" |
9 #include "skia/ext/lazy_pixel_ref.h" | 9 #include "skia/ext/lazy_pixel_ref.h" |
10 #include "skia/ext/refptr.h" | 10 #include "skia/ext/refptr.h" |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 // has lazy pixel refs in the following regions: | 658 // has lazy pixel refs in the following regions: |
659 // ||=======|| | 659 // ||=======|| |
660 // ||x| |x|| | 660 // ||x| |x|| |
661 // ||-- --|| | 661 // ||-- --|| |
662 // || |x|| | 662 // || |x|| |
663 // ||=======|| | 663 // ||=======|| |
664 pile->add_draw_bitmap(non_lazy_bitmap, gfx::Point(0, 0)); | 664 pile->add_draw_bitmap(non_lazy_bitmap, gfx::Point(0, 0)); |
665 pile->RerecordPile(); | 665 pile->RerecordPile(); |
666 | 666 |
667 FakeContentLayerClient content_layer_clients[2][2]; | 667 FakeContentLayerClient content_layer_clients[2][2]; |
668 FakeRenderingStatsInstrumentation stats_instrumentation; | |
669 scoped_refptr<Picture> pictures[2][2]; | 668 scoped_refptr<Picture> pictures[2][2]; |
670 for (int y = 0; y < 2; ++y) { | 669 for (int y = 0; y < 2; ++y) { |
671 for (int x = 0; x < 2; ++x) { | 670 for (int x = 0; x < 2; ++x) { |
672 if (x == 0 && y == 1) | 671 if (x == 0 && y == 1) |
673 continue; | 672 continue; |
674 content_layer_clients[y][x].add_draw_bitmap( | 673 content_layer_clients[y][x].add_draw_bitmap( |
675 lazy_bitmap[y][x], | 674 lazy_bitmap[y][x], |
676 gfx::Point(x * 128 + 10, y * 128 + 10)); | 675 gfx::Point(x * 128 + 10, y * 128 + 10)); |
677 pictures[y][x] = Picture::Create( | 676 pictures[y][x] = Picture::Create( |
678 gfx::Rect(x * 128 + 10, y * 128 + 10, 64, 64)); | 677 gfx::Rect(x * 128 + 10, y * 128 + 10, 64, 64)); |
679 pictures[y][x]->Record( | 678 pictures[y][x]->Record( |
680 &content_layer_clients[y][x], | 679 &content_layer_clients[y][x], |
681 tile_grid_info); | 680 tile_grid_info); |
682 pictures[y][x]->GatherPixelRefs(tile_grid_info, &stats_instrumentation); | 681 pictures[y][x]->GatherPixelRefs(tile_grid_info); |
683 pile->AddPictureToRecording(0, 0, pictures[y][x]); | 682 pile->AddPictureToRecording(0, 0, pictures[y][x]); |
684 } | 683 } |
685 } | 684 } |
686 | 685 |
687 // These should find only one pixel ref. | 686 // These should find only one pixel ref. |
688 { | 687 { |
689 PicturePileImpl::PixelRefIterator iterator( | 688 PicturePileImpl::PixelRefIterator iterator( |
690 gfx::Rect(0, 0, 128, 128), 1.0, pile.get()); | 689 gfx::Rect(0, 0, 128, 128), 1.0, pile.get()); |
691 EXPECT_TRUE(iterator); | 690 EXPECT_TRUE(iterator); |
692 EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); | 691 EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 gfx::Rect canvas_rect(content_bounds); | 740 gfx::Rect canvas_rect(content_bounds); |
742 canvas_rect.Inset(0, 0, -1, -1); | 741 canvas_rect.Inset(0, 0, -1, -1); |
743 | 742 |
744 SkBitmap bitmap; | 743 SkBitmap bitmap; |
745 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 744 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
746 canvas_rect.width(), | 745 canvas_rect.width(), |
747 canvas_rect.height()); | 746 canvas_rect.height()); |
748 bitmap.allocPixels(); | 747 bitmap.allocPixels(); |
749 SkCanvas canvas(bitmap); | 748 SkCanvas canvas(bitmap); |
750 | 749 |
751 PicturePileImpl::RasterStats raster_stats; | 750 FakeRenderingStatsInstrumentation rendering_stats_instrumentation; |
| 751 |
752 pile->RasterToBitmap( | 752 pile->RasterToBitmap( |
753 &canvas, canvas_rect, contents_scale, &raster_stats); | 753 &canvas, canvas_rect, contents_scale, &rendering_stats_instrumentation); |
754 | 754 |
755 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels()); | 755 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels()); |
756 int num_pixels = bitmap.width() * bitmap.height(); | 756 int num_pixels = bitmap.width() * bitmap.height(); |
757 for (int i = 0; i < num_pixels; ++i) { | 757 for (int i = 0; i < num_pixels; ++i) { |
758 EXPECT_EQ(SkColorGetA(pixels[i]), 255u); | 758 EXPECT_EQ(SkColorGetA(pixels[i]), 255u); |
759 } | 759 } |
760 } | 760 } |
761 | 761 |
762 TEST(PicturePileImpl, RasterContentsTransparent) { | 762 TEST(PicturePileImpl, RasterContentsTransparent) { |
763 gfx::Size tile_size(1000, 1000); | 763 gfx::Size tile_size(1000, 1000); |
(...skipping 13 matching lines...) Expand all Loading... |
777 gfx::Rect canvas_rect(content_bounds); | 777 gfx::Rect canvas_rect(content_bounds); |
778 canvas_rect.Inset(0, 0, -1, -1); | 778 canvas_rect.Inset(0, 0, -1, -1); |
779 | 779 |
780 SkBitmap bitmap; | 780 SkBitmap bitmap; |
781 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 781 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
782 canvas_rect.width(), | 782 canvas_rect.width(), |
783 canvas_rect.height()); | 783 canvas_rect.height()); |
784 bitmap.allocPixels(); | 784 bitmap.allocPixels(); |
785 SkCanvas canvas(bitmap); | 785 SkCanvas canvas(bitmap); |
786 | 786 |
787 PicturePileImpl::RasterStats raster_stats; | 787 FakeRenderingStatsInstrumentation rendering_stats_instrumentation; |
788 pile->RasterToBitmap( | 788 pile->RasterToBitmap( |
789 &canvas, canvas_rect, contents_scale, &raster_stats); | 789 &canvas, canvas_rect, contents_scale, &rendering_stats_instrumentation); |
790 | 790 |
791 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels()); | 791 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels()); |
792 int num_pixels = bitmap.width() * bitmap.height(); | 792 int num_pixels = bitmap.width() * bitmap.height(); |
793 for (int i = 0; i < num_pixels; ++i) { | 793 for (int i = 0; i < num_pixels; ++i) { |
794 EXPECT_EQ(SkColorGetA(pixels[i]), 0u); | 794 EXPECT_EQ(SkColorGetA(pixels[i]), 0u); |
795 } | 795 } |
796 } | 796 } |
797 | 797 |
798 } // namespace | 798 } // namespace |
799 } // namespace cc | 799 } // namespace cc |
OLD | NEW |