summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/codec/SkEncodedInfo.cpp
blob: 56f1a0259da8b1ef9ae917742d0ffddaeabb7baf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "include/private/SkEncodedInfo.h"

#include "modules/skcms/skcms.h"

std::unique_ptr<SkEncodedInfo::ICCProfile> SkEncodedInfo::ICCProfile::Make(sk_sp<SkData> data) {
    if (data) {
        skcms_ICCProfile profile;
        if (skcms_Parse(data->data(), data->size(), &profile)) {
            return std::unique_ptr<ICCProfile>(new ICCProfile(profile, std::move(data)));
        }
    }
    return nullptr;
}

std::unique_ptr<SkEncodedInfo::ICCProfile> SkEncodedInfo::ICCProfile::Make(
        const skcms_ICCProfile& profile) {
    return std::unique_ptr<ICCProfile>(new ICCProfile(profile));
}

SkEncodedInfo::ICCProfile::ICCProfile(const skcms_ICCProfile& profile, sk_sp<SkData> data)
    : fProfile(profile)
    , fData(std::move(data))
{}