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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp

Issue 2319293004: Replace FilterEffect::maxEffectRect() with absoluteBounds() (Closed)
Patch Set: Created 4 years, 3 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) 2008 Alex Mathews <possessedpenguinbob@gmail.com> 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * Copyright (C) 2012 University of Szeged 5 * Copyright (C) 2012 University of Szeged
6 * Copyright (C) 2013 Google Inc. All rights reserved. 6 * Copyright (C) 2013 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 30 matching lines...) Expand all
41 FilterEffect::~FilterEffect() 41 FilterEffect::~FilterEffect()
42 { 42 {
43 } 43 }
44 44
45 DEFINE_TRACE(FilterEffect) 45 DEFINE_TRACE(FilterEffect)
46 { 46 {
47 visitor->trace(m_inputEffects); 47 visitor->trace(m_inputEffects);
48 visitor->trace(m_filter); 48 visitor->trace(m_filter);
49 } 49 }
50 50
51 FloatRect FilterEffect::absoluteBounds() const
52 {
53 FloatRect computedBounds = getFilter()->filterRegion();
pdr. 2016/09/08 20:46:12 Should we clip/intersect with the filter region he
fs 2016/09/08 21:08:11 For the same reason stated in SVGFEImage, it doesn
54 if (!filterPrimitiveSubregion().isEmpty())
55 computedBounds.intersect(filterPrimitiveSubregion());
56 return getFilter()->mapLocalRectToAbsoluteRect(computedBounds);
57 }
58
51 FloatRect FilterEffect::determineAbsolutePaintRect(const FloatRect& originalRequ estedRect) 59 FloatRect FilterEffect::determineAbsolutePaintRect(const FloatRect& originalRequ estedRect)
52 { 60 {
53 FloatRect requestedRect = originalRequestedRect; 61 FloatRect requestedRect = originalRequestedRect;
54 // Filters in SVG clip to primitive subregion, while CSS doesn't. 62 // Filters in SVG clip to primitive subregion, while CSS doesn't.
55 if (m_clipsToBounds) 63 if (clipsToBounds())
pdr. 2016/09/08 20:46:12 The comment above m_clipsToBounds makes me think t
fs 2016/09/08 21:08:12 Yes, that probably makes more sense. The way thing
56 requestedRect.intersect(maxEffectRect()); 64 requestedRect.intersect(absoluteBounds());
57 65
58 // We may be called multiple times if result is used more than once. Return 66 // We may be called multiple times if result is used more than once. Return
59 // quickly if if nothing new is required. 67 // quickly if if nothing new is required.
60 if (absolutePaintRect().contains(enclosingIntRect(requestedRect))) 68 if (absolutePaintRect().contains(enclosingIntRect(requestedRect)))
61 return requestedRect; 69 return requestedRect;
62 70
63 FloatRect inputRect = mapPaintRect(requestedRect, false); 71 FloatRect inputRect = mapPaintRect(requestedRect, false);
64 FloatRect inputUnion; 72 FloatRect inputUnion;
65 unsigned size = m_inputEffects.size(); 73 unsigned size = m_inputEffects.size();
66 74
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return ColorSpaceUtilities::convertColor(deviceColor, operatingColorSpace()) ; 128 return ColorSpaceUtilities::convertColor(deviceColor, operatingColorSpace()) ;
121 } 129 }
122 130
123 TextStream& FilterEffect::externalRepresentation(TextStream& ts, int) const 131 TextStream& FilterEffect::externalRepresentation(TextStream& ts, int) const
124 { 132 {
125 // FIXME: We should dump the subRegions of the filter primitives here later. This isn't 133 // FIXME: We should dump the subRegions of the filter primitives here later. This isn't
126 // possible at the moment, because we need more detailed informations from t he target object. 134 // possible at the moment, because we need more detailed informations from t he target object.
127 return ts; 135 return ts;
128 } 136 }
129 137
130 FloatRect FilterEffect::determineMaximumEffectRect()
131 {
132 DCHECK(getFilter());
133 Filter* filter = getFilter();
134
135 // Compute the union of the inputs. Always do this because it has
136 // side-effects. (It computes the maximum effect rect of the input.)
137 FloatRect absoluteInputUnion;
138 for (auto& effect : m_inputEffects)
139 absoluteInputUnion.unite(effect->determineMaximumEffectRect());
140
141 FloatRect absoluteSubregion;
142 switch (getFilterEffectType()) {
143 default:
144 if (m_inputEffects.size()) {
145 absoluteSubregion = absoluteInputUnion;
146 if (clipsToBounds())
147 absoluteSubregion.intersect(filter->mapLocalRectToAbsoluteRect(f ilterPrimitiveSubregion()));
148 break;
149 }
150 // Else fall-through and use the primitive region. (FETurbulence/FEFlood /FEImage)
151 case FilterEffectTypeTile:
152 absoluteSubregion = filter->mapLocalRectToAbsoluteRect(filterPrimitiveSu bregion());
153 break;
154 case FilterEffectTypeSourceInput:
155 absoluteSubregion = filter->absoluteFilterRegion();
156 break;
157 }
158
159 // Clip every filter effect to the filter region.
160 absoluteSubregion.intersect(filter->absoluteFilterRegion());
161
162 m_maxEffectRect = absoluteSubregion;
163 return absoluteSubregion;
164 }
165
166 sk_sp<SkImageFilter> FilterEffect::createImageFilter() 138 sk_sp<SkImageFilter> FilterEffect::createImageFilter()
167 { 139 {
168 return nullptr; 140 return nullptr;
169 } 141 }
170 142
171 sk_sp<SkImageFilter> FilterEffect::createImageFilterWithoutValidation() 143 sk_sp<SkImageFilter> FilterEffect::createImageFilterWithoutValidation()
172 { 144 {
173 return createImageFilter(); 145 return createImageFilter();
174 } 146 }
175 147
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 return m_imageFilters[index].get(); 187 return m_imageFilters[index].get();
216 } 188 }
217 189
218 void FilterEffect::setImageFilter(ColorSpace colorSpace, bool requiresPMColorVal idation, sk_sp<SkImageFilter> imageFilter) 190 void FilterEffect::setImageFilter(ColorSpace colorSpace, bool requiresPMColorVal idation, sk_sp<SkImageFilter> imageFilter)
219 { 191 {
220 int index = getImageFilterIndex(colorSpace, requiresPMColorValidation); 192 int index = getImageFilterIndex(colorSpace, requiresPMColorValidation);
221 m_imageFilters[index] = std::move(imageFilter); 193 m_imageFilters[index] = std::move(imageFilter);
222 } 194 }
223 195
224 } // namespace blink 196 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698