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

Side by Side Diff: third_party/WebKit/Source/core/style/FilterOperation.h

Issue 2375453002: Move FilterOperation*.{cpp,h} to core/style/ (Closed)
Patch Set: Fix EXPORTs Created 4 years, 2 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) 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/CoreExport.h"
29 #include "platform/Length.h" 30 #include "platform/Length.h"
30 #include "platform/PlatformExport.h"
31 #include "platform/graphics/BoxReflection.h" 31 #include "platform/graphics/BoxReflection.h"
32 #include "platform/graphics/Color.h" 32 #include "platform/graphics/Color.h"
33 #include "platform/graphics/filters/Filter.h" 33 #include "platform/graphics/filters/Filter.h"
34 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 #include "wtf/Noncopyable.h" 35 #include "wtf/Noncopyable.h"
36 #include "wtf/text/WTFString.h" 36 #include "wtf/text/WTFString.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 // CSS Filters 40 // CSS Filters
41 41
42 class PLATFORM_EXPORT FilterOperation : public GarbageCollectedFinalized<FilterO peration> { 42 class CORE_EXPORT FilterOperation : public GarbageCollectedFinalized<FilterOpera tion> {
43 WTF_MAKE_NONCOPYABLE(FilterOperation); 43 WTF_MAKE_NONCOPYABLE(FilterOperation);
44 public: 44 public:
45 enum OperationType { 45 enum OperationType {
46 REFERENCE, // url(#somefilter) 46 REFERENCE, // url(#somefilter)
47 GRAYSCALE, 47 GRAYSCALE,
48 SEPIA, 48 SEPIA,
49 SATURATE, 49 SATURATE,
50 HUE_ROTATE, 50 HUE_ROTATE,
51 INVERT, 51 INVERT,
52 OPACITY, 52 OPACITY,
(...skipping 18 matching lines...) Expand all
71 case CONTRAST: 71 case CONTRAST:
72 case BLUR: 72 case BLUR:
73 case DROP_SHADOW: 73 case DROP_SHADOW:
74 return true; 74 return true;
75 case REFERENCE: 75 case REFERENCE:
76 case BOX_REFLECT: 76 case BOX_REFLECT:
77 return false; 77 return false;
78 case NONE: 78 case NONE:
79 break; 79 break;
80 } 80 }
81 ASSERT_NOT_REACHED(); 81 NOTREACHED();
82 return false; 82 return false;
83 } 83 }
84 84
85 virtual ~FilterOperation() { } 85 virtual ~FilterOperation() { }
86 DEFINE_INLINE_VIRTUAL_TRACE() { } 86 DEFINE_INLINE_VIRTUAL_TRACE() { }
87 87
88 static FilterOperation* blend(const FilterOperation* from, const FilterOpera tion* to, double progress); 88 static FilterOperation* blend(const FilterOperation* from, const FilterOpera tion* to, double progress);
89 virtual bool operator==(const FilterOperation&) const = 0; 89 virtual bool operator==(const FilterOperation&) const = 0;
90 bool operator!=(const FilterOperation& o) const { return !(*this == o); } 90 bool operator!=(const FilterOperation& o) const { return !(*this == o); }
91 91
(...skipping 18 matching lines...) Expand all
110 110
111 OperationType m_type; 111 OperationType m_type;
112 112
113 private: 113 private:
114 virtual FilterOperation* blend(const FilterOperation* from, double progress) const = 0; 114 virtual FilterOperation* blend(const FilterOperation* from, double progress) const = 0;
115 }; 115 };
116 116
117 #define DEFINE_FILTER_OPERATION_TYPE_CASTS(thisType, operationType) \ 117 #define DEFINE_FILTER_OPERATION_TYPE_CASTS(thisType, operationType) \
118 DEFINE_TYPE_CASTS(thisType, FilterOperation, op, op->type() == FilterOperati on::operationType, op.type() == FilterOperation::operationType); 118 DEFINE_TYPE_CASTS(thisType, FilterOperation, op, op->type() == FilterOperati on::operationType, op.type() == FilterOperation::operationType);
119 119
120 class PLATFORM_EXPORT ReferenceFilterOperation : public FilterOperation { 120 class CORE_EXPORT ReferenceFilterOperation : public FilterOperation {
121 public: 121 public:
122 static ReferenceFilterOperation* create(const String& url, const AtomicStrin g& fragment) 122 static ReferenceFilterOperation* create(const String& url, const AtomicStrin g& fragment)
123 { 123 {
124 return new ReferenceFilterOperation(url, fragment); 124 return new ReferenceFilterOperation(url, fragment);
125 } 125 }
126 126
127 bool affectsOpacity() const override { return true; } 127 bool affectsOpacity() const override { return true; }
128 bool movesPixels() const override { return true; } 128 bool movesPixels() const override { return true; }
129 FloatRect mapRect(const FloatRect&) const override; 129 FloatRect mapRect(const FloatRect&) const override;
130 130
131 const String& url() const { return m_url; } 131 const String& url() const { return m_url; }
132 const AtomicString& fragment() const { return m_fragment; } 132 const AtomicString& fragment() const { return m_fragment; }
133 133
134 Filter* getFilter() const { return m_filter.get(); } 134 Filter* getFilter() const { return m_filter.get(); }
135 void setFilter(Filter* filter) { m_filter = filter; } 135 void setFilter(Filter* filter) { m_filter = filter; }
136 136
137 DECLARE_VIRTUAL_TRACE(); 137 DECLARE_VIRTUAL_TRACE();
138 138
139 private: 139 private:
140 FilterOperation* blend(const FilterOperation* from, double progress) const o verride 140 FilterOperation* blend(const FilterOperation* from, double progress) const o verride
141 { 141 {
142 ASSERT_NOT_REACHED(); 142 NOTREACHED();
143 return nullptr; 143 return nullptr;
144 } 144 }
145 145
146 bool operator==(const FilterOperation& o) const override 146 bool operator==(const FilterOperation& o) const override
147 { 147 {
148 if (!isSameType(o)) 148 if (!isSameType(o))
149 return false; 149 return false;
150 const ReferenceFilterOperation* other = static_cast<const ReferenceFilte rOperation*>(&o); 150 const ReferenceFilterOperation* other = static_cast<const ReferenceFilte rOperation*>(&o);
151 return m_url == other->m_url; 151 return m_url == other->m_url;
152 } 152 }
153 153
154 ReferenceFilterOperation(const String& url, const AtomicString& fragment) 154 ReferenceFilterOperation(const String& url, const AtomicString& fragment)
155 : FilterOperation(REFERENCE) 155 : FilterOperation(REFERENCE)
156 , m_url(url) 156 , m_url(url)
157 , m_fragment(fragment) 157 , m_fragment(fragment)
158 { 158 {
159 } 159 }
160 160
161 String m_url; 161 String m_url;
162 AtomicString m_fragment; 162 AtomicString m_fragment;
163 Member<Filter> m_filter; 163 Member<Filter> m_filter;
164 }; 164 };
165 165
166 DEFINE_FILTER_OPERATION_TYPE_CASTS(ReferenceFilterOperation, REFERENCE); 166 DEFINE_FILTER_OPERATION_TYPE_CASTS(ReferenceFilterOperation, REFERENCE);
167 167
168 // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color mat rix effect. 168 // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color mat rix effect.
169 // For HUE_ROTATE, the angle of rotation is stored in m_amount. 169 // For HUE_ROTATE, the angle of rotation is stored in m_amount.
170 class PLATFORM_EXPORT BasicColorMatrixFilterOperation : public FilterOperation { 170 class CORE_EXPORT BasicColorMatrixFilterOperation : public FilterOperation {
171 public: 171 public:
172 static BasicColorMatrixFilterOperation* create(double amount, OperationType type) 172 static BasicColorMatrixFilterOperation* create(double amount, OperationType type)
173 { 173 {
174 return new BasicColorMatrixFilterOperation(amount, type); 174 return new BasicColorMatrixFilterOperation(amount, type);
175 } 175 }
176 176
177 double amount() const { return m_amount; } 177 double amount() const { return m_amount; }
178 178
179 179
180 private: 180 private:
(...skipping 17 matching lines...) Expand all
198 198
199 inline bool isBasicColorMatrixFilterOperation(const FilterOperation& operation) 199 inline bool isBasicColorMatrixFilterOperation(const FilterOperation& operation)
200 { 200 {
201 FilterOperation::OperationType type = operation.type(); 201 FilterOperation::OperationType type = operation.type();
202 return type == FilterOperation::GRAYSCALE || type == FilterOperation::SEPIA || type == FilterOperation::SATURATE || type == FilterOperation::HUE_ROTATE; 202 return type == FilterOperation::GRAYSCALE || type == FilterOperation::SEPIA || type == FilterOperation::SATURATE || type == FilterOperation::HUE_ROTATE;
203 } 203 }
204 204
205 DEFINE_TYPE_CASTS(BasicColorMatrixFilterOperation, FilterOperation, op, isBasicC olorMatrixFilterOperation(*op), isBasicColorMatrixFilterOperation(op)); 205 DEFINE_TYPE_CASTS(BasicColorMatrixFilterOperation, FilterOperation, op, isBasicC olorMatrixFilterOperation(*op), isBasicColorMatrixFilterOperation(op));
206 206
207 // INVERT, BRIGHTNESS, CONTRAST and OPACITY are variations on a basic component transfer effect. 207 // INVERT, BRIGHTNESS, CONTRAST and OPACITY are variations on a basic component transfer effect.
208 class PLATFORM_EXPORT BasicComponentTransferFilterOperation : public FilterOpera tion { 208 class CORE_EXPORT BasicComponentTransferFilterOperation : public FilterOperation {
209 public: 209 public:
210 static BasicComponentTransferFilterOperation* create(double amount, Operatio nType type) 210 static BasicComponentTransferFilterOperation* create(double amount, Operatio nType type)
211 { 211 {
212 return new BasicComponentTransferFilterOperation(amount, type); 212 return new BasicComponentTransferFilterOperation(amount, type);
213 } 213 }
214 214
215 double amount() const { return m_amount; } 215 double amount() const { return m_amount; }
216 216
217 bool affectsOpacity() const override { return m_type == OPACITY; } 217 bool affectsOpacity() const override { return m_type == OPACITY; }
218 218
(...skipping 18 matching lines...) Expand all
237 }; 237 };
238 238
239 inline bool isBasicComponentTransferFilterOperation(const FilterOperation& opera tion) 239 inline bool isBasicComponentTransferFilterOperation(const FilterOperation& opera tion)
240 { 240 {
241 FilterOperation::OperationType type = operation.type(); 241 FilterOperation::OperationType type = operation.type();
242 return type == FilterOperation::INVERT || type == FilterOperation::OPACITY | | type == FilterOperation::BRIGHTNESS || type == FilterOperation::CONTRAST; 242 return type == FilterOperation::INVERT || type == FilterOperation::OPACITY | | type == FilterOperation::BRIGHTNESS || type == FilterOperation::CONTRAST;
243 } 243 }
244 244
245 DEFINE_TYPE_CASTS(BasicComponentTransferFilterOperation, FilterOperation, op, is BasicComponentTransferFilterOperation(*op), isBasicComponentTransferFilterOperat ion(op)); 245 DEFINE_TYPE_CASTS(BasicComponentTransferFilterOperation, FilterOperation, op, is BasicComponentTransferFilterOperation(*op), isBasicComponentTransferFilterOperat ion(op));
246 246
247 class PLATFORM_EXPORT BlurFilterOperation : public FilterOperation { 247 class CORE_EXPORT BlurFilterOperation : public FilterOperation {
248 public: 248 public:
249 static BlurFilterOperation* create(const Length& stdDeviation) 249 static BlurFilterOperation* create(const Length& stdDeviation)
250 { 250 {
251 return new BlurFilterOperation(stdDeviation); 251 return new BlurFilterOperation(stdDeviation);
252 } 252 }
253 253
254 const Length& stdDeviation() const { return m_stdDeviation; } 254 const Length& stdDeviation() const { return m_stdDeviation; }
255 255
256 bool affectsOpacity() const override { return true; } 256 bool affectsOpacity() const override { return true; }
257 bool movesPixels() const override { return true; } 257 bool movesPixels() const override { return true; }
(...skipping 13 matching lines...) Expand all
271 : FilterOperation(BLUR) 271 : FilterOperation(BLUR)
272 , m_stdDeviation(stdDeviation) 272 , m_stdDeviation(stdDeviation)
273 { 273 {
274 } 274 }
275 275
276 Length m_stdDeviation; 276 Length m_stdDeviation;
277 }; 277 };
278 278
279 DEFINE_FILTER_OPERATION_TYPE_CASTS(BlurFilterOperation, BLUR); 279 DEFINE_FILTER_OPERATION_TYPE_CASTS(BlurFilterOperation, BLUR);
280 280
281 class PLATFORM_EXPORT DropShadowFilterOperation : public FilterOperation { 281 class CORE_EXPORT DropShadowFilterOperation : public FilterOperation {
282 public: 282 public:
283 static DropShadowFilterOperation* create(const IntPoint& location, int stdDe viation, Color color) 283 static DropShadowFilterOperation* create(const IntPoint& location, int stdDe viation, Color color)
284 { 284 {
285 return new DropShadowFilterOperation(location, stdDeviation, color); 285 return new DropShadowFilterOperation(location, stdDeviation, color);
286 } 286 }
287 287
288 int x() const { return m_location.x(); } 288 int x() const { return m_location.x(); }
289 int y() const { return m_location.y(); } 289 int y() const { return m_location.y(); }
290 IntPoint location() const { return m_location; } 290 IntPoint location() const { return m_location; }
291 int stdDeviation() const { return m_stdDeviation; } 291 int stdDeviation() const { return m_stdDeviation; }
(...skipping 21 matching lines...) Expand all
313 { 313 {
314 } 314 }
315 315
316 IntPoint m_location; // FIXME: should location be in Lengths? 316 IntPoint m_location; // FIXME: should location be in Lengths?
317 int m_stdDeviation; 317 int m_stdDeviation;
318 Color m_color; 318 Color m_color;
319 }; 319 };
320 320
321 DEFINE_FILTER_OPERATION_TYPE_CASTS(DropShadowFilterOperation, DROP_SHADOW); 321 DEFINE_FILTER_OPERATION_TYPE_CASTS(DropShadowFilterOperation, DROP_SHADOW);
322 322
323 class PLATFORM_EXPORT BoxReflectFilterOperation : public FilterOperation { 323 class CORE_EXPORT BoxReflectFilterOperation : public FilterOperation {
324 public: 324 public:
325 static BoxReflectFilterOperation* create(const BoxReflection& reflection) 325 static BoxReflectFilterOperation* create(const BoxReflection& reflection)
326 { 326 {
327 return new BoxReflectFilterOperation(reflection); 327 return new BoxReflectFilterOperation(reflection);
328 } 328 }
329 329
330 const BoxReflection& reflection() const { return m_reflection; } 330 const BoxReflection& reflection() const { return m_reflection; }
331 331
332 bool affectsOpacity() const override { return true; } 332 bool affectsOpacity() const override { return true; }
333 bool movesPixels() const override { return true; } 333 bool movesPixels() const override { return true; }
334 FloatRect mapRect(const FloatRect&) const override; 334 FloatRect mapRect(const FloatRect&) const override;
335 335
336 private: 336 private:
337 FilterOperation* blend(const FilterOperation* from, double progress) const o verride; 337 FilterOperation* blend(const FilterOperation* from, double progress) const o verride;
338 bool operator==(const FilterOperation&) const override; 338 bool operator==(const FilterOperation&) const override;
339 339
340 BoxReflectFilterOperation(const BoxReflection& reflection) 340 BoxReflectFilterOperation(const BoxReflection& reflection)
341 : FilterOperation(BOX_REFLECT) 341 : FilterOperation(BOX_REFLECT)
342 , m_reflection(reflection) 342 , m_reflection(reflection)
343 { 343 {
344 } 344 }
345 345
346 BoxReflection m_reflection; 346 BoxReflection m_reflection;
347 }; 347 };
348 DEFINE_FILTER_OPERATION_TYPE_CASTS(BoxReflectFilterOperation, BOX_REFLECT); 348 DEFINE_FILTER_OPERATION_TYPE_CASTS(BoxReflectFilterOperation, BOX_REFLECT);
349 349
350 } // namespace blink 350 } // namespace blink
351 351
352 #endif // FilterOperation_h 352 #endif // FilterOperation_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/BUILD.gn ('k') | third_party/WebKit/Source/core/style/FilterOperation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698