aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-08-13 14:06:46 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-13 14:06:46 -0700
commit8f4fe37b1cb7c98577d76e7004f35929664e251e (patch)
treea18319a7116ce0e5a55c31b0f9c0527b2caf8864
parent7e6d9c032662d876e83eb8e7bffada7ae0409eed (diff)
some catchup CL revisions
-rw-r--r--gm/image_pict.cpp6
-rw-r--r--include/core/SkImageGenerator.h6
-rw-r--r--src/core/SkImageCacherator.cpp9
-rw-r--r--src/core/SkImageCacherator.h9
4 files changed, 18 insertions, 12 deletions
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index dd1fab549a..a8abea32b3 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -128,10 +128,8 @@ protected:
SkMatrix matrix;
matrix.setTranslate(-100, -100);
- fCache.reset(new SkImageCacherator(SkImageGenerator::NewFromPicture(size,
- fPicture,
- &matrix,
- nullptr)));
+ auto gen = SkImageGenerator::NewFromPicture(size, fPicture, &matrix, nullptr);
+ fCache.reset(SkImageCacherator::NewFromGenerator(gen));
}
void drawSet(SkCanvas* canvas) const {
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index d5885babd7..aa9a6d1157 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -144,9 +144,9 @@ public:
* Regarding the SkImageUsageType parameter:
*
* If the context (the provided one or the generator's intrinsic one) determines that to
- * support the specified usage, it must return a different sized texture (from the generator's
- * native size) it may, so the caller must inspect the texture's width/height
- * (unless kUntiled_SkImageUsedType was specified).
+ * support the specified usage, it must return a different sized texture it may,
+ * so the caller must inspect the texture's width/height and compare them to the generator's
+ * getInfo() width/height.
*/
GrTexture* generateTexture(GrContext*, SkImageUsageType);
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index b225612a17..1f481d0000 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -19,10 +19,17 @@
#include "SkGrPriv.h"
#endif
+SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen) {
+ if (!gen) {
+ return nullptr;
+ }
+ return SkNEW_ARGS(SkImageCacherator, (gen));
+}
+
SkImageCacherator::SkImageCacherator(SkImageGenerator* gen) : fGenerator(gen) {}
SkImageCacherator::~SkImageCacherator() {
- delete fGenerator;
+ SkDELETE(fGenerator);
}
static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) {
diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h
index 86dbd8874f..2403a50a04 100644
--- a/src/core/SkImageCacherator.h
+++ b/src/core/SkImageCacherator.h
@@ -19,7 +19,8 @@ class SkBitmap;
class SkImageCacherator {
public:
// Takes ownership of the generator
- SkImageCacherator(SkImageGenerator* gen);
+ static SkImageCacherator* NewFromGenerator(SkImageGenerator*);
+
~SkImageCacherator();
const SkImageInfo& info() const { return fGenerator->getInfo(); }
@@ -28,8 +29,6 @@ public:
/**
* 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.
*/
bool lockAsBitmap(SkBitmap*);
@@ -37,11 +36,13 @@ public:
* Returns a ref() on the texture produced by this generator. The caller must call unref()
* when it is done. Will return NULL on failure.
*
- * The cached texture is valid until it is unref'd.
+ * The caller is responsible for calling texture->unref() when they are done.
*/
GrTexture* lockAsTexture(GrContext*, SkImageUsageType);
private:
+ SkImageCacherator(SkImageGenerator* gen);
+
bool tryLockAsBitmap(SkBitmap*);
GrTexture* tryLockAsTexture(GrContext*, SkImageUsageType);