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

Unified Diff: src/core/SkImageCacherator.h

Issue 1291803002: Extend SkImageGenerator to support natively generated GrTextures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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/SkImageCacherator.h
diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h
new file mode 100644
index 0000000000000000000000000000000000000000..73f1f61e6bc3e9ea76685f40e07a338332b763ae
--- /dev/null
+++ b/src/core/SkImageCacherator.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkImageCacherator_DEFINED
+#define SkImageCacherator_DEFINED
+
+#include "SkImageGenerator.h"
+
+class GrContext;
+class SkBitmap;
+
+class SkImageCacherator {
+public:
+ // Takes ownership of the generator
+ SkImageCacherator(SkImageGenerator* gen);
scroggo 2015/08/13 19:59:13 Maybe this should be a factory, so we don't end up
reed1 2015/08/13 20:57:08 Done.
+ ~SkImageCacherator();
+
+ const SkImageInfo& info() const { return fGenerator->getInfo(); }
+ SkImageGenerator* generator() const { return fGenerator; }
+
+ /**
+ * On success (true), bitmap will point to the pixels for this generator. If this returns
+ * false, the bitmap will be reset to empty.
+ *
+ * The cached bitmap is valid until it goes out of scope.
scroggo 2015/08/13 19:59:13 Are you saying the bitmap passed to this function
reed1 2015/08/13 20:57:08 Fixed.
+ */
+ bool lockAsBitmap(SkBitmap*);
+
+ /**
+ * Returns a ref() on the texture produced by this generator. The caller must call unref()
+ * when it is done. Will return NULL on failure.
scroggo 2015/08/13 19:59:13 nullptr?
reed1 2015/08/13 20:57:08 Hmmm, I'm not sure that distinction is important i
+ *
+ * The cached texture is valid until it is unref'd.
+ */
+ GrTexture* lockAsTexture(GrContext*, SkImageUsageType);
+
+private:
+ bool tryLockAsBitmap(SkBitmap*);
+ GrTexture* tryLockAsTexture(GrContext*, SkImageUsageType);
+
+ SkImageGenerator* fGenerator;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698