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

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

Issue 1129793005: Replace OwnPtr with WTF::Optional for optional recorders. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge with master Created 5 years, 6 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 10 matching lines...) Expand all
21 #include "core/paint/ScopeRecorder.h" 21 #include "core/paint/ScopeRecorder.h"
22 #include "core/paint/ScrollRecorder.h" 22 #include "core/paint/ScrollRecorder.h"
23 #include "core/paint/ScrollableAreaPainter.h" 23 #include "core/paint/ScrollableAreaPainter.h"
24 #include "core/paint/Transform3DRecorder.h" 24 #include "core/paint/Transform3DRecorder.h"
25 #include "platform/graphics/GraphicsLayer.h" 25 #include "platform/graphics/GraphicsLayer.h"
26 #include "platform/graphics/paint/ClipPathRecorder.h" 26 #include "platform/graphics/paint/ClipPathRecorder.h"
27 #include "platform/graphics/paint/ClipRecorder.h" 27 #include "platform/graphics/paint/ClipRecorder.h"
28 #include "platform/graphics/paint/CompositingDisplayItem.h" 28 #include "platform/graphics/paint/CompositingDisplayItem.h"
29 #include "platform/graphics/paint/DisplayItemList.h" 29 #include "platform/graphics/paint/DisplayItemList.h"
30 #include "platform/graphics/paint/Transform3DDisplayItem.h" 30 #include "platform/graphics/paint/Transform3DDisplayItem.h"
31 #include "wtf/Optional.h"
31 32
32 namespace blink { 33 namespace blink {
33 34
34 static inline bool shouldSuppressPaintingLayer(DeprecatedPaintLayer* layer) 35 static inline bool shouldSuppressPaintingLayer(DeprecatedPaintLayer* layer)
35 { 36 {
36 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC. 37 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC.
37 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document 38 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
38 // will do a full paintInvalidationForWholeLayoutObject(). 39 // will do a full paintInvalidationForWholeLayoutObject().
39 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement()) 40 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement())
40 return true; 41 return true;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 else 206 else
206 offsetFromRoot.move(paintingInfo.subPixelAccumulation); 207 offsetFromRoot.move(paintingInfo.subPixelAccumulation);
207 208
208 LayoutRect rootRelativeBounds; 209 LayoutRect rootRelativeBounds;
209 bool rootRelativeBoundsComputed = false; 210 bool rootRelativeBoundsComputed = false;
210 211
211 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction, 212 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction,
212 // so they are nested properly. 213 // so they are nested properly.
213 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); 214 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags);
214 215
215 OwnPtr<LayerClipRecorder> clipRecorder; 216 Optional<LayerClipRecorder> clipRecorder;
216 OwnPtr<CompositingRecorder> compositingRecorder; 217 Optional<CompositingRecorder> compositingRecorder;
217 // Blending operations must be performed only with the nearest ancestor stac king context. 218 // Blending operations must be performed only with the nearest ancestor stac king context.
218 // Note that there is no need to composite if we're painting the root. 219 // Note that there is no need to composite if we're painting the root.
219 // FIXME: this should be unified further into DeprecatedPaintLayer::paintsWi thTransparency(). 220 // FIXME: this should be unified further into DeprecatedPaintLayer::paintsWi thTransparency().
220 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode (); 221 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode ();
221 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint ingInfo.paintBehavior)) { 222 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint ingInfo.paintBehavior)) {
222 clipRecorder = adoptPtr(new LayerClipRecorder(*context, *m_paintLayer.la youtObject(), DisplayItem::TransparencyClip, 223 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), DisplayItem ::TransparencyClip,
223 m_paintLayer.paintingExtent(paintingInfo.rootLayer, paintingInfo.pai ntDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior), 224 m_paintLayer.paintingExtent(paintingInfo.rootLayer, paintingInfo.pai ntDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior),
224 &paintingInfo, LayoutPoint(), paintFlags)); 225 &paintingInfo, LayoutPoint(), paintFlags);
225 226
226 compositingRecorder = adoptPtr(new CompositingRecorder(*context, *m_pain tLayer.layoutObject(), 227 compositingRecorder.emplace(*context, *m_paintLayer.layoutObject(),
227 WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.la youtObject()->style()->blendMode()), 228 WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.la youtObject()->style()->blendMode()),
228 m_paintLayer.layoutObject()->opacity())); 229 m_paintLayer.layoutObject()->opacity());
229 } 230 }
230 231
231 DeprecatedPaintLayerPaintingInfo localPaintingInfo(paintingInfo); 232 DeprecatedPaintLayerPaintingInfo localPaintingInfo(paintingInfo);
232 233
233 DeprecatedPaintLayerFragments layerFragments; 234 DeprecatedPaintLayerFragments layerFragments;
234 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { 235 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
235 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. 236 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment.
236 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 237 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
237 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_paintLayer.layoutObject()); 238 ShouldRespectOverflowClip respectOverflowClip = shouldRespectOverflowCli p(paintFlags, m_paintLayer.layoutObject());
238 if (fragmentPolicy == ForceSingleFragment) 239 if (fragmentPolicy == ForceSingleFragment)
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // We don't need to collect any fragments in the regular way here. We ha ve already 368 // We don't need to collect any fragments in the regular way here. We ha ve already
368 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this 369 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this
369 // layer is something that can be done further down the path, when the t ransform has 370 // layer is something that can be done further down the path, when the t ransform has
370 // been applied. 371 // been applied.
371 DeprecatedPaintLayerFragment fragment; 372 DeprecatedPaintLayerFragment fragment;
372 fragment.backgroundRect = paintingInfo.paintDirtyRect; 373 fragment.backgroundRect = paintingInfo.paintDirtyRect;
373 fragments.append(fragment); 374 fragments.append(fragment);
374 } 375 }
375 376
376 bool needsScope = fragments.size() > 1; 377 bool needsScope = fragments.size() > 1;
377 for (const auto& fragment: fragments) { 378 for (const auto& fragment : fragments) {
378 OwnPtr<ScopeRecorder> scopeRecorder; 379 Optional<ScopeRecorder> scopeRecorder;
379 if (needsScope) 380 if (needsScope)
380 scopeRecorder = adoptPtr(new ScopeRecorder(*context, *m_paintLayer.l ayoutObject())); 381 scopeRecorder.emplace(*context, *m_paintLayer.layoutObject());
381 OwnPtr<LayerClipRecorder> clipRecorder; 382 Optional<LayerClipRecorder> clipRecorder;
382 if (parentLayer) { 383 if (parentLayer) {
383 ClipRect clipRectForFragment(ancestorBackgroundClipRect); 384 ClipRect clipRectForFragment(ancestorBackgroundClipRect);
384 clipRectForFragment.moveBy(fragment.paginationOffset); 385 clipRectForFragment.moveBy(fragment.paginationOffset);
385 clipRectForFragment.intersect(fragment.backgroundRect); 386 clipRectForFragment.intersect(fragment.backgroundRect);
386 if (clipRectForFragment.isEmpty()) 387 if (clipRectForFragment.isEmpty())
387 continue; 388 continue;
388 if (needsToClip(paintingInfo, clipRectForFragment)) 389 if (needsToClip(paintingInfo, clipRectForFragment))
389 clipRecorder = adoptPtr(new LayerClipRecorder(*context, *parentL ayer->layoutObject(), DisplayItem::ClipLayerParent, clipRectForFragment, &painti ngInfo, fragment.paginationOffset, paintFlags)); 390 clipRecorder.emplace(*context, *parentLayer->layoutObject(), Dis playItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginati onOffset, paintFlags);
390 } 391 }
391 392
392 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag ment.paginationOffset); 393 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag ment.paginationOffset);
393 } 394 }
394 } 395 }
395 396
396 void DeprecatedPaintLayerPainter::paintFragmentByApplyingTransform(GraphicsConte xt* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFla gs paintFlags, const LayoutPoint& fragmentTranslation) 397 void DeprecatedPaintLayerPainter::paintFragmentByApplyingTransform(GraphicsConte xt* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFla gs paintFlags, const LayoutPoint& fragmentTranslation)
397 { 398 {
398 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving 399 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving
399 // the accumulated error for sub-pixel layout. 400 // the accumulated error for sub-pixel layout.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 return m_paintLayer.compositingState() == NotComposited 451 return m_paintLayer.compositingState() == NotComposited
451 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) 452 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)
452 || ((paintFlags & PaintLayerPaintingReflection) && !m_paintLayer.has3DTr ansform()) 453 || ((paintFlags & PaintLayerPaintingReflection) && !m_paintLayer.has3DTr ansform())
453 || paintForFixedRootBackground(&m_paintLayer, paintFlags); 454 || paintForFixedRootBackground(&m_paintLayer, paintFlags);
454 } 455 }
455 456
456 void DeprecatedPaintLayerPainter::paintOverflowControlsForFragments(const Deprec atedPaintLayerFragments& layerFragments, GraphicsContext* context, const Depreca tedPaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 457 void DeprecatedPaintLayerPainter::paintOverflowControlsForFragments(const Deprec atedPaintLayerFragments& layerFragments, GraphicsContext* context, const Depreca tedPaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
457 { 458 {
458 bool needsScope = layerFragments.size() > 1; 459 bool needsScope = layerFragments.size() > 1;
459 for (auto& fragment : layerFragments) { 460 for (auto& fragment : layerFragments) {
460 OwnPtr<ScopeRecorder> scopeRecorder; 461 Optional<ScopeRecorder> scopeRecorder;
461 if (needsScope) 462 if (needsScope)
462 scopeRecorder = adoptPtr(new ScopeRecorder(*context, *m_paintLayer.l ayoutObject())); 463 scopeRecorder.emplace(*context, *m_paintLayer.layoutObject());
463 464
464 OwnPtr<LayerClipRecorder> clipRecorder; 465 Optional<LayerClipRecorder> clipRecorder;
465 466
466 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { 467 if (needsToClip(localPaintingInfo, fragment.backgroundRect))
467 clipRecorder = adoptPtr(new LayerClipRecorder(*context, *m_paintLaye r.layoutObject(), DisplayItem::ClipLayerOverflowControls, fragment.backgroundRec t, &localPaintingInfo, fragment.paginationOffset, paintFlags)); 468 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), Display Item::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fr agment.paginationOffset, paintFlags);
468 }
469 if (DeprecatedPaintLayerScrollableArea* scrollableArea = m_paintLayer.sc rollableArea()) 469 if (DeprecatedPaintLayerScrollableArea* scrollableArea = m_paintLayer.sc rollableArea())
470 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); 470 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
471 } 471 }
472 } 472 }
473 473
474 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* layoutO bject, LayoutBox* ancestorColumnsLayoutObject) 474 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* layoutO bject, LayoutBox* ancestorColumnsLayoutObject)
475 { 475 {
476 LayoutView* view = layoutObject->view(); 476 LayoutView* view = layoutObject->view();
477 LayoutBoxModelObject* prevBlock = layoutObject; 477 LayoutBoxModelObject* prevBlock = layoutObject;
478 LayoutBlock* containingBlock; 478 LayoutBlock* containingBlock;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 currLogicalTopOffset += blockDelta; 605 currLogicalTopOffset += blockDelta;
606 else 606 else
607 currLogicalTopOffset -= blockDelta; 607 currLogicalTopOffset -= blockDelta;
608 } 608 }
609 } 609 }
610 610
611 void DeprecatedPaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const DeprecatedPaintLayerFragment& fragment, GraphicsContext* context, const ClipRec t& clipRect, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintBehavior paintBehavior, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paint Flags, ClipState clipState) 611 void DeprecatedPaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const DeprecatedPaintLayerFragment& fragment, GraphicsContext* context, const ClipRec t& clipRect, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintBehavior paintBehavior, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paint Flags, ClipState clipState)
612 { 612 {
613 ASSERT(m_paintLayer.isSelfPaintingLayer()); 613 ASSERT(m_paintLayer.isSelfPaintingLayer());
614 614
615 OwnPtr<LayerClipRecorder> clipRecorder; 615 Optional<LayerClipRecorder> clipRecorder;
616 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) { 616 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) {
617 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase); 617 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase);
618 LayerClipRecorder::BorderRadiusClippingRule clippingRule; 618 LayerClipRecorder::BorderRadiusClippingRule clippingRule;
619 switch (phase) { 619 switch (phase) {
620 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self. 620 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self.
621 case PaintPhaseSelfOutline: 621 case PaintPhaseSelfOutline:
622 case PaintPhaseMask: // Mask painting will handle clipping to self. 622 case PaintPhaseMask: // Mask painting will handle clipping to self.
623 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; 623 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius;
624 break; 624 break;
625 default: 625 default:
626 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 626 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
627 break; 627 break;
628 } 628 }
629 629
630 clipRecorder = adoptPtr(new LayerClipRecorder(*context, *m_paintLayer.la youtObject(), clipType, clipRect, &paintingInfo, fragment.paginationOffset, pain tFlags, clippingRule)); 630 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), clipType, c lipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule);
631 } 631 }
632 632
633 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForLayoutObject, 0, paintingInfo.rootLayer->layoutObjec t()); 633 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForLayoutObject, 0, paintingInfo.rootLayer->layoutObjec t());
634 OwnPtr<ScrollRecorder> scrollRecorder; 634 OwnPtr<ScrollRecorder> scrollRecorder;
635 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation()); 635 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation());
636 if (&m_paintLayer != paintingInfo.rootLayer && paintingInfo.rootLayer->layou tObject()->hasOverflowClip()) { 636 if (&m_paintLayer != paintingInfo.rootLayer && paintingInfo.rootLayer->layou tObject()->hasOverflowClip()) {
637 // As a sublayer of the root layer, m_paintLayer's painting is not contr olled by the ScrollRecorder 637 // As a sublayer of the root layer, m_paintLayer's painting is not contr olled by the ScrollRecorder
638 // created by BlockPainter of the root layer, so we need to issue Scroll Recorder for them separately. 638 // created by BlockPainter of the root layer, so we need to issue Scroll Recorder for them separately.
639 // FIXME: This doesn't apply in slimming paint phase 2. 639 // FIXME: This doesn't apply in slimming paint phase 2.
640 IntSize scrollOffset = paintingInfo.rootLayer->layoutBox()->scrolledCont entOffset(); 640 IntSize scrollOffset = paintingInfo.rootLayer->layoutBox()->scrolledCont entOffset();
641 if (paintingInfo.rootLayer->scrollsOverflow() || !scrollOffset.isZero()) { 641 if (paintingInfo.rootLayer->scrollsOverflow() || !scrollOffset.isZero()) {
642 paintOffset += scrollOffset; 642 paintOffset += scrollOffset;
643 paintInfo.rect.move(scrollOffset); 643 paintInfo.rect.move(scrollOffset);
644 scrollRecorder = adoptPtr(new ScrollRecorder(*paintInfo.context, *m_ paintLayer.layoutObject(), paintInfo.phase, scrollOffset)); 644 scrollRecorder = adoptPtr(new ScrollRecorder(*paintInfo.context, *m_ paintLayer.layoutObject(), paintInfo.phase, scrollOffset));
645 } 645 }
646 } 646 }
647 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); 647 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
648 } 648 }
649 649
650 void DeprecatedPaintLayerPainter::paintBackgroundForFragments(const DeprecatedPa intLayerFragments& layerFragments, GraphicsContext* context, 650 void DeprecatedPaintLayerPainter::paintBackgroundForFragments(const DeprecatedPa intLayerFragments& layerFragments, GraphicsContext* context,
651 const LayoutRect& transparencyPaintDirtyRect, const DeprecatedPaintLayerPain tingInfo& localPaintingInfo, PaintBehavior paintBehavior, 651 const LayoutRect& transparencyPaintDirtyRect, const DeprecatedPaintLayerPain tingInfo& localPaintingInfo, PaintBehavior paintBehavior,
652 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 652 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
653 { 653 {
654 bool needsScope = layerFragments.size() > 1; 654 bool needsScope = layerFragments.size() > 1;
655 for (auto& fragment: layerFragments) { 655 for (auto& fragment : layerFragments) {
656 OwnPtr<ScopeRecorder> scopeRecorder; 656 Optional<ScopeRecorder> scopeRecorder;
657 if (needsScope) 657 if (needsScope)
658 scopeRecorder = adoptPtr(new ScopeRecorder(*context, *m_paintLayer.l ayoutObject())); 658 scopeRecorder.emplace(*context, *m_paintLayer.layoutObject());
659 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForLayoutObj ect, paintFlags, HasNotClipped); 659 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForLayoutObj ect, paintFlags, HasNotClipped);
660 } 660 }
661 } 661 }
662 662
663 void DeprecatedPaintLayerPainter::paintForegroundForFragments(const DeprecatedPa intLayerFragments& layerFragments, GraphicsContext* context, 663 void DeprecatedPaintLayerPainter::paintForegroundForFragments(const DeprecatedPa intLayerFragments& layerFragments, GraphicsContext* context,
664 const LayoutRect& transparencyPaintDirtyRect, const DeprecatedPaintLayerPain tingInfo& localPaintingInfo, PaintBehavior paintBehavior, 664 const LayoutRect& transparencyPaintDirtyRect, const DeprecatedPaintLayerPain tingInfo& localPaintingInfo, PaintBehavior paintBehavior,
665 LayoutObject* paintingRootForLayoutObject, bool selectionOnly, PaintLayerFla gs paintFlags) 665 LayoutObject* paintingRootForLayoutObject, bool selectionOnly, PaintLayerFla gs paintFlags)
666 { 666 {
667 // Optimize clipping for the single fragment case. 667 // Optimize clipping for the single fragment case.
668 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); 668 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
669 ClipState clipState = HasNotClipped; 669 ClipState clipState = HasNotClipped;
670 OwnPtr<LayerClipRecorder> clipRecorder; 670 Optional<LayerClipRecorder> clipRecorder;
671 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) { 671 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) {
672 clipRecorder = adoptPtr(new LayerClipRecorder(*context, *m_paintLayer.la youtObject(), DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect , &localPaintingInfo, layerFragments[0].paginationOffset, paintFlags)); 672 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), DisplayItem ::ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, lay erFragments[0].paginationOffset, paintFlags);
673 clipState = HasClipped; 673 clipState = HasClipped;
674 } 674 }
675 675
676 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for 676 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for
677 // interleaving of the fragments to work properly. 677 // interleaving of the fragments to work properly.
678 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments, 678 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments,
679 context, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, paintFlags, clipState); 679 context, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, paintFlags, clipState);
680 680
681 if (!selectionOnly) { 681 if (!selectionOnly) {
682 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, paintFlags , clipState); 682 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, paintFlags , clipState);
683 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, paint Flags, clipState); 683 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, paint Flags, clipState);
684 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragm ents, context, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, pa intFlags, clipState); 684 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragm ents, context, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, pa intFlags, clipState);
685 } 685 }
686 } 686 }
687 687
688 void DeprecatedPaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhas e phase, const DeprecatedPaintLayerFragments& layerFragments, GraphicsContext* c ontext, 688 void DeprecatedPaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhas e phase, const DeprecatedPaintLayerFragments& layerFragments, GraphicsContext* c ontext,
689 const DeprecatedPaintLayerPaintingInfo& localPaintingInfo, PaintBehavior pai ntBehavior, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlag s, ClipState clipState) 689 const DeprecatedPaintLayerPaintingInfo& localPaintingInfo, PaintBehavior pai ntBehavior, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlag s, ClipState clipState)
690 { 690 {
691 bool needsScope = layerFragments.size() > 1; 691 bool needsScope = layerFragments.size() > 1;
692 for (auto& fragment: layerFragments) { 692 for (auto& fragment : layerFragments) {
693 if (!fragment.foregroundRect.isEmpty()) { 693 if (!fragment.foregroundRect.isEmpty()) {
694 OwnPtr<ScopeRecorder> scopeRecorder; 694 Optional<ScopeRecorder> scopeRecorder;
695 if (needsScope) 695 if (needsScope)
696 scopeRecorder = adoptPtr(new ScopeRecorder(*context, *m_paintLay er.layoutObject())); 696 scopeRecorder.emplace(*context, *m_paintLayer.layoutObject());
697 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, paintFlags, clipState); 697 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintBehavior, paintingRootForLayoutObject, paintFlags, clipState);
698 } 698 }
699 } 699 }
700 } 700 }
701 701
702 void DeprecatedPaintLayerPainter::paintOutlineForFragments(const DeprecatedPaint LayerFragments& layerFragments, GraphicsContext* context, const DeprecatedPaintL ayerPaintingInfo& localPaintingInfo, 702 void DeprecatedPaintLayerPainter::paintOutlineForFragments(const DeprecatedPaint LayerFragments& layerFragments, GraphicsContext* context, const DeprecatedPaintL ayerPaintingInfo& localPaintingInfo,
703 PaintBehavior paintBehavior, LayoutObject* paintingRootForLayoutObject, Pain tLayerFlags paintFlags) 703 PaintBehavior paintBehavior, LayoutObject* paintingRootForLayoutObject, Pain tLayerFlags paintFlags)
704 { 704 {
705 bool needsScope = layerFragments.size() > 1; 705 bool needsScope = layerFragments.size() > 1;
706 for (auto& fragment: layerFragments) { 706 for (auto& fragment : layerFragments) {
707 if (!fragment.outlineRect.isEmpty()) { 707 if (!fragment.outlineRect.isEmpty()) {
708 OwnPtr<ScopeRecorder> scopeRecorder; 708 Optional<ScopeRecorder> scopeRecorder;
709 if (needsScope) 709 if (needsScope)
710 scopeRecorder = adoptPtr(new ScopeRecorder(*context, *m_paintLay er.layoutObject())); 710 scopeRecorder.emplace(*context, *m_paintLayer.layoutObject());
711 paintFragmentWithPhase(PaintPhaseSelfOutline, fragment, context, fra gment.outlineRect, localPaintingInfo, paintBehavior, paintingRootForLayoutObject , paintFlags, HasNotClipped); 711 paintFragmentWithPhase(PaintPhaseSelfOutline, fragment, context, fra gment.outlineRect, localPaintingInfo, paintBehavior, paintingRootForLayoutObject , paintFlags, HasNotClipped);
712 } 712 }
713 } 713 }
714 } 714 }
715 715
716 void DeprecatedPaintLayerPainter::paintMaskForFragments(const DeprecatedPaintLay erFragments& layerFragments, GraphicsContext* context, const DeprecatedPaintLaye rPaintingInfo& localPaintingInfo, 716 void DeprecatedPaintLayerPainter::paintMaskForFragments(const DeprecatedPaintLay erFragments& layerFragments, GraphicsContext* context, const DeprecatedPaintLaye rPaintingInfo& localPaintingInfo,
717 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 717 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
718 { 718 {
719 bool needsScope = layerFragments.size() > 1; 719 bool needsScope = layerFragments.size() > 1;
720 for (auto& fragment: layerFragments) { 720 for (auto& fragment : layerFragments) {
721 OwnPtr<ScopeRecorder> scopeRecorder; 721 Optional<ScopeRecorder> scopeRecorder;
722 if (needsScope) 722 if (needsScope)
723 scopeRecorder = adoptPtr(new ScopeRecorder(*context, *m_paintLayer.l ayoutObject())); 723 scopeRecorder.emplace(*context, *m_paintLayer.layoutObject());
724 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, PaintBehaviorNormal, paintingRootForLayoutObject, paintFlags, HasNotClipped); 724 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, PaintBehaviorNormal, paintingRootForLayoutObject, paintFlags, HasNotClipped);
725 } 725 }
726 } 726 }
727 727
728 void DeprecatedPaintLayerPainter::paintChildClippingMaskForFragments(const Depre catedPaintLayerFragments& layerFragments, GraphicsContext* context, const Deprec atedPaintLayerPaintingInfo& localPaintingInfo, 728 void DeprecatedPaintLayerPainter::paintChildClippingMaskForFragments(const Depre catedPaintLayerFragments& layerFragments, GraphicsContext* context, const Deprec atedPaintLayerPaintingInfo& localPaintingInfo,
729 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 729 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
730 { 730 {
731 bool needsScope = layerFragments.size() > 1; 731 bool needsScope = layerFragments.size() > 1;
732 for (auto& fragment: layerFragments) { 732 for (auto& fragment: layerFragments) {
733 OwnPtr<ScopeRecorder> scopeRecorder; 733 Optional<ScopeRecorder> scopeRecorder;
734 if (needsScope) 734 if (needsScope)
735 scopeRecorder = adoptPtr(new ScopeRecorder(*context, *m_paintLayer.l ayoutObject())); 735 scopeRecorder.emplace(*context, *m_paintLayer.layoutObject());
736 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, PaintBehaviorNormal, paintingRootForLayout Object, paintFlags, HasNotClipped); 736 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, PaintBehaviorNormal, paintingRootForLayout Object, paintFlags, HasNotClipped);
737 } 737 }
738 } 738 }
739 739
740 void DeprecatedPaintLayerPainter::paintOverlayScrollbars(GraphicsContext* contex t, const LayoutRect& damageRect, PaintBehavior paintBehavior, LayoutObject* pain tingRoot) 740 void DeprecatedPaintLayerPainter::paintOverlayScrollbars(GraphicsContext* contex t, const LayoutRect& damageRect, PaintBehavior paintBehavior, LayoutObject* pain tingRoot)
741 { 741 {
742 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 742 if (!m_paintLayer.containsDirtyOverlayScrollbars())
743 return; 743 return;
744 744
745 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintBehavior, LayoutSize(), paintingRoot); 745 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintBehavior, LayoutSize(), paintingRoot);
746 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 746 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
747 747
748 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 748 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
749 } 749 }
750 750
751 } // namespace blink 751 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698