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

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

Issue 2833883003: Skip paint chunks with effectively invisible opacity. (Closed)
Patch Set: Updated per discussion. 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
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); 37 // The optimization to skip painting for effectively-invisible content is
38 } 38 // limited to SPv1.
39 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
40 return;
39 41
40 void ExpectPaintedOutputVisibility(const char* element_name,
41 bool expected_spv1,
42 bool expected_spv2) {
43 PaintLayer* target_layer = 42 PaintLayer* target_layer =
44 ToLayoutBox(GetLayoutObjectByElementId(element_name))->Layer(); 43 ToLayoutBox(GetLayoutObjectByElementId(element_name))->Layer();
45 PaintLayerPaintingInfo painting_info(nullptr, LayoutRect(), 44 PaintLayerPaintingInfo painting_info(nullptr, LayoutRect(),
46 kGlobalPaintNormalPhase, LayoutSize()); 45 kGlobalPaintNormalPhase, LayoutSize());
47 bool invisible = 46 bool invisible =
48 PaintLayerPainter(*target_layer).PaintedOutputInvisible(painting_info); 47 PaintLayerPainter(*target_layer).PaintedOutputInvisible(painting_info);
49 bool expected_value = RuntimeEnabledFeatures::slimmingPaintV2Enabled()
50 ? expected_spv2
51 : expected_spv1;
52 EXPECT_EQ(expected_value, invisible) 48 EXPECT_EQ(expected_value, invisible)
53 << "Failed painted output visibility [spv2_enabled=" 49 << "Failed painted output visibility [spv2_enabled="
54 << RuntimeEnabledFeatures::slimmingPaintV2Enabled() 50 << RuntimeEnabledFeatures::slimmingPaintV2Enabled()
55 << ", expected=" << expected_value << ", actual=" << invisible << "]."; 51 << ", expected=" << expected_value << ", actual=" << invisible << "].";
56 } 52 }
57 53
58 private: 54 private:
59 void SetUp() override { 55 void SetUp() override {
60 PaintControllerPaintTestBase::SetUp(); 56 PaintControllerPaintTestBase::SetUp();
61 EnableCompositing(); 57 EnableCompositing();
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 ToHTMLElement(table.GetNode()) 784 ToHTMLElement(table.GetNode())
789 ->setAttribute(HTMLNames::styleAttr, 785 ->setAttribute(HTMLNames::styleAttr,
790 "position: relative; border-collapse: collapse"); 786 "position: relative; border-collapse: collapse");
791 GetDocument().View()->UpdateAllLifecyclePhases(); 787 GetDocument().View()->UpdateAllLifecyclePhases();
792 EXPECT_TRUE(layer.NeedsPaintPhaseDescendantBlockBackgrounds()); 788 EXPECT_TRUE(layer.NeedsPaintPhaseDescendantBlockBackgrounds());
793 } 789 }
794 790
795 TEST_P(PaintLayerPainterTest, DontPaintWithTinyOpacity) { 791 TEST_P(PaintLayerPainterTest, DontPaintWithTinyOpacity) {
796 SetBodyInnerHTML( 792 SetBodyInnerHTML(
797 "<div id='target' style='background: blue; opacity: 0.0001'></div>"); 793 "<div id='target' style='background: blue; opacity: 0.0001'></div>");
798 ExpectPaintedOutputVisibility("target", true, false); 794 ExpectPaintedOutputInvisible("target", true);
799 } 795 }
800 796
801 TEST_P(PaintLayerPainterTest, DoPaintWithTinyOpacityAndWillChangeOpacity) { 797 TEST_P(PaintLayerPainterTest, DoPaintWithTinyOpacityAndWillChangeOpacity) {
802 SetBodyInnerHTML( 798 SetBodyInnerHTML(
803 "<div id='target' style='background: blue; opacity: 0.0001; " 799 "<div id='target' style='background: blue; opacity: 0.0001; "
804 "will-change: opacity'></div>"); 800 "will-change: opacity'></div>");
805 ExpectPaintedOutputVisibility("target", false); 801 ExpectPaintedOutputInvisible("target", false);
806 } 802 }
807 803
808 TEST_P(PaintLayerPainterTest, DoPaintWithTinyOpacityAndBackdropFilter) { 804 TEST_P(PaintLayerPainterTest, DoPaintWithTinyOpacityAndBackdropFilter) {
809 SetBodyInnerHTML( 805 SetBodyInnerHTML(
810 "<div id='target' style='background: blue; opacity: 0.0001;" 806 "<div id='target' style='background: blue; opacity: 0.0001;"
811 " backdrop-filter: blur(2px);'></div>"); 807 " backdrop-filter: blur(2px);'></div>");
812 ExpectPaintedOutputVisibility("target", false); 808 ExpectPaintedOutputInvisible("target", false);
813 } 809 }
814 810
815 TEST_P(PaintLayerPainterTest, 811 TEST_P(PaintLayerPainterTest,
816 DoPaintWithTinyOpacityAndBackdropFilterAndWillChangeOpacity) { 812 DoPaintWithTinyOpacityAndBackdropFilterAndWillChangeOpacity) {
817 SetBodyInnerHTML( 813 SetBodyInnerHTML(
818 "<div id='target' style='background: blue; opacity: 0.0001;" 814 "<div id='target' style='background: blue; opacity: 0.0001;"
819 " backdrop-filter: blur(2px); will-change: opacity'></div>"); 815 " backdrop-filter: blur(2px); will-change: opacity'></div>");
820 ExpectPaintedOutputVisibility("target", false); 816 ExpectPaintedOutputInvisible("target", false);
821 } 817 }
822 818
823 TEST_P(PaintLayerPainterTest, DoPaintWithCompositedTinyOpacity) { 819 TEST_P(PaintLayerPainterTest, DoPaintWithCompositedTinyOpacity) {
824 SetBodyInnerHTML( 820 SetBodyInnerHTML(
825 "<div id='target' style='background: blue; opacity: 0.0001;" 821 "<div id='target' style='background: blue; opacity: 0.0001;"
826 " will-change: transform'></div>"); 822 " will-change: transform'></div>");
827 ExpectPaintedOutputVisibility("target", false); 823 ExpectPaintedOutputInvisible("target", false);
828 } 824 }
829 825
830 TEST_P(PaintLayerPainterTest, DoPaintWithNonTinyOpacity) { 826 TEST_P(PaintLayerPainterTest, DoPaintWithNonTinyOpacity) {
831 SetBodyInnerHTML( 827 SetBodyInnerHTML(
832 "<div id='target' style='background: blue; opacity: 0.1'></div>"); 828 "<div id='target' style='background: blue; opacity: 0.1'></div>");
833 ExpectPaintedOutputVisibility("target", false); 829 ExpectPaintedOutputInvisible("target", false);
834 } 830 }
835 831
836 TEST_P(PaintLayerPainterTest, DoPaintWithEffectAnimationZeroOpacity) { 832 TEST_P(PaintLayerPainterTest, DoPaintWithEffectAnimationZeroOpacity) {
837 SetBodyInnerHTML( 833 SetBodyInnerHTML(
838 "<style> " 834 "<style> "
839 "div { " 835 "div { "
840 " width: 100px; " 836 " width: 100px; "
841 " height: 100px; " 837 " height: 100px; "
842 " animation-name: example; " 838 " animation-name: example; "
843 " animation-duration: 4s; " 839 " animation-duration: 4s; "
844 "} " 840 "} "
845 "@keyframes example { " 841 "@keyframes example { "
846 " from { opacity: 0.0;} " 842 " from { opacity: 0.0;} "
847 " to { opacity: 1.0;} " 843 " to { opacity: 1.0;} "
848 "} " 844 "} "
849 "</style> " 845 "</style> "
850 "<div id='target'></div>"); 846 "<div id='target'></div>");
851 ExpectPaintedOutputVisibility("target", false); 847 ExpectPaintedOutputInvisible("target", false);
852 } 848 }
853 849
854 TEST_P(PaintLayerPainterTest, DontPaintWithTransformAnimationZeroOpacity) { 850 TEST_P(PaintLayerPainterTest, DoPaintWithTransformAnimationZeroOpacity) {
855 SetBodyInnerHTML( 851 SetBodyInnerHTML(
856 "<style> " 852 "<style> "
857 "div#target { " 853 "div#target { "
858 " animation-name: example; " 854 " animation-name: example; "
859 " animation-duration: 4s; " 855 " animation-duration: 4s; "
860 " opacity: 0.0; " 856 " opacity: 0.0; "
861 "} " 857 "} "
862 "@keyframes example { " 858 "@keyframes example { "
863 " from { transform: translate(0px, 0px); } " 859 " from { transform: translate(0px, 0px); } "
864 " to { transform: translate(3em, 0px); } " 860 " to { transform: translate(3em, 0px); } "
865 "} " 861 "} "
866 "</style> " 862 "</style> "
867 "<div id='target'>x</div></div>"); 863 "<div id='target'>x</div></div>");
868 ExpectPaintedOutputVisibility("target", false, true); 864 ExpectPaintedOutputInvisible("target", false);
869 } 865 }
870 866
871 TEST_P(PaintLayerPainterTest, 867 TEST_P(PaintLayerPainterTest,
872 DoPaintWithTransformAnimationZeroOpacityWillChangeOpacity) { 868 DoPaintWithTransformAnimationZeroOpacityWillChangeOpacity) {
873 SetBodyInnerHTML( 869 SetBodyInnerHTML(
874 "<style> " 870 "<style> "
875 "div#target { " 871 "div#target { "
876 " animation-name: example; " 872 " animation-name: example; "
877 " animation-duration: 4s; " 873 " animation-duration: 4s; "
878 " opacity: 0.0; " 874 " opacity: 0.0; "
879 " will-change: opacity; " 875 " will-change: opacity; "
880 "} " 876 "} "
881 "@keyframes example { " 877 "@keyframes example { "
882 " from { transform: translate(0px, 0px); } " 878 " from { transform: translate(0px, 0px); } "
883 " to { transform: translate(3em, 0px); } " 879 " to { transform: translate(3em, 0px); } "
884 "} " 880 "} "
885 "</style> " 881 "</style> "
886 "<div id='target'>x</div></div>"); 882 "<div id='target'>x</div></div>");
887 ExpectPaintedOutputVisibility("target", false); 883 ExpectPaintedOutputInvisible("target", false);
888 } 884 }
889 885
890 TEST_P(PaintLayerPainterTest, DoPaintWithWillChangeOpacity) { 886 TEST_P(PaintLayerPainterTest, DoPaintWithWillChangeOpacity) {
891 SetBodyInnerHTML( 887 SetBodyInnerHTML(
892 "<style> " 888 "<style> "
893 "div { " 889 "div { "
894 " width: 100px; " 890 " width: 100px; "
895 " height: 100px; " 891 " height: 100px; "
896 " will-change: opacity;" 892 " will-change: opacity;"
897 "}" 893 "}"
898 "</style> " 894 "</style> "
899 "<div id='target'></div>"); 895 "<div id='target'></div>");
900 ExpectPaintedOutputVisibility("target", false); 896 ExpectPaintedOutputInvisible("target", false);
901 } 897 }
902 898
903 TEST_P(PaintLayerPainterTest, DoPaintWithZeroOpacityAndWillChangeOpacity) { 899 TEST_P(PaintLayerPainterTest, DoPaintWithZeroOpacityAndWillChangeOpacity) {
904 SetBodyInnerHTML( 900 SetBodyInnerHTML(
905 "<style> " 901 "<style> "
906 "div { " 902 "div { "
907 " width: 100px; " 903 " width: 100px; "
908 " height: 100px; " 904 " height: 100px; "
909 " opacity: 0; " 905 " opacity: 0; "
910 " will-change: opacity;" 906 " will-change: opacity;"
911 "}" 907 "}"
912 "</style> " 908 "</style> "
913 "<div id='target'></div>"); 909 "<div id='target'></div>");
914 ExpectPaintedOutputVisibility("target", false); 910 ExpectPaintedOutputInvisible("target", false);
915 } 911 }
916 912
917 TEST_P(PaintLayerPainterTest, 913 TEST_P(PaintLayerPainterTest,
918 DoPaintWithNoContentAndZeroOpacityAndWillChangeOpacity) { 914 DoPaintWithNoContentAndZeroOpacityAndWillChangeOpacity) {
919 SetBodyInnerHTML( 915 SetBodyInnerHTML(
920 "<style> " 916 "<style> "
921 "div { " 917 "div { "
922 " width: 100px; " 918 " width: 100px; "
923 " height: 100px; " 919 " height: 100px; "
924 " opacity: 0; " 920 " opacity: 0; "
925 " will-change: opacity;" 921 " will-change: opacity;"
926 "}" 922 "}"
927 "</style> " 923 "</style> "
928 "<div id='target'></div>"); 924 "<div id='target'></div>");
929 ExpectPaintedOutputVisibility("target", false); 925 ExpectPaintedOutputInvisible("target", false);
930 } 926 }
931 927
932 } // namespace blink 928 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698