/src/skia/include/private/SkJpegMetadataDecoder.h
Line | Count | Source |
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" |
12 | | #include "include/core/SkRefCnt.h" |
13 | | #include "include/core/SkTypes.h" |
14 | | |
15 | | #include <memory> |
16 | | #include <vector> |
17 | | |
18 | | struct SkGainmapInfo; |
19 | | |
20 | | /** |
21 | | * An interface that can be used to extract metadata from an encoded JPEG file. |
22 | | */ |
23 | | class SK_API SkJpegMetadataDecoder { |
24 | | public: |
25 | 16.0k | SkJpegMetadataDecoder() {} |
26 | 16.0k | virtual ~SkJpegMetadataDecoder() {} |
27 | | |
28 | | SkJpegMetadataDecoder(const SkJpegMetadataDecoder&) = delete; |
29 | | SkJpegMetadataDecoder& operator=(const SkJpegMetadataDecoder&) = delete; |
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 | 24.1k | 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). |
41 | | sk_sp<SkData> fData; |
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 true if there is a possibility that this image contains a gainmap image. |
66 | | */ |
67 | | virtual bool mightHaveGainmapImage() const = 0; |
68 | | |
69 | | /** |
70 | | * Given a JPEG encoded image |baseImageData|, return in |outGainmapImageData| the JPEG encoded |
71 | | * gainmap image and return in |outGainmapInfo| its gainmap rendering parameters. Return true if |
72 | | * both output variables were successfully populated, otherwise return false. |
73 | | */ |
74 | | virtual bool findGainmapImage(sk_sp<SkData> baseImageData, |
75 | | sk_sp<SkData>& outGainmapImagedata, |
76 | | SkGainmapInfo& outGainmapInfo) = 0; |
77 | | }; |
78 | | |
79 | | #endif |