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

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

Issue 1709263002: Update SkImageFilter's cache to handle SkSpecialImages and add unit test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 4 years, 10 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
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
11 #include "../private/SkTArray.h" 11 #include "../private/SkTArray.h"
12 #include "../private/SkTemplates.h" 12 #include "../private/SkTemplates.h"
13 #include "../private/SkMutex.h" 13 #include "../private/SkMutex.h"
14 #include "SkFilterQuality.h" 14 #include "SkFilterQuality.h"
15 #include "SkFlattenable.h" 15 #include "SkFlattenable.h"
16 #include "SkMatrix.h" 16 #include "SkMatrix.h"
17 #include "SkRect.h" 17 #include "SkRect.h"
18 #include "SkSurfaceProps.h" 18 #include "SkSurfaceProps.h"
19 19
20 class GrFragmentProcessor; 20 class GrFragmentProcessor;
21 class GrTexture; 21 class GrTexture;
22 class SkBaseDevice; 22 class SkBaseDevice;
23 class SkBitmap; 23 class SkBitmap;
24 class SkColorFilter; 24 class SkColorFilter;
25 struct SkIPoint; 25 struct SkIPoint;
26 class SkSpecialImage;
26 27
27 /** 28 /**
28 * Base class for image filters. If one is installed in the paint, then 29 * Base class for image filters. If one is installed in the paint, then
29 * all drawing occurs as usual, but it is as if the drawing happened into an 30 * all drawing occurs as usual, but it is as if the drawing happened into an
30 * offscreen (before the xfermode is applied). This offscreen bitmap will 31 * offscreen (before the xfermode is applied). This offscreen bitmap will
31 * then be handed to the imagefilter, who in turn creates a new bitmap which 32 * then be handed to the imagefilter, who in turn creates a new bitmap which
32 * is what will finally be drawn to the device (using the original xfermode). 33 * is what will finally be drawn to the device (using the original xfermode).
33 */ 34 */
34 class SK_API SkImageFilter : public SkFlattenable { 35 class SK_API SkImageFilter : public SkFlattenable {
35 public: 36 public:
36 // This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap generation ID) to 37 // This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap generation ID) to
37 // (result, offset). 38 // (result, offset).
38 class Cache : public SkRefCnt { 39 class Cache : public SkRefCnt {
39 public: 40 public:
40 struct Key; 41 struct Key;
41 virtual ~Cache() {} 42 virtual ~Cache() {}
42 static Cache* Create(size_t maxBytes); 43 static Cache* Create(size_t maxBytes);
43 static Cache* Get(); 44 static Cache* Get();
44 virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) con st = 0; 45 virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) con st = 0;
46 virtual SkSpecialImage* get(const Key& key, SkIPoint* offset) const = 0;
45 virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& offset) = 0; 47 virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& offset) = 0;
48 virtual void set(const Key& key, SkSpecialImage* image, const SkIPoint& offset) = 0;
46 virtual void purge() {} 49 virtual void purge() {}
47 virtual void purgeByKeys(const Key[], int) {} 50 virtual void purgeByKeys(const Key[], int) {}
48 }; 51 };
49 52
50 class Context { 53 class Context {
51 public: 54 public:
52 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache) 55 Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache)
53 : fCTM(ctm) 56 : fCTM(ctm)
54 , fClipBounds(clipBounds) 57 , fClipBounds(clipBounds)
55 , fCache(cache) 58 , fCache(cache)
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 */ 464 */
462 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \ 465 #define SK_IMAGEFILTER_UNFLATTEN_COMMON(localVar, expectedCount) \
463 Common localVar; \ 466 Common localVar; \
464 do { \ 467 do { \
465 if (!localVar.unflatten(buffer, expectedCount)) { \ 468 if (!localVar.unflatten(buffer, expectedCount)) { \
466 return NULL; \ 469 return NULL; \
467 } \ 470 } \
468 } while (0) 471 } while (0)
469 472
470 #endif 473 #endif
OLDNEW
« no previous file with comments | « gyp/core.gypi ('k') | src/core/SkImageFilter.cpp » ('j') | tests/ImageFilterCacheTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698