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

Side by Side Diff: public/common/WebFilterOperation.h

Issue 15079005: Create a minimal webkit_common static library for use in browser process (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef WebFilterOperation_h 26 #ifndef WebFilterOperation_h
27 #define WebFilterOperation_h 27 #define WebFilterOperation_h
28 28
29 #include "SkScalar.h" 29 #include "SkScalar.h"
30 #include "WebCommon.h" 30 #include "WebAssertion.h"
31 #include "WebColor.h" 31 #include "WebColor.h"
32 #include "WebPoint.h" 32 #include "WebCommonExport.h"
33 33
34 namespace WebKit { 34 namespace WebKit {
35 35
36 class WebFilterOperation { 36 class WebFilterOperation {
37 public: 37 public:
38 enum FilterType { 38 enum FilterType {
39 FilterTypeGrayscale, 39 FilterTypeGrayscale,
40 FilterTypeSepia, 40 FilterTypeSepia,
41 FilterTypeSaturate, 41 FilterTypeSaturate,
42 FilterTypeHueRotate, 42 FilterTypeHueRotate,
(...skipping 19 matching lines...) Expand all
62 || m_type == FilterTypeInvert 62 || m_type == FilterTypeInvert
63 || m_type == FilterTypeBrightness 63 || m_type == FilterTypeBrightness
64 || m_type == FilterTypeContrast 64 || m_type == FilterTypeContrast
65 || m_type == FilterTypeOpacity 65 || m_type == FilterTypeOpacity
66 || m_type == FilterTypeBlur 66 || m_type == FilterTypeBlur
67 || m_type == FilterTypeDropShadow 67 || m_type == FilterTypeDropShadow
68 || m_type == FilterTypeZoom 68 || m_type == FilterTypeZoom
69 || m_type == FilterTypeSaturatingBrightness); 69 || m_type == FilterTypeSaturatingBrightness);
70 return m_amount; 70 return m_amount;
71 } 71 }
72 WebPoint dropShadowOffset() const 72 int dropShadowOffsetX() const
73 { 73 {
74 WEBKIT_ASSERT(m_type == FilterTypeDropShadow); 74 WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
75 return m_dropShadowOffset; 75 return m_dropShadowOffsetX;
76 }
77 int dropShadowOffsetY() const
78 {
79 WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
80 return m_dropShadowOffsetY;
76 } 81 }
77 WebColor dropShadowColor() const 82 WebColor dropShadowColor() const
78 { 83 {
79 WEBKIT_ASSERT(m_type == FilterTypeDropShadow); 84 WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
80 return m_dropShadowColor; 85 return m_dropShadowColor;
81 } 86 }
82 const SkScalar* matrix() const 87 const SkScalar* matrix() const
83 { 88 {
84 WEBKIT_ASSERT(m_type == FilterTypeColorMatrix); 89 WEBKIT_ASSERT(m_type == FilterTypeColorMatrix);
85 return m_matrix; 90 return m_matrix;
86 } 91 }
87 92
88 int zoomInset() const 93 int zoomInset() const
89 { 94 {
90 WEBKIT_ASSERT(m_type == FilterTypeZoom); 95 WEBKIT_ASSERT(m_type == FilterTypeZoom);
91 return m_zoomInset; 96 return m_zoomInset;
92 } 97 }
93 98
94 static WebFilterOperation createGrayscaleFilter(float amount) { return WebFi lterOperation(FilterTypeGrayscale, amount); } 99 static WebFilterOperation createGrayscaleFilter(float amount) { return WebFi lterOperation(FilterTypeGrayscale, amount); }
95 static WebFilterOperation createSepiaFilter(float amount) { return WebFilter Operation(FilterTypeSepia, amount); } 100 static WebFilterOperation createSepiaFilter(float amount) { return WebFilter Operation(FilterTypeSepia, amount); }
96 static WebFilterOperation createSaturateFilter(float amount) { return WebFil terOperation(FilterTypeSaturate, amount); } 101 static WebFilterOperation createSaturateFilter(float amount) { return WebFil terOperation(FilterTypeSaturate, amount); }
97 static WebFilterOperation createHueRotateFilter(float amount) { return WebFi lterOperation(FilterTypeHueRotate, amount); } 102 static WebFilterOperation createHueRotateFilter(float amount) { return WebFi lterOperation(FilterTypeHueRotate, amount); }
98 static WebFilterOperation createInvertFilter(float amount) { return WebFilte rOperation(FilterTypeInvert, amount); } 103 static WebFilterOperation createInvertFilter(float amount) { return WebFilte rOperation(FilterTypeInvert, amount); }
99 static WebFilterOperation createBrightnessFilter(float amount) { return WebF ilterOperation(FilterTypeBrightness, amount); } 104 static WebFilterOperation createBrightnessFilter(float amount) { return WebF ilterOperation(FilterTypeBrightness, amount); }
100 static WebFilterOperation createContrastFilter(float amount) { return WebFil terOperation(FilterTypeContrast, amount); } 105 static WebFilterOperation createContrastFilter(float amount) { return WebFil terOperation(FilterTypeContrast, amount); }
101 static WebFilterOperation createOpacityFilter(float amount) { return WebFilt erOperation(FilterTypeOpacity, amount); } 106 static WebFilterOperation createOpacityFilter(float amount) { return WebFilt erOperation(FilterTypeOpacity, amount); }
102 static WebFilterOperation createBlurFilter(float amount) { return WebFilterO peration(FilterTypeBlur, amount); } 107 static WebFilterOperation createBlurFilter(float amount) { return WebFilterO peration(FilterTypeBlur, amount); }
103 static WebFilterOperation createDropShadowFilter(WebPoint offset, float stdD eviation, WebColor color) { return WebFilterOperation(FilterTypeDropShadow, offs et, stdDeviation, color); } 108 static WebFilterOperation createDropShadowFilter(int offsetX, int offsetY, f loat stdDeviation, WebColor color) { return WebFilterOperation(FilterTypeDropSha dow, offsetX, offsetY, stdDeviation, color); }
104 static WebFilterOperation createColorMatrixFilter(SkScalar matrix[20]) { ret urn WebFilterOperation(FilterTypeColorMatrix, matrix); } 109 static WebFilterOperation createColorMatrixFilter(SkScalar matrix[20]) { ret urn WebFilterOperation(FilterTypeColorMatrix, matrix); }
105 static WebFilterOperation createZoomFilter(float amount, int inset) { return WebFilterOperation(FilterTypeZoom, amount, inset); } 110 static WebFilterOperation createZoomFilter(float amount, int inset) { return WebFilterOperation(FilterTypeZoom, amount, inset); }
106 static WebFilterOperation createSaturatingBrightnessFilter(float amount) { r eturn WebFilterOperation(FilterTypeSaturatingBrightness, amount); } 111 static WebFilterOperation createSaturatingBrightnessFilter(float amount) { r eturn WebFilterOperation(FilterTypeSaturatingBrightness, amount); }
107 112
108 bool equals(const WebFilterOperation& other) const; 113 bool equals(const WebFilterOperation& other) const;
109 114
110 // Methods for restoring a WebFilterOperation. 115 // Methods for restoring a WebFilterOperation.
111 static WebFilterOperation createEmptyFilter() { return WebFilterOperation(Fi lterTypeGrayscale, 0.0); } 116 static WebFilterOperation createEmptyFilter() { return WebFilterOperation(Fi lterTypeGrayscale, 0.0); }
112 void setType(FilterType type) { m_type = type; } 117 void setType(FilterType type) { m_type = type; }
113 void setAmount(float amount) 118 void setAmount(float amount)
114 { 119 {
115 WEBKIT_ASSERT(m_type == FilterTypeGrayscale 120 WEBKIT_ASSERT(m_type == FilterTypeGrayscale
116 || m_type == FilterTypeSepia 121 || m_type == FilterTypeSepia
117 || m_type == FilterTypeSaturate 122 || m_type == FilterTypeSaturate
118 || m_type == FilterTypeHueRotate 123 || m_type == FilterTypeHueRotate
119 || m_type == FilterTypeInvert 124 || m_type == FilterTypeInvert
120 || m_type == FilterTypeBrightness 125 || m_type == FilterTypeBrightness
121 || m_type == FilterTypeContrast 126 || m_type == FilterTypeContrast
122 || m_type == FilterTypeOpacity 127 || m_type == FilterTypeOpacity
123 || m_type == FilterTypeBlur 128 || m_type == FilterTypeBlur
124 || m_type == FilterTypeDropShadow 129 || m_type == FilterTypeDropShadow
125 || m_type == FilterTypeZoom 130 || m_type == FilterTypeZoom
126 || m_type == FilterTypeSaturatingBrightness); 131 || m_type == FilterTypeSaturatingBrightness);
127 m_amount = amount; 132 m_amount = amount;
128 } 133 }
129 void setDropShadowOffset(WebPoint offset) 134 void setDropShadowOffset(int x, int y)
130 { 135 {
131 WEBKIT_ASSERT(m_type == FilterTypeDropShadow); 136 WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
132 m_dropShadowOffset = offset; 137 m_dropShadowOffsetX = x;
138 m_dropShadowOffsetY = y;
133 } 139 }
134 void setDropShadowColor(WebColor color) 140 void setDropShadowColor(WebColor color)
135 { 141 {
136 WEBKIT_ASSERT(m_type == FilterTypeDropShadow); 142 WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
137 m_dropShadowColor = color; 143 m_dropShadowColor = color;
138 } 144 }
139 void setMatrix(const SkScalar matrix[20]) 145 void setMatrix(const SkScalar matrix[20])
140 { 146 {
141 WEBKIT_ASSERT(m_type == FilterTypeColorMatrix); 147 WEBKIT_ASSERT(m_type == FilterTypeColorMatrix);
142 for (unsigned i = 0; i < 20; ++i) 148 for (unsigned i = 0; i < 20; ++i)
143 m_matrix[i] = matrix[i]; 149 m_matrix[i] = matrix[i];
144 } 150 }
145 void setZoomInset(int inset) 151 void setZoomInset(int inset)
146 { 152 {
147 WEBKIT_ASSERT(m_type == FilterTypeZoom); 153 WEBKIT_ASSERT(m_type == FilterTypeZoom);
148 m_zoomInset = inset; 154 m_zoomInset = inset;
149 } 155 }
150 156
151 private: 157 private:
152 FilterType m_type; 158 FilterType m_type;
153 159
154 float m_amount; 160 float m_amount;
155 WebPoint m_dropShadowOffset; 161 int m_dropShadowOffsetX;
162 int m_dropShadowOffsetY;
156 WebColor m_dropShadowColor; 163 WebColor m_dropShadowColor;
157 SkScalar m_matrix[20]; 164 SkScalar m_matrix[20];
158 int m_zoomInset; 165 int m_zoomInset;
159 166
160 WebFilterOperation(FilterType type, float amount) 167 WebFilterOperation(FilterType type, float amount)
161 : m_type(type) 168 : m_type(type)
162 , m_amount(amount) 169 , m_amount(amount)
163 , m_dropShadowOffset(0, 0) 170 , m_dropShadowOffsetX(0)
171 , m_dropShadowOffsetY(0)
164 , m_dropShadowColor(0) 172 , m_dropShadowColor(0)
165 , m_zoomInset(0) 173 , m_zoomInset(0)
166 { 174 {
167 WEBKIT_ASSERT(m_type != FilterTypeDropShadow && m_type != FilterTypeColo rMatrix); 175 WEBKIT_ASSERT(m_type != FilterTypeDropShadow && m_type != FilterTypeColo rMatrix);
168 memset(m_matrix, 0, sizeof(m_matrix)); 176 memset(m_matrix, 0, sizeof(m_matrix));
169 } 177 }
170 178
171 WebFilterOperation(FilterType type, WebPoint offset, float stdDeviation, Web Color color) 179 WebFilterOperation(FilterType type, int offsetX, int offsetY, float stdDevia tion, WebColor color)
172 : m_type(type) 180 : m_type(type)
173 , m_amount(stdDeviation) 181 , m_amount(stdDeviation)
174 , m_dropShadowOffset(offset) 182 , m_dropShadowOffsetX(offsetX)
183 , m_dropShadowOffsetY(offsetY)
175 , m_dropShadowColor(color) 184 , m_dropShadowColor(color)
176 , m_zoomInset(0) 185 , m_zoomInset(0)
177 { 186 {
178 WEBKIT_ASSERT(m_type == FilterTypeDropShadow); 187 WEBKIT_ASSERT(m_type == FilterTypeDropShadow);
179 memset(m_matrix, 0, sizeof(m_matrix)); 188 memset(m_matrix, 0, sizeof(m_matrix));
180 } 189 }
181 190
182 WEBKIT_EXPORT WebFilterOperation(FilterType, SkScalar matrix[20]); 191 BLINK_COMMON_EXPORT WebFilterOperation(FilterType, SkScalar matrix[20]);
183 192
184 WebFilterOperation(FilterType type, float amount, int inset) 193 WebFilterOperation(FilterType type, float amount, int inset)
185 : m_type(type) 194 : m_type(type)
186 , m_amount(amount) 195 , m_amount(amount)
187 , m_dropShadowOffset(0, 0) 196 , m_dropShadowOffsetX(0)
197 , m_dropShadowOffsetY(0)
188 , m_dropShadowColor(0) 198 , m_dropShadowColor(0)
189 , m_zoomInset(inset) 199 , m_zoomInset(inset)
190 { 200 {
191 WEBKIT_ASSERT(m_type == FilterTypeZoom); 201 WEBKIT_ASSERT(m_type == FilterTypeZoom);
192 memset(m_matrix, 0, sizeof(m_matrix)); 202 memset(m_matrix, 0, sizeof(m_matrix));
193 } 203 }
194 }; 204 };
195 205
196 inline bool operator==(const WebFilterOperation& a, const WebFilterOperation& b) 206 inline bool operator==(const WebFilterOperation& a, const WebFilterOperation& b)
197 { 207 {
198 return a.equals(b); 208 return a.equals(b);
199 } 209 }
200 210
201 inline bool operator!=(const WebFilterOperation& a, const WebFilterOperation& b) 211 inline bool operator!=(const WebFilterOperation& a, const WebFilterOperation& b)
202 { 212 {
203 return !(a == b); 213 return !(a == b);
204 } 214 }
205 215
206 } 216 }
207 217
208 #endif 218 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698