reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
reed | 011f39a | 2014-08-28 13:35:23 -0700 | [diff] [blame] | 8 | #ifndef SkResourceCache_DEFINED |
| 9 | #define SkResourceCache_DEFINED |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkBitmap.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "include/private/SkTDArray.h" |
Ben Wagner | 21bca28 | 2019-05-15 10:15:52 -0400 | [diff] [blame] | 13 | #include "src/core/SkMessageBus.h" |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 14 | |
reed | 9d93c2e | 2014-10-08 05:17:12 -0700 | [diff] [blame] | 15 | class SkCachedData; |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 16 | class SkDiscardableMemory; |
ssid | 33c594c | 2015-08-27 09:23:54 -0700 | [diff] [blame] | 17 | class SkTraceMemoryDump; |
reed@google.com | d94697c | 2013-07-24 14:31:33 +0000 | [diff] [blame] | 18 | |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 19 | /** |
| 20 | * Cache object for bitmaps (with possible scale in X Y as part of the key). |
| 21 | * |
| 22 | * Multiple caches can be instantiated, but each instance is not implicitly |
| 23 | * thread-safe, so if a given instance is to be shared across threads, the |
| 24 | * caller must manage the access itself (e.g. via a mutex). |
| 25 | * |
| 26 | * As a convenience, a global instance is also defined, which can be safely |
| 27 | * access across threads via the static methods (e.g. FindAndLock, etc.). |
| 28 | */ |
reed | 011f39a | 2014-08-28 13:35:23 -0700 | [diff] [blame] | 29 | class SkResourceCache { |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 30 | public: |
reed | 4f987e9 | 2014-08-20 13:41:56 -0700 | [diff] [blame] | 31 | struct Key { |
bungeman | 70bb808 | 2016-02-17 10:13:49 -0800 | [diff] [blame] | 32 | /** Key subclasses must call this after their own fields and data are initialized. |
| 33 | * All fields and data must be tightly packed. |
| 34 | * @param nameSpace must be unique per Key subclass. |
| 35 | * @param sharedID == 0 means ignore this field, does not support group purging. |
| 36 | * @param dataSize is size of fields and data of the subclass, must be a multiple of 4. |
| 37 | */ |
| 38 | void init(void* nameSpace, uint64_t sharedID, size_t dataSize); |
reed | 4f987e9 | 2014-08-20 13:41:56 -0700 | [diff] [blame] | 39 | |
bungeman | 70bb808 | 2016-02-17 10:13:49 -0800 | [diff] [blame] | 40 | /** Returns the size of this key. */ |
| 41 | size_t size() const { |
| 42 | return fCount32 << 2; |
| 43 | } |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 44 | |
| 45 | void* getNamespace() const { return fNamespace; } |
| 46 | uint64_t getSharedID() const { return ((uint64_t)fSharedID_hi << 32) | fSharedID_lo; } |
reed | 4f987e9 | 2014-08-20 13:41:56 -0700 | [diff] [blame] | 47 | |
| 48 | // This is only valid after having called init(). |
| 49 | uint32_t hash() const { return fHash; } |
| 50 | |
| 51 | bool operator==(const Key& other) const { |
| 52 | const uint32_t* a = this->as32(); |
| 53 | const uint32_t* b = other.as32(); |
mtklein | 484bbe5 | 2014-10-21 10:55:22 -0700 | [diff] [blame] | 54 | for (int i = 0; i < fCount32; ++i) { // (This checks fCount == other.fCount first.) |
reed | 4f987e9 | 2014-08-20 13:41:56 -0700 | [diff] [blame] | 55 | if (a[i] != b[i]) { |
| 56 | return false; |
| 57 | } |
| 58 | } |
| 59 | return true; |
| 60 | } |
| 61 | |
reed | 4f987e9 | 2014-08-20 13:41:56 -0700 | [diff] [blame] | 62 | private: |
fmalita | 171e5b7 | 2014-10-22 11:20:40 -0700 | [diff] [blame] | 63 | int32_t fCount32; // local + user contents count32 |
reed | 4f987e9 | 2014-08-20 13:41:56 -0700 | [diff] [blame] | 64 | uint32_t fHash; |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 65 | // split uint64_t into hi and lo so we don't force ourselves to pad on 32bit machines. |
| 66 | uint32_t fSharedID_lo; |
| 67 | uint32_t fSharedID_hi; |
fmalita | 171e5b7 | 2014-10-22 11:20:40 -0700 | [diff] [blame] | 68 | void* fNamespace; // A unique namespace tag. This is hashed. |
reed | 4f987e9 | 2014-08-20 13:41:56 -0700 | [diff] [blame] | 69 | /* uint32_t fContents32[] */ |
| 70 | |
| 71 | const uint32_t* as32() const { return (const uint32_t*)this; } |
reed | 4f987e9 | 2014-08-20 13:41:56 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
reed | 680fb9e | 2014-08-26 09:08:04 -0700 | [diff] [blame] | 74 | struct Rec { |
reed | 011f39a | 2014-08-28 13:35:23 -0700 | [diff] [blame] | 75 | typedef SkResourceCache::Key Key; |
reed | 680fb9e | 2014-08-26 09:08:04 -0700 | [diff] [blame] | 76 | |
reed | c90e014 | 2014-09-15 11:39:44 -0700 | [diff] [blame] | 77 | Rec() {} |
reed | 680fb9e | 2014-08-26 09:08:04 -0700 | [diff] [blame] | 78 | virtual ~Rec() {} |
| 79 | |
| 80 | uint32_t getHash() const { return this->getKey().hash(); } |
piotaixr | 8159146 | 2014-09-02 11:27:11 -0700 | [diff] [blame] | 81 | |
reed | 680fb9e | 2014-08-26 09:08:04 -0700 | [diff] [blame] | 82 | virtual const Key& getKey() const = 0; |
| 83 | virtual size_t bytesUsed() const = 0; |
piotaixr | 8159146 | 2014-09-02 11:27:11 -0700 | [diff] [blame] | 84 | |
Mike Reed | 7a542c5 | 2017-04-11 12:03:44 -0400 | [diff] [blame] | 85 | // Called if the cache needs to purge/remove/delete the Rec. Default returns true. |
| 86 | // Subclass may return false if there are outstanding references to it (e.g. bitmaps). |
| 87 | // Will only be deleted/removed-from-the-cache when this returns true. |
| 88 | virtual bool canBePurged() { return true; } |
| 89 | |
| 90 | // A rec is first created/initialized, and then added to the cache. As part of the add(), |
| 91 | // the cache will callback into the rec with postAddInstall, passing in whatever payload |
| 92 | // was passed to add/Add. |
| 93 | // |
| 94 | // This late-install callback exists because the process of add-ing might end up deleting |
| 95 | // the new rec (if an existing rec in the cache has the same key and cannot be purged). |
| 96 | // If the new rec will be deleted during add, the pre-existing one (with the same key) |
| 97 | // will have postAddInstall() called on it instead, so that either way an "install" will |
| 98 | // happen during the add. |
| 99 | virtual void postAddInstall(void*) {} |
| 100 | |
reed | 216b643 | 2015-08-19 12:25:40 -0700 | [diff] [blame] | 101 | // for memory usage diagnostics |
| 102 | virtual const char* getCategory() const = 0; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 103 | virtual SkDiscardableMemory* diagnostic_only_getDiscardable() const { return nullptr; } |
reed | 216b643 | 2015-08-19 12:25:40 -0700 | [diff] [blame] | 104 | |
reed | 680fb9e | 2014-08-26 09:08:04 -0700 | [diff] [blame] | 105 | private: |
| 106 | Rec* fNext; |
| 107 | Rec* fPrev; |
piotaixr | 8159146 | 2014-09-02 11:27:11 -0700 | [diff] [blame] | 108 | |
reed | 011f39a | 2014-08-28 13:35:23 -0700 | [diff] [blame] | 109 | friend class SkResourceCache; |
reed | 680fb9e | 2014-08-26 09:08:04 -0700 | [diff] [blame] | 110 | }; |
| 111 | |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 112 | // Used with SkMessageBus |
| 113 | struct PurgeSharedIDMessage { |
| 114 | PurgeSharedIDMessage(uint64_t sharedID) : fSharedID(sharedID) {} |
Chris Dalton | 9a986cf | 2018-10-18 15:27:59 -0600 | [diff] [blame] | 115 | uint64_t fSharedID; |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 116 | }; |
| 117 | |
reed | 680fb9e | 2014-08-26 09:08:04 -0700 | [diff] [blame] | 118 | typedef const Rec* ID; |
| 119 | |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 120 | /** |
reed | c90e014 | 2014-09-15 11:39:44 -0700 | [diff] [blame] | 121 | * Callback function for find(). If called, the cache will have found a match for the |
| 122 | * specified Key, and will pass in the corresponding Rec, along with a caller-specified |
| 123 | * context. The function can read the data in Rec, and copy whatever it likes into context |
| 124 | * (casting context to whatever it really is). |
| 125 | * |
| 126 | * The return value determines what the cache will do with the Rec. If the function returns |
| 127 | * true, then the Rec is considered "valid". If false is returned, the Rec will be considered |
| 128 | * "stale" and will be purged from the cache. |
| 129 | */ |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 130 | typedef bool (*FindVisitor)(const Rec&, void* context); |
reed | c90e014 | 2014-09-15 11:39:44 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 133 | * Returns a locked/pinned SkDiscardableMemory instance for the specified |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 134 | * number of bytes, or nullptr on failure. |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 135 | */ |
| 136 | typedef SkDiscardableMemory* (*DiscardableFactory)(size_t bytes); |
| 137 | |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 138 | /* |
| 139 | * The following static methods are thread-safe wrappers around a global |
| 140 | * instance of this cache. |
| 141 | */ |
| 142 | |
reed | c90e014 | 2014-09-15 11:39:44 -0700 | [diff] [blame] | 143 | /** |
| 144 | * Returns true if the visitor was called on a matching Key, and the visitor returned true. |
| 145 | * |
| 146 | * Find() will search the cache for the specified Key. If no match is found, return false and |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 147 | * do not call the FindVisitor. If a match is found, return whatever the visitor returns. |
reed | c90e014 | 2014-09-15 11:39:44 -0700 | [diff] [blame] | 148 | * Its return value is interpreted to mean: |
| 149 | * true : Rec is valid |
| 150 | * false : Rec is "stale" -- the cache will purge it. |
| 151 | */ |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 152 | static bool Find(const Key& key, FindVisitor, void* context); |
Mike Reed | 7a542c5 | 2017-04-11 12:03:44 -0400 | [diff] [blame] | 153 | static void Add(Rec*, void* payload = nullptr); |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 154 | |
reed | 216b643 | 2015-08-19 12:25:40 -0700 | [diff] [blame] | 155 | typedef void (*Visitor)(const Rec&, void* context); |
| 156 | // Call the visitor for every Rec in the cache. |
| 157 | static void VisitAll(Visitor, void* context); |
| 158 | |
halcanary | 805ef15 | 2014-07-17 06:58:01 -0700 | [diff] [blame] | 159 | static size_t GetTotalBytesUsed(); |
| 160 | static size_t GetTotalByteLimit(); |
| 161 | static size_t SetTotalByteLimit(size_t newLimit); |
| 162 | |
| 163 | static size_t SetSingleAllocationByteLimit(size_t); |
| 164 | static size_t GetSingleAllocationByteLimit(); |
reed | 1d9e80f | 2015-01-26 11:24:37 -0800 | [diff] [blame] | 165 | static size_t GetEffectiveSingleAllocationByteLimit(); |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 166 | |
reed | 56b00d9 | 2014-09-11 12:22:34 -0700 | [diff] [blame] | 167 | static void PurgeAll(); |
| 168 | |
reed | 216b643 | 2015-08-19 12:25:40 -0700 | [diff] [blame] | 169 | static void TestDumpMemoryStatistics(); |
| 170 | |
ssid | 33c594c | 2015-08-27 09:23:54 -0700 | [diff] [blame] | 171 | /** Dump memory usage statistics of every Rec in the cache using the |
| 172 | SkTraceMemoryDump interface. |
| 173 | */ |
| 174 | static void DumpMemoryStatistics(SkTraceMemoryDump* dump); |
| 175 | |
piotaixr | 8159146 | 2014-09-02 11:27:11 -0700 | [diff] [blame] | 176 | /** |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 177 | * Returns the DiscardableFactory used by the global cache, or nullptr. |
reed | 30ad530 | 2014-09-16 10:39:55 -0700 | [diff] [blame] | 178 | */ |
| 179 | static DiscardableFactory GetDiscardableFactory(); |
| 180 | |
qiankun.miao | d9aac34 | 2014-10-23 07:58:17 -0700 | [diff] [blame] | 181 | static SkCachedData* NewCachedData(size_t bytes); |
| 182 | |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 183 | static void PostPurgeSharedID(uint64_t sharedID); |
| 184 | |
reed@google.com | fa7fd80 | 2013-12-12 21:37:25 +0000 | [diff] [blame] | 185 | /** |
| 186 | * Call SkDebugf() with diagnostic information about the state of the cache |
| 187 | */ |
| 188 | static void Dump(); |
| 189 | |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 190 | /////////////////////////////////////////////////////////////////////////// |
| 191 | |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 192 | /** |
| 193 | * Construct the cache to call DiscardableFactory when it |
| 194 | * allocates memory for the pixels. In this mode, the cache has |
halcanary | 805ef15 | 2014-07-17 06:58:01 -0700 | [diff] [blame] | 195 | * not explicit budget, and so methods like getTotalBytesUsed() |
| 196 | * and getTotalByteLimit() will return 0, and setTotalByteLimit |
| 197 | * will ignore its argument and return 0. |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 198 | */ |
reed | 011f39a | 2014-08-28 13:35:23 -0700 | [diff] [blame] | 199 | SkResourceCache(DiscardableFactory); |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 200 | |
| 201 | /** |
| 202 | * Construct the cache, allocating memory with malloc, and respect the |
| 203 | * byteLimit, purging automatically when a new image is added to the cache |
| 204 | * that pushes the total bytesUsed over the limit. Note: The limit can be |
halcanary | 805ef15 | 2014-07-17 06:58:01 -0700 | [diff] [blame] | 205 | * changed at runtime with setTotalByteLimit. |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 206 | */ |
reed | 011f39a | 2014-08-28 13:35:23 -0700 | [diff] [blame] | 207 | explicit SkResourceCache(size_t byteLimit); |
| 208 | ~SkResourceCache(); |
skia.committer@gmail.com | 7f1af50 | 2013-07-24 07:01:12 +0000 | [diff] [blame] | 209 | |
reed | 595aa05 | 2014-09-15 10:15:18 -0700 | [diff] [blame] | 210 | /** |
reed | c90e014 | 2014-09-15 11:39:44 -0700 | [diff] [blame] | 211 | * Returns true if the visitor was called on a matching Key, and the visitor returned true. |
| 212 | * |
| 213 | * find() will search the cache for the specified Key. If no match is found, return false and |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 214 | * do not call the FindVisitor. If a match is found, return whatever the visitor returns. |
reed | c90e014 | 2014-09-15 11:39:44 -0700 | [diff] [blame] | 215 | * Its return value is interpreted to mean: |
| 216 | * true : Rec is valid |
| 217 | * false : Rec is "stale" -- the cache will purge it. |
reed | 595aa05 | 2014-09-15 10:15:18 -0700 | [diff] [blame] | 218 | */ |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 219 | bool find(const Key&, FindVisitor, void* context); |
Mike Reed | 7a542c5 | 2017-04-11 12:03:44 -0400 | [diff] [blame] | 220 | void add(Rec*, void* payload = nullptr); |
reed | 216b643 | 2015-08-19 12:25:40 -0700 | [diff] [blame] | 221 | void visitAll(Visitor, void* context); |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 222 | |
halcanary | 805ef15 | 2014-07-17 06:58:01 -0700 | [diff] [blame] | 223 | size_t getTotalBytesUsed() const { return fTotalBytesUsed; } |
| 224 | size_t getTotalByteLimit() const { return fTotalByteLimit; } |
skia.committer@gmail.com | 7f1af50 | 2013-07-24 07:01:12 +0000 | [diff] [blame] | 225 | |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 226 | /** |
halcanary | 805ef15 | 2014-07-17 06:58:01 -0700 | [diff] [blame] | 227 | * This is respected by SkBitmapProcState::possiblyScaleImage. |
| 228 | * 0 is no maximum at all; this is the default. |
| 229 | * setSingleAllocationByteLimit() returns the previous value. |
| 230 | */ |
| 231 | size_t setSingleAllocationByteLimit(size_t maximumAllocationSize); |
| 232 | size_t getSingleAllocationByteLimit() const; |
reed | 1d9e80f | 2015-01-26 11:24:37 -0800 | [diff] [blame] | 233 | // returns the logical single allocation size (pinning against the budget when the cache |
| 234 | // is not backed by discardable memory. |
| 235 | size_t getEffectiveSingleAllocationByteLimit() const; |
| 236 | |
halcanary | 805ef15 | 2014-07-17 06:58:01 -0700 | [diff] [blame] | 237 | /** |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 238 | * Set the maximum number of bytes available to this cache. If the current |
| 239 | * cache exceeds this new value, it will be purged to try to fit within |
| 240 | * this new limit. |
| 241 | */ |
halcanary | 805ef15 | 2014-07-17 06:58:01 -0700 | [diff] [blame] | 242 | size_t setTotalByteLimit(size_t newLimit); |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 243 | |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 244 | void purgeSharedID(uint64_t sharedID); |
| 245 | |
reed | 56b00d9 | 2014-09-11 12:22:34 -0700 | [diff] [blame] | 246 | void purgeAll() { |
| 247 | this->purgeAsNeeded(true); |
| 248 | } |
| 249 | |
reed | 30ad530 | 2014-09-16 10:39:55 -0700 | [diff] [blame] | 250 | DiscardableFactory discardableFactory() const { return fDiscardableFactory; } |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 251 | |
reed | 9d93c2e | 2014-10-08 05:17:12 -0700 | [diff] [blame] | 252 | SkCachedData* newCachedData(size_t bytes); |
| 253 | |
reed@google.com | fa7fd80 | 2013-12-12 21:37:25 +0000 | [diff] [blame] | 254 | /** |
| 255 | * Call SkDebugf() with diagnostic information about the state of the cache |
| 256 | */ |
| 257 | void dump() const; |
| 258 | |
reed@google.com | 5d1e558 | 2013-07-25 14:36:15 +0000 | [diff] [blame] | 259 | private: |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 260 | Rec* fHead; |
| 261 | Rec* fTail; |
| 262 | |
reed@google.com | 5d1e558 | 2013-07-25 14:36:15 +0000 | [diff] [blame] | 263 | class Hash; |
| 264 | Hash* fHash; |
| 265 | |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 266 | DiscardableFactory fDiscardableFactory; |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 267 | |
halcanary | 805ef15 | 2014-07-17 06:58:01 -0700 | [diff] [blame] | 268 | size_t fTotalBytesUsed; |
| 269 | size_t fTotalByteLimit; |
| 270 | size_t fSingleAllocationByteLimit; |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 271 | int fCount; |
| 272 | |
reed | 7eeba25 | 2015-02-24 13:54:23 -0800 | [diff] [blame] | 273 | SkMessageBus<PurgeSharedIDMessage>::Inbox fPurgeSharedIDInbox; |
| 274 | |
| 275 | void checkMessages(); |
reed | 56b00d9 | 2014-09-11 12:22:34 -0700 | [diff] [blame] | 276 | void purgeAsNeeded(bool forcePurge = false); |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 277 | |
| 278 | // linklist management |
| 279 | void moveToHead(Rec*); |
| 280 | void addToHead(Rec*); |
mtklein | 18300a3 | 2016-03-16 13:53:35 -0700 | [diff] [blame] | 281 | void release(Rec*); |
reed | c90e014 | 2014-09-15 11:39:44 -0700 | [diff] [blame] | 282 | void remove(Rec*); |
reed@google.com | e4eb122 | 2013-12-09 22:29:30 +0000 | [diff] [blame] | 283 | |
| 284 | void init(); // called by constructors |
| 285 | |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 286 | #ifdef SK_DEBUG |
| 287 | void validate() const; |
| 288 | #else |
| 289 | void validate() const {} |
| 290 | #endif |
| 291 | }; |
reed@google.com | 602a1d7 | 2013-07-23 19:13:54 +0000 | [diff] [blame] | 292 | #endif |