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/layout/ClipPathOperation.h" | 9 #include "core/layout/ClipPathOperation.h" |
10 #include "core/layout/FilterEffectRenderer.h" | 10 #include "core/layout/FilterEffectRenderer.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 return; | 189 return; |
190 | 190 |
191 // Ensure our lists are up-to-date. | 191 // Ensure our lists are up-to-date. |
192 m_renderLayer.stackingNode()->updateLayerListsIfNeeded(); | 192 m_renderLayer.stackingNode()->updateLayerListsIfNeeded(); |
193 | 193 |
194 LayoutPoint offsetFromRoot; | 194 LayoutPoint offsetFromRoot; |
195 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); | 195 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); |
196 | 196 |
197 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) | 197 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) |
198 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); | 198 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); |
| 199 else |
| 200 offsetFromRoot.move(paintingInfo.subPixelAccumulation); |
199 | 201 |
200 LayoutRect rootRelativeBounds; | 202 LayoutRect rootRelativeBounds; |
201 bool rootRelativeBoundsComputed = false; | 203 bool rootRelativeBoundsComputed = false; |
202 | 204 |
203 // These helpers output clip and compositing operations using a RAII pattern
. Stack-allocated-varibles are destructed in the reverse order of construction, | 205 // These helpers output clip and compositing operations using a RAII pattern
. Stack-allocated-varibles are destructed in the reverse order of construction, |
204 // so they are nested properly. | 206 // so they are nested properly. |
205 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela
tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); | 207 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela
tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); |
206 | 208 |
207 OwnPtr<LayerClipRecorder> clipRecorder; | 209 OwnPtr<LayerClipRecorder> clipRecorder; |
208 OwnPtr<CompositingRecorder> compositingRecorder; | 210 OwnPtr<CompositingRecorder> compositingRecorder; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 bool LayerPainter::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& paint
ingInfo, PaintLayerFlags paintFlags) | 436 bool LayerPainter::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& paint
ingInfo, PaintLayerFlags paintFlags) |
435 { | 437 { |
436 DisableCompositingQueryAsserts disabler; | 438 DisableCompositingQueryAsserts disabler; |
437 | 439 |
438 return m_renderLayer.compositingState() == NotComposited | 440 return m_renderLayer.compositingState() == NotComposited |
439 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) | 441 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) |
440 || ((paintFlags & PaintLayerPaintingReflection) && !m_renderLayer.has3DT
ransform()) | 442 || ((paintFlags & PaintLayerPaintingReflection) && !m_renderLayer.has3DT
ransform()) |
441 || paintForFixedRootBackground(&m_renderLayer, paintFlags); | 443 || paintForFixedRootBackground(&m_renderLayer, paintFlags); |
442 } | 444 } |
443 | 445 |
444 static inline LayoutSize subPixelAccumulationIfNeeded(const LayoutSize& subPixel
Accumulation, CompositingState compositingState) | |
445 { | |
446 // Only apply the sub-pixel accumulation if we don't paint into our own back
ing layer, otherwise the position | |
447 // of the renderer already includes any sub-pixel offset. | |
448 if (compositingState == PaintsIntoOwnBacking) | |
449 return LayoutSize(); | |
450 return subPixelAccumulation; | |
451 } | |
452 | |
453 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer
Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
PaintLayerFlags paintFlags) | 446 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer
Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
PaintLayerFlags paintFlags) |
454 { | 447 { |
455 for (size_t i = 0; i < layerFragments.size(); ++i) { | 448 for (size_t i = 0; i < layerFragments.size(); ++i) { |
456 const LayerFragment& fragment = layerFragments.at(i); | 449 const LayerFragment& fragment = layerFragments.at(i); |
457 | 450 |
458 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); | 451 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); |
459 OwnPtr<LayerClipRecorder> clipRecorder; | 452 OwnPtr<LayerClipRecorder> clipRecorder; |
460 | 453 |
461 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { | 454 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { |
462 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer
(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect, &l
ocalPaintingInfo, fragment.paginationOffset, paintFlags)); | 455 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer
(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect, &l
ocalPaintingInfo, fragment.paginationOffset, paintFlags)); |
463 } | 456 } |
464 if (LayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea()
) | 457 if (LayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea()
) |
465 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context
, roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.layout
BoxLocation() + subPixelAccumulationIfNeeded(localPaintingInfo.subPixelAccumulat
ion, m_renderLayer.compositingState()))), pixelSnappedIntRect(fragment.backgroun
dRect.rect()), true); | 458 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context
, roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.layout
BoxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); |
466 } | 459 } |
467 } | 460 } |
468 | 461 |
469 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* rendere
r, LayoutBox* ancestorColumnsRenderer) | 462 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* rendere
r, LayoutBox* ancestorColumnsRenderer) |
470 { | 463 { |
471 RenderView* view = renderer->view(); | 464 RenderView* view = renderer->view(); |
472 LayoutBoxModelObject* prevBlock = renderer; | 465 LayoutBoxModelObject* prevBlock = renderer; |
473 RenderBlock* containingBlock; | 466 RenderBlock* containingBlock; |
474 for (containingBlock = renderer->containingBlock(); | 467 for (containingBlock = renderer->containingBlock(); |
475 containingBlock && containingBlock != view && containingBlock != ancesto
rColumnsRenderer; | 468 containingBlock && containingBlock != view && containingBlock != ancesto
rColumnsRenderer; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 break; | 610 break; |
618 default: | 611 default: |
619 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; | 612 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; |
620 break; | 613 break; |
621 } | 614 } |
622 | 615 |
623 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(),
context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paintFlag
s, clippingRule)); | 616 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(),
context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paintFlag
s, clippingRule)); |
624 } | 617 } |
625 | 618 |
626 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa
intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); | 619 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa
intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); |
627 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca
tion() - m_renderLayer.layoutBoxLocation() + subPixelAccumulationIfNeeded(painti
ngInfo.subPixelAccumulation, m_renderLayer.compositingState()))); | 620 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca
tion() - m_renderLayer.layoutBoxLocation())); |
628 } | 621 } |
629 | 622 |
630 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme
nts, GraphicsContext* context, | 623 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme
nts, GraphicsContext* context, |
631 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local
PaintingInfo, PaintBehavior paintBehavior, | 624 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local
PaintingInfo, PaintBehavior paintBehavior, |
632 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags) | 625 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags) |
633 { | 626 { |
634 for (const auto& fragment: layerFragments) { | 627 for (const auto& fragment: layerFragments) { |
635 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); | 628 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); |
636 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra
gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer,
paintFlags, HasNotClipped); | 629 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra
gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer,
paintFlags, HasNotClipped); |
637 } | 630 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 if (!m_renderLayer.containsDirtyOverlayScrollbars()) | 700 if (!m_renderLayer.containsDirtyOverlayScrollbars()) |
708 return; | 701 return; |
709 | 702 |
710 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect),
paintBehavior, LayoutSize(), paintingRoot); | 703 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect),
paintBehavior, LayoutSize(), paintingRoot); |
711 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 704 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
712 | 705 |
713 m_renderLayer.setContainsDirtyOverlayScrollbars(false); | 706 m_renderLayer.setContainsDirtyOverlayScrollbars(false); |
714 } | 707 } |
715 | 708 |
716 } // namespace blink | 709 } // namespace blink |
OLD | NEW |