5#ifndef FLUTTER_DISPLAY_LIST_DL_COLOR_H_
6#define FLUTTER_DISPLAY_LIST_DL_COLOR_H_
30 : alpha_(toF((
argb >> 24) & 0xff)),
31 red_(toF((
argb >> 16) & 0xff)),
32 green_(toF((
argb >> 8) & 0xff)),
33 blue_(toF((
argb >> 0) & 0xff)),
40 : alpha_(
std::clamp(alpha, 0.0f, 1.0f)),
44 color_space_(colorspace) {}
52 return ARGB(a, r, g, b);
97 constexpr bool isOpaque()
const {
return alpha_ >= 1.f; }
102 inline int getAlpha()
const {
return toC(alpha_); }
105 inline int getRed()
const {
return toC(red_); }
108 inline int getGreen()
const {
return toC(green_); }
111 inline int getBlue()
const {
return toC(blue_); }
121 return DlColor((
argb() & 0x00FFFFFF) | (alpha << 24));
124 return DlColor((
argb() & 0xFF00FFFF) | (red << 16));
127 return DlColor((
argb() & 0xFFFF00FF) | (green << 8));
130 return DlColor((
argb() & 0xFFFFFF00) | (blue << 0));
133 return DlColor(alpha, red_, green_, blue_, color_space_);
136 return DlColor(alpha_, red, green_, blue_, color_space_);
139 return DlColor(alpha_, red_, green, blue_, color_space_);
142 return DlColor(alpha_, red_, green_, blue, color_space_);
152 : opacity >= 1 ? *this
162 return toC(alpha_) << 24 |
173 return color_space_ == other.color_space_ &&
174 std::abs(alpha_ - other.alpha_) < delta &&
175 std::abs(red_ - other.red_) < delta &&
176 std::abs(green_ - other.green_) < delta &&
177 std::abs(blue_ - other.blue_) < delta;
180 return alpha_ == other.alpha_ && red_ == other.red_ &&
181 green_ == other.green_ && blue_ == other.blue_ &&
182 color_space_ == other.color_space_;
192 static constexpr DlScalar toF(uint8_t comp) {
return comp * (1.0f / 255); }
193 static inline uint8_t toC(
DlScalar fComp) {
return std::round(fComp * 255); }
impeller::Scalar DlScalar
static constexpr DlColor kMagenta()
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor kDarkMagenta()
DlColor withBlue(uint8_t blue) const
constexpr DlColor(uint32_t argb)
static constexpr DlColor RGBA(DlScalar r, DlScalar g, DlScalar b, DlScalar a)
Construct a 32 bit color from floating point R, G, B, and A color channels.
static constexpr DlColor kBlack()
static constexpr DlColor kCrimson()
static constexpr DlColor kMaroon()
static constexpr DlColor ARGB(DlScalar a, DlScalar r, DlScalar g, DlScalar b)
Construct a 32 bit color from floating point A, R, G, and B color channels.
static constexpr DlScalar toOpacity(uint8_t alpha)
static constexpr DlColor kAqua()
static constexpr DlColor kYellow()
static constexpr DlColor kPurple()
static constexpr DlColor kFuchsia()
static constexpr DlColor kLightGrey()
static constexpr DlColor kChartreuse()
constexpr DlColorSpace getColorSpace() const
static constexpr DlColor kCornflowerBlue()
bool operator==(DlColor const &other) const
static constexpr DlColor kDarkGreen()
static constexpr DlColor kAliceBlue()
constexpr DlScalar getRedF() const
constexpr DlScalar getAlphaF() const
DlColor withColorSpace(DlColorSpace color_space) const
constexpr DlScalar getBlueF() const
static constexpr DlColor kMidGrey()
constexpr DlColor withAlphaF(float alpha) const
constexpr DlScalar getGreenF() const
static constexpr DlColor kTransparent()
static uint8_t toAlpha(DlScalar opacity)
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
constexpr DlColor(DlScalar alpha, DlScalar red, DlScalar green, DlScalar blue, DlColorSpace colorspace)
static constexpr DlColor kOrange()
constexpr DlColor withRedF(float red) const
constexpr DlColor withGreenF(float green) const
constexpr DlColor withBlueF(float blue) const
DlColor withGreen(uint8_t green) const
constexpr bool isTransparent() const
static constexpr DlColor kDarkGrey()
static constexpr DlColor kCyan()
static constexpr DlColor kSkyBlue()
static constexpr DlColor kLimeGreen()
static constexpr DlColor kOrangeRed()
static constexpr DlColor kGreenYellow()
bool isClose(DlColor const &other, DlScalar delta=1.0f/256.0f)
DlColor withRed(uint8_t red) const
constexpr bool isOpaque() const
DlColor withAlpha(uint8_t alpha) const
constexpr DlColor modulateOpacity(DlScalar opacity) const