Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 static ShouldRespectOverflowClipType ShouldRespectOverflowClip( | 57 static ShouldRespectOverflowClipType ShouldRespectOverflowClip( |
| 58 PaintLayerFlags paint_flags, | 58 PaintLayerFlags paint_flags, |
| 59 const LayoutObject& layout_object) { | 59 const LayoutObject& layout_object) { |
| 60 return (paint_flags & kPaintLayerPaintingOverflowContents || | 60 return (paint_flags & kPaintLayerPaintingOverflowContents || |
| 61 (paint_flags & kPaintLayerPaintingChildClippingMaskPhase && | 61 (paint_flags & kPaintLayerPaintingChildClippingMaskPhase && |
| 62 layout_object.HasClipPath())) | 62 layout_object.HasClipPath())) |
| 63 ? kIgnoreOverflowClip | 63 ? kIgnoreOverflowClip |
| 64 : kRespectOverflowClip; | 64 : kRespectOverflowClip; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool PaintLayerPainter::PaintedOutputInvisible( | |
|
chrishtr
2017/04/26 19:58:21
I think we still need this for SPv1.
wkorman
2017/04/27 00:02:32
Restored SPv1 behavior.
| |
| 68 const PaintLayerPaintingInfo& painting_info) { | |
| 69 const LayoutObject& layout_object = paint_layer_.GetLayoutObject(); | |
| 70 if (layout_object.HasBackdropFilter()) | |
| 71 return false; | |
| 72 | |
| 73 // Always paint when 'will-change: opacity' is present. Reduces jank for | |
| 74 // common animation implementation approaches, for example, an element that | |
| 75 // starts with opacity zero and later begins to animate. | |
| 76 if (layout_object.StyleRef().HasWillChangeOpacityHint()) | |
| 77 return false; | |
| 78 | |
| 79 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | |
| 80 if (layout_object.StyleRef().Opacity()) | |
| 81 return false; | |
| 82 | |
| 83 const EffectPaintPropertyNode* effect = | |
| 84 layout_object.PaintProperties()->Effect(); | |
| 85 if (effect && effect->RequiresCompositingForAnimation()) { | |
| 86 return false; | |
| 87 } | |
| 88 } | |
| 89 | |
| 90 // 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 | |
| 92 // less leads to a color output of less than 0.5 in all channels, hence | |
| 93 // not visible. | |
| 94 static const float kMinimumVisibleOpacity = 0.0004f; | |
| 95 if (paint_layer_.PaintsWithTransparency( | |
| 96 painting_info.GetGlobalPaintFlags())) { | |
| 97 if (layout_object.StyleRef().Opacity() < kMinimumVisibleOpacity) { | |
| 98 return true; | |
| 99 } | |
| 100 } | |
| 101 return false; | |
| 102 } | |
| 103 | |
| 104 PaintResult PaintLayerPainter::Paint( | 67 PaintResult PaintLayerPainter::Paint( |
| 105 GraphicsContext& context, | 68 GraphicsContext& context, |
| 106 const PaintLayerPaintingInfo& painting_info, | 69 const PaintLayerPaintingInfo& painting_info, |
| 107 PaintLayerFlags paint_flags) { | 70 PaintLayerFlags paint_flags) { |
| 108 // https://code.google.com/p/chromium/issues/detail?id=343772 | 71 // https://code.google.com/p/chromium/issues/detail?id=343772 |
| 109 DisableCompositingQueryAsserts disabler; | 72 DisableCompositingQueryAsserts disabler; |
| 110 | 73 |
| 111 if (paint_layer_.GetCompositingState() != kNotComposited) { | 74 if (paint_layer_.GetCompositingState() != kNotComposited) { |
| 112 if (painting_info.GetGlobalPaintFlags() & | 75 if (painting_info.GetGlobalPaintFlags() & |
| 113 kGlobalPaintFlattenCompositingLayers) { | 76 kGlobalPaintFlattenCompositingLayers) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 128 if (ShouldSuppressPaintingLayer(paint_layer_)) | 91 if (ShouldSuppressPaintingLayer(paint_layer_)) |
| 129 return kFullyPainted; | 92 return kFullyPainted; |
| 130 | 93 |
| 131 if (paint_layer_.GetLayoutObject().View()->GetFrame() && | 94 if (paint_layer_.GetLayoutObject().View()->GetFrame() && |
| 132 paint_layer_.GetLayoutObject() | 95 paint_layer_.GetLayoutObject() |
| 133 .View() | 96 .View() |
| 134 ->GetFrame() | 97 ->GetFrame() |
| 135 ->ShouldThrottleRendering()) | 98 ->ShouldThrottleRendering()) |
| 136 return kFullyPainted; | 99 return kFullyPainted; |
| 137 | 100 |
| 138 // If this layer is totally invisible then there is nothing to paint. | |
| 139 if (PaintedOutputInvisible(painting_info)) | |
| 140 return kFullyPainted; | |
| 141 | |
| 142 if (paint_layer_.PaintsWithTransparency(painting_info.GetGlobalPaintFlags())) | 101 if (paint_layer_.PaintsWithTransparency(painting_info.GetGlobalPaintFlags())) |
| 143 paint_flags |= kPaintLayerHaveTransparency; | 102 paint_flags |= kPaintLayerHaveTransparency; |
| 144 | 103 |
| 145 if (paint_layer_.PaintsWithTransform(painting_info.GetGlobalPaintFlags()) && | 104 if (paint_layer_.PaintsWithTransform(painting_info.GetGlobalPaintFlags()) && |
| 146 !(paint_flags & kPaintLayerAppliedTransform)) | 105 !(paint_flags & kPaintLayerAppliedTransform)) |
| 147 return PaintLayerWithTransform(context, painting_info, paint_flags); | 106 return PaintLayerWithTransform(context, painting_info, paint_flags); |
| 148 | 107 |
| 149 return PaintLayerContentsCompositingAllPhases(context, painting_info, | 108 return PaintLayerContentsCompositingAllPhases(context, painting_info, |
| 150 paint_flags); | 109 paint_flags); |
| 151 } | 110 } |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1241 context, layout_object, kPaintPhaseClippingMask)) | 1200 context, layout_object, kPaintPhaseClippingMask)) |
| 1242 return; | 1201 return; |
| 1243 | 1202 |
| 1244 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); | 1203 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); |
| 1245 LayoutObjectDrawingRecorder drawing_recorder( | 1204 LayoutObjectDrawingRecorder drawing_recorder( |
| 1246 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); | 1205 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); |
| 1247 context.FillRect(snapped_clip_rect, Color::kBlack); | 1206 context.FillRect(snapped_clip_rect, Color::kBlack); |
| 1248 } | 1207 } |
| 1249 | 1208 |
| 1250 } // namespace blink | 1209 } // namespace blink |
| OLD | NEW |