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 |
11 #include "../private/SkTArray.h" | 11 #include "../private/SkTArray.h" |
12 #include "../private/SkTemplates.h" | 12 #include "../private/SkTemplates.h" |
13 #include "../private/SkMutex.h" | 13 #include "../private/SkMutex.h" |
14 #include "SkFilterQuality.h" | 14 #include "SkFilterQuality.h" |
15 #include "SkFlattenable.h" | 15 #include "SkFlattenable.h" |
16 #include "SkMatrix.h" | 16 #include "SkMatrix.h" |
17 #include "SkRect.h" | 17 #include "SkRect.h" |
18 #include "SkSurfaceProps.h" | 18 #include "SkSurfaceProps.h" |
19 | 19 |
| 20 class GrContext; |
20 class GrFragmentProcessor; | 21 class GrFragmentProcessor; |
21 class GrTexture; | 22 class GrTexture; |
22 class SkBaseDevice; | 23 class SkBaseDevice; |
23 class SkBitmap; | 24 class SkBitmap; |
24 class SkColorFilter; | 25 class SkColorFilter; |
25 struct SkIPoint; | 26 struct SkIPoint; |
26 class SkSpecialImage; | 27 class SkSpecialImage; |
27 | 28 |
28 /** | 29 /** |
29 * Base class for image filters. If one is installed in the paint, then | 30 * Base class for image filters. If one is installed in the paint, then |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 * textures. For single-pass effects, use asFragmentProcessor(). src is t
he | 190 * textures. For single-pass effects, use asFragmentProcessor(). src is t
he |
190 * source image for processing, as a texture-backed bitmap. result is | 191 * source image for processing, as a texture-backed bitmap. result is |
191 * the destination bitmap, which should contain a texture-backed pixelref | 192 * the destination bitmap, which should contain a texture-backed pixelref |
192 * on success. offset is the amount to translate the resulting image | 193 * on success. offset is the amount to translate the resulting image |
193 * relative to the src when it is drawn. The default implementation does | 194 * relative to the src when it is drawn. The default implementation does |
194 * single-pass processing using asFragmentProcessor(). | 195 * single-pass processing using asFragmentProcessor(). |
195 */ | 196 */ |
196 virtual bool filterImageGPUDeprecated(Proxy*, const SkBitmap& src, const Con
text&, | 197 virtual bool filterImageGPUDeprecated(Proxy*, const SkBitmap& src, const Con
text&, |
197 SkBitmap* result, SkIPoint* offset) co
nst; | 198 SkBitmap* result, SkIPoint* offset) co
nst; |
198 | 199 |
| 200 #if SK_SUPPORT_GPU |
| 201 static sk_sp<SkSpecialImage> DrawWithFP(GrContext* context, |
| 202 sk_sp<GrFragmentProcessor> fp, |
| 203 const SkIRect& bounds, |
| 204 SkImageFilter::Proxy* proxy); |
| 205 #endif |
| 206 |
199 /** | 207 /** |
200 * Returns whether this image filter is a color filter and puts the color f
ilter into the | 208 * Returns whether this image filter is a color filter and puts the color f
ilter into the |
201 * "filterPtr" parameter if it can. Does nothing otherwise. | 209 * "filterPtr" parameter if it can. Does nothing otherwise. |
202 * If this returns false, then the filterPtr is unchanged. | 210 * If this returns false, then the filterPtr is unchanged. |
203 * If this returns true, then if filterPtr is not null, it must be set to a
ref'd colorfitler | 211 * If this returns true, then if filterPtr is not null, it must be set to a
ref'd colorfitler |
204 * (i.e. it may not be set to NULL). | 212 * (i.e. it may not be set to NULL). |
205 */ | 213 */ |
206 bool isColorFilterNode(SkColorFilter** filterPtr) const { | 214 bool isColorFilterNode(SkColorFilter** filterPtr) const { |
207 return this->onIsColorFilterNode(filterPtr); | 215 return this->onIsColorFilterNode(filterPtr); |
208 } | 216 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 SkBitmap* result, SkIPoint* offset) const; | 419 SkBitmap* result, SkIPoint* offset) const; |
412 | 420 |
413 /** | 421 /** |
414 * Return true (and return a ref'd colorfilter) if this node in the DAG is
just a | 422 * Return true (and return a ref'd colorfilter) if this node in the DAG is
just a |
415 * colorfilter w/o CropRect constraints. | 423 * colorfilter w/o CropRect constraints. |
416 */ | 424 */ |
417 virtual bool onIsColorFilterNode(SkColorFilter** /*filterPtr*/) const { | 425 virtual bool onIsColorFilterNode(SkColorFilter** /*filterPtr*/) const { |
418 return false; | 426 return false; |
419 } | 427 } |
420 | 428 |
421 /** Given a "srcBounds" rect, computes destination bounds for this | 429 /** Given a "srcBounds" rect, computes destination bounds for this filter. |
422 * destination bounds for this filter. "dstBounds" are computed by | 430 * "dstBounds" are computed by transforming the crop rect by the context's |
423 * transforming the crop rect by the context's CTM, applying it to the | 431 * CTM, applying it to the initial bounds, and intersecting the result with |
424 * initial bounds, and intersecting the result with the context's clip | 432 * the context's clip bounds. "srcBounds" (if non-null) are computed by |
425 * bounds. "srcBounds" (if non-null) are computed by intersecting the | 433 * intersecting the initial bounds with "dstBounds", to ensure that we neve
r |
426 * initial bounds with "dstBounds", to ensure that we never sample | 434 * sample outside of the crop rect (this restriction may be relaxed in the |
427 * outside of the crop rect (this restriction may be relaxed in the | |
428 * future). | 435 * future). |
429 */ | 436 */ |
430 bool applyCropRect(const Context&, const SkIRect& srcBounds, SkIRect* dstBou
nds) const; | 437 bool applyCropRect(const Context&, const SkIRect& srcBounds, SkIRect* dstBou
nds) const; |
431 | 438 |
432 /** A variant of the above call which takes the original source bitmap and | 439 /** A variant of the above call which takes the original source bitmap and |
433 * source offset. If the resulting crop rect is not entirely contained by | 440 * source offset. If the resulting crop rect is not entirely contained by |
434 * the source bitmap's bounds, it creates a new bitmap in "result" and | 441 * the source bitmap's bounds, it creates a new bitmap in "result" and |
435 * pads the edges with transparent black. In that case, the srcOffset is | 442 * pads the edges with transparent black. In that case, the srcOffset is |
436 * modified to be the same as the bounds, since no further adjustment is | 443 * modified to be the same as the bounds, since no further adjustment is |
437 * needed by the caller. This version should only be used by filters | 444 * needed by the caller. This version should only be used by filters |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 */ | 502 */ |
496 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ | 503 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ |
497 Common localVar; \ | 504 Common localVar; \ |
498 do { \ | 505 do { \ |
499 if (!localVar.unflatten(buffer, expectedCount)) { \ | 506 if (!localVar.unflatten(buffer, expectedCount)) { \ |
500 return NULL; \ | 507 return NULL; \ |
501 } \ | 508 } \ |
502 } while (0) | 509 } while (0) |
503 | 510 |
504 #endif | 511 #endif |
OLD | NEW |