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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerPainter.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 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 "core/paint/PaintLayerPainter.h" 5 #include "core/paint/PaintLayerPainter.h"
6 6
7 #include "core/frame/LocalFrame.h" 7 #include "core/frame/LocalFrame.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/paint/ClipPathClipper.h" 9 #include "core/paint/ClipPathClipper.h"
10 #include "core/paint/FilterPainter.h" 10 #include "core/paint/FilterPainter.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (layout_object.HasBackdropFilter()) 70 if (layout_object.HasBackdropFilter())
71 return false; 71 return false;
72 72
73 // Always paint when 'will-change: opacity' is present. Reduces jank for 73 // Always paint when 'will-change: opacity' is present. Reduces jank for
74 // common animation implementation approaches, for example, an element that 74 // common animation implementation approaches, for example, an element that
75 // starts with opacity zero and later begins to animate. 75 // starts with opacity zero and later begins to animate.
76 if (layout_object.StyleRef().HasWillChangeOpacityHint()) 76 if (layout_object.StyleRef().HasWillChangeOpacityHint())
77 return false; 77 return false;
78 78
79 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 79 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
80 if (layout_object.StyleRef().Opacity()) 80 const ObjectPaintProperties* properties = layout_object.PaintProperties();
81 return false;
82
83 const EffectPaintPropertyNode* effect = 81 const EffectPaintPropertyNode* effect =
84 layout_object.PaintProperties()->Effect(); 82 properties ? properties->Effect() : nullptr;
85 if (effect && effect->RequiresCompositingForAnimation()) { 83 if (effect && effect->RequiresCompositingForAnimation()) {
86 return false; 84 return false;
87 } 85 }
88 } 86 }
89 87
90 // 0.0004f < 1/2048. With 10-bit color channels (only available on the 88 // 0.0004f < 1/2048. With 10-bit color channels (only available on the
91 // newest Macs; otherwise it's 8-bit), we see that an alpha of 1/2048 or 89 // newest Macs; otherwise it's 8-bit), we see that an alpha of 1/2048 or
92 // less leads to a color output of less than 0.5 in all channels, hence 90 // less leads to a color output of less than 0.5 in all channels, hence
93 // not visible. 91 // not visible.
94 static const float kMinimumVisibleOpacity = 0.0004f; 92 static const float kMinimumVisibleOpacity = 0.0004f;
95 if (paint_layer_.PaintsWithTransparency( 93 if (paint_layer_.PaintsWithTransparency(
96 painting_info.GetGlobalPaintFlags())) { 94 painting_info.GetGlobalPaintFlags()) &&
97 if (layout_object.StyleRef().Opacity() < kMinimumVisibleOpacity) { 95 layout_object.StyleRef().Opacity() < kMinimumVisibleOpacity)
98 return true; 96 return true;
99 }
100 }
101 return false; 97 return false;
102 } 98 }
103 99
104 PaintResult PaintLayerPainter::Paint( 100 PaintResult PaintLayerPainter::Paint(
105 GraphicsContext& context, 101 GraphicsContext& context,
106 const PaintLayerPaintingInfo& painting_info, 102 const PaintLayerPaintingInfo& painting_info,
107 PaintLayerFlags paint_flags) { 103 PaintLayerFlags paint_flags) {
108 // https://code.google.com/p/chromium/issues/detail?id=343772 104 // https://code.google.com/p/chromium/issues/detail?id=343772
109 DisableCompositingQueryAsserts disabler; 105 DisableCompositingQueryAsserts disabler;
110 106
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 context, layout_object, kPaintPhaseClippingMask)) 1237 context, layout_object, kPaintPhaseClippingMask))
1242 return; 1238 return;
1243 1239
1244 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); 1240 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect());
1245 LayoutObjectDrawingRecorder drawing_recorder( 1241 LayoutObjectDrawingRecorder drawing_recorder(
1246 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); 1242 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect);
1247 context.FillRect(snapped_clip_rect, Color::kBlack); 1243 context.FillRect(snapped_clip_rect, Color::kBlack);
1248 } 1244 }
1249 1245
1250 } // namespace blink 1246 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698