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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayerPainter.cpp

Issue 1284203004: Generate scroll/clip display item hierarchy for SPv2 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: still long way to go Created 5 years, 4 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "core/paint/DeprecatedPaintLayerPainter.h" 6 #include "core/paint/DeprecatedPaintLayerPainter.h"
7 7
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/layout/ClipPathOperation.h" 9 #include "core/layout/ClipPathOperation.h"
10 #include "core/layout/LayoutBlock.h" 10 #include "core/layout/LayoutBlock.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ScopeRecorder scopeRecorder(*context); 103 ScopeRecorder scopeRecorder(*context);
104 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl ags | PaintLayerPaintingReflection); 104 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl ags | PaintLayerPaintingReflection);
105 } 105 }
106 106
107 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; 107 localPaintFlags |= PaintLayerPaintingCompositingAllPhases;
108 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy); 108 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy);
109 } 109 }
110 110
111 class ClipPathHelper { 111 class ClipPathHelper {
112 public: 112 public:
113 ClipPathHelper(GraphicsContext* context, const DeprecatedPaintLayer& paintLa yer, const DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutRect& rootRelat iveBounds, bool& rootRelativeBoundsComputed, 113 ClipPathHelper(GraphicsContext* context, const DeprecatedPaintLayer& paintLa yer, const LayoutRect& interestRect, LayoutRect& rootRelativeBounds, bool& rootR elativeBoundsComputed,
114 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) 114 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags)
115 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context) 115 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context)
116 { 116 {
117 const ComputedStyle& style = paintLayer.layoutObject()->styleRef(); 117 const ComputedStyle& style = paintLayer.layoutObject()->styleRef();
118 118
119 // Clip-path, like border radius, must not be applied to the contents of a composited-scrolling container. 119 // Clip-path, like border radius, must not be applied to the contents of a composited-scrolling container.
120 // It must, however, still be applied to the mask layer, so that the com positor can properly mask the 120 // It must, however, still be applied to the mask layer, so that the com positor can properly mask the
121 // scrolling contents and scrollbars. 121 // scrolling contents and scrollbars.
122 if (!paintLayer.layoutObject()->hasClipPath() || (paintLayer.needsCompos itedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) 122 if (!paintLayer.layoutObject()->hasClipPath() || (paintLayer.needsCompos itedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase)))
123 return; 123 return;
124 124
125 m_clipperState = SVGClipPainter::ClipperNotApplied; 125 m_clipperState = SVGClipPainter::ClipperNotApplied;
126 126
127 ASSERT(style.clipPath()); 127 ASSERT(style.clipPath());
128 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { 128 if (style.clipPath()->type() == ClipPathOperation::SHAPE) {
129 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl ipPath()); 129 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl ipPath());
130 if (clipPath->isValid()) { 130 if (clipPath->isValid()) {
131 if (!rootRelativeBoundsComputed) { 131 if (!rootRelativeBoundsComputed) {
132 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); 132 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(offsetFromRoot);
133 rootRelativeBoundsComputed = true; 133 rootRelativeBoundsComputed = true;
134 } 134 }
135 m_clipPathRecorder.emplace(*context, *paintLayer.layoutObject(), clipPath->path(rootRelativeBounds)); 135 m_clipPathRecorder.emplace(*context, *paintLayer.layoutObject(), clipPath->path(rootRelativeBounds));
136 } 136 }
137 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) { 137 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) {
138 ReferenceClipPathOperation* referenceClipPathOperation = toReference ClipPathOperation(style.clipPath()); 138 ReferenceClipPathOperation* referenceClipPathOperation = toReference ClipPathOperation(style.clipPath());
139 Document& document = paintLayer.layoutObject()->document(); 139 Document& document = paintLayer.layoutObject()->document();
140 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405) 140 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405)
141 Element* element = document.getElementById(referenceClipPathOperatio n->fragment()); 141 Element* element = document.getElementById(referenceClipPathOperatio n->fragment());
142 if (isSVGClipPathElement(element) && element->layoutObject()) { 142 if (isSVGClipPathElement(element) && element->layoutObject()) {
143 if (!rootRelativeBoundsComputed) { 143 if (!rootRelativeBoundsComputed) {
144 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); 144 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(offsetFromRoot);
145 rootRelativeBoundsComputed = true; 145 rootRelativeBoundsComputed = true;
146 } 146 }
147 147
148 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour ceContainer(element->layoutObject())); 148 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour ceContainer(element->layoutObject()));
149 if (!SVGClipPainter(*m_resourceClipper).applyClippingToContext(* paintLayer.layoutObject(), rootRelativeBounds, 149 if (!SVGClipPainter(*m_resourceClipper).applyClippingToContext(* paintLayer.layoutObject(), rootRelativeBounds,
150 paintingInfo.paintDirtyRect, context, m_clipperState)) { 150 interestRect, context, m_clipperState)) {
151 // No need to post-apply the clipper if this failed. 151 // No need to post-apply the clipper if this failed.
152 m_resourceClipper = 0; 152 m_resourceClipper = 0;
153 } 153 }
154 } 154 }
155 } 155 }
156 } 156 }
157 157
158 ~ClipPathHelper() 158 ~ClipPathHelper()
159 { 159 {
160 if (m_resourceClipper) 160 if (m_resourceClipper)
(...skipping 28 matching lines...) Expand all
189 && ((isPaintingScrollingContent && isPaintingCompositedBackground) 189 && ((isPaintingScrollingContent && isPaintingCompositedBackground)
190 || (!isPaintingScrollingContent && isPaintingCompositedForeground)); 190 || (!isPaintingScrollingContent && isPaintingCompositedForeground));
191 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting Layer && !isPaintingOverlayScrollbars; 191 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting Layer && !isPaintingOverlayScrollbars;
192 192
193 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement()) 193 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement())
194 return; 194 return;
195 195
196 // Ensure our lists are up-to-date. 196 // Ensure our lists are up-to-date.
197 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); 197 m_paintLayer.stackingNode()->updateLayerListsIfNeeded();
198 198
199 LayoutPoint offsetFromRoot; 199 LayoutPoint offsetFromRoot = toLayoutPoint(paintingInfo.subPixelAccumulation );
200 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); 200 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
201 201 m_paintLayer.convertToLayerCoordsSansOverflowScroll(paintingInfo.rootLay er, offsetFromRoot);
202 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking)
203 offsetFromRoot.move(m_paintLayer.subpixelAccumulation());
204 else 202 else
205 offsetFromRoot.move(paintingInfo.subPixelAccumulation); 203 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot );
206 204
207 LayoutRect rootRelativeBounds; 205 LayoutRect rootRelativeBounds;
208 bool rootRelativeBoundsComputed = false; 206 bool rootRelativeBoundsComputed = false;
209 207
210 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction, 208 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction,
211 // so they are nested properly. 209 // so they are nested properly.
212 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); 210 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo.paintDirty Rect, rootRelativeBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags );
213 211
214 Optional<LayerClipRecorder> clipRecorder; 212 Optional<LayerClipRecorder> clipRecorder;
215 Optional<CompositingRecorder> compositingRecorder; 213 Optional<CompositingRecorder> compositingRecorder;
216 // Blending operations must be performed only with the nearest ancestor stac king context. 214 // Blending operations must be performed only with the nearest ancestor stac king context.
217 // Note that there is no need to composite if we're painting the root. 215 // Note that there is no need to composite if we're painting the root.
218 // FIXME: this should be unified further into DeprecatedPaintLayer::paintsWi thTransparency(). 216 // FIXME: this should be unified further into DeprecatedPaintLayer::paintsWi thTransparency().
219 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode (); 217 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode ();
220 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint ingInfo.globalPaintFlags())) { 218 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint ingInfo.globalPaintFlags())) {
221 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), DisplayItem ::TransparencyClip, 219 // TODO(trchen): The transparent clip serves the purpose of raster hint for Skia,
pdr. 2015/08/25 20:47:55 Can we fix this before landing your patch? I agree
trchen 2015/08/26 07:39:04 Done.
222 m_paintLayer.paintingExtent(paintingInfo.rootLayer, paintingInfo.pai ntDirtyRect, paintingInfo.globalPaintFlags()), 220 // so the Skia layer can be sized according to the bounding box of conte nts being
223 &paintingInfo, LayoutPoint(), paintFlags); 221 // composited. The clip itself should be no-op, but will actually cause anti-alias
222 // artifact for transformed contents. Should remove this and use the 'bo unds' parameter
223 // in CompositingRecorder instead.
224 // For SPv2 the compositing bounds is unknown until layerization and imp l-side animation
225 // has been applied. It should be computed using display item cull rects at a later stage.
226 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
227 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), Display Item::TransparencyClip,
228 m_paintLayer.paintingExtent(paintingInfo.rootLayer, paintingInfo .paintDirtyRect, paintingInfo.globalPaintFlags()),
229 &paintingInfo, LayoutPoint(), paintFlags);
230 }
224 231
225 compositingRecorder.emplace(*context, *m_paintLayer.layoutObject(), 232 compositingRecorder.emplace(*context, *m_paintLayer.layoutObject(),
226 WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.la youtObject()->style()->blendMode()), 233 WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.la youtObject()->style()->blendMode()),
227 m_paintLayer.layoutObject()->opacity()); 234 m_paintLayer.layoutObject()->opacity());
228 } 235 }
229 236
230 DeprecatedPaintLayerPaintingInfo localPaintingInfo(paintingInfo);
231 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking)
232 localPaintingInfo.subPixelAccumulation = m_paintLayer.subpixelAccumulati on();
233
234 DeprecatedPaintLayerFragments layerFragments; 237 DeprecatedPaintLayerFragments layerFragments;
235 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { 238 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
236 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. 239 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment.
237 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 240 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
238 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_paintLayer.layoutObject()); 241 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_paintLayer.layoutObject());
239 if (fragmentPolicy == ForceSingleFragment) 242 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
240 m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, Ignore OverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.su bPixelAccumulation); 243 // TODO(trchen): Need to handle layer fragmentation.
241 else 244 DeprecatedPaintLayerFragment fragment;
242 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation); 245 fragment.layerBounds = LayoutRect(offsetFromRoot, LayoutSize(m_paint Layer.size()));
246 fragment.backgroundRect = LayoutRect::infiniteRect();
247 fragment.foregroundRect = LayoutRect::infiniteRect();
248 fragment.outlineRect = LayoutRect::infiniteRect();
249 layerFragments.append(fragment);
250 } else if (fragmentPolicy == ForceSingleFragment) {
251 m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScr ollbarSize, respectOverflowClip, &offsetFromRoot, paintingInfo.subPixelAccumulat ion);
252 } else {
253 m_paintLayer.collectFragments(layerFragments, paintingInfo.rootLayer , paintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOve rflowClip, &offsetFromRoot, paintingInfo.subPixelAccumulation);
254 }
255
243 if (shouldPaintContent) 256 if (shouldPaintContent)
244 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot); 257 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, paintingInfo, paintFlags, offsetFromRoot);
245 } 258 }
246 259
247 bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelec tionOnly; 260 bool selectionOnly = paintingInfo.globalPaintFlags() & GlobalPaintSelectionO nly;
248 // If this layer's layoutObject is a child of the paintingRoot, we paint unc onditionally, which 261 // If this layer's layoutObject is a child of the paintingRoot, we paint unc onditionally, which
249 // is done by passing a nil paintingRoot down to our layoutObject (as if no paintingRoot was ever set). 262 // is done by passing a nil paintingRoot down to our layoutObject (as if no paintingRoot was ever set).
250 // Else, our layout tree may or may not contain the painting root, so we pas s that root along 263 // Else, our layout tree may or may not contain the painting root, so we pas s that root along
251 // so it will be tested against as we descend through the layoutObjects. 264 // so it will be tested against as we descend through the layoutObjects.
252 LayoutObject* paintingRootForLayoutObject = 0; 265 LayoutObject* paintingRootForLayoutObject = 0;
253 if (localPaintingInfo.paintingRoot && !m_paintLayer.layoutObject()->isDescen dantOf(localPaintingInfo.paintingRoot)) 266 if (paintingInfo.paintingRoot && !m_paintLayer.layoutObject()->isDescendantO f(paintingInfo.paintingRoot))
254 paintingRootForLayoutObject = localPaintingInfo.paintingRoot; 267 paintingRootForLayoutObject = paintingInfo.paintingRoot;
255 268
256 { // Begin block for the lifetime of any filter. 269 { // Begin block for the lifetime of any filter.
257 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags, 270 // FilterRecorder may mutate paintingInfo.
271 DeprecatedPaintLayerPaintingInfo localPaintingInfo(paintingInfo);
272 ClipRect compositingBound;
273 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
274 // Similar to transparency clip above, for SPv2 the compositing boun d is only
275 // known since layerization and impl-side animation has been applied .
276 compositingBound = localPaintingInfo.paintDirtyRect;
277 } else if (!layerFragments.isEmpty()) {
278 // TODO(trchen): Using layerFragments[0].backgroundRect as compositi ng bound is
279 // incorrect. Using the union of the fragment clip rects could be a workaround
280 // but is still wrong in operation order. Conceptually it should be equivalent
281 // as painting the filtered stacking context as a whole, then cut th e results into
282 // fragments for pasting.
283 compositingBound = layerFragments[0].backgroundRect;
284 }
285 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, compo sitingBound, localPaintingInfo, paintFlags,
258 rootRelativeBounds, rootRelativeBoundsComputed); 286 rootRelativeBounds, rootRelativeBoundsComputed);
259 287
260 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly; 288 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly;
261 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound); 289 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound);
262 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent; 290 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent;
263 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound; 291 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound;
264 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; 292 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars;
265 293
266 if (shouldPaintBackground) { 294 if (shouldPaintBackground) {
267 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 295 paintBackgroundForFragments(layerFragments, context, localPaintingIn fo.paintDirtyRect,
268 localPaintingInfo, paintingRootForLayoutObject, paintFlags); 296 localPaintingInfo, paintingRootForLayoutObject, paintFlags);
269 } 297 }
270 298
271 if (shouldPaintNegZOrderList) 299 if (shouldPaintNegZOrderList)
272 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFl ags); 300 paintChildren(NegativeZOrderChildren, context, localPaintingInfo, pa intFlags);
273 301
274 if (shouldPaintOwnContents) { 302 if (shouldPaintOwnContents) {
275 paintForegroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 303 paintForegroundForFragments(layerFragments, context, localPaintingIn fo.paintDirtyRect,
276 localPaintingInfo, paintingRootForLayoutObject, selectionOnly, p aintFlags); 304 localPaintingInfo, paintingRootForLayoutObject, selectionOnly, p aintFlags);
277 } 305 }
278 306
279 if (shouldPaintOutline) 307 if (shouldPaintOutline)
280 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags); 308 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags);
281 309
282 if (shouldPaintNormalFlowAndPosZOrderLists) 310 if (shouldPaintNormalFlowAndPosZOrderLists)
283 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, paintingInfo, paintFlags); 311 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, localPaintingInfo, paintFlags);
284 312
285 if (shouldPaintOverlayScrollbars) 313 if (shouldPaintOverlayScrollbars)
286 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags); 314 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags);
287 } // FilterPainter block 315 } // FilterPainter block
288 316
289 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly; 317 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly;
290 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; 318 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly;
291 319
292 if (shouldPaintMask) 320 if (shouldPaintMask)
293 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForLayoutObject, paintFlags); 321 paintMaskForFragments(layerFragments, context, paintingInfo, paintingRoo tForLayoutObject, paintFlags);
294 if (shouldPaintClippingMask) { 322 if (shouldPaintClippingMask) {
295 // Paint the border radius mask for the fragments. 323 // Paint the border radius mask for the fragments.
296 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForLayoutObject, paintFlags); 324 paintChildClippingMaskForFragments(layerFragments, context, paintingInfo , paintingRootForLayoutObject, paintFlags);
297 } 325 }
298 } 326 }
299 327
300 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting Info& localPaintingInfo, const ClipRect& clipRect) 328 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting Info& localPaintingInfo, const ClipRect& clipRect)
301 { 329 {
302 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius(); 330 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius();
303 } 331 }
304 332
305 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot ) 333 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot )
306 { 334 {
307 if (m_paintLayer.enclosingPaginationLayer()) 335 if (m_paintLayer.enclosingPaginationLayer())
308 return true; // The fragments created have already been found to interse ct with the damage rect. 336 return true; // The fragments created have already been found to interse ct with the damage rect.
309 337
310 if (&m_paintLayer == localPaintingInfo.rootLayer && (localPaintFlags & Paint LayerPaintingOverflowContents)) 338 if (&m_paintLayer == localPaintingInfo.rootLayer && (localPaintFlags & Paint LayerPaintingOverflowContents))
311 return true; 339 return true;
312 340
313 for (DeprecatedPaintLayerFragment& fragment: fragments) { 341 for (DeprecatedPaintLayerFragment& fragment: fragments) {
314 LayoutPoint newOffsetFromRoot = offsetFromRoot + fragment.paginationOffs et; 342 LayoutPoint newOffsetFromRoot = offsetFromRoot + fragment.paginationOffs et;
315 // Note that this really only works reliably on the first fragment. If t he layer has visible 343 // Note that this really only works reliably on the first fragment. If t he layer has visible
316 // overflow and a subsequent fragment doesn't intersect with the border box of the layer 344 // overflow and a subsequent fragment doesn't intersect with the border box of the layer
317 // (i.e. only contains an overflow portion of the layer), intersection w ill fail. The reason 345 // (i.e. only contains an overflow portion of the layer), intersection w ill fail. The reason
318 // for this is that fragment.layerBounds is set to the border box, not t he bounding box, of 346 // for this is that fragment.layerBounds is set to the border box, not t he bounding box, of
319 // the layer. 347 // the layer.
320 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, fragment.bac kgroundRect.rect(), localPaintingInfo.rootLayer, &newOffsetFromRoot)) 348 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, fragment.bac kgroundRect.rect(), nullptr, &newOffsetFromRoot))
321 return true; 349 return true;
322 } 350 }
323 return false; 351 return false;
324 } 352 }
325 353
326 void DeprecatedPaintLayerPainter::paintLayerWithTransform(GraphicsContext* conte xt, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintF lags) 354 void DeprecatedPaintLayerPainter::paintLayerWithTransform(GraphicsContext* conte xt, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintF lags)
327 { 355 {
328 TransformationMatrix layerTransform = m_paintLayer.renderableTransform(paint ingInfo.globalPaintFlags()); 356 TransformationMatrix layerTransform = m_paintLayer.renderableTransform(paint ingInfo.globalPaintFlags());
329 // If the transform can't be inverted, then don't paint anything. 357 // If the transform can't be inverted, then don't paint anything.
330 if (!layerTransform.isInvertible()) 358 if (!layerTransform.isInvertible())
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 436
409 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL ayerFlags paintFlags) 437 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL ayerFlags paintFlags)
410 { 438 {
411 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) 439 if (!m_paintLayer.hasSelfPaintingLayerDescendant())
412 return; 440 return;
413 441
414 #if ENABLE(ASSERT) 442 #if ENABLE(ASSERT)
415 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); 443 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode());
416 #endif 444 #endif
417 445
446 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
447 paintChildrenV2(childrenToVisit, context, paintingInfo, paintFlags);
pdr. 2015/08/25 20:47:55 return here?
trchen 2015/08/26 07:39:04 Done.
448
418 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation; 449 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation;
419 if (m_paintLayer.layoutObject()->hasOverflowClip()) 450 if (m_paintLayer.layoutObject()->hasOverflowClip())
420 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff set(); 451 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff set();
421 452
422 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit); 453 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit);
423 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { 454 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) {
424 DeprecatedPaintLayerPainter childPainter(*child->layer()); 455 DeprecatedPaintLayerPainter childPainter(*child->layer());
425 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents() 456 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents()
426 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). 457 // and CompositedDeprecatedPaintLayerMapping::doPaintTask().
427 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain tFlags(), paintFlags)) 458 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain tFlags(), paintFlags))
428 continue; 459 continue;
429 460
430 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo; 461 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo;
431 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation; 462 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation;
432 // Rare case: accumulate scroll offset of non-stacking-context ancestors up to m_paintLayer. 463 // Rare case: accumulate scroll offset of non-stacking-context ancestors up to m_paintLayer.
433 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { 464 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) {
434 if (parentLayer->layoutObject()->hasOverflowClip()) 465 if (parentLayer->layoutObject()->hasOverflowClip())
435 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset(); 466 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset();
436 } 467 }
437 468
438 childPainter.paintLayer(context, childPaintingInfo, paintFlags); 469 childPainter.paintLayer(context, childPaintingInfo, paintFlags);
439 } 470 }
440 } 471 }
441 472
473 static void recursivelyScrollAndPaintChildLayer(Vector<DeprecatedPaintLayer*>& c lippingAncestors, DeprecatedPaintLayer& child, GraphicsContext& context, const D eprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
474 {
475 if (clippingAncestors.isEmpty()) {
476 DeprecatedPaintLayerPainter childPainter(child);
477 childPainter.paintLayer(&context, paintingInfo, paintFlags);
478 return;
479 }
480 DeprecatedPaintLayer* layer = clippingAncestors.last();
481 clippingAncestors.removeLast();
482
483 // TODO(trchen): Add LayerClipRecorder here.
484
485 IntSize scrollOffset = layer->layoutBox()->scrolledContentOffset();
486 Optional<ScrollRecorder> scrollRecorder;
487 if (layer->scrollsOverflow() || !scrollOffset.isZero())
488 scrollRecorder.emplace(context, *layer->layoutObject(), PaintPhaseBlockB ackground, scrollOffset);
489 recursivelyScrollAndPaintChildLayer(clippingAncestors, child, context, paint ingInfo, paintFlags);
490 }
491
492 void DeprecatedPaintLayerPainter::paintChildrenV2(unsigned childrenToVisit, Grap hicsContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, Pain tLayerFlags paintFlags)
493 {
494 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit);
495 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) {
496 EPosition childPosition = child->layer()->layoutObject()->style()->posit ion();
497 if (childPosition == FixedPosition) {
498 // TODO(trchen): Refer to the transform/clip node of the nearest tra nsformed ancestor.
499 continue;
500 }
501
502 Vector<DeprecatedPaintLayer*> clippingAncestors;
503
504 // TODO(trchen): Needs to add referrals to reuse existing transform/clip nodes.
505 DeprecatedPaintLayer* currentLayer = child->layer();
506 while (currentLayer && currentLayer != &m_paintLayer) {
507 EPosition position = currentLayer->layoutObject()->style()->position ();
508 ASSERT(position != FixedPosition);
509
510 DeprecatedPaintLayer* container;
pdr. 2015/08/25 20:47:55 DeprecatedPaintLayer* container = nullptr; (pointe
trchen 2015/08/26 07:39:04 Done.
511 if (position == AbsolutePosition) {
512 bool ranPastThisLayer;
513 container = currentLayer->enclosingPositionedAncestor(&m_paintLa yer, &ranPastThisLayer);
514 if (ranPastThisLayer)
515 break;
516 } else {
517 container = currentLayer->parent();
518 }
519 if (!container)
520 break;
521
522 if (container->layoutObject()->hasOverflowClip())
523 clippingAncestors.append(container);
524
525 currentLayer = container;
526 }
527
528 recursivelyScrollAndPaintChildLayer(clippingAncestors, *child->layer(), *context, paintingInfo, paintFlags);
529 }
530 }
531
442 // FIXME: inline this. 532 // FIXME: inline this.
443 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags) 533 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags)
444 { 534 {
445 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly); 535 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly);
446 } 536 }
447 537
448 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai ntFlags globalPaintFlags, PaintLayerFlags paintFlags) 538 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai ntFlags globalPaintFlags, PaintLayerFlags paintFlags)
449 { 539 {
450 DisableCompositingQueryAsserts disabler; 540 DisableCompositingQueryAsserts disabler;
451 541
(...skipping 17 matching lines...) Expand all
469 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), Display Item::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fr agment.paginationOffset, paintFlags); 559 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), Display Item::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fr agment.paginationOffset, paintFlags);
470 if (DeprecatedPaintLayerScrollableArea* scrollableArea = m_paintLayer.sc rollableArea()) 560 if (DeprecatedPaintLayerScrollableArea* scrollableArea = m_paintLayer.sc rollableArea())
471 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); 561 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
472 } 562 }
473 } 563 }
474 564
475 void DeprecatedPaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const DeprecatedPaintLayerFragment& fragment, GraphicsContext* context, const ClipRec t& clipRect, const DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags, ClipState clipState) 565 void DeprecatedPaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const DeprecatedPaintLayerFragment& fragment, GraphicsContext* context, const ClipRec t& clipRect, const DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags, ClipState clipState)
476 { 566 {
477 ASSERT(m_paintLayer.isSelfPaintingLayer()); 567 ASSERT(m_paintLayer.isSelfPaintingLayer());
478 568
569 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
570 PaintInfo paintInfo(context, enclosingIntRect(paintingInfo.paintDirtyRec t), phase, paintingInfo.globalPaintFlags(), paintFlags, paintingRootForLayoutObj ect, 0, paintingInfo.rootLayer->layoutObject());
571 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_pa intLayer.layoutBoxLocation());
572 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
573 return;
574 }
575
479 Optional<LayerClipRecorder> clipRecorder; 576 Optional<LayerClipRecorder> clipRecorder;
480 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) { 577 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) {
481 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase); 578 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase);
482 LayerClipRecorder::BorderRadiusClippingRule clippingRule; 579 LayerClipRecorder::BorderRadiusClippingRule clippingRule;
483 switch (phase) { 580 switch (phase) {
484 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self. 581 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self.
485 case PaintPhaseSelfOutline: 582 case PaintPhaseSelfOutline:
486 case PaintPhaseMask: // Mask painting will handle clipping to self. 583 case PaintPhaseMask: // Mask painting will handle clipping to self.
487 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; 584 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius;
488 break; 585 break;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 701 if (!m_paintLayer.containsDirtyOverlayScrollbars())
605 return; 702 return;
606 703
607 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); 704 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot);
608 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 705 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
609 706
610 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 707 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
611 } 708 }
612 709
613 } // namespace blink 710 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698