From f9436b8235620fd9baa5d341e37eedf9c306f68c Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Mon, 9 Jan 2017 15:59:17 -0500 Subject: Allow constrained and unconstrained picture-images BUG=skia: Change-Id: Id9b7b2c82c634fec50f9a57f4b59ce0c02e0706a Reviewed-on: https://skia-review.googlesource.com/6818 Commit-Queue: Matt Sarett Reviewed-by: Mike Reed Reviewed-by: Florin Malita --- include/core/SkImage.h | 10 ++++++---- src/core/SkPictureImageGenerator.cpp | 6 +++--- 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 MakeFromPicture(sk_sp 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 MakeFromPicture(sk_sp, 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 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::MakeFromPicture(sk_sp 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::MakeFromPicture(sk_sp picture, const SkISize& dimensions, const SkMatrix* matrix, const SkPaint* paint, -- cgit v1.2.3