From 0741818e7ab4e9ea8505b8a8687412f0e3804c65 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Tue, 15 Aug 2017 12:24:02 -0400 Subject: Move calls to conversion_possible to SkCodec Move common code into the base class, so subclasses need not call conversion_possible. Use SkEncodedInfo rather than SkImageInfo, and use the proper frame. API Changes: - SkAndroidCodec: - Add getEncodedInfo(), for SkBitmapRegionCodec - SkEncodedInfo: - Add opaque() helper - SkBitmapRegionDecoder: - Remove unused conversionSupported (Split off from skia-review.googlesource.com/c/25746) Bug: skia:5601 Change-Id: If4a40d4b98a3dd0afde2b6058f92315a393a5baf Reviewed-on: https://skia-review.googlesource.com/34361 Reviewed-by: Mike Klein Reviewed-by: Derek Sollenberger Commit-Queue: Leon Scroggins --- include/codec/SkAndroidCodec.h | 3 ++- include/codec/SkCodec.h | 7 +++++++ include/codec/SkEncodedInfo.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'include/codec') diff --git a/include/codec/SkAndroidCodec.h b/include/codec/SkAndroidCodec.h index 3571108edd..cc93bf18c4 100644 --- a/include/codec/SkAndroidCodec.h +++ b/include/codec/SkAndroidCodec.h @@ -41,8 +41,9 @@ public: */ static std::unique_ptr MakeFromData(sk_sp, SkPngChunkReader* = nullptr); - virtual ~SkAndroidCodec() {} + virtual ~SkAndroidCodec(); + const SkEncodedInfo& getEncodedInfo() const; const SkImageInfo& getInfo() const { return fInfo; } diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h index fb4f165dbf..8ec44c8539 100644 --- a/include/codec/SkCodec.h +++ b/include/codec/SkCodec.h @@ -845,6 +845,13 @@ private: bool fStartedIncrementalDecode; + /** + * Return whether {srcColor, srcIsOpaque, srcCS} can convert to dst. + * + * Will be called for the appropriate frame, prior to initializing the colorXform. + */ + virtual bool conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color srcColor, + bool srcIsOpaque, const SkColorSpace* srcCS) const; /** * Return whether these dimensions are supported as a scale. * diff --git a/include/codec/SkEncodedInfo.h b/include/codec/SkEncodedInfo.h index 3b1ce48713..dce88cadc1 100644 --- a/include/codec/SkEncodedInfo.h +++ b/include/codec/SkEncodedInfo.h @@ -156,6 +156,8 @@ public: Color color() const { return fColor; } Alpha alpha() const { return fAlpha; } + bool opaque() const { return fAlpha == kOpaque_Alpha; } + uint8_t bitsPerComponent() const { return fBitsPerComponent; } uint8_t bitsPerPixel() const { -- cgit v1.2.3