20#define _IMPELLER_ASSERT_BLEND_MODE(blend_mode) \
21 auto enum_##blend_mode = static_cast<std::underlying_type_t<BlendMode>>( \
22 BlendMode::k##blend_mode); \
23 if (i != enum_##blend_mode) { \
29 std::underlying_type_t<BlendMode>
i = 0;
40 "IMPELLER_FOR_EACH_BLEND_MODE must match impeller::BlendMode.");
42#define _IMPELLER_BLEND_MODE_NAME_LIST(blend_mode) #blend_mode,
74 i = (
R ==
x) ? 3 : ((
G ==
x) ? 5 : 1);
98 i =
static_cast<int64_t
>(
floor(
h));
210 src.Premultiply() * (1.0f -
dst.alpha);
229 blend_func(
dst.green,
src.green),
230 blend_func(
dst.blue,
src.blue));
237 switch (blend_mode) {
246 return (
src.Premultiply() +
dst.Premultiply() * (1 -
src.alpha))
250 return (
dst.Premultiply() +
src.Premultiply() * (1 -
dst.alpha))
254 return (
src.Premultiply() *
dst.alpha).Unpremultiply();
257 return (
dst.Premultiply() *
src.alpha).Unpremultiply();
260 return (
src.Premultiply() * (1 -
dst.alpha)).Unpremultiply();
263 return (
dst.Premultiply() * (1 -
src.alpha)).Unpremultiply();
266 return (
src.Premultiply() *
dst.alpha +
267 dst.Premultiply() * (1 -
src.alpha))
271 return (
dst.Premultiply() *
src.alpha +
272 src.Premultiply() * (1 -
dst.alpha))
276 return (
src.Premultiply() * (1 -
dst.alpha) +
277 dst.Premultiply() * (1 -
src.alpha))
281 return (
Min(
src.Premultiply() +
dst.Premultiply(), 1)).Unpremultiply();
284 return (
src.Premultiply() *
dst.Premultiply()).Unpremultiply();
287 return s +
d -
s *
d;
294 Vector3 screen = screen_src +
s - screen_src *
s;
329 Vector3 screen = screen_src +
d - screen_src *
d;
343 d + (2.0 *
s - 1.0) * (
D -
d),
349 return (
d -
s).Abs();
353 return d +
s - 2.0f *
d *
s;
379 auto* c = color_matrix.
array;
389 static auto conversion = [](
Scalar component) {
390 if (component <= 0.0031308) {
391 return component * 12.92;
393 return 1.055 * pow(component, (1.0 / 2.4)) - 0.055;
400 static auto conversion = [](
Scalar component) {
401 if (component <= 0.04045) {
402 return component / 12.92;
404 return pow((component + 0.055) / 1.055, 2.4);
411 return SPrintF(
"R=%.1f,G=%.1f,B=%.1f,A=%.1f",
#define _IMPELLER_ASSERT_BLEND_MODE(blend_mode)
#define _IMPELLER_BLEND_MODE_NAME_LIST(blend_mode)
#define IMPELLER_FOR_EACH_BLEND_MODE(V)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Dart_NativeFunction function
static void luminosity(float dr, float dg, float db, float *sr, float *sg, float *sb)
static void saturation(float dr, float dg, float db, float *sr, float *sg, float *sb)
static float max(float r, float g, float b)
static float lum(float r, float g, float b)
static float min(float r, float g, float b)
SK_API sk_sp< SkShader > Color(SkColor)
static constexpr const char * kBlendModeNames[]
static constexpr Color Min(Color c, float threshold)
static constexpr bool ValidateBlendModes()
static constexpr Vector3 SetSaturation(Vector3 color, Scalar saturation)
constexpr float kEhCloseEnough
static constexpr Scalar Saturation(Vector3 color)
static constexpr Vector3 ToRGB(Color color)
const char * BlendModeToString(BlendMode blend_mode)
std::string SPrintF(const char *format,...)
static constexpr Color FromRGB(Vector3 color, Scalar alpha)
static constexpr Vector3 SetLuminosity(Vector3 color, Scalar luminosity)
static constexpr Color ApplyBlendedColor(Color dst, Color src, Vector3 blend_result)
static constexpr Color DoColorBlend(Color dst, Color src, const std::function< Vector3(Vector3, Vector3)> &blend_rgb_func)
std::string ColorToString(const Color &color)
static constexpr Color DoColorBlendComponents(Color dst, Color src, const std::function< Scalar(Scalar, Scalar)> &blend_func)
static constexpr Vector3 ComponentChoose(Vector3 a, Vector3 b, Vector3 value, Scalar cutoff)
static constexpr Vector3 ClipColor(Vector3 color)
static constexpr Scalar Luminosity(Vector3 color)
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
SIN Vec< N, float > floor(const Vec< N, float > &x)
static ColorHSB FromRGB(Color rgb)
constexpr ColorHSB(Scalar h, Scalar s, Scalar b, Scalar a)
static constexpr Color BlackTransparent()
Color LinearToSRGB() const
Convert the color from linear space to sRGB space.
Color ApplyColorMatrix(const ColorMatrix &color_matrix) const
A color filter that transforms colors through a 4x5 color matrix.
constexpr Color Unpremultiply() const
constexpr Color Premultiply() const
Color SRGBToLinear() const
Convert the color from sRGB space to linear space.
Color Blend(Color source, BlendMode blend_mode) const
Blends an unpremultiplied destination color into a given unpremultiplied source color to form a new u...