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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge) | 81 explicit CropRect(const SkRect& rect, uint32_t flags = kHasAll_CropEdge) |
82 : fRect(rect), fFlags(flags) {} | 82 : fRect(rect), fFlags(flags) {} |
83 uint32_t flags() const { return fFlags; } | 83 uint32_t flags() const { return fFlags; } |
84 const SkRect& rect() const { return fRect; } | 84 const SkRect& rect() const { return fRect; } |
85 #ifndef SK_IGNORE_TO_STRING | 85 #ifndef SK_IGNORE_TO_STRING |
86 void toString(SkString* str) const; | 86 void toString(SkString* str) const; |
87 #endif | 87 #endif |
88 | 88 |
89 /** | 89 /** |
90 * Apply this cropRect to the imageBounds. If a given edge of the cropR
ect is not | 90 * Apply this cropRect to the imageBounds. If a given edge of the cropR
ect is not |
91 * set, then the corresponding edge from imageBounds will be used. | 91 * set, then the corresponding edge from imageBounds will be used. If "
embiggen" |
| 92 * is true, the crop rect is allowed to enlarge the size of the rect, o
therwise |
| 93 * it may only reduce the rect. Filters that can affect transparent bla
ck should |
| 94 * pass "true", while all other filters should pass "false". |
92 * | 95 * |
93 * Note: imageBounds is in "device" space, as the output cropped rectan
gle will be, | 96 * Note: imageBounds is in "device" space, as the output cropped rectan
gle will be, |
94 * so the matrix is ignored for those. It is only applied the croprect'
s bounds. | 97 * so the matrix is ignored for those. It is only applied the croprect'
s bounds. |
95 */ | 98 */ |
96 void applyTo(const SkIRect& imageBounds, const SkMatrix&, SkIRect* cropp
ed) const; | 99 void applyTo(const SkIRect& imageBounds, const SkMatrix&, bool embiggen, |
| 100 SkIRect* cropped) const; |
97 | 101 |
98 private: | 102 private: |
99 SkRect fRect; | 103 SkRect fRect; |
100 uint32_t fFlags; | 104 uint32_t fFlags; |
101 }; | 105 }; |
102 | 106 |
103 enum TileUsage { | 107 enum TileUsage { |
104 kPossible_TileUsage, //!< the created device may be drawn tiled | 108 kPossible_TileUsage, //!< the created device may be drawn tiled |
105 kNever_TileUsage, //!< the created device will never be drawn tile
d | 109 kNever_TileUsage, //!< the created device will never be drawn tile
d |
106 }; | 110 }; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 * drawn in the correct location.) | 246 * drawn in the correct location.) |
243 */ | 247 */ |
244 bool cropRectIsSet() const { return fCropRect.flags() != 0x0; } | 248 bool cropRectIsSet() const { return fCropRect.flags() != 0x0; } |
245 | 249 |
246 CropRect getCropRect() const { return fCropRect; } | 250 CropRect getCropRect() const { return fCropRect; } |
247 | 251 |
248 // Default impl returns union of all input bounds. | 252 // Default impl returns union of all input bounds. |
249 virtual SkRect computeFastBounds(const SkRect&) const; | 253 virtual SkRect computeFastBounds(const SkRect&) const; |
250 | 254 |
251 // Can this filter DAG compute the resulting bounds of an object-space recta
ngle? | 255 // Can this filter DAG compute the resulting bounds of an object-space recta
ngle? |
252 virtual bool canComputeFastBounds() const; | 256 bool canComputeFastBounds() const; |
253 | 257 |
254 /** | 258 /** |
255 * If this filter can be represented by another filter + a localMatrix, ret
urn that filter, | 259 * If this filter can be represented by another filter + a localMatrix, ret
urn that filter, |
256 * else return null. | 260 * else return null. |
257 */ | 261 */ |
258 sk_sp<SkImageFilter> makeWithLocalMatrix(const SkMatrix&) const; | 262 sk_sp<SkImageFilter> makeWithLocalMatrix(const SkMatrix&) const; |
259 | 263 |
260 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR | 264 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR |
261 SkImageFilter* newWithLocalMatrix(const SkMatrix& matrix) const { | 265 SkImageFilter* newWithLocalMatrix(const SkMatrix& matrix) const { |
262 return this->makeWithLocalMatrix(matrix).release(); | 266 return this->makeWithLocalMatrix(matrix).release(); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 Context mapContext(const Context& ctx) const; | 463 Context mapContext(const Context& ctx) const; |
460 | 464 |
461 private: | 465 private: |
462 friend class SkGraphics; | 466 friend class SkGraphics; |
463 static void PurgeCache(); | 467 static void PurgeCache(); |
464 | 468 |
465 bool filterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, | 469 bool filterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, |
466 SkBitmap* result, SkIPoint* offset) const; | 470 SkBitmap* result, SkIPoint* offset) const; |
467 | 471 |
468 bool usesSrcInput() const { return fUsesSrcInput; } | 472 bool usesSrcInput() const { return fUsesSrcInput; } |
| 473 virtual bool affectsTransparentBlack() const { return false; } |
469 | 474 |
470 typedef SkFlattenable INHERITED; | 475 typedef SkFlattenable INHERITED; |
471 int fInputCount; | 476 int fInputCount; |
472 SkImageFilter** fInputs; | 477 SkImageFilter** fInputs; |
473 bool fUsesSrcInput; | 478 bool fUsesSrcInput; |
474 CropRect fCropRect; | 479 CropRect fCropRect; |
475 uint32_t fUniqueID; // Globally unique | 480 uint32_t fUniqueID; // Globally unique |
476 mutable SkTArray<Cache::Key> fCacheKeys; | 481 mutable SkTArray<Cache::Key> fCacheKeys; |
477 mutable SkMutex fMutex; | 482 mutable SkMutex fMutex; |
478 }; | 483 }; |
479 | 484 |
480 /** | 485 /** |
481 * Helper to unflatten the common data, and return NULL if we fail. | 486 * Helper to unflatten the common data, and return NULL if we fail. |
482 */ | 487 */ |
483 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ | 488 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ |
484 Common localVar; \ | 489 Common localVar; \ |
485 do { \ | 490 do { \ |
486 if (!localVar.unflatten(buffer, expectedCount)) { \ | 491 if (!localVar.unflatten(buffer, expectedCount)) { \ |
487 return NULL; \ | 492 return NULL; \ |
488 } \ | 493 } \ |
489 } while (0) | 494 } while (0) |
490 | 495 |
491 #endif | 496 #endif |
OLD | NEW |