aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-03-19 08:31:14 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-19 08:31:14 -0700
commit3ef71e343bf075888fb50892350390b4dd47de24 (patch)
treed4765ef144928600322cf21bdb41b37f05a55697 /include
parent647211f1243f2dc925588e75038be49cad7b5431 (diff)
guarded change to SkImageGenerator to make getInfo() const
Diffstat (limited to 'include')
-rw-r--r--include/codec/SkCodec.h4
-rw-r--r--include/core/SkImageGenerator.h31
2 files changed, 26 insertions, 9 deletions
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 6d0557cb28..3550bb1831 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -58,10 +58,12 @@ protected:
* initially returns a non-opaque answer, but completing the decode
* reveals that the image is actually opaque.
*/
+#ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO
bool onGetInfo(SkImageInfo* info) SK_OVERRIDE {
*info = fInfo;
return true;
}
+#endif
// Helper for subclasses.
const SkImageInfo& getOriginalInfo() { return fInfo; }
@@ -99,5 +101,7 @@ private:
const SkImageInfo fInfo;
SkAutoTDelete<SkStream> fStream;
bool fNeedsRewind;
+
+ typedef SkImageGenerator INHERITED;
};
#endif // SkCodec_DEFINED
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index a5440bd3b4..5f8f5ba8fb 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -65,15 +65,19 @@ public:
SkData* refEncodedData() { return this->onRefEncodedData(); }
/**
- * Return some information about the image, allowing the owner of
- * this object to allocate pixels.
- *
- * Repeated calls to this function should give the same results,
- * allowing the PixelRef to be immutable.
- *
- * @return false if anything goes wrong.
+ * Return the ImageInfo associated with this generator.
*/
- bool getInfo(SkImageInfo* info);
+#ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO
+ SkImageInfo getInfo();
+ bool getInfo(SkImageInfo* info) {
+ if (info) {
+ *info = this->getInfo();
+ }
+ return true;
+ }
+#else
+ const SkImageInfo& getInfo() const { return fInfo; }
+#endif
/**
* Used to describe the result of a call to getPixels().
@@ -206,8 +210,14 @@ public:
static SkImageGenerator* NewFromData(SkData*);
protected:
- virtual SkData* onRefEncodedData();
+#ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO
+ SkImageGenerator() : fInfo(SkImageInfo::MakeUnknown(0, 0) ) {}
virtual bool onGetInfo(SkImageInfo* info);
+#endif
+ SkImageGenerator(const SkImageInfo& info) : fInfo(info) {}
+
+ virtual SkData* onRefEncodedData();
+
#ifdef SK_SUPPORT_LEGACY_OPTIONLESS_GET_PIXELS
virtual Result onGetPixels(const SkImageInfo& info,
void* pixels, size_t rowBytes,
@@ -219,6 +229,9 @@ protected:
virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]);
virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
SkYUVColorSpace* colorSpace);
+
+private:
+ const SkImageInfo fInfo;
};
#endif // SkImageGenerator_DEFINED