#include "core/fpdfapi/page/cpdf_colorspace.h"
#include <math.h>
#include <stdint.h>
#include <algorithm>
#include <array>
#include <limits>
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>
#include "core/fpdfapi/page/cpdf_devicecs.h"
#include "core/fpdfapi/page/cpdf_docpagedata.h"
#include "core/fpdfapi/page/cpdf_function.h"
#include "core/fpdfapi/page/cpdf_iccprofile.h"
#include "core/fpdfapi/page/cpdf_indexedcs.h"
#include "core/fpdfapi/page/cpdf_pattern.h"
#include "core/fpdfapi/page/cpdf_patterncs.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_name.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcodec/icc/icc_transform.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/containers/contains.h"
#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_2d_size.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/maybe_owned.h"
#include "core/fxcrt/notreached.h"
#include "core/fxcrt/scoped_set_insertion.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxcrt/zip.h"
#include "core/fxge/dib/fx_dib.h"
namespace {
constexpr auto kSRGBSamples1 = …;
constexpr auto kSRGBSamples2 = …;
constexpr size_t kBlackWhitePointCount = …;
void GetDefaultBlackPoint(pdfium::span<float> pPoints) { … }
void GetBlackPoint(const CPDF_Dictionary* pDict, pdfium::span<float> pPoints) { … }
bool GetWhitePoint(const CPDF_Dictionary* pDict, pdfium::span<float> pPoints) { … }
class CPDF_CalGray final : public CPDF_ColorSpace { … };
class CPDF_CalRGB final : public CPDF_ColorSpace { … };
class CPDF_LabCS final : public CPDF_ColorSpace { … };
class CPDF_ICCBasedCS final : public CPDF_BasedCS { … };
class CPDF_SeparationCS final : public CPDF_BasedCS { … };
class CPDF_DeviceNCS final : public CPDF_BasedCS { … };
class Vector_3by1 { … };
class Matrix_3by3 { … };
float RGB_Conversion(float colorComponent) { … }
FX_RGB_STRUCT<float> XYZ_to_sRGB(float X, float Y, float Z) { … }
FX_RGB_STRUCT<float> XYZ_to_sRGB_WhitePoint(float X,
float Y,
float Z,
float Xw,
float Yw,
float Zw) { … }
class StockColorSpaces { … };
StockColorSpaces* g_stock_colorspaces = …;
}
PatternValue::PatternValue() = default;
PatternValue::PatternValue(const PatternValue& that) = default;
PatternValue::~PatternValue() = default;
void PatternValue::SetComps(pdfium::span<const float> comps) { … }
void CPDF_ColorSpace::InitializeGlobals() { … }
void CPDF_ColorSpace::DestroyGlobals() { … }
RetainPtr<CPDF_ColorSpace> CPDF_ColorSpace::GetStockCS(Family family) { … }
RetainPtr<CPDF_ColorSpace> CPDF_ColorSpace::GetStockCSForName(
const ByteString& name) { … }
RetainPtr<CPDF_ColorSpace> CPDF_ColorSpace::Load(
CPDF_Document* pDoc,
const CPDF_Object* pObj,
std::set<const CPDF_Object*>* pVisited) { … }
RetainPtr<CPDF_ColorSpace> CPDF_ColorSpace::AllocateColorSpace(
ByteStringView bsFamilyName) { … }
uint32_t CPDF_ColorSpace::ComponentsForFamily(Family family) { … }
std::vector<float> CPDF_ColorSpace::CreateBufAndSetDefaultColor() const { … }
uint32_t CPDF_ColorSpace::ComponentCount() const { … }
void CPDF_ColorSpace::GetDefaultValue(int iComponent,
float* value,
float* min,
float* max) const { … }
void CPDF_ColorSpace::TranslateImageLine(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int pixels,
int image_width,
int image_height,
bool bTransMask) const { … }
void CPDF_ColorSpace::EnableStdConversion(bool bEnabled) { … }
bool CPDF_ColorSpace::IsNormal() const { … }
const CPDF_PatternCS* CPDF_ColorSpace::AsPatternCS() const { … }
const CPDF_IndexedCS* CPDF_ColorSpace::AsIndexedCS() const { … }
CPDF_ColorSpace::CPDF_ColorSpace(Family family) : … { … }
CPDF_ColorSpace::~CPDF_ColorSpace() = default;
void CPDF_ColorSpace::SetComponentsForStockCS(uint32_t nComponents) { … }
CPDF_CalGray::CPDF_CalGray() : … { … }
CPDF_CalGray::~CPDF_CalGray() = default;
uint32_t CPDF_CalGray::v_Load(CPDF_Document* pDoc,
const CPDF_Array* pArray,
std::set<const CPDF_Object*>* pVisited) { … }
std::optional<FX_RGB_STRUCT<float>> CPDF_CalGray::GetRGB(
pdfium::span<const float> pBuf) const { … }
void CPDF_CalGray::TranslateImageLine(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int pixels,
int image_width,
int image_height,
bool bTransMask) const { … }
CPDF_CalRGB::CPDF_CalRGB() : … { … }
CPDF_CalRGB::~CPDF_CalRGB() = default;
uint32_t CPDF_CalRGB::v_Load(CPDF_Document* pDoc,
const CPDF_Array* pArray,
std::set<const CPDF_Object*>* pVisited) { … }
std::optional<FX_RGB_STRUCT<float>> CPDF_CalRGB::GetRGB(
pdfium::span<const float> pBuf) const { … }
void CPDF_CalRGB::TranslateImageLine(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int pixels,
int image_width,
int image_height,
bool bTransMask) const { … }
CPDF_LabCS::CPDF_LabCS() : … { … }
CPDF_LabCS::~CPDF_LabCS() = default;
void CPDF_LabCS::GetDefaultValue(int iComponent,
float* value,
float* min,
float* max) const { … }
uint32_t CPDF_LabCS::v_Load(CPDF_Document* pDoc,
const CPDF_Array* pArray,
std::set<const CPDF_Object*>* pVisited) { … }
std::optional<FX_RGB_STRUCT<float>> CPDF_LabCS::GetRGB(
pdfium::span<const float> pBuf) const { … }
void CPDF_LabCS::TranslateImageLine(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int pixels,
int image_width,
int image_height,
bool bTransMask) const { … }
CPDF_ICCBasedCS::CPDF_ICCBasedCS() : … { … }
CPDF_ICCBasedCS::~CPDF_ICCBasedCS() = default;
uint32_t CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc,
const CPDF_Array* pArray,
std::set<const CPDF_Object*>* pVisited) { … }
std::optional<FX_RGB_STRUCT<float>> CPDF_ICCBasedCS::GetRGB(
pdfium::span<const float> pBuf) const { … }
void CPDF_ICCBasedCS::TranslateImageLine(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int pixels,
int image_width,
int image_height,
bool bTransMask) const { … }
bool CPDF_ICCBasedCS::IsNormal() const { … }
bool CPDF_ICCBasedCS::FindAlternateProfile(
CPDF_Document* pDoc,
const CPDF_Dictionary* pDict,
std::set<const CPDF_Object*>* pVisited,
uint32_t nExpectedComponents) { … }
RetainPtr<CPDF_ColorSpace> CPDF_ICCBasedCS::GetStockAlternateProfile(
uint32_t nComponents) { … }
std::vector<float> CPDF_ICCBasedCS::GetRanges(const CPDF_Dictionary* pDict,
uint32_t nComponents) { … }
CPDF_SeparationCS::CPDF_SeparationCS() : … { … }
CPDF_SeparationCS::~CPDF_SeparationCS() = default;
void CPDF_SeparationCS::GetDefaultValue(int iComponent,
float* value,
float* min,
float* max) const { … }
uint32_t CPDF_SeparationCS::v_Load(CPDF_Document* pDoc,
const CPDF_Array* pArray,
std::set<const CPDF_Object*>* pVisited) { … }
std::optional<FX_RGB_STRUCT<float>> CPDF_SeparationCS::GetRGB(
pdfium::span<const float> pBuf) const { … }
CPDF_DeviceNCS::CPDF_DeviceNCS() : … { … }
CPDF_DeviceNCS::~CPDF_DeviceNCS() = default;
void CPDF_DeviceNCS::GetDefaultValue(int iComponent,
float* value,
float* min,
float* max) const { … }
uint32_t CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc,
const CPDF_Array* pArray,
std::set<const CPDF_Object*>* pVisited) { … }
std::optional<FX_RGB_STRUCT<float>> CPDF_DeviceNCS::GetRGB(
pdfium::span<const float> pBuf) const { … }