1 /* 2 * Copyright 2024 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkJpegMetadataDecoderImpl_DEFINED 9 #define SkJpegMetadataDecoderImpl_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "include/private/SkJpegMetadataDecoder.h" 13 14 #include <vector> 15 16 #ifdef SK_CODEC_DECODES_JPEG_GAINMAPS 17 #include "include/private/SkXmp.h" 18 #endif // SK_CODEC_DECODES_JPEG_GAINMAPS 19 20 class SkData; 21 class SkJpegSourceMgr; 22 struct SkGainmapInfo; 23 24 using SkJpegMarker = SkJpegMetadataDecoder::Segment; 25 using SkJpegMarkerList = std::vector<SkJpegMarker>; 26 27 class SkJpegMetadataDecoderImpl : public SkJpegMetadataDecoder { 28 public: 29 SkJpegMetadataDecoderImpl(SkJpegMarkerList markerList); 30 SkJpegMetadataDecoderImpl(sk_sp<SkData> data); 31 32 bool findGainmapImage(SkJpegSourceMgr* sourceMgr, 33 sk_sp<SkData>& outGainmapImageData, 34 SkGainmapInfo& outGainmapInfo) const; 35 36 #ifdef SK_CODEC_DECODES_JPEG_GAINMAPS 37 std::unique_ptr<SkXmp> getXmpMetadata() const; 38 #endif // SK_CODEC_DECODES_JPEG_GAINMAPS 39 40 // SkJpegMetadataDecoder implementation: 41 sk_sp<SkData> getExifMetadata(bool copyData) const override; 42 sk_sp<SkData> getICCProfileData(bool copyData) const override; 43 sk_sp<SkData> getISOGainmapMetadata(bool copyData) const override; 44 bool mightHaveGainmapImage() const override; 45 bool findGainmapImage(sk_sp<SkData> baseImageData, 46 sk_sp<SkData>& outGainmapImageData, 47 SkGainmapInfo& outGainmapInfo) override; 48 49 private: 50 SkJpegMarkerList fMarkerList; 51 }; 52 53 #endif // SkJpegMetadataDecoderImpl_DEFINED 54