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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/LayerPainter.h" | 6 #include "core/paint/LayerPainter.h" |
7 | 7 |
8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
10 #include "core/paint/FilterPainter.h" | 10 #include "core/paint/FilterPainter.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 99 } |
100 | 100 |
101 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); | 101 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); |
102 | 102 |
103 return; | 103 return; |
104 } | 104 } |
105 | 105 |
106 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); | 106 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); |
107 } | 107 } |
108 | 108 |
109 class TransparencyLayerHelper { | |
110 public: | |
111 TransparencyLayerHelper(GraphicsContext* context, RenderLayer& renderLayer,
const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize
& subPixelAccumulation, PaintBehavior paintBehavior) | |
112 : m_transparencyLayerInProgress(false) | |
113 , m_context(context) | |
114 , m_renderLayer(renderLayer) | |
115 { | |
116 // Blending operations must be performed only with the nearest ancestor
stacking context. | |
117 // Note that there is no need to create a transparency layer if we're pa
inting the root. | |
118 // FIXME: this should be unified further into RenderLayer::paintsWithTra
nsparency(). | |
119 bool shouldUseTransparencyLayerForBlendMode = !renderLayer.renderer()->i
sDocumentElement() && renderLayer.stackingNode()->isStackingContext() && renderL
ayer.hasNonIsolatedDescendantWithBlendMode(); | |
120 if (!shouldUseTransparencyLayerForBlendMode && !renderLayer.paintsWithTr
ansparency(paintBehavior)) | |
121 return; | |
122 | |
123 OwnPtr<BeginTransparencyDisplayItem> beginTransparencyDisplayItem = adop
tPtr(new BeginTransparencyDisplayItem( | |
124 renderLayer.renderer(), DisplayItem::BeginTransparency, renderLayer.
paintingExtent(rootLayer, paintDirtyRect, subPixelAccumulation, paintBehavior), | |
125 renderLayer.renderer()->style()->blendMode(), renderLayer.renderer()
->opacity())); | |
126 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | |
127 renderLayer.renderer()->view()->viewDisplayList().add(beginTranspare
ncyDisplayItem.release()); | |
128 else | |
129 beginTransparencyDisplayItem->replay(context); | |
130 | |
131 m_transparencyLayerInProgress = true; | |
132 } | |
133 | |
134 ~TransparencyLayerHelper() | |
135 { | |
136 if (!m_transparencyLayerInProgress) | |
137 return; | |
138 OwnPtr<EndTransparencyDisplayItem> endTransparencyDisplayItem = adoptPtr
(new EndTransparencyDisplayItem(m_renderLayer.renderer(), DisplayItem::EndTransp
arency)); | |
139 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | |
140 m_renderLayer.renderer()->view()->viewDisplayList().add(endTranspare
ncyDisplayItem.release()); | |
141 else | |
142 endTransparencyDisplayItem->replay(m_context); | |
143 } | |
144 private: | |
145 bool m_transparencyLayerInProgress; | |
146 GraphicsContext* m_context; | |
147 const RenderLayer& m_renderLayer; | |
148 }; | |
149 | |
150 void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, con
st LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) | 109 void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, con
st LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
151 { | 110 { |
152 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); | 111 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); |
153 | 112 |
154 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform)
; | 113 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform)
; |
155 | 114 |
156 // Paint the reflection first if we have one. | 115 // Paint the reflection first if we have one. |
157 if (m_renderLayer.reflectionInfo()) | 116 if (m_renderLayer.reflectionInfo()) |
158 m_renderLayer.reflectionInfo()->paint(context, paintingInfo, localPaintF
lags | PaintLayerPaintingReflection); | 117 m_renderLayer.reflectionInfo()->paint(context, paintingInfo, localPaintF
lags | PaintLayerPaintingReflection); |
159 | 118 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 222 |
264 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) | 223 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) |
265 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); | 224 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); |
266 | 225 |
267 LayoutRect rootRelativeBounds; | 226 LayoutRect rootRelativeBounds; |
268 bool rootRelativeBoundsComputed = false; | 227 bool rootRelativeBoundsComputed = false; |
269 | 228 |
270 // These helpers output clip and transparency layers using a RAII pattern. S
tack-allocated-varibles are destructed in the reverse order of construction, | 229 // These helpers output clip and transparency layers using a RAII pattern. S
tack-allocated-varibles are destructed in the reverse order of construction, |
271 // so they are nested properly. | 230 // so they are nested properly. |
272 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela
tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); | 231 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela
tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); |
273 TransparencyLayerHelper transparencyLayerHelper(context, m_renderLayer, pain
tingInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulati
on, paintingInfo.paintBehavior); | 232 |
| 233 OwnPtr<TransparencyRecorder> transparencyRecorder; |
| 234 // Blending operations must be performed only with the nearest ancestor stac
king context. |
| 235 // Note that there is no need to create a transparency layer if we're painti
ng the root. |
| 236 // FIXME: this should be unified further into RenderLayer::paintsWithTranspa
rency(). |
| 237 bool shouldUseTransparencyLayerForBlendMode = !m_renderLayer.renderer()->isD
ocumentElement() && m_renderLayer.stackingNode()->isStackingContext() && m_rende
rLayer.hasNonIsolatedDescendantWithBlendMode(); |
| 238 if (shouldUseTransparencyLayerForBlendMode || m_renderLayer.paintsWithTransp
arency(paintingInfo.paintBehavior)) { |
| 239 transparencyRecorder = adoptPtr(new TransparencyRecorder(context, m_rend
erLayer.renderer(), DisplayItem::BeginTransparency, m_renderLayer.paintingExtent
(paintingInfo.rootLayer, paintingInfo.paintDirtyRect, |
| 240 paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior), m_re
nderLayer.renderer()->style()->blendMode(), m_renderLayer.renderer()->opacity())
); |
| 241 } |
274 | 242 |
275 LayerPaintingInfo localPaintingInfo(paintingInfo); | 243 LayerPaintingInfo localPaintingInfo(paintingInfo); |
276 | 244 |
277 LayerFragments layerFragments; | 245 LayerFragments layerFragments; |
278 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars)
{ | 246 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars)
{ |
279 // Collect the fragments. This will compute the clip rectangles and pain
t offsets for each layer fragment. | 247 // Collect the fragments. This will compute the clip rectangles and pain
t offsets for each layer fragment. |
280 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay
er, localPaintingInfo.paintDirtyRect, | 248 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay
er, localPaintingInfo.paintDirtyRect, |
281 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai
ntingClipRects, IgnoreOverlayScrollbarSize, | 249 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai
ntingClipRects, IgnoreOverlayScrollbarSize, |
282 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of
fsetFromRoot, localPaintingInfo.subPixelAccumulation); | 250 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of
fsetFromRoot, localPaintingInfo.subPixelAccumulation); |
283 if (shouldPaintContent) | 251 if (shouldPaintContent) |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 722 |
755 OwnPtr<ClipRecorder> clipRecorder; | 723 OwnPtr<ClipRecorder> clipRecorder; |
756 if (needsToClip(paintingInfo, clipRect)) | 724 if (needsToClip(paintingInfo, clipRect)) |
757 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), c
ontext, DisplayItem::ClipLayerFragmentParent, clipRect, &paintingInfo, LayoutPoi
nt(), paintFlags)); | 725 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), c
ontext, DisplayItem::ClipLayerFragmentParent, clipRect, &paintingInfo, LayoutPoi
nt(), paintFlags)); |
758 | 726 |
759 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen
t.paginationOffset); | 727 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen
t.paginationOffset); |
760 } | 728 } |
761 } | 729 } |
762 | 730 |
763 } // namespace blink | 731 } // namespace blink |
OLD | NEW |