diff --git a/src/codec/SkHeifCodec.cpp b/src/codec/SkHeifCodec.cpp index f3ad2a8784..ae452c4dfb 100644 --- a/src/codec/SkHeifCodec.cpp +++ b/src/codec/SkHeifCodec.cpp @@ -118,11 +118,9 @@ private: std::unique_ptr fStream; }; -#ifndef SK_LEGACY_HEIF_API static void releaseProc(const void* ptr, void* context) { delete reinterpret_cast*>(context); } -#endif std::unique_ptr SkHeifCodec::MakeFromStream(std::unique_ptr stream, SkCodec::SelectionPolicy selectionPolicy, Result* result) { @@ -138,7 +136,6 @@ std::unique_ptr SkHeifCodec::MakeFromStream(std::unique_ptr s return nullptr; } -#ifndef SK_LEGACY_HEIF_API size_t frameCount = 1; if (selectionPolicy == SkCodec::SelectionPolicy::kPreferAnimation) { HeifFrameInfo sequenceInfo; @@ -147,22 +144,13 @@ std::unique_ptr SkHeifCodec::MakeFromStream(std::unique_ptr s heifInfo = std::move(sequenceInfo); } } -#endif std::unique_ptr profile = nullptr; -#ifdef SK_LEGACY_HEIF_API - if ((heifInfo.mIccSize > 0) && (heifInfo.mIccData != nullptr)) { - // FIXME: Would it be possible to use MakeWithoutCopy? - auto icc = SkData::MakeWithCopy(heifInfo.mIccData.get(), heifInfo.mIccSize); - profile = SkEncodedInfo::ICCProfile::Make(std::move(icc)); - } -#else if (heifInfo.mIccData.size() > 0) { auto iccData = new std::vector(std::move(heifInfo.mIccData)); auto icc = SkData::MakeWithProc(iccData->data(), iccData->size(), releaseProc, iccData); profile = SkEncodedInfo::ICCProfile::Make(std::move(icc)); } -#endif if (profile && profile->profile()->data_color_space != skcms_Signature_RGB) { // This will result in sRGB. profile = nullptr; @@ -174,28 +162,19 @@ std::unique_ptr SkHeifCodec::MakeFromStream(std::unique_ptr s *result = kSuccess; return std::unique_ptr(new SkHeifCodec( - std::move(info), heifDecoder.release(), orientation -#ifndef SK_LEGACY_HEIF_API - , frameCount > 1 -#endif - )); + std::move(info), heifDecoder.release(), orientation, frameCount > 1)); } SkHeifCodec::SkHeifCodec( SkEncodedInfo&& info, HeifDecoder* heifDecoder, - SkEncodedOrigin origin -#ifndef SK_LEGACY_HEIF_API - , bool useAnimation -#endif - ) + SkEncodedOrigin origin, + bool useAnimation) : INHERITED(std::move(info), skcms_PixelFormat_RGBA_8888, nullptr, origin) , fHeifDecoder(heifDecoder) , fSwizzleSrcRow(nullptr) , fColorXformSrcRow(nullptr) -#ifndef SK_LEGACY_HEIF_API , fUseAnimation(useAnimation) -#endif {} bool SkHeifCodec::conversionSupported(const SkImageInfo& dstInfo, bool srcIsOpaque, @@ -286,7 +265,6 @@ int SkHeifCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes return count; } -#ifndef SK_LEGACY_HEIF_API int SkHeifCodec::onGetFrameCount() { if (!fUseAnimation) { return 1; @@ -357,7 +335,6 @@ bool SkHeifCodec::onGetFrameInfo(int i, FrameInfo* frameInfo) const { int SkHeifCodec::onGetRepetitionCount() { return kRepetitionCountInfinite; } -#endif // SK_LEGACY_HEIF_API /* * Performs the heif decode @@ -373,11 +350,6 @@ SkCodec::Result SkHeifCodec::onGetPixels(const SkImageInfo& dstInfo, return kUnimplemented; } -#ifdef SK_LEGACY_HEIF_API - if (!fHeifDecoder->decode(&fFrameInfo)) { - return kInvalidInput; - } -#else bool success; if (fUseAnimation) { success = fHeifDecoder->decodeSequence(options.fFrameIndex, &fFrameInfo); @@ -388,7 +360,6 @@ SkCodec::Result SkHeifCodec::onGetPixels(const SkImageInfo& dstInfo, if (!success) { return kInvalidInput; } -#endif // SK_LEGACY_HEIF_API fSwizzler.reset(nullptr); this->allocateStorage(dstInfo); diff --git a/src/codec/SkHeifCodec.h b/src/codec/SkHeifCodec.h index ad223c2759..2391e6ff99 100644 --- a/src/codec/SkHeifCodec.h +++ b/src/codec/SkHeifCodec.h @@ -43,14 +43,12 @@ protected: return SkEncodedImageFormat::kHEIF; } -#ifndef SK_LEGACY_HEIF_API int onGetFrameCount() override; bool onGetFrameInfo(int, FrameInfo*) const override; int onGetRepetitionCount() override; const SkFrameHolder* getFrameHolder() const override { return &fFrameHolder; } -#endif bool conversionSupported(const SkImageInfo&, bool, bool) override; @@ -61,11 +59,7 @@ private: * Creates an instance of the decoder * Called only by NewFromStream */ - SkHeifCodec(SkEncodedInfo&&, HeifDecoder*, SkEncodedOrigin -#ifndef SK_LEGACY_HEIF_API - , bool animation -#endif - ); + SkHeifCodec(SkEncodedInfo&&, HeifDecoder*, SkEncodedOrigin, bool animation); void initializeSwizzler(const SkImageInfo& dstInfo, const Options& options); void allocateStorage(const SkImageInfo& dstInfo); @@ -88,7 +82,6 @@ private: uint32_t* fColorXformSrcRow; std::unique_ptr fSwizzler; -#ifndef SK_LEGACY_HEIF_API bool fUseAnimation; class Frame : public SkFrame { @@ -128,7 +121,6 @@ private: }; FrameHolder fFrameHolder; -#endif // SK_LEGACY_HEIF_API typedef SkCodec INHERITED; }; diff --git a/src/codec/SkStubHeifDecoderAPI.h b/src/codec/SkStubHeifDecoderAPI.h index 4f936090b0..413ec62800 100644 --- a/src/codec/SkStubHeifDecoderAPI.h +++ b/src/codec/SkStubHeifDecoderAPI.h @@ -32,22 +32,12 @@ struct HeifStream { }; struct HeifFrameInfo { -#ifdef SK_LEGACY_HEIF_API - int mRotationAngle; - int mWidth; - int mHeight; - int mBytesPerPixel; - - size_t mIccSize; - std::unique_ptr mIccData; -#else uint32_t mWidth; uint32_t mHeight; int32_t mRotationAngle; // Rotation angle, clockwise, should be multiple of 90 uint32_t mBytesPerPixel; // Number of bytes for one pixel int64_t mDurationUs; // Duration of the frame in us std::vector mIccData; // ICC data array -#endif }; struct HeifDecoder { @@ -56,21 +46,17 @@ struct HeifDecoder { return false; } -#ifndef SK_LEGACY_HEIF_API bool getSequenceInfo(HeifFrameInfo* frameInfo, size_t *frameCount) { return false; } -#endif bool decode(HeifFrameInfo*) { return false; } -#ifndef SK_LEGACY_HEIF_API bool decodeSequence(int frameIndex, HeifFrameInfo* frameInfo) { return false; } -#endif bool setOutputColor(HeifColorFormat) { return false;