chromium/third_party/skia/src/encode/SkICC.cpp

/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "include/encode/SkICC.h"

#include "include/core/SkColorSpace.h"
#include "include/core/SkData.h"
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkFixed.h"
#include "include/private/base/SkFloatingPoint.h"
#include "modules/skcms/skcms.h"
#include "src/base/SkAutoMalloc.h"
#include "src/base/SkEndian.h"
#include "src/core/SkMD5.h"
#include "src/core/SkStreamPriv.h"
#include "src/encode/SkICCPriv.h"

#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <utility>
#include <vector>

namespace {

// The number of input and output channels.
constexpr size_t kNumChannels =;

// The D50 illuminant.
constexpr float kD50_x =;
constexpr float kD50_y =;
constexpr float kD50_z =;

// This is like SkFloatToFixed, but rounds to nearest, preserving as much accuracy as possible
// when going float -> fixed -> float (it has the same accuracy when going fixed -> float -> fixed).
// The use of double is necessary to accommodate the full potential 32-bit mantissa of the 16.16
// SkFixed value, and so avoiding rounding problems with float. Also, see the comment in SkFixed.h.
SkFixed float_round_to_fixed(float x) {}

// Convert a float to a uInt16Number, with 0.0 mapping go 0 and 1.0 mapping to |one|.
uint16_t float_to_uInt16Number(float x, uint16_t one) {}

// The uInt16Number used by curveType has 1.0 map to 0xFFFF. See section "10.6. curveType".
constexpr uint16_t kOne16CurveType =;

// The uInt16Number used to encoude XYZ values has 1.0 map to 0x8000. See section "6.3.4.2 General
// PCS encoding" and Table 11.
constexpr uint16_t kOne16XYZ =;

struct ICCHeader {};

sk_sp<SkData> write_xyz_tag(float x, float y, float z) {}

sk_sp<SkData> write_matrix(const skcms_Matrix3x4* matrix) {}

bool nearly_equal(float x, float y) {}

bool nearly_equal(const skcms_TransferFunction& u,
                  const skcms_TransferFunction& v) {}

bool nearly_equal(const skcms_Matrix3x3& u, const skcms_Matrix3x3& v) {}

constexpr uint32_t kCICPPrimariesSRGB =;
constexpr uint32_t kCICPPrimariesP3 =;
constexpr uint32_t kCICPPrimariesRec2020 =;

uint32_t get_cicp_primaries(const skcms_Matrix3x3& toXYZD50) {}

constexpr uint32_t kCICPTrfnSRGB =;
constexpr uint32_t kCICPTrfn2Dot2 =;
constexpr uint32_t kCICPTrfnLinear =;
constexpr uint32_t kCICPTrfnPQ =;
constexpr uint32_t kCICPTrfnHLG =;

uint32_t get_cicp_trfn(const skcms_TransferFunction& fn) {}

std::string get_desc_string(const skcms_TransferFunction& fn,
                            const skcms_Matrix3x3& toXYZD50) {}

sk_sp<SkData> write_text_tag(const char* text) {}

// Write a CICP tag.
sk_sp<SkData> write_cicp_tag(const skcms_CICP& cicp) {}

constexpr float kToneMapInputMax =;
constexpr float kToneMapOutputMax =;

// Scalar tone map gain function.
float tone_map_gain(float x) {}

// Scalar tone map inverse function
float tone_map_inverse(float y) {}

// Evaluate PQ and HLG transfer functions without tonemapping. The maximum returned value is
// kToneMapInputMax.
float hdr_trfn_eval(const skcms_TransferFunction& fn, float x) {}

// Write a lookup table based 1D curve.
sk_sp<SkData> write_trc_tag(const skcms_Curve& trc) {}

sk_sp<SkData> write_clut(const uint8_t* grid_points, const uint8_t* grid_16) {}

// Write an A2B or B2A tag.
sk_sp<SkData> write_mAB_or_mBA_tag(uint32_t type,
                                   const skcms_Curve* b_curves,
                                   const skcms_Curve* a_curves,
                                   const uint8_t* grid_points,
                                   const uint8_t* grid_16,
                                   const skcms_Curve* m_curves,
                                   const skcms_Matrix3x4* matrix) {}

}  // namespace

sk_sp<SkData> SkWriteICCProfile(const skcms_ICCProfile* profile, const char* desc) {}

sk_sp<SkData> SkWriteICCProfile(const skcms_TransferFunction& fn, const skcms_Matrix3x3& toXYZD50) {}