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

Unified Diff: src/core/SkMaskCache.h

Issue 592843003: Add SkCachedData and use it for SkMipMap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use explicit runtime flag to recognize Discardable, to allow clients to subclass Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: src/core/SkMaskCache.h
diff --git a/src/core/SkMaskCache.h b/src/core/SkMaskCache.h
new file mode 100644
index 0000000000000000000000000000000000000000..e7e096c2b4f797bb4bebb67e4c5b4b2936c9aef4
--- /dev/null
+++ b/src/core/SkMaskCache.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkMaskCache_DEFINED
+#define SkMaskCache_DEFINED
+
+#include "SkScalar.h"
+#include "SkMask.h"
+
+class SkCachedData;
+class SkDiscardableMemory;
+struct SkMask;
+class SkResourceCache;
+class SkRRect;
+
+class SkMaskCache {
+public:
+ static SkCachedData* NewCachedData(size_t size, SkResourceCache* localCache = NULL);
+
+ /**
+ * If a matching mask/pixel-data is found for the specified key, lock the pixel-data and
+ * return the mask and pixel-data. In the case the caller MUST call unlock() on the pixel-data
+ * when they are done using it, after which the pixel-data object will no longer be valid.
+ *
+ * If NULL is returned, the mask parameter is ignored.
+ */
+ static SkCachedData* FindAndLock(SkScalar sigma, const SkRect&,
+ SkMask* result, SkResourceCache* localCache = NULL);
+ static SkCachedData* FindAndLock(SkScalar sigma, const SkRect& r0, const SkRect& r1,
+ SkMask* result, SkResourceCache* localCache = NULL);
+ static SkCachedData* FindAndLock(SkScalar sigma, const SkRRect&,
+ SkMask* result, SkResourceCache* localCache = NULL);
+
+ /**
+ * Add a mask and its pixel-data to the cache. The pixel-data MUST be locked.
+ * Ownership of the pixel-data is transfered to the cache, so the caller must not reference
+ * it after this call.
+ */
+ static void Add(SkScalar sigma, const SkRect&,
+ const SkMask& result, SkCachedData* data, SkResourceCache* localCache = NULL);
+ static void Add(SkScalar sigma, const SkRect& r0, const SkRect& r1,
+ const SkMask& result, SkCachedData* data, SkResourceCache* localCache = NULL);
+ static void Add(SkScalar sigma, const SkRRect&,
+ const SkMask& result, SkCachedData* data, SkResourceCache* localCache = NULL);
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698