зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1722031 - Fix RelativeLuminanceUtils::Adjust to not choke on blacks / zero components. r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D120722
This commit is contained in:
Родитель
3f0667829d
Коммит
01317e823b
|
@ -29,10 +29,13 @@ class RelativeLuminanceUtils {
|
||||||
float g = ComputeComponent(NS_GET_G(aColor));
|
float g = ComputeComponent(NS_GET_G(aColor));
|
||||||
float b = ComputeComponent(NS_GET_B(aColor));
|
float b = ComputeComponent(NS_GET_B(aColor));
|
||||||
float luminance = ComputeFromComponents(r, g, b);
|
float luminance = ComputeFromComponents(r, g, b);
|
||||||
float factor = aLuminance / luminance;
|
float factor = (aLuminance + 0.05f) / (luminance + 0.05f);
|
||||||
uint8_t r1 = DecomputeComponent(r * factor);
|
uint8_t r1 =
|
||||||
uint8_t g1 = DecomputeComponent(g * factor);
|
DecomputeComponent(std::max(0.0f, (r + 0.05f) * factor - 0.05f));
|
||||||
uint8_t b1 = DecomputeComponent(b * factor);
|
uint8_t g1 =
|
||||||
|
DecomputeComponent(std::max(0.0f, (g + 0.05f) * factor - 0.05f));
|
||||||
|
uint8_t b1 =
|
||||||
|
DecomputeComponent(std::max(0.0f, (b + 0.05f) * factor - 0.05f));
|
||||||
return NS_RGBA(r1, g1, b1, NS_GET_A(aColor));
|
return NS_RGBA(r1, g1, b1, NS_GET_A(aColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче