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

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: 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 bool LayerPainter::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& paint ingInfo, PaintLayerFlags paintFlags) 437 bool LayerPainter::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& paint ingInfo, PaintLayerFlags paintFlags)
436 { 438 {
437 DisableCompositingQueryAsserts disabler; 439 DisableCompositingQueryAsserts disabler;
438 440
439 return m_renderLayer.compositingState() == NotComposited 441 return m_renderLayer.compositingState() == NotComposited
440 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) 442 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)
441 || ((paintFlags & PaintLayerPaintingReflection) && !m_renderLayer.has3DT ransform()) 443 || ((paintFlags & PaintLayerPaintingReflection) && !m_renderLayer.has3DT ransform())
442 || paintForFixedRootBackground(&m_renderLayer, paintFlags); 444 || paintForFixedRootBackground(&m_renderLayer, paintFlags);
443 } 445 }
444 446
445 static inline LayoutSize subPixelAccumulationIfNeeded(const LayoutSize& subPixel Accumulation, CompositingState compositingState)
446 {
447 // Only apply the sub-pixel accumulation if we don't paint into our own back ing layer, otherwise the position
448 // of the renderer already includes any sub-pixel offset.
449 if (compositingState == PaintsIntoOwnBacking)
450 return LayoutSize();
451 return subPixelAccumulation;
452 }
453
454 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 447 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
455 { 448 {
456 for (size_t i = 0; i < layerFragments.size(); ++i) { 449 for (size_t i = 0; i < layerFragments.size(); ++i) {
457 const LayerFragment& fragment = layerFragments.at(i); 450 const LayerFragment& fragment = layerFragments.at(i);
458 451
459 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 452 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer());
460 OwnPtr<LayerClipRecorder> clipRecorder; 453 OwnPtr<LayerClipRecorder> clipRecorder;
461 454
462 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { 455 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) {
463 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer (), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect, &l ocalPaintingInfo, fragment.paginationOffset, paintFlags)); 456 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer (), context, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect, &l ocalPaintingInfo, fragment.paginationOffset, paintFlags));
464 } 457 }
465 if (LayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea() ) 458 if (LayerScrollableArea* scrollableArea = m_renderLayer.scrollableArea() )
466 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); 459 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_renderLayer.layout BoxLocation())), pixelSnappedIntRect(fragment.backgroundRect.rect()), true);
467 } 460 }
468 } 461 }
469 462
470 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* rendere r, LayoutBox* ancestorColumnsRenderer) 463 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* rendere r, LayoutBox* ancestorColumnsRenderer)
471 { 464 {
472 LayoutView* view = renderer->view(); 465 LayoutView* view = renderer->view();
473 LayoutBoxModelObject* prevBlock = renderer; 466 LayoutBoxModelObject* prevBlock = renderer;
474 LayoutBlock* containingBlock; 467 LayoutBlock* containingBlock;
475 for (containingBlock = renderer->containingBlock(); 468 for (containingBlock = renderer->containingBlock();
476 containingBlock && containingBlock != view && containingBlock != ancesto rColumnsRenderer; 469 containingBlock && containingBlock != view && containingBlock != ancesto rColumnsRenderer;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 break; 611 break;
619 default: 612 default:
620 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 613 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
621 break; 614 break;
622 } 615 }
623 616
624 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paintFlag s, clippingRule)); 617 clipRecorder = adoptPtr(new LayerClipRecorder(m_renderLayer.renderer(), context, clipType, clipRect, &paintingInfo, fragment.paginationOffset, paintFlag s, clippingRule));
625 } 618 }
626 619
627 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); 620 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer());
628 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca tion() - m_renderLayer.layoutBoxLocation() + subPixelAccumulationIfNeeded(painti ngInfo.subPixelAccumulation, m_renderLayer.compositingState()))); 621 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca tion() - m_renderLayer.layoutBoxLocation()));
629 } 622 }
630 623
631 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context, 624 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context,
632 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior, 625 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior,
633 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 626 LayoutObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
634 { 627 {
635 for (const auto& fragment: layerFragments) { 628 for (const auto& fragment: layerFragments) {
636 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer()); 629 ScopeRecorder scopeRecorder(context, *m_renderLayer.renderer());
637 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, HasNotClipped); 630 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, HasNotClipped);
638 } 631 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 if (!m_renderLayer.containsDirtyOverlayScrollbars()) 701 if (!m_renderLayer.containsDirtyOverlayScrollbars())
709 return; 702 return;
710 703
711 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d amageRect)), paintBehavior, LayoutSize(), paintingRoot); 704 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d amageRect)), paintBehavior, LayoutSize(), paintingRoot);
712 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 705 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
713 706
714 m_renderLayer.setContainsDirtyOverlayScrollbars(false); 707 m_renderLayer.setContainsDirtyOverlayScrollbars(false);
715 } 708 }
716 709
717 } // namespace blink 710 } // 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