Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: include/core/SkImageFilter.h

Issue 1370323002: Implement SkImageFilter::Cache with SkResourceCache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: build Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkImageFilter.cpp » ('j') | src/core/SkImageFilter.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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() {}
46 }; 45 };
47 46
48 class Context { 47 class Context {
49 public: 48 public:
50 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) : 49 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) :
51 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) { 50 fCTM(ctm), fClipBounds(clipBounds), fCache(cache) {
52 } 51 }
53 const SkMatrix& ctm() const { return fCTM; } 52 const SkMatrix& ctm() const { return fCTM; }
54 const SkIRect& clipBounds() const { return fClipBounds; } 53 const SkIRect& clipBounds() const { return fClipBounds; }
55 Cache* cache() const { return fCache; } 54 Cache* cache() const { return fCache; }
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 367
369 /** 368 /**
370 * Returns true if this filter can cause transparent black pixels to become 369 * Returns true if this filter can cause transparent black pixels to become
371 * visible (ie., alpha > 0). The default implementation returns false. This 370 * visible (ie., alpha > 0). The default implementation returns false. This
372 * function is non-recursive, i.e., only queries this filter and not its 371 * function is non-recursive, i.e., only queries this filter and not its
373 * inputs. 372 * inputs.
374 */ 373 */
375 virtual bool affectsTransparentBlack() const; 374 virtual bool affectsTransparentBlack() const;
376 375
377 private: 376 private:
378 friend class SkGraphics;
379 static void PurgeCache();
380
381 bool usesSrcInput() const { return fUsesSrcInput; } 377 bool usesSrcInput() const { return fUsesSrcInput; }
382 378
383 typedef SkFlattenable INHERITED; 379 typedef SkFlattenable INHERITED;
384 int fInputCount; 380 int fInputCount;
385 SkImageFilter** fInputs; 381 SkImageFilter** fInputs;
386 bool fUsesSrcInput; 382 bool fUsesSrcInput;
387 CropRect fCropRect; 383 CropRect fCropRect;
388 uint32_t fUniqueID; // Globally unique 384 uint32_t fUniqueID; // Globally unique
389 }; 385 };
390 386
391 /** 387 /**
392 * Helper to unflatten the common data, and return NULL if we fail. 388 * Helper to unflatten the common data, and return NULL if we fail.
393 */ 389 */
394 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ 390 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \
395 Common localVar; \ 391 Common localVar; \
396 do { \ 392 do { \
397 if (!localVar.unflatten(buffer, expectedCount)) { \ 393 if (!localVar.unflatten(buffer, expectedCount)) { \
398 return NULL; \ 394 return NULL; \
399 } \ 395 } \
400 } while (0) 396 } while (0)
401 397
402 #endif 398 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkImageFilter.cpp » ('j') | src/core/SkImageFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698