| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkImageFilter_DEFINED | 8 #ifndef SkImageFilter_DEFINED |
| 9 #define SkImageFilter_DEFINED | 9 #define SkImageFilter_DEFINED |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const Context&, | 135 virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const Context&, |
| 136 SkBitmap* result, SkIPoint* offset) const; | 136 SkBitmap* result, SkIPoint* offset) const; |
| 137 | 137 |
| 138 /** | 138 /** |
| 139 * Returns whether this image filter is a color filter and puts the color f
ilter into the | 139 * Returns whether this image filter is a color filter and puts the color f
ilter into the |
| 140 * "filterPtr" parameter if it can. Does nothing otherwise. | 140 * "filterPtr" parameter if it can. Does nothing otherwise. |
| 141 * If this returns false, then the filterPtr is unchanged. | 141 * If this returns false, then the filterPtr is unchanged. |
| 142 * If this returns true, then if filterPtr is not null, it must be set to a
ref'd colorfitler | 142 * If this returns true, then if filterPtr is not null, it must be set to a
ref'd colorfitler |
| 143 * (i.e. it may not be set to NULL). | 143 * (i.e. it may not be set to NULL). |
| 144 */ | 144 */ |
| 145 virtual bool asColorFilter(SkColorFilter** filterPtr) const; | 145 bool isColorFilterNode(SkColorFilter** filterPtr) const { |
| 146 return this->onIsColorFilterNode(filterPtr); |
| 147 } |
| 148 |
| 149 // DEPRECATED : use isColorFilterNode() instead |
| 150 bool asColorFilter(SkColorFilter** filterPtr) const { |
| 151 return this->isColorFilterNode(filterPtr); |
| 152 } |
| 153 |
| 154 /** |
| 155 * Returns true (and optionally returns a ref'd filter) if this imagefilter
can be completely |
| 156 * replaced by the returned colorfilter. i.e. the two effects will affect d
rawing in the |
| 157 * same way. |
| 158 */ |
| 159 bool asAColorFilter(SkColorFilter** filterPtr) const { |
| 160 return this->countInputs() > 0 && |
| 161 NULL == this->getInput(0) && |
| 162 this->isColorFilterNode(filterPtr); |
| 163 } |
| 146 | 164 |
| 147 /** | 165 /** |
| 148 * Returns the number of inputs this filter will accept (some inputs can | 166 * Returns the number of inputs this filter will accept (some inputs can |
| 149 * be NULL). | 167 * be NULL). |
| 150 */ | 168 */ |
| 151 int countInputs() const { return fInputCount; } | 169 int countInputs() const { return fInputCount; } |
| 152 | 170 |
| 153 /** | 171 /** |
| 154 * Returns the input filter at a given index, or NULL if no input is | 172 * Returns the input filter at a given index, or NULL if no input is |
| 155 * connected. The indices used are filter-specific. | 173 * connected. The indices used are filter-specific. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 SkBitmap* result, SkIPoint* offset) const; | 282 SkBitmap* result, SkIPoint* offset) const; |
| 265 // Given the bounds of the destination rect to be filled in device | 283 // Given the bounds of the destination rect to be filled in device |
| 266 // coordinates (first parameter), and the CTM, compute (conservatively) | 284 // coordinates (first parameter), and the CTM, compute (conservatively) |
| 267 // which rect of the source image would be required (third parameter). | 285 // which rect of the source image would be required (third parameter). |
| 268 // Used for clipping and temp-buffer allocations, so the result need not | 286 // Used for clipping and temp-buffer allocations, so the result need not |
| 269 // be exact, but should never be smaller than the real answer. The default | 287 // be exact, but should never be smaller than the real answer. The default |
| 270 // implementation recursively unions all input bounds, or returns false if | 288 // implementation recursively unions all input bounds, or returns false if |
| 271 // no inputs. | 289 // no inputs. |
| 272 virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const
; | 290 virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const
; |
| 273 | 291 |
| 292 /** |
| 293 * Return true (and return a ref'd colorfilter) if this node in the DAG is
just a |
| 294 * colorfilter w/o CropRect constraints. |
| 295 */ |
| 296 virtual bool onIsColorFilterNode(SkColorFilter** /*filterPtr*/) const { |
| 297 return false; |
| 298 } |
| 299 |
| 274 /** Computes source bounds as the src bitmap bounds offset by srcOffset. | 300 /** Computes source bounds as the src bitmap bounds offset by srcOffset. |
| 275 * Apply the transformed crop rect to the bounds if any of the | 301 * Apply the transformed crop rect to the bounds if any of the |
| 276 * corresponding edge flags are set. Intersects the result against the | 302 * corresponding edge flags are set. Intersects the result against the |
| 277 * context's clipBounds, and returns the result in "bounds". If there is | 303 * context's clipBounds, and returns the result in "bounds". If there is |
| 278 * no intersection, returns false and leaves "bounds" unchanged. | 304 * no intersection, returns false and leaves "bounds" unchanged. |
| 279 */ | 305 */ |
| 280 bool applyCropRect(const Context&, const SkBitmap& src, const SkIPoint& srcO
ffset, | 306 bool applyCropRect(const Context&, const SkBitmap& src, const SkIPoint& srcO
ffset, |
| 281 SkIRect* bounds) const; | 307 SkIRect* bounds) const; |
| 282 | 308 |
| 283 /** Same as the above call, except that if the resulting crop rect is not | 309 /** Same as the above call, except that if the resulting crop rect is not |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 */ | 351 */ |
| 326 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ | 352 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ |
| 327 Common localVar; \ | 353 Common localVar; \ |
| 328 do { \ | 354 do { \ |
| 329 if (!localVar.unflatten(buffer, expectedCount)) { \ | 355 if (!localVar.unflatten(buffer, expectedCount)) { \ |
| 330 return NULL; \ | 356 return NULL; \ |
| 331 } \ | 357 } \ |
| 332 } while (0) | 358 } while (0) |
| 333 | 359 |
| 334 #endif | 360 #endif |
| OLD | NEW |