aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/gradients/SkGradientBitmapCache.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-08-21 10:50:25 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-21 10:50:25 -0700
commita6cac4ce3896669e1b5935def0a84b4456ec9777 (patch)
tree91edc56fb08438e184d7fdefce62dff627f3fbbb /src/effects/gradients/SkGradientBitmapCache.h
parent04617139f7f715bdc05a32a58e65e3c208bccff4 (diff)
rename gradients private BitmapCache to GradientBitmapCache
R=caryclark@google.com NOTREECHECKS=True Author: reed@google.com Review URL: https://codereview.chromium.org/474983005
Diffstat (limited to 'src/effects/gradients/SkGradientBitmapCache.h')
-rw-r--r--src/effects/gradients/SkGradientBitmapCache.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/effects/gradients/SkGradientBitmapCache.h b/src/effects/gradients/SkGradientBitmapCache.h
new file mode 100644
index 0000000000..009b9561a7
--- /dev/null
+++ b/src/effects/gradients/SkGradientBitmapCache.h
@@ -0,0 +1,49 @@
+
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#ifndef SkGradientBitmapCache_DEFINED
+#define SkGradientBitmapCache_DEFINED
+
+#include "SkBitmap.h"
+
+class SkGradientBitmapCache : SkNoncopyable {
+public:
+ SkGradientBitmapCache(int maxEntries);
+ ~SkGradientBitmapCache();
+
+ bool find(const void* buffer, size_t len, SkBitmap*) const;
+ void add(const void* buffer, size_t len, const SkBitmap&);
+
+private:
+ int fEntryCount;
+ const int fMaxEntries;
+
+ struct Entry;
+ mutable Entry* fHead;
+ mutable Entry* fTail;
+
+ inline Entry* detach(Entry*) const;
+ inline void attachToHead(Entry*) const;
+
+#ifdef SK_DEBUG
+ void validate() const;
+#else
+ void validate() const {}
+#endif
+
+ class AutoValidate : SkNoncopyable {
+ public:
+ AutoValidate(const SkGradientBitmapCache* bc) : fBC(bc) { bc->validate(); }
+ ~AutoValidate() { fBC->validate(); }
+ private:
+ const SkGradientBitmapCache* fBC;
+ };
+};
+
+#endif