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

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

Issue 976543002: Fix pixel snapping issue when transforming (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase and go back to last patch Created 5 years, 9 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
« Source/core/layout/Layer.cpp ('K') | « Source/core/layout/Layer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return; 190 return;
191 191
192 // Ensure our lists are up-to-date. 192 // Ensure our lists are up-to-date.
193 m_renderLayer.stackingNode()->updateLayerListsIfNeeded(); 193 m_renderLayer.stackingNode()->updateLayerListsIfNeeded();
194 194
195 LayoutPoint offsetFromRoot; 195 LayoutPoint offsetFromRoot;
196 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); 196 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
197 197
198 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) 198 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking)
199 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); 199 offsetFromRoot.move(m_renderLayer.subpixelAccumulation());
200 else
201 offsetFromRoot.move(paintingInfo.subPixelAccumulation);
200 202
201 LayoutRect rootRelativeBounds; 203 LayoutRect rootRelativeBounds;
202 bool rootRelativeBoundsComputed = false; 204 bool rootRelativeBoundsComputed = false;
203 205
204 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction, 206 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction,
205 // so they are nested properly. 207 // so they are nested properly.
206 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); 208 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags);
207 209
208 OwnPtr<LayerClipRecorder> clipRecorder; 210 OwnPtr<LayerClipRecorder> clipRecorder;
209 OwnPtr<CompositingRecorder> compositingRecorder; 211 OwnPtr<CompositingRecorder> compositingRecorder;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 bool LayerPainter::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& paint ingInfo, PaintLayerFlags paintFlags) 438 bool LayerPainter::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& paint ingInfo, PaintLayerFlags paintFlags)
437 { 439 {
438 DisableCompositingQueryAsserts disabler; 440 DisableCompositingQueryAsserts disabler;
439 441
440 return m_renderLayer.compositingState() == NotComposited 442 return m_renderLayer.compositingState() == NotComposited
441 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) 443 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)
442 || ((paintFlags & PaintLayerPaintingReflection) && !m_renderLayer.has3DT ransform()) 444 || ((paintFlags & PaintLayerPaintingReflection) && !m_renderLayer.has3DT ransform())
443 || paintForFixedRootBackground(&m_renderLayer, paintFlags); 445 || paintForFixedRootBackground(&m_renderLayer, paintFlags);
444 } 446 }
445 447
446 static inline LayoutSize subPixelAccumulationIfNeeded(const LayoutSize& subPixel Accumulation, CompositingState compositingState)
447 {
448 // Only apply the sub-pixel accumulation if we don't paint into our own back ing layer, otherwise the position
449 // of the renderer already includes any sub-pixel offset.
450 if (compositingState == PaintsIntoOwnBacking)
451 return LayoutSize();
452 return subPixelAccumulation;
453 }
454
455 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 448 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
456 { 449 {
457 for (size_t i = 0; i < layerFragments.size(); ++i) { 450 for (size_t i = 0; i < layerFragments.size(); ++i) {
458 const LayerFragment& fragment = layerFragments.at(i); 451 const LayerFragment& fragment = layerFragments.at(i);
459 452
460 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject()); 453 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
461 OwnPtr<LayerClipRecorder> clipRecorder; 454 OwnPtr<LayerClipRecorder> clipRecorder;
462 455
463 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { 456 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) {
464 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.layoutOb ject(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect , &localPaintingInfo, fragment.paginationOffset, paintFlags)); 457 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.layoutOb ject(), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect , &localPaintingInfo, fragment.paginationOffset, paintFlags));
465 } 458 }
466 if (LayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea() ) 459 if (LayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea() )
467 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); 460 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.layout BoxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
468 } 461 }
469 } 462 }
470 463
471 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* rendere r, LayoutBox* ancestorColumnsRenderer) 464 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* rendere r, LayoutBox* ancestorColumnsRenderer)
472 { 465 {
473 LayoutView* view = renderer->view(); 466 LayoutView* view = renderer->view();
474 LayoutBoxModelObject* prevBlock = renderer; 467 LayoutBoxModelObject* prevBlock = renderer;
475 LayoutBlock* containingBlock; 468 LayoutBlock* containingBlock;
476 for (containingBlock = renderer->containingBlock(); 469 for (containingBlock = renderer->containingBlock();
477 containingBlock && containingBlock != view && containingBlock != ancesto rColumnsRenderer; 470 containingBlock && containingBlock != view && containingBlock != ancesto rColumnsRenderer;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 break; 612 break;
620 default: 613 default:
621 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 614 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
622 break; 615 break;
623 } 616 }
624 617
625 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.layoutObject (), context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paint Flags, clippingRule)); 618 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.layoutObject (), context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paint Flags, clippingRule));
626 } 619 }
627 620
628 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->layoutObject()) ; 621 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->layoutObject()) ;
629 m_renderLayer.layoutObject()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.layoutBoxLocation() + subPixelAccumulationIfNeeded(pa intingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); 622 m_renderLayer.layoutObject()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.layoutBoxLocation()));
630 } 623 }
631 624
632 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context, 625 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context,
633 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior, 626 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior,
634 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 627 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
635 { 628 {
636 for (const auto& fragment: layerFragments) { 629 for (const auto& fragment: layerFragments) {
637 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject()); 630 ScopeRecorder scopeRecorder(context, *m_renderLayer.layoutObject());
638 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, HasNotClipped); 631 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, HasNotClipped);
639 } 632 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 if (!m_renderLayer.containsDirtyOverlayScrollbars()) 702 if (!m_renderLayer.containsDirtyOverlayScrollbars())
710 return; 703 return;
711 704
712 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d amageRect)), paintBehavior, LayoutSize(), paintingRoot); 705 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d amageRect)), paintBehavior, LayoutSize(), paintingRoot);
713 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 706 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
714 707
715 m_renderLayer.setContainsDirtyOverlayScrollbars(false); 708 m_renderLayer.setContainsDirtyOverlayScrollbars(false);
716 } 709 }
717 710
718 } // namespace blink 711 } // namespace blink
OLDNEW
« Source/core/layout/Layer.cpp ('K') | « Source/core/layout/Layer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698