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

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

Issue 2303703002: Revamp filter primitive region calculations for Filter Effects (Closed)
Patch Set: Baselines again; Manual for mac10.11-retina 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) 2013 Google Inc. All rights reserved. 5 * Copyright (C) 2013 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 typedef HeapVector<Member<FilterEffect>> FilterEffectVector; 44 typedef HeapVector<Member<FilterEffect>> FilterEffectVector;
45 45
46 enum FilterEffectType { 46 enum FilterEffectType {
47 FilterEffectTypeUnknown, 47 FilterEffectTypeUnknown,
48 FilterEffectTypeImage, 48 FilterEffectTypeImage,
49 FilterEffectTypeTile, 49 FilterEffectTypeTile,
50 FilterEffectTypeSourceInput 50 FilterEffectTypeSourceInput
51 }; 51 };
52 52
53 enum DetermineSubregionFlag { 53 enum DetermineMaxEffectRectFlag {
54 DetermineSubregionNone = 0, 54 DetermineMaxEffectRectNone = 0,
55 MapRectForward = 1, 55 MapRectForward = 1,
56 ClipToFilterRegion = 1 << 1 56 ClipToFilterRegion = 1 << 1
57 }; 57 };
58 58
59 typedef int DetermineSubregionFlags; 59 typedef int DetermineMaxEffectRectFlags;
60 60
61 class PLATFORM_EXPORT FilterEffect : public GarbageCollectedFinalized<FilterEffe ct> { 61 class PLATFORM_EXPORT FilterEffect : public GarbageCollectedFinalized<FilterEffe ct> {
62 WTF_MAKE_NONCOPYABLE(FilterEffect); 62 WTF_MAKE_NONCOPYABLE(FilterEffect);
63 public: 63 public:
64 virtual ~FilterEffect(); 64 virtual ~FilterEffect();
65 DECLARE_VIRTUAL_TRACE(); 65 DECLARE_VIRTUAL_TRACE();
66 66
67 void clearResult(); 67 void clearResult();
68 68
69 FilterEffectVector& inputEffects() { return m_inputEffects; } 69 FilterEffectVector& inputEffects() { return m_inputEffects; }
70 FilterEffect* inputEffect(unsigned) const; 70 FilterEffect* inputEffect(unsigned) const;
71 unsigned numberOfEffectInputs() const { return m_inputEffects.size(); } 71 unsigned numberOfEffectInputs() const { return m_inputEffects.size(); }
72 72
73 inline bool hasImageFilter() const 73 inline bool hasImageFilter() const
74 { 74 {
75 return m_imageFilters[0] || m_imageFilters[1] || m_imageFilters[2] || m_ imageFilters[3]; 75 return m_imageFilters[0] || m_imageFilters[1] || m_imageFilters[2] || m_ imageFilters[3];
76 } 76 }
77 77
78 IntRect absolutePaintRect() const { return m_absolutePaintRect; } 78 IntRect absolutePaintRect() const { return m_absolutePaintRect; }
79 79
80 FloatRect maxEffectRect() const { return m_maxEffectRect; } 80 FloatRect maxEffectRect() const { return m_maxEffectRect; }
81 void setMaxEffectRect(const FloatRect& maxEffectRect) { m_maxEffectRect = ma xEffectRect; }
82 81
83 virtual sk_sp<SkImageFilter> createImageFilter(); 82 virtual sk_sp<SkImageFilter> createImageFilter();
84 virtual sk_sp<SkImageFilter> createImageFilterWithoutValidation(); 83 virtual sk_sp<SkImageFilter> createImageFilterWithoutValidation();
85 84
86 // Mapping a rect forwards determines which which destination pixels a 85 // Mapping a rect forwards determines which which destination pixels a
87 // given source rect would affect. Mapping a rect backwards determines 86 // given source rect would affect. Mapping a rect backwards determines
88 // which pixels from the source rect would be required to fill a given 87 // which pixels from the source rect would be required to fill a given
89 // destination rect. Note that these are not necessarily the inverse of 88 // destination rect. Note that these are not necessarily the inverse of
90 // each other. For example, for FEGaussianBlur, they are the same 89 // each other. For example, for FEGaussianBlur, they are the same
91 // transformation. 90 // transformation.
92 virtual FloatRect mapRect(const FloatRect& rect, bool forward = true) const { return rect; } 91 virtual FloatRect mapRect(const FloatRect& rect, bool forward = true) const { return rect; }
93 // A version of the above that is used for calculating paint rects. We can't 92 // A version of the above that is used for calculating paint rects. We can't
94 // use mapRect above for that, because that is also used for calculating eff ect 93 // use mapRect above for that, because that is also used for calculating eff ect
95 // regions for CSS filters and has undesirable effects for tile and 94 // regions for CSS filters and has undesirable effects for tile and
96 // displacement map. 95 // displacement map.
97 virtual FloatRect mapPaintRect(const FloatRect& rect, bool forward) const 96 virtual FloatRect mapPaintRect(const FloatRect& rect, bool forward) const
98 { 97 {
99 return mapRect(rect, forward); 98 return mapRect(rect, forward);
100 } 99 }
101 FloatRect mapRectRecursive(const FloatRect&) const; 100 FloatRect mapRectRecursive(const FloatRect&) const;
102 101
103 virtual FilterEffectType getFilterEffectType() const { return FilterEffectTy peUnknown; } 102 virtual FilterEffectType getFilterEffectType() const { return FilterEffectTy peUnknown; }
104 103
105 virtual TextStream& externalRepresentation(TextStream&, int indention = 0) c onst; 104 virtual TextStream& externalRepresentation(TextStream&, int indention = 0) c onst;
106 105
107 // The following functions are SVG specific and will move to LayoutSVGResour ceFilterPrimitive.
108 // See bug https://bugs.webkit.org/show_bug.cgi?id=45614.
109 bool hasX() const { return m_hasX; }
110 void setHasX(bool value) { m_hasX = value; }
111
112 bool hasY() const { return m_hasY; }
113 void setHasY(bool value) { m_hasY = value; }
114
115 bool hasWidth() const { return m_hasWidth; }
116 void setHasWidth(bool value) { m_hasWidth = value; }
117
118 bool hasHeight() const { return m_hasHeight; }
119 void setHasHeight(bool value) { m_hasHeight = value; }
120
121 FloatRect filterPrimitiveSubregion() const { return m_filterPrimitiveSubregi on; } 106 FloatRect filterPrimitiveSubregion() const { return m_filterPrimitiveSubregi on; }
122 void setFilterPrimitiveSubregion(const FloatRect& filterPrimitiveSubregion) { m_filterPrimitiveSubregion = filterPrimitiveSubregion; } 107 void setFilterPrimitiveSubregion(const FloatRect& filterPrimitiveSubregion) { m_filterPrimitiveSubregion = filterPrimitiveSubregion; }
123 108
124 const FloatRect& effectBoundaries() const { return m_effectBoundaries; }
125 void setEffectBoundaries(const FloatRect& effectBoundaries) { m_effectBounda ries = effectBoundaries; }
126 FloatRect applyEffectBoundaries(const FloatRect&) const;
127
128 Filter* getFilter() { return m_filter; } 109 Filter* getFilter() { return m_filter; }
129 const Filter* getFilter() const { return m_filter; } 110 const Filter* getFilter() const { return m_filter; }
130 111
131 bool clipsToBounds() const { return m_clipsToBounds; } 112 bool clipsToBounds() const { return m_clipsToBounds; }
132 void setClipsToBounds(bool value) { m_clipsToBounds = value; } 113 void setClipsToBounds(bool value) { m_clipsToBounds = value; }
133 114
134 ColorSpace operatingColorSpace() const { return m_operatingColorSpace; } 115 ColorSpace operatingColorSpace() const { return m_operatingColorSpace; }
135 virtual void setOperatingColorSpace(ColorSpace colorSpace) { m_operatingColo rSpace = colorSpace; } 116 virtual void setOperatingColorSpace(ColorSpace colorSpace) { m_operatingColo rSpace = colorSpace; }
136 117
137 FloatRect determineFilterPrimitiveSubregion(DetermineSubregionFlags = Determ ineSubregionNone); 118 FloatRect determineMaximumEffectRect(DetermineMaxEffectRectFlags);
138 119
139 virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedAbsol uteRect); 120 virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedAbsol uteRect);
140 virtual bool affectsTransparentPixels() { return false; } 121 virtual bool affectsTransparentPixels() { return false; }
141 122
142 // Return false if the filter will only operate correctly on valid RGBA valu es, with 123 // Return false if the filter will only operate correctly on valid RGBA valu es, with
143 // alpha in [0,255] and each color component in [0, alpha]. 124 // alpha in [0,255] and each color component in [0, alpha].
144 virtual bool mayProduceInvalidPreMultipliedPixels() { return false; } 125 virtual bool mayProduceInvalidPreMultipliedPixels() { return false; }
145 126
146 SkImageFilter* getImageFilter(ColorSpace, bool requiresPMColorValidation) co nst; 127 SkImageFilter* getImageFilter(ColorSpace, bool requiresPMColorValidation) co nst;
147 void setImageFilter(ColorSpace, bool requiresPMColorValidation, sk_sp<SkImag eFilter>); 128 void setImageFilter(ColorSpace, bool requiresPMColorValidation, sk_sp<SkImag eFilter>);
(...skipping 24 matching lines...) Expand all
172 FloatRect m_maxEffectRect; 153 FloatRect m_maxEffectRect;
173 Member<Filter> m_filter; 154 Member<Filter> m_filter;
174 155
175 // The following member variables are SVG specific and will move to LayoutSV GResourceFilterPrimitive. 156 // The following member variables are SVG specific and will move to LayoutSV GResourceFilterPrimitive.
176 // See bug https://bugs.webkit.org/show_bug.cgi?id=45614. 157 // See bug https://bugs.webkit.org/show_bug.cgi?id=45614.
177 158
178 // The subregion of a filter primitive according to the SVG Filter specifica tion in local coordinates. 159 // The subregion of a filter primitive according to the SVG Filter specifica tion in local coordinates.
179 // This is SVG specific and needs to move to LayoutSVGResourceFilterPrimitiv e. 160 // This is SVG specific and needs to move to LayoutSVGResourceFilterPrimitiv e.
180 FloatRect m_filterPrimitiveSubregion; 161 FloatRect m_filterPrimitiveSubregion;
181 162
182 // x, y, width and height of the actual SVGFE*Element. Is needed to determin e the subregion of the
183 // filter primitive on a later step.
184 FloatRect m_effectBoundaries;
185 bool m_hasX;
186 bool m_hasY;
187 bool m_hasWidth;
188 bool m_hasHeight;
189
190 // Should the effect clip to its primitive region, or expand to use the comb ined region of its inputs. 163 // Should the effect clip to its primitive region, or expand to use the comb ined region of its inputs.
191 bool m_clipsToBounds; 164 bool m_clipsToBounds;
192 165
193 bool m_originTainted; 166 bool m_originTainted;
194 167
195 ColorSpace m_operatingColorSpace; 168 ColorSpace m_operatingColorSpace;
196 169
197 sk_sp<SkImageFilter> m_imageFilters[4]; 170 sk_sp<SkImageFilter> m_imageFilters[4];
198 }; 171 };
199 172
200 } // namespace blink 173 } // namespace blink
201 174
202 #endif // FilterEffect_h 175 #endif // FilterEffect_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698