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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 1855303002: Replace filter outsets with bounds mapping in Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: senorblanco review comments Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 { 1053 {
1054 if (m_shouldIsolateCompositedDescendants == static_cast<unsigned>(shouldIsol ateCompositedDescendants)) 1054 if (m_shouldIsolateCompositedDescendants == static_cast<unsigned>(shouldIsol ateCompositedDescendants))
1055 return; 1055 return;
1056 1056
1057 m_shouldIsolateCompositedDescendants = shouldIsolateCompositedDescendants; 1057 m_shouldIsolateCompositedDescendants = shouldIsolateCompositedDescendants;
1058 1058
1059 if (hasCompositedLayerMapping()) 1059 if (hasCompositedLayerMapping())
1060 compositedLayerMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdat eLocal); 1060 compositedLayerMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdat eLocal);
1061 } 1061 }
1062 1062
1063 bool PaintLayer::hasAncestorWithFilterOutsets() const 1063 bool PaintLayer::hasAncestorWithFilterThatMovesPixels() const
1064 { 1064 {
1065 for (const PaintLayer* curr = this; curr; curr = curr->parent()) { 1065 for (const PaintLayer* curr = this; curr; curr = curr->parent()) {
1066 if (curr->hasFilterOutsets()) 1066 if (curr->hasFilterThatMovesPixels())
1067 return true; 1067 return true;
1068 } 1068 }
1069 return false; 1069 return false;
1070 } 1070 }
1071 1071
1072 static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, cons t PaintLayer* layer, const PaintLayer* rootLayer, 1072 static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, cons t PaintLayer* layer, const PaintLayer* rootLayer,
1073 PaintLayer::TransparencyClipBoxBehavior transparencyBehavior, const LayoutSi ze& subPixelAccumulation, GlobalPaintFlags globalPaintFlags) 1073 PaintLayer::TransparencyClipBoxBehavior transparencyBehavior, const LayoutSi ze& subPixelAccumulation, GlobalPaintFlags globalPaintFlags)
1074 { 1074 {
1075 // If we have a mask, then the clip is limited to the border box area (and t here is 1075 // If we have a mask, then the clip is limited to the border box area (and t here is
1076 // no need to examine child layers). 1076 // no need to examine child layers).
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 1114
1115 delta.move(subPixelAccumulation); 1115 delta.move(subPixelAccumulation);
1116 IntPoint pixelSnappedDelta = roundedIntPoint(delta); 1116 IntPoint pixelSnappedDelta = roundedIntPoint(delta);
1117 TransformationMatrix transform; 1117 TransformationMatrix transform;
1118 transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y()); 1118 transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y());
1119 if (layer->transform()) 1119 if (layer->transform())
1120 transform = transform * *layer->transform(); 1120 transform = transform * *layer->transform();
1121 1121
1122 // We don't use fragment boxes when collecting a transformed layer's bou nding box, since it always 1122 // We don't use fragment boxes when collecting a transformed layer's bou nding box, since it always
1123 // paints unfragmented. 1123 // paints unfragmented.
1124 LayoutRect clipRect = layer->physicalBoundingBox(layer); 1124 LayoutRect clipRect = layer->physicalBoundingBox(LayoutPoint());
1125 expandClipRectForDescendantsAndReflection(clipRect, layer, layer, transp arencyBehavior, subPixelAccumulation, globalPaintFlags); 1125 expandClipRectForDescendantsAndReflection(clipRect, layer, layer, transp arencyBehavior, subPixelAccumulation, globalPaintFlags);
1126 clipRect.expand(layer->filterOutsets()); 1126 LayoutRect result = enclosingLayoutRect(transform.mapRect(layer->mapRect ForFilter(FloatRect(clipRect))));
1127 LayoutRect result = transform.mapRect(clipRect);
1128 if (!paginationLayer) 1127 if (!paginationLayer)
1129 return result; 1128 return result;
1130 1129
1131 // We have to break up the transformed extent across our columns. 1130 // We have to break up the transformed extent across our columns.
1132 // Split our box up into the actual fragment boxes that layout in the co lumns/pages and unite those together to 1131 // Split our box up into the actual fragment boxes that layout in the co lumns/pages and unite those together to
1133 // get our true bounding box. 1132 // get our true bounding box.
1134 LayoutFlowThread* enclosingFlowThread = toLayoutFlowThread(paginationLay er->layoutObject()); 1133 LayoutFlowThread* enclosingFlowThread = toLayoutFlowThread(paginationLay er->layoutObject());
1135 result = enclosingFlowThread->fragmentsBoundingBox(result); 1134 result = enclosingFlowThread->fragmentsBoundingBox(result);
1136 1135
1137 LayoutPoint rootLayerDelta; 1136 LayoutPoint rootLayerDelta;
1138 paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta); 1137 paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta);
1139 result.moveBy(rootLayerDelta); 1138 result.moveBy(rootLayerDelta);
1140 return result; 1139 return result;
1141 } 1140 }
1142 1141
1143 LayoutRect clipRect = layer->fragmentsBoundingBox(rootLayer); 1142 LayoutRect clipRect = layer->fragmentsBoundingBox(rootLayer);
1144 expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, transp arencyBehavior, subPixelAccumulation, globalPaintFlags); 1143 expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, transp arencyBehavior, subPixelAccumulation, globalPaintFlags);
1145 clipRect.expand(layer->filterOutsets()); 1144 clipRect = layer->mapLayoutRectForFilter(clipRect);
1146 clipRect.move(subPixelAccumulation); 1145 clipRect.move(subPixelAccumulation);
1147 return clipRect; 1146 return clipRect;
1148 } 1147 }
1149 1148
1150 LayoutRect PaintLayer::paintingExtent(const PaintLayer* rootLayer, const LayoutS ize& subPixelAccumulation, GlobalPaintFlags globalPaintFlags) 1149 LayoutRect PaintLayer::paintingExtent(const PaintLayer* rootLayer, const LayoutS ize& subPixelAccumulation, GlobalPaintFlags globalPaintFlags)
1151 { 1150 {
1152 return transparencyClipBox(this, rootLayer, PaintingTransparencyClipBox, Roo tOfTransparencyClipBox, subPixelAccumulation, globalPaintFlags); 1151 return transparencyClipBox(this, rootLayer, PaintingTransparencyClipBox, Roo tOfTransparencyClipBox, subPixelAccumulation, globalPaintFlags);
1153 } 1152 }
1154 1153
1155 void* PaintLayer::operator new(size_t sz) 1154 void* PaintLayer::operator new(size_t sz)
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 // a recursive computation of stacking children yields no results. This breaks cases when there are stacking 2212 // a recursive computation of stacking children yields no results. This breaks cases when there are stacking
2214 // children of the parent, that need to be included in reflected composi ted bounds. 2213 // children of the parent, that need to be included in reflected composi ted bounds.
2215 // Fix this by including composited bounds of stacking children of the r eflected Layer. 2214 // Fix this by including composited bounds of stacking children of the r eflected Layer.
2216 if (hasCompositedLayerMapping() && parent() && parent()->reflectionInfo( ) && parent()->reflectionInfo()->reflectionLayer() == this) 2215 if (hasCompositedLayerMapping() && parent() && parent()->reflectionInfo( ) && parent()->reflectionInfo()->reflectionLayer() == this)
2217 expandRectForReflectionAndStackingChildren(parent(), result); 2216 expandRectForReflectionAndStackingChildren(parent(), result);
2218 else 2217 else
2219 expandRectForReflectionAndStackingChildren(this, result); 2218 expandRectForReflectionAndStackingChildren(this, result);
2220 2219
2221 // Only enlarge by the filter outsets if we know the filter is going to be rendered in software. 2220 // Only enlarge by the filter outsets if we know the filter is going to be rendered in software.
2222 // Accelerated filters will handle their own outsets. 2221 // Accelerated filters will handle their own outsets.
2223 if (paintsWithFilters()) { 2222 if (paintsWithFilters())
2224 result.expand(filterOutsets()); 2223 result = mapLayoutRectForFilter(result);
2225 }
2226 } 2224 }
2227 2225
2228 if (transform() && paintsWithTransform(GlobalPaintNormalPhase) && (this != a ncestorLayer || options == MaybeIncludeTransformForAncestorLayer)) 2226 if (transform() && paintsWithTransform(GlobalPaintNormalPhase) && (this != a ncestorLayer || options == MaybeIncludeTransformForAncestorLayer))
2229 result = transform()->mapRect(result); 2227 result = transform()->mapRect(result);
2230 2228
2231 if (enclosingPaginationLayer()) { 2229 if (enclosingPaginationLayer()) {
2232 convertFromFlowThreadToVisualBoundingBoxInAncestor(ancestorLayer, result ); 2230 convertFromFlowThreadToVisualBoundingBoxInAncestor(ancestorLayer, result );
2233 return result; 2231 return result;
2234 } 2232 }
2235 LayoutPoint delta; 2233 LayoutPoint delta;
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
2701 } 2699 }
2702 2700
2703 FilterEffect* PaintLayer::lastFilterEffect() const 2701 FilterEffect* PaintLayer::lastFilterEffect() const
2704 { 2702 {
2705 FilterEffectBuilder* builder = updateFilterEffectBuilder(); 2703 FilterEffectBuilder* builder = updateFilterEffectBuilder();
2706 if (!builder) 2704 if (!builder)
2707 return nullptr; 2705 return nullptr;
2708 return builder->lastEffect(); 2706 return builder->lastEffect();
2709 } 2707 }
2710 2708
2711 bool PaintLayer::hasFilterOutsets() const 2709 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const
2712 { 2710 {
2713 if (!layoutObject()->hasFilterInducingProperty()) 2711 if (!hasFilterThatMovesPixels())
2712 return rect;
2713 // Ensure the filter-chain is refreshed wrt reference filters.
2714 updateFilterEffectBuilder();
2715
2716 FilterOperations filterOperations = computeFilterOperations(layoutObject()-> styleRef());
2717 return filterOperations.mapRect(rect);
2718 }
2719
2720 LayoutRect PaintLayer::mapLayoutRectForFilter(const LayoutRect& rect) const
2721 {
2722 if (!hasFilterThatMovesPixels())
2723 return rect;
2724 return enclosingLayoutRect(mapRectForFilter(FloatRect(rect)));
2725 }
2726
2727 bool PaintLayer::hasFilterThatMovesPixels() const
2728 {
2729 if (!hasFilterInducingProperty())
2714 return false; 2730 return false;
2715 const ComputedStyle& style = layoutObject()->styleRef(); 2731 const ComputedStyle& style = layoutObject()->styleRef();
2716 if (style.hasFilter() && style.filter().hasOutsets()) 2732 if (style.hasFilter() && style.filter().hasFilterThatMovesPixels())
2717 return true; 2733 return true;
2718 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && style.hasBoxRefl ect()) 2734 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && style.hasBoxRefl ect())
2719 return true; 2735 return true;
2720 return false; 2736 return false;
2721 } 2737 }
2722 2738
2723 FilterOutsets PaintLayer::filterOutsets() const
2724 {
2725 if (!layoutObject()->hasFilterInducingProperty())
2726 return FilterOutsets();
2727
2728 // Ensure the filter-chain is refreshed wrt reference filters.
2729 updateFilterEffectBuilder();
2730
2731 return layoutObject()->style()->filter().outsets();
2732 }
2733
2734 void PaintLayer::updateOrRemoveFilterEffectBuilder() 2739 void PaintLayer::updateOrRemoveFilterEffectBuilder()
2735 { 2740 {
2736 // FilterEffectBuilder is only used to render the filters in software mode, 2741 // FilterEffectBuilder is only used to render the filters in software mode,
2737 // so we always need to run updateOrRemoveFilterEffectBuilder after the comp osited 2742 // so we always need to run updateOrRemoveFilterEffectBuilder after the comp osited
2738 // mode might have changed for this layer. 2743 // mode might have changed for this layer.
2739 if (!paintsWithFilters()) { 2744 if (!paintsWithFilters()) {
2740 // Don't delete the whole filter info here, because we might use it 2745 // Don't delete the whole filter info here, because we might use it
2741 // for loading CSS shader files. 2746 // for loading CSS shader files.
2742 if (PaintLayerFilterInfo* filterInfo = this->filterInfo()) 2747 if (PaintLayerFilterInfo* filterInfo = this->filterInfo())
2743 filterInfo->setBuilder(nullptr); 2748 filterInfo->setBuilder(nullptr);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 2883
2879 void showLayerTree(const blink::LayoutObject* layoutObject) 2884 void showLayerTree(const blink::LayoutObject* layoutObject)
2880 { 2885 {
2881 if (!layoutObject) { 2886 if (!layoutObject) {
2882 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2887 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2883 return; 2888 return;
2884 } 2889 }
2885 showLayerTree(layoutObject->enclosingLayer()); 2890 showLayerTree(layoutObject->enclosingLayer());
2886 } 2891 }
2887 #endif 2892 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | third_party/WebKit/Source/platform/geometry/IntRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698