| 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 24 matching lines...) Expand all Loading... |
| 35 // This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap
generation ID) to | 35 // This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap
generation ID) to |
| 36 // (result, offset). | 36 // (result, offset). |
| 37 class Cache : public SkRefCnt { | 37 class Cache : public SkRefCnt { |
| 38 public: | 38 public: |
| 39 struct Key; | 39 struct Key; |
| 40 virtual ~Cache() {} | 40 virtual ~Cache() {} |
| 41 static Cache* Create(size_t maxBytes); | 41 static Cache* Create(size_t maxBytes); |
| 42 static Cache* Get(); | 42 static Cache* Get(); |
| 43 virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) con
st = 0; | 43 virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) con
st = 0; |
| 44 virtual void set(const Key& key, const SkBitmap& result, const SkIPoint&
offset) = 0; | 44 virtual void set(const Key& key, const SkBitmap& result, const SkIPoint&
offset) = 0; |
| 45 virtual void purge() {} |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 class Context { | 48 class Context { |
| 48 public: | 49 public: |
| 49 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) : | 50 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) : |
| 50 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) { | 51 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) { |
| 51 } | 52 } |
| 52 const SkMatrix& ctm() const { return fCTM; } | 53 const SkMatrix& ctm() const { return fCTM; } |
| 53 const SkIRect& clipBounds() const { return fClipBounds; } | 54 const SkIRect& clipBounds() const { return fClipBounds; } |
| 54 Cache* cache() const { return fCache; } | 55 Cache* cache() const { return fCache; } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 368 |
| 368 /** | 369 /** |
| 369 * Returns true if this filter can cause transparent black pixels to become | 370 * Returns true if this filter can cause transparent black pixels to become |
| 370 * visible (ie., alpha > 0). The default implementation returns false. This | 371 * visible (ie., alpha > 0). The default implementation returns false. This |
| 371 * function is non-recursive, i.e., only queries this filter and not its | 372 * function is non-recursive, i.e., only queries this filter and not its |
| 372 * inputs. | 373 * inputs. |
| 373 */ | 374 */ |
| 374 virtual bool affectsTransparentBlack() const; | 375 virtual bool affectsTransparentBlack() const; |
| 375 | 376 |
| 376 private: | 377 private: |
| 378 friend class SkGraphics; |
| 379 static void PurgeCache(); |
| 380 |
| 377 bool usesSrcInput() const { return fUsesSrcInput; } | 381 bool usesSrcInput() const { return fUsesSrcInput; } |
| 378 | 382 |
| 379 typedef SkFlattenable INHERITED; | 383 typedef SkFlattenable INHERITED; |
| 380 int fInputCount; | 384 int fInputCount; |
| 381 SkImageFilter** fInputs; | 385 SkImageFilter** fInputs; |
| 382 bool fUsesSrcInput; | 386 bool fUsesSrcInput; |
| 383 CropRect fCropRect; | 387 CropRect fCropRect; |
| 384 uint32_t fUniqueID; // Globally unique | 388 uint32_t fUniqueID; // Globally unique |
| 385 }; | 389 }; |
| 386 | 390 |
| 387 /** | 391 /** |
| 388 * 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. |
| 389 */ | 393 */ |
| 390 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ | 394 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ |
| 391 Common localVar; \ | 395 Common localVar; \ |
| 392 do { \ | 396 do { \ |
| 393 if (!localVar.unflatten(buffer, expectedCount)) { \ | 397 if (!localVar.unflatten(buffer, expectedCount)) { \ |
| 394 return NULL; \ | 398 return NULL; \ |
| 395 } \ | 399 } \ |
| 396 } while (0) | 400 } while (0) |
| 397 | 401 |
| 398 #endif | 402 #endif |
| OLD | NEW |