diff options
author | Mike Reed <reed@google.com> | 2017-02-15 15:14:16 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-15 20:51:28 +0000 |
commit | 185130c643f0f6b20dcf14c200074748be282a7e (patch) | |
tree | 049a9162c7ed7c298a4966000b9aa805f75282ad /include | |
parent | eb62829a83a0a4f4fdd1230a3c08140e38052602 (diff) |
return and take SkImageGenerator as unique_ptr
BUG=skia:
Change-Id: I4bc11042dd1dbf1eabd40af206027bc65acc3186
Reviewed-on: https://skia-review.googlesource.com/8444
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkGraphics.h | 14 | ||||
-rw-r--r-- | include/core/SkImage.h | 4 | ||||
-rw-r--r-- | include/core/SkImageGenerator.h | 17 |
3 files changed, 28 insertions, 7 deletions
diff --git a/include/core/SkGraphics.h b/include/core/SkGraphics.h index d5a730d9e0..bf8228b9cc 100644 --- a/include/core/SkGraphics.h +++ b/include/core/SkGraphics.h @@ -8,7 +8,7 @@ #ifndef SkGraphics_DEFINED #define SkGraphics_DEFINED -#include "SkTypes.h" +#include "SkRefCnt.h" class SkData; class SkImageGenerator; @@ -157,7 +157,8 @@ public: */ static void SetTLSFontCacheLimit(size_t bytes); - typedef SkImageGenerator* (*ImageGeneratorFromEncodedFactory)(SkData*); + typedef std::unique_ptr<SkImageGenerator> + (*ImageGeneratorFromEncodedDataFactory)(sk_sp<SkData>); /** * To instantiate images from encoded data, first looks at this runtime function-ptr. If it @@ -166,8 +167,15 @@ public: * * Returns the previous factory (which could be NULL). */ + static ImageGeneratorFromEncodedDataFactory + SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory); + +#ifdef SK_SUPPORT_BARE_PTR_IMAGEGENERATOR + typedef SkImageGenerator* (*ImageGeneratorFromEncodedFactory)(SkData*); static ImageGeneratorFromEncodedFactory - SetImageGeneratorFromEncodedFactory(ImageGeneratorFromEncodedFactory); + SetImageGeneratorFromEncodedFactory(ImageGeneratorFromEncodedFactory); +#endif + }; class SkAutoGraphics { diff --git a/include/core/SkImage.h b/include/core/SkImage.h index aaafb44c42..444ce6815e 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -73,7 +73,11 @@ public: * * If a subset is specified, it must be contained within the generator's bounds. */ + static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerator>, + const SkIRect* subset = nullptr); +#ifdef SK_SUPPORT_BARE_PTR_IMAGEGENERATOR static sk_sp<SkImage> MakeFromGenerator(SkImageGenerator*, const SkIRect* subset = nullptr); +#endif /** * Construct a new SkImage based on the specified encoded data. Returns NULL on failure, diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h index a8a858d6da..44d59438ee 100644 --- a/include/core/SkImageGenerator.h +++ b/include/core/SkImageGenerator.h @@ -146,18 +146,27 @@ public: * this returns a new ImageGenerator for it. Otherwise this returns NULL. Either way * the caller is still responsible for managing their ownership of the data. */ - static SkImageGenerator* NewFromEncoded(SkData*); + static std::unique_ptr<SkImageGenerator> MakeFromEncoded(sk_sp<SkData>); /** Return a new image generator backed by the specified picture. If the size is empty or * the picture is NULL, this returns NULL. * The optional matrix and paint arguments are passed to drawPicture() at rasterization * time. */ - static SkImageGenerator* NewFromPicture(const SkISize&, const SkPicture*, const SkMatrix*, - const SkPaint*, SkImage::BitDepth, sk_sp<SkColorSpace>); + static std::unique_ptr<SkImageGenerator> MakeFromPicture(const SkISize&, sk_sp<SkPicture>, + const SkMatrix*, const SkPaint*, + SkImage::BitDepth, + sk_sp<SkColorSpace>); bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo& info, SkBitmap::Allocator* allocator); +#ifdef SK_SUPPORT_BARE_PTR_IMAGEGENERATOR + static SkImageGenerator* NewFromPicture(const SkISize& size, const SkPicture* picture, + const SkMatrix* matrix, const SkPaint* paint, + SkImage::BitDepth depth, sk_sp<SkColorSpace> cs); + static SkImageGenerator* NewFromEncoded(SkData* data); +#endif + protected: enum { kNeedNewImageUniqueID = 0 @@ -188,7 +197,7 @@ private: // This is our default impl, which may be different on different platforms. // It is called from NewFromEncoded() after it has checked for any runtime factory. // The SkData will never be NULL, as that will have been checked by NewFromEncoded. - static SkImageGenerator* NewFromEncodedImpl(SkData*); + static std::unique_ptr<SkImageGenerator> MakeFromEncodedImpl(sk_sp<SkData>); }; #endif // SkImageGenerator_DEFINED |