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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 171 } |
172 | 172 |
173 /** | 173 /** |
174 * Returns true (and optionally returns a ref'd filter) if this imagefilter
can be completely | 174 * Returns true (and optionally returns a ref'd filter) if this imagefilter
can be completely |
175 * replaced by the returned colorfilter. i.e. the two effects will affect d
rawing in the | 175 * replaced by the returned colorfilter. i.e. the two effects will affect d
rawing in the |
176 * same way. | 176 * same way. |
177 */ | 177 */ |
178 bool asAColorFilter(SkColorFilter** filterPtr) const { | 178 bool asAColorFilter(SkColorFilter** filterPtr) const { |
179 return this->countInputs() > 0 && | 179 return this->countInputs() > 0 && |
180 NULL == this->getInput(0) && | 180 NULL == this->getInput(0) && |
| 181 !this->affectsTransparentBlack() && |
181 this->isColorFilterNode(filterPtr); | 182 this->isColorFilterNode(filterPtr); |
182 } | 183 } |
183 | 184 |
184 /** | 185 /** |
185 * Returns the number of inputs this filter will accept (some inputs can | 186 * Returns the number of inputs this filter will accept (some inputs can |
186 * be NULL). | 187 * be NULL). |
187 */ | 188 */ |
188 int countInputs() const { return fInputCount; } | 189 int countInputs() const { return fInputCount; } |
189 | 190 |
190 /** | 191 /** |
(...skipping 16 matching lines...) Expand all Loading... |
207 * filterImageGPU(). (The latter ensures that the resulting buffer is | 208 * filterImageGPU(). (The latter ensures that the resulting buffer is |
208 * drawn in the correct location.) | 209 * drawn in the correct location.) |
209 */ | 210 */ |
210 bool cropRectIsSet() const { return fCropRect.flags() != 0x0; } | 211 bool cropRectIsSet() const { return fCropRect.flags() != 0x0; } |
211 | 212 |
212 CropRect getCropRect() const { return fCropRect; } | 213 CropRect getCropRect() const { return fCropRect; } |
213 | 214 |
214 // Default impl returns union of all input bounds. | 215 // Default impl returns union of all input bounds. |
215 virtual void computeFastBounds(const SkRect&, SkRect*) const; | 216 virtual void computeFastBounds(const SkRect&, SkRect*) const; |
216 | 217 |
| 218 // Can this filter DAG compute the resulting bounds of an object-space recta
ngle? |
| 219 bool canComputeFastBounds() const; |
| 220 |
217 /** | 221 /** |
218 * Create an SkMatrixImageFilter, which transforms its input by the given ma
trix. | 222 * Create an SkMatrixImageFilter, which transforms its input by the given ma
trix. |
219 */ | 223 */ |
220 static SkImageFilter* CreateMatrixFilter(const SkMatrix& matrix, | 224 static SkImageFilter* CreateMatrixFilter(const SkMatrix& matrix, |
221 SkFilterQuality, | 225 SkFilterQuality, |
222 SkImageFilter* input = NULL); | 226 SkImageFilter* input = NULL); |
223 | 227 |
224 #if SK_SUPPORT_GPU | 228 #if SK_SUPPORT_GPU |
225 /** | 229 /** |
226 * Wrap the given texture in a texture-backed SkBitmap. | 230 * Wrap the given texture in a texture-backed SkBitmap. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 * | 359 * |
356 * The effect can assume its vertexCoords space maps 1-to-1 with texels | 360 * The effect can assume its vertexCoords space maps 1-to-1 with texels |
357 * in the texture. "matrix" is a transformation to apply to filter | 361 * in the texture. "matrix" is a transformation to apply to filter |
358 * parameters before they are used in the effect. Note that this function | 362 * parameters before they are used in the effect. Note that this function |
359 * will be called with (NULL, NULL, SkMatrix::I()) to query for support, | 363 * will be called with (NULL, NULL, SkMatrix::I()) to query for support, |
360 * so returning "true" indicates support for all possible matrices. | 364 * so returning "true" indicates support for all possible matrices. |
361 */ | 365 */ |
362 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrProcessorDataManag
er*, GrTexture*, | 366 virtual bool asFragmentProcessor(GrFragmentProcessor**, GrProcessorDataManag
er*, GrTexture*, |
363 const SkMatrix&, const SkIRect& bounds) con
st; | 367 const SkMatrix&, const SkIRect& bounds) con
st; |
364 | 368 |
| 369 /** |
| 370 * Returns true if this filter can cause transparent black pixels to become |
| 371 * visible (ie., alpha > 0). The default implementation returns false. This |
| 372 * function is non-recursive, i.e., only queries this filter and not its |
| 373 * inputs. |
| 374 */ |
| 375 virtual bool affectsTransparentBlack() const; |
| 376 |
365 private: | 377 private: |
366 friend class SkGraphics; | 378 friend class SkGraphics; |
367 static void PurgeCache(); | 379 static void PurgeCache(); |
368 | 380 |
369 bool usesSrcInput() const { return fUsesSrcInput; } | 381 bool usesSrcInput() const { return fUsesSrcInput; } |
370 | 382 |
371 typedef SkFlattenable INHERITED; | 383 typedef SkFlattenable INHERITED; |
372 int fInputCount; | 384 int fInputCount; |
373 SkImageFilter** fInputs; | 385 SkImageFilter** fInputs; |
374 bool fUsesSrcInput; | 386 bool fUsesSrcInput; |
375 CropRect fCropRect; | 387 CropRect fCropRect; |
376 uint32_t fUniqueID; // Globally unique | 388 uint32_t fUniqueID; // Globally unique |
377 }; | 389 }; |
378 | 390 |
379 /** | 391 /** |
380 * Helper to unflatten the common data, and return NULL if we fail. | 392 * Helper to unflatten the common data, and return NULL if we fail. |
381 */ | 393 */ |
382 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ | 394 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ |
383 Common localVar; \ | 395 Common localVar; \ |
384 do { \ | 396 do { \ |
385 if (!localVar.unflatten(buffer, expectedCount)) { \ | 397 if (!localVar.unflatten(buffer, expectedCount)) { \ |
386 return NULL; \ | 398 return NULL; \ |
387 } \ | 399 } \ |
388 } while (0) | 400 } while (0) |
389 | 401 |
390 #endif | 402 #endif |
OLD | NEW |