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