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

Unified Diff: src/lazy/SkCachingPixelRef.h

Issue 1359393004: Revert of remove unused SkCachingPixelRef (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « gyp/core.gypi ('k') | src/lazy/SkCachingPixelRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lazy/SkCachingPixelRef.h
diff --git a/src/lazy/SkCachingPixelRef.h b/src/lazy/SkCachingPixelRef.h
new file mode 100644
index 0000000000000000000000000000000000000000..1057441d5e4b1d7d5053c25f2696238687d33ee7
--- /dev/null
+++ b/src/lazy/SkCachingPixelRef.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkCachingPixelRef_DEFINED
+#define SkCachingPixelRef_DEFINED
+
+#include "SkBitmapCache.h"
+#include "SkImageInfo.h"
+#include "SkImageGenerator.h"
+#include "SkPixelRef.h"
+
+class SkColorTable;
+
+/**
+ * PixelRef which defers decoding until SkBitmap::lockPixels() is
+ * called. Caches the decoded images in the global
+ * SkScaledImageCache. When the pixels are unlocked, this cache may
+ * or be destroyed before the next lock. If so, onLockPixels will
+ * attempt to re-decode.
+ *
+ * Decoding is handled by the SkImageGenerator
+ */
+class SkCachingPixelRef : public SkPixelRef {
+public:
+
+ /**
+ * Takes ownership of SkImageGenerator. If this method fails for
+ * whatever reason, it will return false and immediatetely delete
+ * the generator. If it succeeds, it will modify destination
+ * bitmap.
+ *
+ * If Install fails or when the SkCachingPixelRef that is
+ * installed into destination is destroyed, it will call
+ * `delete` on the generator. Therefore, generator should be
+ * allocated with `new`.
+ */
+ static bool Install(SkImageGenerator* gen, SkBitmap* dst);
+
+protected:
+ virtual ~SkCachingPixelRef();
+ bool onNewLockPixels(LockRec*) override;
+ void onUnlockPixels() override;
+ bool onLockPixelsAreWritable() const override { return false; }
+
+ SkData* onRefEncodedData() override {
+ return fImageGenerator->refEncodedData();
+ }
+
+ bool onIsLazyGenerated() const override { return true; }
+
+private:
+ SkImageGenerator* const fImageGenerator;
+ bool fErrorInDecoding;
+ const size_t fRowBytes;
+
+ SkBitmap fLockedBitmap;
+
+ SkCachingPixelRef(const SkImageInfo&, SkImageGenerator*, size_t rowBytes);
+
+ typedef SkPixelRef INHERITED;
+};
+
+#endif // SkCachingPixelRef_DEFINED
« no previous file with comments | « gyp/core.gypi ('k') | src/lazy/SkCachingPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698