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

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

Issue 2881213002: cc: Remove deprecated DisplayItemList::Raster overload. (Closed)
Patch Set: update 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/paint/display_item_list.cc ('k') | cc/paint/paint_op_buffer.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/display_item_list.h" 5 #include "cc/paint/display_item_list.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 auto list = make_scoped_refptr(new DisplayItemList); 725 auto list = make_scoped_refptr(new DisplayItemList);
726 726
727 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( 727 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>(
728 80, SkBlendMode::kSrcOver, nullptr, nullptr, false); 728 80, SkBlendMode::kSrcOver, nullptr, nullptr, false);
729 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 729 list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
730 kVisualRect, CreateRectPictureWithAlpha(kVisualRect, 40)); 730 kVisualRect, CreateRectPictureWithAlpha(kVisualRect, 40));
731 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); 731 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>();
732 list->Finalize(); 732 list->Finalize();
733 733
734 SaveCountingCanvas canvas; 734 SaveCountingCanvas canvas;
735 list->Raster(&canvas, nullptr); 735 list->Raster(&canvas);
736 736
737 EXPECT_EQ(0, canvas.save_count_); 737 EXPECT_EQ(0, canvas.save_count_);
738 EXPECT_EQ(0, canvas.restore_count_); 738 EXPECT_EQ(0, canvas.restore_count_);
739 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); 739 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_);
740 740
741 float expected_alpha = 80 * 40 / 255.f; 741 float expected_alpha = 80 * 40 / 255.f;
742 EXPECT_LE(std::abs(expected_alpha - canvas.paint_.getAlpha()), 1.f); 742 EXPECT_LE(std::abs(expected_alpha - canvas.paint_.getAlpha()), 1.f);
743 } 743 }
744 744
745 // Verify that compositing item / end compositing item is a noop. 745 // Verify that compositing item / end compositing item is a noop.
746 // Here we're testing that Skia does an optimization that skips 746 // Here we're testing that Skia does an optimization that skips
747 // save/restore with nothing in between. If skia stops doing this 747 // save/restore with nothing in between. If skia stops doing this
748 // then we should reimplement this optimization in display list raster. 748 // then we should reimplement this optimization in display list raster.
749 TEST(DisplayItemListTest, SaveRestoreNoops) { 749 TEST(DisplayItemListTest, SaveRestoreNoops) {
750 auto list = make_scoped_refptr(new DisplayItemList); 750 auto list = make_scoped_refptr(new DisplayItemList);
751 751
752 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( 752 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>(
753 80, SkBlendMode::kSrcOver, nullptr, nullptr, false); 753 80, SkBlendMode::kSrcOver, nullptr, nullptr, false);
754 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); 754 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>();
755 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( 755 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>(
756 255, SkBlendMode::kSrcOver, nullptr, nullptr, false); 756 255, SkBlendMode::kSrcOver, nullptr, nullptr, false);
757 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); 757 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>();
758 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( 758 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>(
759 255, SkBlendMode::kSrc, nullptr, nullptr, false); 759 255, SkBlendMode::kSrc, nullptr, nullptr, false);
760 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); 760 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>();
761 list->Finalize(); 761 list->Finalize();
762 762
763 SaveCountingCanvas canvas; 763 SaveCountingCanvas canvas;
764 list->Raster(&canvas, nullptr); 764 list->Raster(&canvas);
765 765
766 EXPECT_EQ(0, canvas.save_count_); 766 EXPECT_EQ(0, canvas.save_count_);
767 EXPECT_EQ(0, canvas.restore_count_); 767 EXPECT_EQ(0, canvas.restore_count_);
768 } 768 }
769 769
770 // The same as SaveDrawRestore, but with save flags that prevent the 770 // The same as SaveDrawRestore, but with save flags that prevent the
771 // optimization. 771 // optimization.
772 TEST(DisplayItemListTest, SaveDrawRestoreFail_BadSaveFlags) { 772 TEST(DisplayItemListTest, SaveDrawRestoreFail_BadSaveFlags) {
773 auto list = make_scoped_refptr(new DisplayItemList); 773 auto list = make_scoped_refptr(new DisplayItemList);
774 774
775 // Use a blend mode that's not compatible with the SaveDrawRestore 775 // Use a blend mode that's not compatible with the SaveDrawRestore
776 // optimization. 776 // optimization.
777 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( 777 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>(
778 80, SkBlendMode::kSrc, nullptr, nullptr, false); 778 80, SkBlendMode::kSrc, nullptr, nullptr, false);
779 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 779 list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
780 kVisualRect, CreateRectPictureWithAlpha(kVisualRect, 40)); 780 kVisualRect, CreateRectPictureWithAlpha(kVisualRect, 40));
781 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); 781 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>();
782 list->Finalize(); 782 list->Finalize();
783 783
784 SaveCountingCanvas canvas; 784 SaveCountingCanvas canvas;
785 list->Raster(&canvas, nullptr); 785 list->Raster(&canvas);
786 786
787 EXPECT_EQ(1, canvas.save_count_); 787 EXPECT_EQ(1, canvas.save_count_);
788 EXPECT_EQ(1, canvas.restore_count_); 788 EXPECT_EQ(1, canvas.restore_count_);
789 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); 789 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_);
790 EXPECT_LE(40, canvas.paint_.getAlpha()); 790 EXPECT_LE(40, canvas.paint_.getAlpha());
791 } 791 }
792 792
793 // The same as SaveDrawRestore, but with too many ops in the PaintRecord. 793 // The same as SaveDrawRestore, but with too many ops in the PaintRecord.
794 TEST(DisplayItemListTest, SaveDrawRestoreFail_TooManyOps) { 794 TEST(DisplayItemListTest, SaveDrawRestoreFail_TooManyOps) {
795 sk_sp<const PaintRecord> record; 795 sk_sp<const PaintRecord> record;
(...skipping 13 matching lines...) Expand all
809 auto list = make_scoped_refptr(new DisplayItemList); 809 auto list = make_scoped_refptr(new DisplayItemList);
810 810
811 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( 811 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>(
812 80, SkBlendMode::kSrcOver, nullptr, nullptr, false); 812 80, SkBlendMode::kSrcOver, nullptr, nullptr, false);
813 list->CreateAndAppendDrawingItem<DrawingDisplayItem>(kVisualRect, 813 list->CreateAndAppendDrawingItem<DrawingDisplayItem>(kVisualRect,
814 std::move(record)); 814 std::move(record));
815 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); 815 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>();
816 list->Finalize(); 816 list->Finalize();
817 817
818 SaveCountingCanvas canvas; 818 SaveCountingCanvas canvas;
819 list->Raster(&canvas, nullptr); 819 list->Raster(&canvas);
820 820
821 EXPECT_EQ(1, canvas.save_count_); 821 EXPECT_EQ(1, canvas.save_count_);
822 EXPECT_EQ(1, canvas.restore_count_); 822 EXPECT_EQ(1, canvas.restore_count_);
823 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); 823 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_);
824 EXPECT_LE(40, canvas.paint_.getAlpha()); 824 EXPECT_LE(40, canvas.paint_.getAlpha());
825 } 825 }
826 826
827 } // namespace cc 827 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/display_item_list.cc ('k') | cc/paint/paint_op_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698