| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef FilterOperation_h | 26 #ifndef FilterOperation_h |
| 27 #define FilterOperation_h | 27 #define FilterOperation_h |
| 28 | 28 |
| 29 #include "core/platform/graphics/filters/Filter.h" | |
| 30 #include "core/platform/graphics/filters/ReferenceFilter.h" | |
| 31 #include "platform/Length.h" | 29 #include "platform/Length.h" |
| 30 #include "platform/PlatformExport.h" |
| 32 #include "platform/graphics/Color.h" | 31 #include "platform/graphics/Color.h" |
| 32 #include "platform/graphics/filters/Filter.h" |
| 33 #include "platform/graphics/filters/ReferenceFilter.h" |
| 33 #include "wtf/OwnPtr.h" | 34 #include "wtf/OwnPtr.h" |
| 34 #include "wtf/PassOwnPtr.h" | 35 #include "wtf/PassOwnPtr.h" |
| 35 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
| 36 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 37 | 38 |
| 38 namespace WebCore { | 39 namespace WebCore { |
| 39 | 40 |
| 40 // CSS Filters | 41 // CSS Filters |
| 41 | 42 |
| 42 class FilterOperation : public RefCounted<FilterOperation> { | 43 class PLATFORM_EXPORT FilterOperation : public RefCounted<FilterOperation> { |
| 43 public: | 44 public: |
| 44 enum OperationType { | 45 enum OperationType { |
| 45 REFERENCE, // url(#somefilter) | 46 REFERENCE, // url(#somefilter) |
| 46 GRAYSCALE, | 47 GRAYSCALE, |
| 47 SEPIA, | 48 SEPIA, |
| 48 SATURATE, | 49 SATURATE, |
| 49 HUE_ROTATE, | 50 HUE_ROTATE, |
| 50 INVERT, | 51 INVERT, |
| 51 OPACITY, | 52 OPACITY, |
| 52 BRIGHTNESS, | 53 BRIGHTNESS, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 106 |
| 106 OperationType m_type; | 107 OperationType m_type; |
| 107 | 108 |
| 108 private: | 109 private: |
| 109 virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, doubl
e progress) const = 0; | 110 virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, doubl
e progress) const = 0; |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 #define DEFINE_FILTER_OPERATION_TYPE_CASTS(thisType, operationType) \ | 113 #define DEFINE_FILTER_OPERATION_TYPE_CASTS(thisType, operationType) \ |
| 113 DEFINE_TYPE_CASTS(thisType, FilterOperation, op, op->type() == FilterOperati
on::operationType, op.type() == FilterOperation::operationType); | 114 DEFINE_TYPE_CASTS(thisType, FilterOperation, op, op->type() == FilterOperati
on::operationType, op.type() == FilterOperation::operationType); |
| 114 | 115 |
| 115 class ReferenceFilterOperation : public FilterOperation { | 116 class PLATFORM_EXPORT ReferenceFilterOperation : public FilterOperation { |
| 116 public: | 117 public: |
| 117 static PassRefPtr<ReferenceFilterOperation> create(const String& url, const
String& fragment) | 118 static PassRefPtr<ReferenceFilterOperation> create(const String& url, const
String& fragment) |
| 118 { | 119 { |
| 119 return adoptRef(new ReferenceFilterOperation(url, fragment)); | 120 return adoptRef(new ReferenceFilterOperation(url, fragment)); |
| 120 } | 121 } |
| 121 | 122 |
| 122 virtual bool affectsOpacity() const { return true; } | 123 virtual bool affectsOpacity() const { return true; } |
| 123 virtual bool movesPixels() const { return true; } | 124 virtual bool movesPixels() const { return true; } |
| 124 | 125 |
| 125 const String& url() const { return m_url; } | 126 const String& url() const { return m_url; } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 152 | 153 |
| 153 String m_url; | 154 String m_url; |
| 154 String m_fragment; | 155 String m_fragment; |
| 155 RefPtr<ReferenceFilter> m_filter; | 156 RefPtr<ReferenceFilter> m_filter; |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 DEFINE_FILTER_OPERATION_TYPE_CASTS(ReferenceFilterOperation, REFERENCE); | 159 DEFINE_FILTER_OPERATION_TYPE_CASTS(ReferenceFilterOperation, REFERENCE); |
| 159 | 160 |
| 160 // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color mat
rix effect. | 161 // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color mat
rix effect. |
| 161 // For HUE_ROTATE, the angle of rotation is stored in m_amount. | 162 // For HUE_ROTATE, the angle of rotation is stored in m_amount. |
| 162 class BasicColorMatrixFilterOperation : public FilterOperation { | 163 class PLATFORM_EXPORT BasicColorMatrixFilterOperation : public FilterOperation { |
| 163 public: | 164 public: |
| 164 static PassRefPtr<BasicColorMatrixFilterOperation> create(double amount, Ope
rationType type) | 165 static PassRefPtr<BasicColorMatrixFilterOperation> create(double amount, Ope
rationType type) |
| 165 { | 166 { |
| 166 return adoptRef(new BasicColorMatrixFilterOperation(amount, type)); | 167 return adoptRef(new BasicColorMatrixFilterOperation(amount, type)); |
| 167 } | 168 } |
| 168 | 169 |
| 169 double amount() const { return m_amount; } | 170 double amount() const { return m_amount; } |
| 170 | 171 |
| 171 | 172 |
| 172 private: | 173 private: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 190 | 191 |
| 191 inline bool isBasicColorMatrixFilterOperation(const FilterOperation& operation) | 192 inline bool isBasicColorMatrixFilterOperation(const FilterOperation& operation) |
| 192 { | 193 { |
| 193 FilterOperation::OperationType type = operation.type(); | 194 FilterOperation::OperationType type = operation.type(); |
| 194 return type == FilterOperation::GRAYSCALE || type == FilterOperation::SEPIA
|| type == FilterOperation::SATURATE || type == FilterOperation::HUE_ROTATE; | 195 return type == FilterOperation::GRAYSCALE || type == FilterOperation::SEPIA
|| type == FilterOperation::SATURATE || type == FilterOperation::HUE_ROTATE; |
| 195 } | 196 } |
| 196 | 197 |
| 197 DEFINE_TYPE_CASTS(BasicColorMatrixFilterOperation, FilterOperation, op, isBasicC
olorMatrixFilterOperation(*op), isBasicColorMatrixFilterOperation(op)); | 198 DEFINE_TYPE_CASTS(BasicColorMatrixFilterOperation, FilterOperation, op, isBasicC
olorMatrixFilterOperation(*op), isBasicColorMatrixFilterOperation(op)); |
| 198 | 199 |
| 199 // INVERT, BRIGHTNESS, CONTRAST and OPACITY are variations on a basic component
transfer effect. | 200 // INVERT, BRIGHTNESS, CONTRAST and OPACITY are variations on a basic component
transfer effect. |
| 200 class BasicComponentTransferFilterOperation : public FilterOperation { | 201 class PLATFORM_EXPORT BasicComponentTransferFilterOperation : public FilterOpera
tion { |
| 201 public: | 202 public: |
| 202 static PassRefPtr<BasicComponentTransferFilterOperation> create(double amoun
t, OperationType type) | 203 static PassRefPtr<BasicComponentTransferFilterOperation> create(double amoun
t, OperationType type) |
| 203 { | 204 { |
| 204 return adoptRef(new BasicComponentTransferFilterOperation(amount, type))
; | 205 return adoptRef(new BasicComponentTransferFilterOperation(amount, type))
; |
| 205 } | 206 } |
| 206 | 207 |
| 207 double amount() const { return m_amount; } | 208 double amount() const { return m_amount; } |
| 208 | 209 |
| 209 virtual bool affectsOpacity() const { return m_type == OPACITY; } | 210 virtual bool affectsOpacity() const { return m_type == OPACITY; } |
| 210 | 211 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 229 }; | 230 }; |
| 230 | 231 |
| 231 inline bool isBasicComponentTransferFilterOperation(const FilterOperation& opera
tion) | 232 inline bool isBasicComponentTransferFilterOperation(const FilterOperation& opera
tion) |
| 232 { | 233 { |
| 233 FilterOperation::OperationType type = operation.type(); | 234 FilterOperation::OperationType type = operation.type(); |
| 234 return type == FilterOperation::INVERT || type == FilterOperation::OPACITY |
| type == FilterOperation::BRIGHTNESS || type == FilterOperation::CONTRAST; | 235 return type == FilterOperation::INVERT || type == FilterOperation::OPACITY |
| type == FilterOperation::BRIGHTNESS || type == FilterOperation::CONTRAST; |
| 235 } | 236 } |
| 236 | 237 |
| 237 DEFINE_TYPE_CASTS(BasicComponentTransferFilterOperation, FilterOperation, op, is
BasicComponentTransferFilterOperation(*op), isBasicComponentTransferFilterOperat
ion(op)); | 238 DEFINE_TYPE_CASTS(BasicComponentTransferFilterOperation, FilterOperation, op, is
BasicComponentTransferFilterOperation(*op), isBasicComponentTransferFilterOperat
ion(op)); |
| 238 | 239 |
| 239 class BlurFilterOperation : public FilterOperation { | 240 class PLATFORM_EXPORT BlurFilterOperation : public FilterOperation { |
| 240 public: | 241 public: |
| 241 static PassRefPtr<BlurFilterOperation> create(Length stdDeviation) | 242 static PassRefPtr<BlurFilterOperation> create(Length stdDeviation) |
| 242 { | 243 { |
| 243 return adoptRef(new BlurFilterOperation(stdDeviation)); | 244 return adoptRef(new BlurFilterOperation(stdDeviation)); |
| 244 } | 245 } |
| 245 | 246 |
| 246 Length stdDeviation() const { return m_stdDeviation; } | 247 Length stdDeviation() const { return m_stdDeviation; } |
| 247 | 248 |
| 248 virtual bool affectsOpacity() const { return true; } | 249 virtual bool affectsOpacity() const { return true; } |
| 249 virtual bool movesPixels() const { return true; } | 250 virtual bool movesPixels() const { return true; } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 263 : FilterOperation(BLUR) | 264 : FilterOperation(BLUR) |
| 264 , m_stdDeviation(stdDeviation) | 265 , m_stdDeviation(stdDeviation) |
| 265 { | 266 { |
| 266 } | 267 } |
| 267 | 268 |
| 268 Length m_stdDeviation; | 269 Length m_stdDeviation; |
| 269 }; | 270 }; |
| 270 | 271 |
| 271 DEFINE_FILTER_OPERATION_TYPE_CASTS(BlurFilterOperation, BLUR); | 272 DEFINE_FILTER_OPERATION_TYPE_CASTS(BlurFilterOperation, BLUR); |
| 272 | 273 |
| 273 class DropShadowFilterOperation : public FilterOperation { | 274 class PLATFORM_EXPORT DropShadowFilterOperation : public FilterOperation { |
| 274 public: | 275 public: |
| 275 static PassRefPtr<DropShadowFilterOperation> create(const IntPoint& location
, int stdDeviation, Color color) | 276 static PassRefPtr<DropShadowFilterOperation> create(const IntPoint& location
, int stdDeviation, Color color) |
| 276 { | 277 { |
| 277 return adoptRef(new DropShadowFilterOperation(location, stdDeviation, co
lor)); | 278 return adoptRef(new DropShadowFilterOperation(location, stdDeviation, co
lor)); |
| 278 } | 279 } |
| 279 | 280 |
| 280 int x() const { return m_location.x(); } | 281 int x() const { return m_location.x(); } |
| 281 int y() const { return m_location.y(); } | 282 int y() const { return m_location.y(); } |
| 282 IntPoint location() const { return m_location; } | 283 IntPoint location() const { return m_location; } |
| 283 int stdDeviation() const { return m_stdDeviation; } | 284 int stdDeviation() const { return m_stdDeviation; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 309 int m_stdDeviation; | 310 int m_stdDeviation; |
| 310 Color m_color; | 311 Color m_color; |
| 311 }; | 312 }; |
| 312 | 313 |
| 313 DEFINE_FILTER_OPERATION_TYPE_CASTS(DropShadowFilterOperation, DROP_SHADOW); | 314 DEFINE_FILTER_OPERATION_TYPE_CASTS(DropShadowFilterOperation, DROP_SHADOW); |
| 314 | 315 |
| 315 } // namespace WebCore | 316 } // namespace WebCore |
| 316 | 317 |
| 317 | 318 |
| 318 #endif // FilterOperation_h | 319 #endif // FilterOperation_h |
| OLD | NEW |