diff options
author | Matt Sarett <msarett@google.com> | 2017-01-09 15:59:17 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-09 21:40:27 +0000 |
commit | f9436b8235620fd9baa5d341e37eedf9c306f68c (patch) | |
tree | 3feb7a32442a46462abb46dcf48159d6a6133aa1 | |
parent | 6294d3f79ecfb9355ce6d65305e28c5d60f4d05f (diff) |
Allow constrained and unconstrained picture-images
BUG=skia:
Change-Id: Id9b7b2c82c634fec50f9a57f4b59ce0c02e0706a
Reviewed-on: https://skia-review.googlesource.com/6818
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
-rw-r--r-- | include/core/SkImage.h | 10 | ||||
-rw-r--r-- | src/core/SkPictureImageGenerator.cpp | 6 | ||||
-rw-r--r-- | src/image/SkImage.cpp | 4 |
3 files changed, 10 insertions, 10 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h index 7d282daecf..9ecfb272a6 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -159,15 +159,17 @@ public: kF16, }; -#ifdef SK_USE_LEGACY_MAKE_PICTURE_API + /** + * Create a new image from the specified picture. + * This SkImage has no defined BitDepth or SkColorSpace, it is a flexible container for + * draw commands. + */ static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions, const SkMatrix* matrix, const SkPaint* paint); -#endif /** * Create a new image from the specified picture. - * Creating an SkImage from an SkPicture requires snapping the picture to a particular - * BitDepth and SkColorSpace. + * On creation of the SkImage, snap the SkPicture to a particular BitDepth and SkColorSpace. */ static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture>, const SkISize& dimensions, const SkMatrix*, const SkPaint*, BitDepth, diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp index 3a4749b480..762654af70 100644 --- a/src/core/SkPictureImageGenerator.cpp +++ b/src/core/SkPictureImageGenerator.cpp @@ -44,15 +44,15 @@ SkImageGenerator* SkPictureImageGenerator::Create(const SkISize& size, const SkP const SkMatrix* matrix, const SkPaint* paint, SkImage::BitDepth bitDepth, sk_sp<SkColorSpace> colorSpace) { - if (!picture || size.isEmpty() || !colorSpace) { + if (!picture || size.isEmpty()) { return nullptr; } - if (SkImage::BitDepth::kF16 == bitDepth && !colorSpace->gammaIsLinear()) { + if (SkImage::BitDepth::kF16 == bitDepth && (!colorSpace || !colorSpace->gammaIsLinear())) { return nullptr; } - if (!colorSpace->gammaCloseToSRGB() && !colorSpace->gammaIsLinear()) { + if (colorSpace && (!colorSpace->gammaCloseToSRGB() && !colorSpace->gammaIsLinear())) { return nullptr; } diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index f49a2ce285..66301341d3 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -299,13 +299,11 @@ bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) con return true; } -#ifdef SK_USE_LEGACY_MAKE_PICTURE_API sk_sp<SkImage> SkImage::MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions, const SkMatrix* matrix, const SkPaint* paint) { return SkImage::MakeFromPicture(std::move(picture), dimensions, matrix, paint, BitDepth::kU8, - SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); + nullptr); } -#endif sk_sp<SkImage> SkImage::MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions, const SkMatrix* matrix, const SkPaint* paint, |