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

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

Issue 2873003002: Add stable id to PaintImage. (Closed)
Patch Set: rebase 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_unittest.cc ('k') | cc/paint/discardable_image_store.h » ('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 26 matching lines...) Expand all
37 sk_sp<const SkImage> image; 37 sk_sp<const SkImage> image;
38 gfx::Rect image_rect; 38 gfx::Rect image_rect;
39 SkSize scale; 39 SkSize scale;
40 }; 40 };
41 41
42 sk_sp<PaintRecord> CreateRecording(const sk_sp<SkImage>& discardable_image, 42 sk_sp<PaintRecord> CreateRecording(const sk_sp<SkImage>& discardable_image,
43 const gfx::Rect& visible_rect) { 43 const gfx::Rect& visible_rect) {
44 PaintRecorder recorder; 44 PaintRecorder recorder;
45 PaintCanvas* canvas = 45 PaintCanvas* canvas =
46 recorder.beginRecording(visible_rect.width(), visible_rect.height()); 46 recorder.beginRecording(visible_rect.width(), visible_rect.height());
47 canvas->drawImage( 47 canvas->drawImage(PaintImage(PaintImage::GetNextId(), discardable_image,
48 PaintImage(discardable_image, PaintImage::AnimationType::STATIC, 48 PaintImage::AnimationType::STATIC,
49 PaintImage::CompletionState::DONE), 49 PaintImage::CompletionState::DONE),
50 0, 0, nullptr); 50 0, 0, nullptr);
51 sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture(); 51 sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture();
52 return record; 52 return record;
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 class DiscardableImageMapTest : public testing::Test { 57 class DiscardableImageMapTest : public testing::Test {
58 public: 58 public:
59 std::vector<PositionScaleDrawImage> GetDiscardableImagesInRect( 59 std::vector<PositionScaleDrawImage> GetDiscardableImagesInRect(
60 const DiscardableImageMap& image_map, 60 const DiscardableImageMap& image_map,
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 EXPECT_EQ(1u, images.size()); 671 EXPECT_EQ(1u, images.size());
672 EXPECT_TRUE(images[0].image == discardable_image); 672 EXPECT_TRUE(images[0].image == discardable_image);
673 EXPECT_EQ(gfx::Rect(250, 250), inset_rects[0]); 673 EXPECT_EQ(gfx::Rect(250, 250), inset_rects[0]);
674 } 674 }
675 675
676 TEST_F(DiscardableImageMapTest, GathersDiscardableImagesFromNestedOps) { 676 TEST_F(DiscardableImageMapTest, GathersDiscardableImagesFromNestedOps) {
677 sk_sp<PaintRecord> internal_record = sk_make_sp<PaintRecord>(); 677 sk_sp<PaintRecord> internal_record = sk_make_sp<PaintRecord>();
678 sk_sp<SkImage> discardable_image = 678 sk_sp<SkImage> discardable_image =
679 CreateDiscardableImage(gfx::Size(100, 100)); 679 CreateDiscardableImage(gfx::Size(100, 100));
680 internal_record->push<DrawImageOp>( 680 internal_record->push<DrawImageOp>(
681 PaintImage(discardable_image, PaintImage::AnimationType::STATIC, 681 PaintImage(PaintImage::GetNextId(), discardable_image,
682 PaintImage::AnimationType::STATIC,
682 PaintImage::CompletionState::DONE), 683 PaintImage::CompletionState::DONE),
683 0.f, 0.f, nullptr); 684 0.f, 0.f, nullptr);
684 685
685 sk_sp<PaintRecord> list_record = sk_make_sp<PaintRecord>(); 686 sk_sp<PaintRecord> list_record = sk_make_sp<PaintRecord>();
686 sk_sp<SkImage> discardable_image2 = 687 sk_sp<SkImage> discardable_image2 =
687 CreateDiscardableImage(gfx::Size(100, 100)); 688 CreateDiscardableImage(gfx::Size(100, 100));
688 list_record->push<DrawImageOp>( 689 list_record->push<DrawImageOp>(
689 PaintImage(discardable_image2, PaintImage::AnimationType::STATIC, 690 PaintImage(PaintImage::GetNextId(), discardable_image2,
691 PaintImage::AnimationType::STATIC,
690 PaintImage::CompletionState::DONE), 692 PaintImage::CompletionState::DONE),
691 100.f, 100.f, nullptr); 693 100.f, 100.f, nullptr);
692 scoped_refptr<DisplayItemList> display_list = new DisplayItemList; 694 scoped_refptr<DisplayItemList> display_list = new DisplayItemList;
693 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 695 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
694 gfx::Rect(100, 100, 100, 100), list_record); 696 gfx::Rect(100, 100, 100, 100), list_record);
695 display_list->Finalize(); 697 display_list->Finalize();
696 698
697 PaintOpBuffer buffer; 699 PaintOpBuffer buffer;
698 buffer.push<DrawRecordOp>(internal_record); 700 buffer.push<DrawRecordOp>(internal_record);
699 buffer.push<DrawDisplayItemListOp>(display_list); 701 buffer.push<DrawDisplayItemListOp>(display_list);
(...skipping 12 matching lines...) Expand all
712 EXPECT_TRUE(discardable_image == images[0].image()); 714 EXPECT_TRUE(discardable_image == images[0].image());
713 715
714 images.clear(); 716 images.clear();
715 image_map_.GetDiscardableImagesInRect(gfx::Rect(105, 105, 5, 95), 1.f, 717 image_map_.GetDiscardableImagesInRect(gfx::Rect(105, 105, 5, 95), 1.f,
716 target_color_space, &images); 718 target_color_space, &images);
717 EXPECT_EQ(1u, images.size()); 719 EXPECT_EQ(1u, images.size());
718 EXPECT_TRUE(discardable_image2 == images[0].image()); 720 EXPECT_TRUE(discardable_image2 == images[0].image());
719 } 721 }
720 722
721 } // namespace cc 723 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_image_layer_unittest.cc ('k') | cc/paint/discardable_image_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698