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

Unified Diff: src/lazy/SkCachingPixelRef.h

Issue 54203006: Break up SkLazyPixelRef functionally into class hierarchy. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove SkCachingPixelRef::fCache Created 7 years, 1 month 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 | « src/core/SkBitmap.cpp ('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..5d54ab7bb6677db4d80bf8b2f8abf69aae760692
--- /dev/null
+++ b/src/lazy/SkCachingPixelRef.h
@@ -0,0 +1,72 @@
+/*
+ * 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 "SkImage.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 pure-virtual functions onDecodeInfo()
+ * and onDecode(). Subclasses of this class need only provide those
+ * two functions.
+ */
+class SkCachingPixelRef : public SkPixelRef {
+public:
+ explicit SkCachingPixelRef();
reed1 2013/11/04 14:49:06 don't need this word if there is no parameter
hal.canary 2013/11/04 15:25:22 Done.
+ virtual ~SkCachingPixelRef();
+
+protected:
+ virtual void* onLockPixels(SkColorTable** colorTable) SK_OVERRIDE;
+ virtual void onUnlockPixels() SK_OVERRIDE;
+ virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; }
+ virtual bool onImplementsDecodeInto() SK_OVERRIDE { return true; }
+ virtual bool onDecodeInto(int pow2, SkBitmap*) SK_OVERRIDE;
+
+ /**
+ * Configure the supplied bitmap for this pixelRef, based on
+ * information provided by onDecodeInfo(). Does not set the
+ * bitmap's pixelRef. */
+ bool configure(SkBitmap* bitmap);
+
+ /**
+ * Cache info from onDecodeInfo(). Returns NULL on failure.
+ */
+ const SkImageInfo* getInfo();
+
+ /**
+ * Return some information about the pixels, allowing this class
+ * to allocate pixels. @return false if anything goes wrong.
+ */
+ virtual bool onDecodeInfo(SkImageInfo* info) = 0;
+ /**
+ * Decode into the given pixels, a block of memory of size
+ * (info->fHeight * rowBytes) bytes. Should follow the format
+ * reported by onDecodeInfo().
+ * @return false if anything goes wrong.
+ */
+ virtual bool onDecode(void* pixels, size_t rowBytes) = 0;
reed1 2013/11/04 14:49:06 nit: I think onDecodePixels would be clearer, sinc
hal.canary 2013/11/04 15:25:22 Done
+
+private:
+ bool fErrorInDecoding;
+ void* fScaledCacheId;
+ SkImageInfo fInfo;
+
+ typedef SkPixelRef INHERITED;
+};
+
+#endif // SkCachingPixelRef_DEFINED
+
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/lazy/SkCachingPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698