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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2620763005: Pad inval rects to compensate for Skia's hairline stroke
Patch Set: limit to composited bounds Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.h ('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 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 layerDirtyRect.move(-layer->offsetFromLayoutObject()); 2727 layerDirtyRect.move(-layer->offsetFromLayoutObject());
2728 layer->setNeedsDisplayInRect(layerDirtyRect, invalidationReason, client); 2728 layer->setNeedsDisplayInRect(layerDirtyRect, invalidationReason, client);
2729 } 2729 }
2730 } 2730 }
2731 2731
2732 IntRect r; 2732 IntRect r;
2733 PaintInvalidationReason invalidationReason; 2733 PaintInvalidationReason invalidationReason;
2734 const DisplayItemClient& client; 2734 const DisplayItemClient& client;
2735 }; 2735 };
2736 2736
2737 IntRect CompositedLayerMapping::adjustedInvalRect(const LayoutRect& r) const {
2738 // Skia's hairline stroke may extend .5 units outside the computed path
2739 // bounds. Pad defensively.
2740 static constexpr float kInvalRectPadding = .5f;
2741
2742 LayoutRect adjustedRect(r);
2743 adjustedRect.inflate(LayoutUnit(kInvalRectPadding));
2744 adjustedRect.intersect(m_compositedBounds);
2745 adjustedRect.move(m_owningLayer.subpixelAccumulation());
2746
2747 return enclosingIntRect(adjustedRect);
2748 }
2749
2737 void CompositedLayerMapping::setContentsNeedDisplayInRect( 2750 void CompositedLayerMapping::setContentsNeedDisplayInRect(
2738 const LayoutRect& r, 2751 const LayoutRect& r,
2739 PaintInvalidationReason invalidationReason, 2752 PaintInvalidationReason invalidationReason,
2740 const DisplayItemClient& client) { 2753 const DisplayItemClient& client) {
2741 DCHECK(!m_owningLayer.layoutObject()->usesCompositedScrolling()); 2754 DCHECK(!m_owningLayer.layoutObject()->usesCompositedScrolling());
2742 // TODO(wangxianzhu): Enable the following assert after paint invalidation for 2755 // TODO(wangxianzhu): Enable the following assert after paint invalidation for
2743 // spv2 is ready. 2756 // spv2 is ready.
2744 // ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2757 // ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2745 2758
2746 SetContentsNeedsDisplayInRectFunctor functor = { 2759 SetContentsNeedsDisplayInRectFunctor functor = {adjustedInvalRect(r),
2747 enclosingIntRect(LayoutRect( 2760 invalidationReason, client};
2748 r.location() + m_owningLayer.subpixelAccumulation(), r.size())),
2749 invalidationReason, client};
2750 ApplyToGraphicsLayers(this, functor, ApplyToContentLayers); 2761 ApplyToGraphicsLayers(this, functor, ApplyToContentLayers);
2751 } 2762 }
2752 2763
2753 void CompositedLayerMapping::setNonScrollingContentsNeedDisplayInRect( 2764 void CompositedLayerMapping::setNonScrollingContentsNeedDisplayInRect(
2754 const LayoutRect& r, 2765 const LayoutRect& r,
2755 PaintInvalidationReason invalidationReason, 2766 PaintInvalidationReason invalidationReason,
2756 const DisplayItemClient& client) { 2767 const DisplayItemClient& client) {
2757 DCHECK(m_owningLayer.layoutObject()->usesCompositedScrolling()); 2768 DCHECK(m_owningLayer.layoutObject()->usesCompositedScrolling());
2758 // TODO(wangxianzhu): Enable the following assert after paint invalidation for 2769 // TODO(wangxianzhu): Enable the following assert after paint invalidation for
2759 // spv2 is ready. 2770 // spv2 is ready.
2760 // ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2771 // ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2761 2772
2762 SetContentsNeedsDisplayInRectFunctor functor = { 2773 SetContentsNeedsDisplayInRectFunctor functor = {adjustedInvalRect(r),
2763 enclosingIntRect(LayoutRect( 2774 invalidationReason, client};
2764 r.location() + m_owningLayer.subpixelAccumulation(), r.size())),
2765 invalidationReason, client};
2766 ApplyToGraphicsLayers(this, functor, ApplyToNonScrollingContentLayers); 2775 ApplyToGraphicsLayers(this, functor, ApplyToNonScrollingContentLayers);
2767 } 2776 }
2768 2777
2769 void CompositedLayerMapping::setScrollingContentsNeedDisplayInRect( 2778 void CompositedLayerMapping::setScrollingContentsNeedDisplayInRect(
2770 const LayoutRect& r, 2779 const LayoutRect& r,
2771 PaintInvalidationReason invalidationReason, 2780 PaintInvalidationReason invalidationReason,
2772 const DisplayItemClient& client) { 2781 const DisplayItemClient& client) {
2773 DCHECK(m_owningLayer.layoutObject()->usesCompositedScrolling()); 2782 DCHECK(m_owningLayer.layoutObject()->usesCompositedScrolling());
2774 // TODO(wangxianzhu): Enable the following assert after paint invalidation for 2783 // TODO(wangxianzhu): Enable the following assert after paint invalidation for
2775 // spv2 is ready. 2784 // spv2 is ready.
2776 // ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2785 // ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2777 2786
2778 SetContentsNeedsDisplayInRectFunctor functor = { 2787 SetContentsNeedsDisplayInRectFunctor functor = {adjustedInvalRect(r),
2779 enclosingIntRect(LayoutRect( 2788 invalidationReason, client};
2780 r.location() + m_owningLayer.subpixelAccumulation(), r.size())),
2781 invalidationReason, client};
2782 ApplyToGraphicsLayers(this, functor, ApplyToScrollingContentLayers); 2789 ApplyToGraphicsLayers(this, functor, ApplyToScrollingContentLayers);
2783 } 2790 }
2784 2791
2785 const GraphicsLayerPaintInfo* CompositedLayerMapping::containingSquashedLayer( 2792 const GraphicsLayerPaintInfo* CompositedLayerMapping::containingSquashedLayer(
2786 const LayoutObject* layoutObject, 2793 const LayoutObject* layoutObject,
2787 const Vector<GraphicsLayerPaintInfo>& layers, 2794 const Vector<GraphicsLayerPaintInfo>& layers,
2788 unsigned maxSquashedLayerIndex) { 2795 unsigned maxSquashedLayerIndex) {
2789 if (!layoutObject) 2796 if (!layoutObject)
2790 return nullptr; 2797 return nullptr;
2791 for (size_t i = 0; i < layers.size() && i < maxSquashedLayerIndex; ++i) { 2798 for (size_t i = 0; i < layers.size() && i < maxSquashedLayerIndex; ++i) {
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
3444 } else if (graphicsLayer == m_decorationOutlineLayer.get()) { 3451 } else if (graphicsLayer == m_decorationOutlineLayer.get()) {
3445 name = "Decoration Layer"; 3452 name = "Decoration Layer";
3446 } else { 3453 } else {
3447 ASSERT_NOT_REACHED(); 3454 ASSERT_NOT_REACHED();
3448 } 3455 }
3449 3456
3450 return name; 3457 return name;
3451 } 3458 }
3452 3459
3453 } // namespace blink 3460 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698