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

Unified Diff: src/lazy/SkDiscardablePixelRef.h

Issue 74793011: Add SkImageGenerator Interface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: protected destructor 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
Index: src/lazy/SkDiscardablePixelRef.h
diff --git a/src/lazy/SkDiscardablePixelRef.h b/src/lazy/SkDiscardablePixelRef.h
new file mode 100644
index 0000000000000000000000000000000000000000..4ccfce6286c5403e5a3b2f5148402ca061285b92
--- /dev/null
+++ b/src/lazy/SkDiscardablePixelRef.h
@@ -0,0 +1,54 @@
+/*
+ * 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 SkDiscardablePixelRef_DEFINED
+#define SkDiscardablePixelRef_DEFINED
+
+#include "SkPixelRef.h"
+#include "SkImageGenerator.h"
+#include "SkImageInfo.h"
+
+class SkDiscardableMemory;
+
+/**
+ * An interface that allows a purgable PixelRef to re-decode an image.
+ */
+
+class SkDiscardablePixelRef : public SkPixelRef {
+public:
+ /**
+ * Takes ownership of SkImageGenerator.
+ * Will modify SkBitmap
+ */
+ static bool Install(SkImageGenerator* generator, SkBitmap* destination);
+
+ SK_DECLARE_UNFLATTENABLE_OBJECT()
+
+protected:
+ ~SkDiscardablePixelRef();
+ virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE;
+ virtual void onUnlockPixels() SK_OVERRIDE;
+ virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; }
+
+ virtual SkData* onRefEncodedData() SK_OVERRIDE {
+ return fGenerator->refEncodedData();
+ }
+
+private:
+ SkImageGenerator* fGenerator;
+ SkDiscardableMemory* fDiscardableMemory;
+ SkImageInfo fInfo;
scroggo 2013/11/19 22:19:27 Can fInfo, fSize, and fRowBytes be const?
hal.canary 2013/11/20 00:07:10 Done. Even the pointer can be const (but not the
+ size_t fSize; // size of memeory to be allocated
scroggo 2013/11/19 22:19:27 memory*
hal.canary 2013/11/20 00:07:10 Done.
+ size_t fRowBytes; // ???
scroggo 2013/11/19 22:19:27 ???
hal.canary 2013/11/20 00:07:10 Done.
+
+ /* Takes ownership of SkImageGenerator. */
+ SkDiscardablePixelRef(SkImageGenerator* generator,
+ const SkImageInfo& info,
+ size_t size,
+ size_t rowBytes);
+};
+#endif // SkDiscardablePixelRef_DEFINED

Powered by Google App Engine
This is Rietveld 408576698