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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm, | 175 SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm, |
176 MapDirection = kReverse_MapDirection) const; | 176 MapDirection = kReverse_MapDirection) const; |
177 | 177 |
178 /** | 178 /** |
179 * Returns true if the filter can be processed on the GPU. This is most | 179 * Returns true if the filter can be processed on the GPU. This is most |
180 * often used for multi-pass effects, where intermediate results must be | 180 * often used for multi-pass effects, where intermediate results must be |
181 * rendered to textures. For single-pass effects, use asFragmentProcessor(
). | 181 * rendered to textures. For single-pass effects, use asFragmentProcessor(
). |
182 * The default implementation returns asFragmentProcessor(NULL, NULL, SkMat
rix::I(), | 182 * The default implementation returns asFragmentProcessor(NULL, NULL, SkMat
rix::I(), |
183 * SkIRect()). | 183 * SkIRect()). |
184 */ | 184 */ |
185 virtual bool canFilterImageGPU() const; | 185 virtual bool canFilterImageGPU() const { return false; } |
186 | 186 |
187 /** | 187 /** |
188 * Process this image filter on the GPU. This is most often used for | 188 * Process this image filter on the GPU. This is most often used for |
189 * multi-pass effects, where intermediate results must be rendered to | 189 * multi-pass effects, where intermediate results must be rendered to |
190 * textures. For single-pass effects, use asFragmentProcessor(). src is t
he | 190 * textures. For single-pass effects, use asFragmentProcessor(). src is t
he |
191 * source image for processing, as a texture-backed bitmap. result is | 191 * source image for processing, as a texture-backed bitmap. result is |
192 * the destination bitmap, which should contain a texture-backed pixelref | 192 * the destination bitmap, which should contain a texture-backed pixelref |
193 * on success. offset is the amount to translate the resulting image | 193 * on success. offset is the amount to translate the resulting image |
194 * 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 |
195 * single-pass processing using asFragmentProcessor(). | 195 * single-pass processing using asFragmentProcessor(). |
196 */ | 196 */ |
197 virtual bool filterImageGPUDeprecated(Proxy*, const SkBitmap& src, const Con
text&, | 197 virtual bool filterImageGPUDeprecated(Proxy*, const SkBitmap&, const Context
&, |
198 SkBitmap* result, SkIPoint* offset) co
nst; | 198 SkBitmap*, SkIPoint*) const { |
| 199 SkASSERT(false); |
| 200 return false; |
| 201 } |
199 | 202 |
200 #if SK_SUPPORT_GPU | 203 #if SK_SUPPORT_GPU |
201 static sk_sp<SkSpecialImage> DrawWithFP(GrContext* context, | 204 static sk_sp<SkSpecialImage> DrawWithFP(GrContext* context, |
202 sk_sp<GrFragmentProcessor> fp, | 205 sk_sp<GrFragmentProcessor> fp, |
203 const SkIRect& bounds, | 206 const SkIRect& bounds, |
204 SkImageFilter::Proxy* proxy); | 207 SkImageFilter::Proxy* proxy); |
205 #endif | 208 #endif |
206 | 209 |
207 /** | 210 /** |
208 * Returns whether this image filter is a color filter and puts the color f
ilter into the | 211 * Returns whether this image filter is a color filter and puts the color f
ilter into the |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 * which are not capable of processing a smaller source bitmap into a | 448 * which are not capable of processing a smaller source bitmap into a |
446 * larger destination. | 449 * larger destination. |
447 */ | 450 */ |
448 bool applyCropRectDeprecated(const Context&, Proxy* proxy, const SkBitmap& s
rc, | 451 bool applyCropRectDeprecated(const Context&, Proxy* proxy, const SkBitmap& s
rc, |
449 SkIPoint* srcOffset, SkIRect* bounds, SkBitmap*
result) const; | 452 SkIPoint* srcOffset, SkIRect* bounds, SkBitmap*
result) const; |
450 | 453 |
451 sk_sp<SkSpecialImage> applyCropRect(const Context&, SkSpecialImage* src, SkI
Point* srcOffset, | 454 sk_sp<SkSpecialImage> applyCropRect(const Context&, SkSpecialImage* src, SkI
Point* srcOffset, |
452 SkIRect* bounds) const; | 455 SkIRect* bounds) const; |
453 | 456 |
454 /** | 457 /** |
455 * Returns true if the filter can be expressed a single-pass | |
456 * GrProcessor, used to process this filter on the GPU, or false if | |
457 * not. | |
458 * | |
459 * If effect is non-NULL, a new GrProcessor instance is stored | |
460 * in it. The caller assumes ownership of the stage, and it is up to the | |
461 * caller to unref it. | |
462 * | |
463 * The effect can assume its vertexCoords space maps 1-to-1 with texels | |
464 * in the texture. "matrix" is a transformation to apply to filter | |
465 * parameters before they are used in the effect. Note that this function | |
466 * will be called with (NULL, NULL, SkMatrix::I()) to query for support, | |
467 * so returning "true" indicates support for all possible matrices. | |
468 */ | |
469 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const Sk
Matrix&, | |
470 const SkIRect& bounds) const; | |
471 | |
472 /** | |
473 * Creates a modified Context for use when recursing up the image filter DA
G. | 458 * Creates a modified Context for use when recursing up the image filter DA
G. |
474 * The clip bounds are adjusted to accommodate any margins that this | 459 * The clip bounds are adjusted to accommodate any margins that this |
475 * filter requires by calling this node's | 460 * filter requires by calling this node's |
476 * onFilterNodeBounds(..., kReverse_MapDirection). | 461 * onFilterNodeBounds(..., kReverse_MapDirection). |
477 */ | 462 */ |
478 Context mapContext(const Context& ctx) const; | 463 Context mapContext(const Context& ctx) const; |
479 | 464 |
480 private: | 465 private: |
481 friend class SkGraphics; | 466 friend class SkGraphics; |
482 static void PurgeCache(); | 467 static void PurgeCache(); |
(...skipping 19 matching lines...) Expand all Loading... |
502 */ | 487 */ |
503 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ | 488 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ |
504 Common localVar; \ | 489 Common localVar; \ |
505 do { \ | 490 do { \ |
506 if (!localVar.unflatten(buffer, expectedCount)) { \ | 491 if (!localVar.unflatten(buffer, expectedCount)) { \ |
507 return NULL; \ | 492 return NULL; \ |
508 } \ | 493 } \ |
509 } while (0) | 494 } while (0) |
510 | 495 |
511 #endif | 496 #endif |
OLD | NEW |