7#include "core/fxge/cfx_color.h"
11#include "third_party/base/notreached.h"
16 "color type values must be ordered");
18 "color type values must be ordered");
20 "color type values must be ordered");
24bool InRange(
float comp) {
25 return comp >= 0.0f && comp <= 1.0f;
28CFX_Color ConvertCMYK2GRAY(
float dC,
float dM,
float dY,
float dK) {
29 if (!InRange(dC) || !InRange(dM) || !InRange(dY) || !InRange(dK))
33 1.0f -
std::min(1.0f, 0.3f * dC + 0.59f * dM + 0.11f * dY + dK));
48CFX_Color ConvertRGB2GRAY(
float dR,
float dG,
float dB) {
49 if (!InRange(dR) || !InRange(dG) || !InRange(dB))
54CFX_Color ConvertCMYK2RGB(
float dC,
float dM,
float dY,
float dK) {
55 if (!InRange(dC) || !InRange(dM) || !InRange(dY) || !InRange(dK))
58 1.0f -
std::min(1.0f, dM + dK),
59 1.0f -
std::min(1.0f, dY + dK));
62CFX_Color ConvertRGB2CMYK(
float dR,
float dG,
float dB) {
63 if (!InRange(dR) || !InRange(dG) || !InRange(dB))
70 std::min(c,
std::min(m, y)));
86 switch (nConvertColorType) {
90 NOTREACHED_NORETURN();
100 switch (nConvertColorType) {
107 NOTREACHED_NORETURN();
114 switch (nConvertColorType) {
124 NOTREACHED_NORETURN();
156 static_cast<int32_t>(ret
.fColor3 * 255)
);
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
CFX_Color operator/(float fColorDivide) const
CFX_Color operator-(float fColorSub) const
CFX_Color ConvertColorType(Type nConvertColorType) const
CFX_Color & operator=(const CFX_Color &that)=default
FX_COLORREF ToFXColor(int32_t nTransparency) const
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)