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

Side by Side Diff: src/core/SkImageFilterCache.h

Issue 1919063002: Image filters: de-nest SkImageFilter::Cache and Cache::Key. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix copyright Created 4 years, 7 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 | « src/core/SkImageFilter.cpp ('k') | src/core/SkImageFilterCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkImageFilterCache_DEFINED
9 #define SkImageFilterCache_DEFINED
10
11 #include "SkMatrix.h"
12 #include "SkRefCnt.h"
13
14 struct SkIPoint;
15 class SkSpecialImage;
16
17 struct SkImageFilterCacheKey {
18 SkImageFilterCacheKey(const uint32_t uniqueID, const SkMatrix& matrix,
19 const SkIRect& clipBounds, uint32_t srcGenID, const SkIRect& srcSubset)
20 : fUniqueID(uniqueID)
21 , fMatrix(matrix)
22 , fClipBounds(clipBounds)
23 , fSrcGenID(srcGenID)
24 , fSrcSubset(srcSubset) {
25 // Assert that Key is tightly-packed, since it is hashed.
26 static_assert(sizeof(SkImageFilterCacheKey) == sizeof(uint32_t) + sizeof (SkMatrix) +
27 sizeof(SkIRect) + sizeof(uint32_t) + 4 * si zeof(int32_t),
28 "image_filter_key_tight_packing");
29 fMatrix.getType(); // force initialization of type, so hashes match
30 }
31
32 uint32_t fUniqueID;
33 SkMatrix fMatrix;
34 SkIRect fClipBounds;
35 uint32_t fSrcGenID;
36 SkIRect fSrcSubset;
37
38 bool operator==(const SkImageFilterCacheKey& other) const {
39 return fUniqueID == other.fUniqueID &&
40 fMatrix == other.fMatrix &&
41 fClipBounds == other.fClipBounds &&
42 fSrcGenID == other.fSrcGenID &&
43 fSrcSubset == other.fSrcSubset;
44 }
45 };
46
47 // This cache maps from (filter's unique ID + CTM + clipBounds + src bitmap gene ration ID) to
48 // (result, offset).
49 class SkImageFilterCache : public SkRefCnt {
50 public:
51 virtual ~SkImageFilterCache() {}
52 static SkImageFilterCache* Create(size_t maxBytes);
53 static SkImageFilterCache* Get();
54 virtual SkSpecialImage* get(const SkImageFilterCacheKey& key, SkIPoint* offs et) const = 0;
55 virtual void set(const SkImageFilterCacheKey& key, SkSpecialImage* image,
56 const SkIPoint& offset) = 0;
57 virtual void purge() = 0;
58 virtual void purgeByKeys(const SkImageFilterCacheKey[], int) = 0;
59 SkDEBUGCODE(virtual int count() const = 0;)
60 };
61
62 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | src/core/SkImageFilterCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698