aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/codec/SkAndroidCodec.h
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-07-23 15:30:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-25 15:35:23 +0000
commitede7bac43fbc69b9fdf1c178890ba6353f5bb140 (patch)
treedccdba46e7abf125e2f90e6dc08eca00ad9cb09b /include/codec/SkAndroidCodec.h
parentfa3ed03720b5083afd3620c9239863f05f2eedbd (diff)
use unique_ptr for codec factories
Will need guards for android (at least) Bug: skia: Change-Id: I2bb8e656997984489ef1f2e41cd3d301c4e7b947 Reviewed-on: https://skia-review.googlesource.com/26040 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include/codec/SkAndroidCodec.h')
-rw-r--r--include/codec/SkAndroidCodec.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/codec/SkAndroidCodec.h b/include/codec/SkAndroidCodec.h
index b4dd3854e6..e785411ea9 100644
--- a/include/codec/SkAndroidCodec.h
+++ b/include/codec/SkAndroidCodec.h
@@ -29,7 +29,8 @@ public:
* If NULL is returned, the stream is deleted immediately. Otherwise, the
* SkCodec takes ownership of it, and will delete it when done with it.
*/
- static SkAndroidCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL);
+ static std::unique_ptr<SkAndroidCodec> MakeFromStream(std::unique_ptr<SkStream>,
+ SkPngChunkReader* = nullptr);
/**
* If this data represents an encoded image that we know how to decode,
@@ -38,10 +39,19 @@ public:
* The SkPngChunkReader handles unknown chunks in PNGs.
* See SkCodec.h for more details.
*/
- static SkAndroidCodec* NewFromData(sk_sp<SkData>, SkPngChunkReader* = NULL);
+ static std::unique_ptr<SkAndroidCodec> MakeFromData(sk_sp<SkData>, SkPngChunkReader* = nullptr);
+
+#ifdef SK_SUPPORT_LEGACY_CODEC_NEW
+ static SkAndroidCodec* NewFromStream(SkStream* stream, SkPngChunkReader* reader) {
+ return MakeFromStream(std::unique_ptr<SkStream>(stream), reader).release();
+ }
+ static SkAndroidCodec* NewFromData(sk_sp<SkData> data, SkPngChunkReader* reader) {
+ return MakeFromData(std::move(data), reader).release();
+ }
static SkAndroidCodec* NewFromData(SkData* data, SkPngChunkReader* reader) {
return NewFromData(sk_ref_sp(data), reader);
}
+#endif
virtual ~SkAndroidCodec() {}