Flutter Engine
The Flutter Engine
SkJpegMetadataDecoder.h
Go to the documentation of this file.
1/*
2 * Copyright 2013 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 SkJpegMetadataDecoder_DEFINED
9#define SkJpegMetadataDecoder_DEFINED
10
11#include "include/core/SkData.h"
14
15#include <memory>
16#include <vector>
17
18struct SkGainmapInfo;
19
20/**
21 * An interface that can be used to extract metadata from an encoded JPEG file.
22 */
24public:
27
30
31 /**
32 * A segment from a JPEG file. This is usually populated from a jpeg_marker_struct.
33 */
34 struct SK_API Segment {
35 Segment(uint8_t marker, sk_sp<SkData> data) : fMarker(marker), fData(std::move(data)) {}
36
37 // The segment's marker.
38 uint8_t fMarker = 0;
39
40 // The segment's parameters (not including the marker and parameter length).
42 };
43
44 /**
45 * Create metadata for the specified segments from a JPEG file's header (defined as all segments
46 * before the first StartOfScan). This may return nullptr.
47 */
48 static std::unique_ptr<SkJpegMetadataDecoder> Make(std::vector<Segment> headerSegments);
49
50 /**
51 * Return the Exif data attached to the image (if any) and nullptr otherwise. If |copyData| is
52 * false, then the returned SkData may directly reference the data provided when this object was
53 * created.
54 */
55 virtual sk_sp<SkData> getExifMetadata(bool copyData) const = 0;
56
57 /**
58 * Return the ICC profile of the image if any, and nullptr otherwise. If |copyData| is false,
59 * then the returned SkData may directly reference the data provided when this object was
60 * created.
61 */
62 virtual sk_sp<SkData> getICCProfileData(bool copyData) const = 0;
63
64 /**
65 * Return the ISO 21496-1 metadata, if any, and nullptr otherwise. If |copyData| is false,
66 * then the returned SkData may directly reference the data provided when this object was
67 * created.
68 */
69 virtual sk_sp<SkData> getISOGainmapMetadata(bool copyData) const = 0;
70
71 /**
72 * Return true if there is a possibility that this image contains a gainmap image.
73 */
74 virtual bool mightHaveGainmapImage() const = 0;
75
76 /**
77 * Given a JPEG encoded image |baseImageData|, return in |outGainmapImageData| the JPEG encoded
78 * gainmap image and return in |outGainmapInfo| its gainmap rendering parameters. Return true if
79 * both output variables were successfully populated, otherwise return false.
80 */
81 virtual bool findGainmapImage(sk_sp<SkData> baseImageData,
82 sk_sp<SkData>& outGainmapImagedata,
83 SkGainmapInfo& outGainmapInfo) = 0;
84};
85
86#endif
static const char marker[]
#define SK_API
Definition: SkAPI.h:35
virtual sk_sp< SkData > getISOGainmapMetadata(bool copyData) const =0
virtual bool mightHaveGainmapImage() const =0
virtual sk_sp< SkData > getExifMetadata(bool copyData) const =0
SkJpegMetadataDecoder & operator=(const SkJpegMetadataDecoder &)=delete
virtual bool findGainmapImage(sk_sp< SkData > baseImageData, sk_sp< SkData > &outGainmapImagedata, SkGainmapInfo &outGainmapInfo)=0
virtual sk_sp< SkData > getICCProfileData(bool copyData) const =0
SkJpegMetadataDecoder(const SkJpegMetadataDecoder &)=delete
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
Definition: ref_ptr.h:256
Segment(uint8_t marker, sk_sp< SkData > data)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63