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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerPainterTest.cpp

Issue 2833883003: Skip paint chunks with effectively invisible opacity. (Closed)
Patch Set: Created 3 years, 8 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
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 "core/paint/PaintLayerPainter.h" 5 #include "core/paint/PaintLayerPainter.h"
6 6
7 #include "core/layout/LayoutBoxModelObject.h" 7 #include "core/layout/LayoutBoxModelObject.h"
8 #include "core/layout/compositing/CompositedLayerMapping.h" 8 #include "core/layout/compositing/CompositedLayerMapping.h"
9 #include "core/paint/PaintControllerPaintTest.h" 9 #include "core/paint/PaintControllerPaintTest.h"
10 #include "platform/graphics/GraphicsContext.h" 10 #include "platform/graphics/GraphicsContext.h"
(...skipping 14 matching lines...) Expand all
25 : public testing::WithParamInterface<PaintLayerPainterTestParam>, 25 : public testing::WithParamInterface<PaintLayerPainterTestParam>,
26 private ScopedRootLayerScrollingForTest, 26 private ScopedRootLayerScrollingForTest,
27 public PaintControllerPaintTestBase { 27 public PaintControllerPaintTestBase {
28 USING_FAST_MALLOC(PaintLayerPainterTest); 28 USING_FAST_MALLOC(PaintLayerPainterTest);
29 29
30 public: 30 public:
31 PaintLayerPainterTest() 31 PaintLayerPainterTest()
32 : ScopedRootLayerScrollingForTest(GetParam().root_layer_scrolling), 32 : ScopedRootLayerScrollingForTest(GetParam().root_layer_scrolling),
33 PaintControllerPaintTestBase(GetParam().slimming_paint_v2) {} 33 PaintControllerPaintTestBase(GetParam().slimming_paint_v2) {}
34 34
35 void ExpectPaintedOutputVisibility(const char* element_name, 35 void ExpectPaintedOutputInvisible(const char* element_name,
36 bool expected_spv1) { 36 bool expected_value) {
37 ExpectPaintedOutputVisibility(element_name, expected_spv1, expected_spv1);
wkorman 2017/04/20 22:23:56 With this patch we've seemingly achieved conformit
38 }
39
40 void ExpectPaintedOutputVisibility(const char* element_name,
wkorman 2017/04/20 22:23:56 I renamed this for easier mental parsing w.r.t. it
41 bool expected_spv1,
42 bool expected_spv2) {
43 PaintLayer* target_layer = 37 PaintLayer* target_layer =
44 ToLayoutBox(GetLayoutObjectByElementId(element_name))->Layer(); 38 ToLayoutBox(GetLayoutObjectByElementId(element_name))->Layer();
45 PaintLayerPaintingInfo painting_info(nullptr, LayoutRect(), 39 PaintLayerPaintingInfo painting_info(nullptr, LayoutRect(),
46 kGlobalPaintNormalPhase, LayoutSize()); 40 kGlobalPaintNormalPhase, LayoutSize());
47 bool invisible = 41 bool invisible =
48 PaintLayerPainter(*target_layer).PaintedOutputInvisible(painting_info); 42 PaintLayerPainter(*target_layer).PaintedOutputInvisible(painting_info);
49 bool expected_value = RuntimeEnabledFeatures::slimmingPaintV2Enabled()
50 ? expected_spv2
51 : expected_spv1;
52 EXPECT_EQ(expected_value, invisible) 43 EXPECT_EQ(expected_value, invisible)
53 << "Failed painted output visibility [spv2_enabled=" 44 << "Failed painted output visibility [spv2_enabled="
54 << RuntimeEnabledFeatures::slimmingPaintV2Enabled() 45 << RuntimeEnabledFeatures::slimmingPaintV2Enabled()
55 << ", expected=" << expected_value << ", actual=" << invisible << "]."; 46 << ", expected=" << expected_value << ", actual=" << invisible << "].";
56 } 47 }
57 48
58 private: 49 private:
59 void SetUp() override { 50 void SetUp() override {
60 PaintControllerPaintTestBase::SetUp(); 51 PaintControllerPaintTestBase::SetUp();
61 EnableCompositing(); 52 EnableCompositing();
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 ToHTMLElement(table.GetNode()) 779 ToHTMLElement(table.GetNode())
789 ->setAttribute(HTMLNames::styleAttr, 780 ->setAttribute(HTMLNames::styleAttr,
790 "position: relative; border-collapse: collapse"); 781 "position: relative; border-collapse: collapse");
791 GetDocument().View()->UpdateAllLifecyclePhases(); 782 GetDocument().View()->UpdateAllLifecyclePhases();
792 EXPECT_TRUE(layer.NeedsPaintPhaseDescendantBlockBackgrounds()); 783 EXPECT_TRUE(layer.NeedsPaintPhaseDescendantBlockBackgrounds());
793 } 784 }
794 785
795 TEST_P(PaintLayerPainterTest, DontPaintWithTinyOpacity) { 786 TEST_P(PaintLayerPainterTest, DontPaintWithTinyOpacity) {
796 SetBodyInnerHTML( 787 SetBodyInnerHTML(
797 "<div id='target' style='background: blue; opacity: 0.0001'></div>"); 788 "<div id='target' style='background: blue; opacity: 0.0001'></div>");
798 ExpectPaintedOutputVisibility("target", true, false); 789 ExpectPaintedOutputInvisible("target", true);
wkorman 2017/04/20 22:23:56 Highlighting -- this is one of two test cases stan
799 } 790 }
800 791
801 TEST_P(PaintLayerPainterTest, DoPaintWithTinyOpacityAndWillChangeOpacity) { 792 TEST_P(PaintLayerPainterTest, DoPaintWithTinyOpacityAndWillChangeOpacity) {
802 SetBodyInnerHTML( 793 SetBodyInnerHTML(
803 "<div id='target' style='background: blue; opacity: 0.0001; " 794 "<div id='target' style='background: blue; opacity: 0.0001; "
804 "will-change: opacity'></div>"); 795 "will-change: opacity'></div>");
805 ExpectPaintedOutputVisibility("target", false); 796 ExpectPaintedOutputInvisible("target", false);
806 } 797 }
807 798
808 TEST_P(PaintLayerPainterTest, DoPaintWithTinyOpacityAndBackdropFilter) { 799 TEST_P(PaintLayerPainterTest, DoPaintWithTinyOpacityAndBackdropFilter) {
809 SetBodyInnerHTML( 800 SetBodyInnerHTML(
810 "<div id='target' style='background: blue; opacity: 0.0001;" 801 "<div id='target' style='background: blue; opacity: 0.0001;"
811 " backdrop-filter: blur(2px);'></div>"); 802 " backdrop-filter: blur(2px);'></div>");
812 ExpectPaintedOutputVisibility("target", false); 803 ExpectPaintedOutputInvisible("target", false);
813 } 804 }
814 805
815 TEST_P(PaintLayerPainterTest, 806 TEST_P(PaintLayerPainterTest,
816 DoPaintWithTinyOpacityAndBackdropFilterAndWillChangeOpacity) { 807 DoPaintWithTinyOpacityAndBackdropFilterAndWillChangeOpacity) {
817 SetBodyInnerHTML( 808 SetBodyInnerHTML(
818 "<div id='target' style='background: blue; opacity: 0.0001;" 809 "<div id='target' style='background: blue; opacity: 0.0001;"
819 " backdrop-filter: blur(2px); will-change: opacity'></div>"); 810 " backdrop-filter: blur(2px); will-change: opacity'></div>");
820 ExpectPaintedOutputVisibility("target", false); 811 ExpectPaintedOutputInvisible("target", false);
821 } 812 }
822 813
823 TEST_P(PaintLayerPainterTest, DoPaintWithCompositedTinyOpacity) { 814 TEST_P(PaintLayerPainterTest, DoPaintWithCompositedTinyOpacity) {
824 SetBodyInnerHTML( 815 SetBodyInnerHTML(
825 "<div id='target' style='background: blue; opacity: 0.0001;" 816 "<div id='target' style='background: blue; opacity: 0.0001;"
826 " will-change: transform'></div>"); 817 " will-change: transform'></div>");
827 ExpectPaintedOutputVisibility("target", false); 818 ExpectPaintedOutputInvisible("target", false);
828 } 819 }
829 820
830 TEST_P(PaintLayerPainterTest, DoPaintWithNonTinyOpacity) { 821 TEST_P(PaintLayerPainterTest, DoPaintWithNonTinyOpacity) {
831 SetBodyInnerHTML( 822 SetBodyInnerHTML(
832 "<div id='target' style='background: blue; opacity: 0.1'></div>"); 823 "<div id='target' style='background: blue; opacity: 0.1'></div>");
833 ExpectPaintedOutputVisibility("target", false); 824 ExpectPaintedOutputInvisible("target", false);
834 } 825 }
835 826
836 TEST_P(PaintLayerPainterTest, DoPaintWithEffectAnimationZeroOpacity) { 827 TEST_P(PaintLayerPainterTest, DoPaintWithEffectAnimationZeroOpacity) {
837 SetBodyInnerHTML( 828 SetBodyInnerHTML(
838 "<style> " 829 "<style> "
839 "div { " 830 "div { "
840 " width: 100px; " 831 " width: 100px; "
841 " height: 100px; " 832 " height: 100px; "
842 " animation-name: example; " 833 " animation-name: example; "
843 " animation-duration: 4s; " 834 " animation-duration: 4s; "
844 "} " 835 "} "
845 "@keyframes example { " 836 "@keyframes example { "
846 " from { opacity: 0.0;} " 837 " from { opacity: 0.0;} "
847 " to { opacity: 1.0;} " 838 " to { opacity: 1.0;} "
848 "} " 839 "} "
849 "</style> " 840 "</style> "
850 "<div id='target'></div>"); 841 "<div id='target'></div>");
851 ExpectPaintedOutputVisibility("target", false); 842 ExpectPaintedOutputInvisible("target", false);
852 } 843 }
853 844
854 TEST_P(PaintLayerPainterTest, DontPaintWithTransformAnimationZeroOpacity) { 845 TEST_P(PaintLayerPainterTest, DontPaintWithTransformAnimationZeroOpacity) {
855 SetBodyInnerHTML( 846 SetBodyInnerHTML(
856 "<style> " 847 "<style> "
857 "div#target { " 848 "div#target { "
858 " animation-name: example; " 849 " animation-name: example; "
859 " animation-duration: 4s; " 850 " animation-duration: 4s; "
860 " opacity: 0.0; " 851 " opacity: 0.0; "
861 "} " 852 "} "
862 "@keyframes example { " 853 "@keyframes example { "
863 " from { transform: translate(0px, 0px); } " 854 " from { transform: translate(0px, 0px); } "
864 " to { transform: translate(3em, 0px); } " 855 " to { transform: translate(3em, 0px); } "
865 "} " 856 "} "
866 "</style> " 857 "</style> "
867 "<div id='target'>x</div></div>"); 858 "<div id='target'>x</div></div>");
868 ExpectPaintedOutputVisibility("target", false, true); 859 ExpectPaintedOutputInvisible("target", false);
wkorman 2017/04/20 22:23:56 Highlighting -- this is one of two test cases stan
869 } 860 }
870 861
871 TEST_P(PaintLayerPainterTest, 862 TEST_P(PaintLayerPainterTest,
872 DoPaintWithTransformAnimationZeroOpacityWillChangeOpacity) { 863 DoPaintWithTransformAnimationZeroOpacityWillChangeOpacity) {
873 SetBodyInnerHTML( 864 SetBodyInnerHTML(
874 "<style> " 865 "<style> "
875 "div#target { " 866 "div#target { "
876 " animation-name: example; " 867 " animation-name: example; "
877 " animation-duration: 4s; " 868 " animation-duration: 4s; "
878 " opacity: 0.0; " 869 " opacity: 0.0; "
879 " will-change: opacity; " 870 " will-change: opacity; "
880 "} " 871 "} "
881 "@keyframes example { " 872 "@keyframes example { "
882 " from { transform: translate(0px, 0px); } " 873 " from { transform: translate(0px, 0px); } "
883 " to { transform: translate(3em, 0px); } " 874 " to { transform: translate(3em, 0px); } "
884 "} " 875 "} "
885 "</style> " 876 "</style> "
886 "<div id='target'>x</div></div>"); 877 "<div id='target'>x</div></div>");
887 ExpectPaintedOutputVisibility("target", false); 878 ExpectPaintedOutputInvisible("target", false);
888 } 879 }
889 880
890 TEST_P(PaintLayerPainterTest, DoPaintWithWillChangeOpacity) { 881 TEST_P(PaintLayerPainterTest, DoPaintWithWillChangeOpacity) {
891 SetBodyInnerHTML( 882 SetBodyInnerHTML(
892 "<style> " 883 "<style> "
893 "div { " 884 "div { "
894 " width: 100px; " 885 " width: 100px; "
895 " height: 100px; " 886 " height: 100px; "
896 " will-change: opacity;" 887 " will-change: opacity;"
897 "}" 888 "}"
898 "</style> " 889 "</style> "
899 "<div id='target'></div>"); 890 "<div id='target'></div>");
900 ExpectPaintedOutputVisibility("target", false); 891 ExpectPaintedOutputInvisible("target", false);
901 } 892 }
902 893
903 TEST_P(PaintLayerPainterTest, DoPaintWithZeroOpacityAndWillChangeOpacity) { 894 TEST_P(PaintLayerPainterTest, DoPaintWithZeroOpacityAndWillChangeOpacity) {
904 SetBodyInnerHTML( 895 SetBodyInnerHTML(
905 "<style> " 896 "<style> "
906 "div { " 897 "div { "
907 " width: 100px; " 898 " width: 100px; "
908 " height: 100px; " 899 " height: 100px; "
909 " opacity: 0; " 900 " opacity: 0; "
910 " will-change: opacity;" 901 " will-change: opacity;"
911 "}" 902 "}"
912 "</style> " 903 "</style> "
913 "<div id='target'></div>"); 904 "<div id='target'></div>");
914 ExpectPaintedOutputVisibility("target", false); 905 ExpectPaintedOutputInvisible("target", false);
915 } 906 }
916 907
917 TEST_P(PaintLayerPainterTest, 908 TEST_P(PaintLayerPainterTest,
918 DoPaintWithNoContentAndZeroOpacityAndWillChangeOpacity) { 909 DoPaintWithNoContentAndZeroOpacityAndWillChangeOpacity) {
919 SetBodyInnerHTML( 910 SetBodyInnerHTML(
920 "<style> " 911 "<style> "
921 "div { " 912 "div { "
922 " width: 100px; " 913 " width: 100px; "
923 " height: 100px; " 914 " height: 100px; "
924 " opacity: 0; " 915 " opacity: 0; "
925 " will-change: opacity;" 916 " will-change: opacity;"
926 "}" 917 "}"
927 "</style> " 918 "</style> "
928 "<div id='target'></div>"); 919 "<div id='target'></div>");
929 ExpectPaintedOutputVisibility("target", false); 920 ExpectPaintedOutputInvisible("target", false);
930 } 921 }
931 922
932 } // namespace blink 923 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698