Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: cc/paint/discardable_image_map_unittest.cc

Issue 2889653002: Remove cullRect() from PaintOpBuffer. (Closed)
Patch Set: movecullrect2 rebase-once-and-for-all Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_image_layer.cc ('k') | cc/paint/display_item_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/paint/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
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 gfx::Rect visible_rect(500, 500); 654 gfx::Rect visible_rect(500, 500);
655 655
656 PaintImage discardable_image = 656 PaintImage discardable_image =
657 CreateDiscardablePaintImage(gfx::Size(500, 500)); 657 CreateDiscardablePaintImage(gfx::Size(500, 500));
658 sk_sp<PaintRecord> record = CreateRecording(discardable_image, visible_rect); 658 sk_sp<PaintRecord> record = CreateRecording(discardable_image, visible_rect);
659 659
660 scoped_refptr<DisplayItemList> display_list = new DisplayItemList; 660 scoped_refptr<DisplayItemList> display_list = new DisplayItemList;
661 display_list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( 661 display_list->CreateAndAppendPairedBeginItem<ClipDisplayItem>(
662 gfx::Rect(250, 250), std::vector<SkRRect>(), false); 662 gfx::Rect(250, 250), std::vector<SkRRect>(), false);
663 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 663 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
664 gfx::Rect(500, 500), record); 664 gfx::Rect(500, 500), record, SkRect::MakeWH(500, 500));
665 display_list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); 665 display_list->CreateAndAppendPairedEndItem<EndClipDisplayItem>();
666 display_list->Finalize(); 666 display_list->Finalize();
667 display_list->GenerateDiscardableImagesMetadata(); 667 display_list->GenerateDiscardableImagesMetadata();
668 668
669 const DiscardableImageMap& image_map = 669 const DiscardableImageMap& image_map =
670 display_list->discardable_image_map_for_testing(); 670 display_list->discardable_image_map_for_testing();
671 std::vector<PositionScaleDrawImage> images = 671 std::vector<PositionScaleDrawImage> images =
672 GetDiscardableImagesInRect(image_map, visible_rect); 672 GetDiscardableImagesInRect(image_map, visible_rect);
673 std::vector<gfx::Rect> inset_rects = InsetImageRects(images); 673 std::vector<gfx::Rect> inset_rects = InsetImageRects(images);
674 EXPECT_EQ(1u, images.size()); 674 EXPECT_EQ(1u, images.size());
675 EXPECT_TRUE(images[0].image == discardable_image); 675 EXPECT_TRUE(images[0].image == discardable_image);
676 EXPECT_EQ(gfx::Rect(250, 250), inset_rects[0]); 676 EXPECT_EQ(gfx::Rect(250, 250), inset_rects[0]);
677 } 677 }
678 678
679 TEST_F(DiscardableImageMapTest, GathersDiscardableImagesFromNestedOps) { 679 TEST_F(DiscardableImageMapTest, GathersDiscardableImagesFromNestedOps) {
680 sk_sp<PaintRecord> internal_record = sk_make_sp<PaintRecord>(); 680 sk_sp<PaintRecord> internal_record = sk_make_sp<PaintRecord>();
681 PaintImage discardable_image = 681 PaintImage discardable_image =
682 CreateDiscardablePaintImage(gfx::Size(100, 100)); 682 CreateDiscardablePaintImage(gfx::Size(100, 100));
683 internal_record->push<DrawImageOp>(discardable_image, 0.f, 0.f, nullptr); 683 internal_record->push<DrawImageOp>(discardable_image, 0.f, 0.f, nullptr);
684 684
685 sk_sp<PaintRecord> list_record = sk_make_sp<PaintRecord>(); 685 sk_sp<PaintRecord> list_record = sk_make_sp<PaintRecord>();
686 PaintImage discardable_image2 = 686 PaintImage discardable_image2 =
687 CreateDiscardablePaintImage(gfx::Size(100, 100)); 687 CreateDiscardablePaintImage(gfx::Size(100, 100));
688 list_record->push<DrawImageOp>(discardable_image2, 100.f, 100.f, nullptr); 688 list_record->push<DrawImageOp>(discardable_image2, 100.f, 100.f, nullptr);
689 scoped_refptr<DisplayItemList> display_list = new DisplayItemList; 689 scoped_refptr<DisplayItemList> display_list = new DisplayItemList;
690 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 690 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
691 gfx::Rect(100, 100, 100, 100), list_record); 691 gfx::Rect(100, 100, 100, 100), list_record, SkRect::MakeWH(100, 100));
692 display_list->Finalize(); 692 display_list->Finalize();
693 693
694 PaintOpBuffer buffer; 694 PaintOpBuffer buffer;
695 buffer.push<DrawRecordOp>(internal_record); 695 buffer.push<DrawRecordOp>(internal_record);
696 buffer.push<DrawDisplayItemListOp>(display_list); 696 buffer.push<DrawDisplayItemListOp>(display_list);
697 DiscardableImageMap image_map_; 697 DiscardableImageMap image_map_;
698 { 698 {
699 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map_, 699 DiscardableImageMap::ScopedMetadataGenerator generator(&image_map_,
700 gfx::Size(200, 200)); 700 gfx::Size(200, 200));
701 generator.image_store()->GatherDiscardableImages(&buffer); 701 generator.image_store()->GatherDiscardableImages(&buffer);
702 } 702 }
703 703
704 gfx::ColorSpace target_color_space; 704 gfx::ColorSpace target_color_space;
705 std::vector<DrawImage> images; 705 std::vector<DrawImage> images;
706 image_map_.GetDiscardableImagesInRect(gfx::Rect(0, 0, 5, 95), 1.f, 706 image_map_.GetDiscardableImagesInRect(gfx::Rect(0, 0, 5, 95), 1.f,
707 target_color_space, &images); 707 target_color_space, &images);
708 EXPECT_EQ(1u, images.size()); 708 EXPECT_EQ(1u, images.size());
709 EXPECT_TRUE(discardable_image == images[0].paint_image()); 709 EXPECT_TRUE(discardable_image == images[0].paint_image());
710 710
711 images.clear(); 711 images.clear();
712 image_map_.GetDiscardableImagesInRect(gfx::Rect(105, 105, 5, 95), 1.f, 712 image_map_.GetDiscardableImagesInRect(gfx::Rect(105, 105, 5, 95), 1.f,
713 target_color_space, &images); 713 target_color_space, &images);
714 EXPECT_EQ(1u, images.size()); 714 EXPECT_EQ(1u, images.size());
715 EXPECT_TRUE(discardable_image2 == images[0].paint_image()); 715 EXPECT_TRUE(discardable_image2 == images[0].paint_image());
716 } 716 }
717 717
718 } // namespace cc 718 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_image_layer.cc ('k') | cc/paint/display_item_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698