[Impeller] Remove unused ColorHSB. (flutter/engine#54659)

I didn't realize I hadn't cleaned this up. We've never needed it in Impeller.
This commit is contained in:
Chinmay Garde
2024-08-20 20:47:19 -07:00
committed by GitHub
parent 3452638b57
commit bc6d7fa164
2 changed files with 0 additions and 112 deletions

View File

@@ -49,83 +49,6 @@ const char* BlendModeToString(BlendMode blend_mode) {
blend_mode)];
}
ColorHSB ColorHSB::FromRGB(Color rgb) {
Scalar R = rgb.red;
Scalar G = rgb.green;
Scalar B = rgb.blue;
Scalar v = 0.0;
Scalar x = 0.0;
Scalar f = 0.0;
int64_t i = 0;
x = fmin(R, G);
x = fmin(x, B);
v = fmax(R, G);
v = fmax(v, B);
if (v == x) {
return ColorHSB(0.0, 0.0, v, rgb.alpha);
}
f = (R == x) ? G - B : ((G == x) ? B - R : R - G);
i = (R == x) ? 3 : ((G == x) ? 5 : 1);
return ColorHSB(((i - f / (v - x)) / 6.0), (v - x) / v, v, rgb.alpha);
}
Color ColorHSB::ToRGBA() const {
Scalar h = hue * 6.0;
Scalar s = saturation;
Scalar v = brightness;
Scalar m = 0.0;
Scalar n = 0.0;
Scalar f = 0.0;
int64_t i = 0;
if (h == 0) {
h = 0.01;
}
if (h == 0.0) {
return Color(v, v, v, alpha);
}
i = static_cast<int64_t>(floor(h));
f = h - i;
if (!(i & 1)) {
f = 1 - f;
}
m = v * (1 - s);
n = v * (1 - s * f);
switch (i) {
case 6:
case 0:
return Color(v, n, m, alpha);
case 1:
return Color(n, v, m, alpha);
case 2:
return Color(m, v, n, alpha);
case 3:
return Color(m, n, v, alpha);
case 4:
return Color(n, m, v, alpha);
case 5:
return Color(v, m, n, alpha);
}
return Color(0, 0, 0, alpha);
}
Color::Color(const ColorHSB& hsbColor) : Color(hsbColor.ToRGBA()) {}
Color::Color(const Vector4& value)
: red(value.x), green(value.y), blue(value.z), alpha(value.w) {}

View File

@@ -49,7 +49,6 @@
namespace impeller {
struct ColorHSB;
struct Vector4;
enum class YUVColorSpace { kBT601LimitedRange, kBT601FullRange };
@@ -144,8 +143,6 @@ struct Color {
constexpr Color() {}
explicit Color(const ColorHSB& hsbColor);
explicit Color(const Vector4& value);
constexpr Color(Scalar r, Scalar g, Scalar b, Scalar a)
@@ -920,38 +917,6 @@ constexpr inline Color operator/(T value, const Color& c) {
std::string ColorToString(const Color& color);
/**
* Represents a color by its constituent hue, saturation, brightness and alpha
*/
struct ColorHSB {
/**
* The hue of the color (0 to 1)
*/
Scalar hue;
/**
* The saturation of the color (0 to 1)
*/
Scalar saturation;
/**
* The brightness of the color (0 to 1)
*/
Scalar brightness;
/**
* The alpha of the color (0 to 1)
*/
Scalar alpha;
constexpr ColorHSB(Scalar h, Scalar s, Scalar b, Scalar a)
: hue(h), saturation(s), brightness(b), alpha(a) {}
static ColorHSB FromRGB(Color rgb);
Color ToRGBA() const;
};
static_assert(sizeof(Color) == 4 * sizeof(Scalar));
} // namespace impeller