Coverage Report

Created: 2024-05-20 07:14

/src/skia/include/private/SkXmp.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2023 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 SkXmp_DEFINED
9
#define SkXmp_DEFINED
10
11
#include "include/core/SkRefCnt.h"
12
#include "include/private/base/SkAPI.h"
13
14
class SkData;
15
struct SkGainmapInfo;
16
17
#include <cstddef>
18
#include <memory>
19
20
/*
21
 * An interface to extract information from XMP metadata.
22
 */
23
class SK_API SkXmp {
24
public:
25
2.76k
    SkXmp() = default;
26
2.76k
    virtual ~SkXmp() = default;
27
    // Make noncopyable
28
    SkXmp(const SkXmp&) = delete;
29
    SkXmp& operator= (const SkXmp&) = delete;
30
31
    // Create from XMP data.
32
    static std::unique_ptr<SkXmp> Make(sk_sp<SkData> xmpData);
33
    // Create from standard XMP + extended XMP data, see XMP Specification Part 3: Storage in files,
34
    // Section 1.1.3.1: Extended XMP in JPEG
35
    static std::unique_ptr<SkXmp> Make(sk_sp<SkData> xmpStandard, sk_sp<SkData> xmpExtended);
36
37
    // Extract HDRGM gainmap parameters.
38
    // TODO(b/338342146): Remove this once all callers are removed.
39
0
    bool getGainmapInfoHDRGM(SkGainmapInfo* info) const { return getGainmapInfoAdobe(info); }
40
41
    // Extract gainmap parameters from http://ns.adobe.com/hdr-gain-map/1.0/.
42
    virtual bool getGainmapInfoAdobe(SkGainmapInfo* info) const = 0;
43
44
    // If the image specifies http://ns.apple.com/pixeldatainfo/1.0/ AuxiliaryImageType of
45
    // urn:com:apple:photo:2020:aux:hdrgainmap, and includes a http://ns.apple.com/HDRGainMap/1.0/
46
    // HDRGainMapVersion, then populate |info| with gainmap parameters that will approximate the
47
    // math specified at [0] and return true.
48
    // [0] https://developer.apple.com/documentation/appkit/images_and_pdf/
49
    //     applying_apple_hdr_effect_to_your_photos
50
    virtual bool getGainmapInfoApple(float exifHdrHeadroom, SkGainmapInfo* info) const = 0;
51
52
    // If this includes GContainer metadata and the GContainer contains an item with semantic
53
    // GainMap and Mime of image/jpeg, then return true, and populate |offset| and |size| with
54
    // that item's offset (from the end of the primary JPEG image's EndOfImage), and the size of
55
    // the gainmap.
56
    virtual bool getContainerGainmapLocation(size_t* offset, size_t* size) const = 0;
57
58
    // Return the GUID of an Extended XMP if present, or null otherwise.
59
    virtual const char* getExtendedXmpGuid() const = 0;
60
};
61
62
#endif