| OLD | NEW |
| 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 Loading... |
| 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 DetermineMaxEffectRectFlag { | 53 enum DetermineSubregionFlag { |
| 54 DetermineMaxEffectRectNone = 0, | 54 DetermineSubregionNone = 0, |
| 55 MapRectForward = 1, | 55 MapRectForward = 1, |
| 56 ClipToFilterRegion = 1 << 1 | 56 ClipToFilterRegion = 1 << 1 |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 typedef int DetermineMaxEffectRectFlags; | 59 typedef int DetermineSubregionFlags; |
| 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; } |
| 81 | 82 |
| 82 virtual sk_sp<SkImageFilter> createImageFilter(); | 83 virtual sk_sp<SkImageFilter> createImageFilter(); |
| 83 virtual sk_sp<SkImageFilter> createImageFilterWithoutValidation(); | 84 virtual sk_sp<SkImageFilter> createImageFilterWithoutValidation(); |
| 84 | 85 |
| 85 // Mapping a rect forwards determines which which destination pixels a | 86 // Mapping a rect forwards determines which which destination pixels a |
| 86 // given source rect would affect. Mapping a rect backwards determines | 87 // given source rect would affect. Mapping a rect backwards determines |
| 87 // which pixels from the source rect would be required to fill a given | 88 // which pixels from the source rect would be required to fill a given |
| 88 // destination rect. Note that these are not necessarily the inverse of | 89 // destination rect. Note that these are not necessarily the inverse of |
| 89 // each other. For example, for FEGaussianBlur, they are the same | 90 // each other. For example, for FEGaussianBlur, they are the same |
| 90 // transformation. | 91 // transformation. |
| 91 virtual FloatRect mapRect(const FloatRect& rect, bool forward = true) const
{ return rect; } | 92 virtual FloatRect mapRect(const FloatRect& rect, bool forward = true) const
{ return rect; } |
| 92 // A version of the above that is used for calculating paint rects. We can't | 93 // A version of the above that is used for calculating paint rects. We can't |
| 93 // use mapRect above for that, because that is also used for calculating eff
ect | 94 // use mapRect above for that, because that is also used for calculating eff
ect |
| 94 // regions for CSS filters and has undesirable effects for tile and | 95 // regions for CSS filters and has undesirable effects for tile and |
| 95 // displacement map. | 96 // displacement map. |
| 96 virtual FloatRect mapPaintRect(const FloatRect& rect, bool forward) const | 97 virtual FloatRect mapPaintRect(const FloatRect& rect, bool forward) const |
| 97 { | 98 { |
| 98 return mapRect(rect, forward); | 99 return mapRect(rect, forward); |
| 99 } | 100 } |
| 100 FloatRect mapRectRecursive(const FloatRect&) const; | 101 FloatRect mapRectRecursive(const FloatRect&) const; |
| 101 | 102 |
| 102 virtual FilterEffectType getFilterEffectType() const { return FilterEffectTy
peUnknown; } | 103 virtual FilterEffectType getFilterEffectType() const { return FilterEffectTy
peUnknown; } |
| 103 | 104 |
| 104 virtual TextStream& externalRepresentation(TextStream&, int indention = 0) c
onst; | 105 virtual TextStream& externalRepresentation(TextStream&, int indention = 0) c
onst; |
| 105 | 106 |
| 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 |
| 106 FloatRect filterPrimitiveSubregion() const { return m_filterPrimitiveSubregi
on; } | 121 FloatRect filterPrimitiveSubregion() const { return m_filterPrimitiveSubregi
on; } |
| 107 void setFilterPrimitiveSubregion(const FloatRect& filterPrimitiveSubregion)
{ m_filterPrimitiveSubregion = filterPrimitiveSubregion; } | 122 void setFilterPrimitiveSubregion(const FloatRect& filterPrimitiveSubregion)
{ m_filterPrimitiveSubregion = filterPrimitiveSubregion; } |
| 108 | 123 |
| 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 |
| 109 Filter* getFilter() { return m_filter; } | 128 Filter* getFilter() { return m_filter; } |
| 110 const Filter* getFilter() const { return m_filter; } | 129 const Filter* getFilter() const { return m_filter; } |
| 111 | 130 |
| 112 bool clipsToBounds() const { return m_clipsToBounds; } | 131 bool clipsToBounds() const { return m_clipsToBounds; } |
| 113 void setClipsToBounds(bool value) { m_clipsToBounds = value; } | 132 void setClipsToBounds(bool value) { m_clipsToBounds = value; } |
| 114 | 133 |
| 115 ColorSpace operatingColorSpace() const { return m_operatingColorSpace; } | 134 ColorSpace operatingColorSpace() const { return m_operatingColorSpace; } |
| 116 virtual void setOperatingColorSpace(ColorSpace colorSpace) { m_operatingColo
rSpace = colorSpace; } | 135 virtual void setOperatingColorSpace(ColorSpace colorSpace) { m_operatingColo
rSpace = colorSpace; } |
| 117 | 136 |
| 118 FloatRect determineMaximumEffectRect(DetermineMaxEffectRectFlags); | 137 FloatRect determineFilterPrimitiveSubregion(DetermineSubregionFlags = Determ
ineSubregionNone); |
| 119 | 138 |
| 120 virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedAbsol
uteRect); | 139 virtual FloatRect determineAbsolutePaintRect(const FloatRect& requestedAbsol
uteRect); |
| 121 virtual bool affectsTransparentPixels() { return false; } | 140 virtual bool affectsTransparentPixels() { return false; } |
| 122 | 141 |
| 123 // Return false if the filter will only operate correctly on valid RGBA valu
es, with | 142 // Return false if the filter will only operate correctly on valid RGBA valu
es, with |
| 124 // alpha in [0,255] and each color component in [0, alpha]. | 143 // alpha in [0,255] and each color component in [0, alpha]. |
| 125 virtual bool mayProduceInvalidPreMultipliedPixels() { return false; } | 144 virtual bool mayProduceInvalidPreMultipliedPixels() { return false; } |
| 126 | 145 |
| 127 SkImageFilter* getImageFilter(ColorSpace, bool requiresPMColorValidation) co
nst; | 146 SkImageFilter* getImageFilter(ColorSpace, bool requiresPMColorValidation) co
nst; |
| 128 void setImageFilter(ColorSpace, bool requiresPMColorValidation, sk_sp<SkImag
eFilter>); | 147 void setImageFilter(ColorSpace, bool requiresPMColorValidation, sk_sp<SkImag
eFilter>); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 153 FloatRect m_maxEffectRect; | 172 FloatRect m_maxEffectRect; |
| 154 Member<Filter> m_filter; | 173 Member<Filter> m_filter; |
| 155 | 174 |
| 156 // The following member variables are SVG specific and will move to LayoutSV
GResourceFilterPrimitive. | 175 // The following member variables are SVG specific and will move to LayoutSV
GResourceFilterPrimitive. |
| 157 // See bug https://bugs.webkit.org/show_bug.cgi?id=45614. | 176 // See bug https://bugs.webkit.org/show_bug.cgi?id=45614. |
| 158 | 177 |
| 159 // The subregion of a filter primitive according to the SVG Filter specifica
tion in local coordinates. | 178 // The subregion of a filter primitive according to the SVG Filter specifica
tion in local coordinates. |
| 160 // This is SVG specific and needs to move to LayoutSVGResourceFilterPrimitiv
e. | 179 // This is SVG specific and needs to move to LayoutSVGResourceFilterPrimitiv
e. |
| 161 FloatRect m_filterPrimitiveSubregion; | 180 FloatRect m_filterPrimitiveSubregion; |
| 162 | 181 |
| 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 |
| 163 // Should the effect clip to its primitive region, or expand to use the comb
ined region of its inputs. | 190 // Should the effect clip to its primitive region, or expand to use the comb
ined region of its inputs. |
| 164 bool m_clipsToBounds; | 191 bool m_clipsToBounds; |
| 165 | 192 |
| 166 bool m_originTainted; | 193 bool m_originTainted; |
| 167 | 194 |
| 168 ColorSpace m_operatingColorSpace; | 195 ColorSpace m_operatingColorSpace; |
| 169 | 196 |
| 170 sk_sp<SkImageFilter> m_imageFilters[4]; | 197 sk_sp<SkImageFilter> m_imageFilters[4]; |
| 171 }; | 198 }; |
| 172 | 199 |
| 173 } // namespace blink | 200 } // namespace blink |
| 174 | 201 |
| 175 #endif // FilterEffect_h | 202 #endif // FilterEffect_h |
| OLD | NEW |