Bug 1477366 - Handle color space conversion for drop shadow filters with WebRender. r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D17089

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-01-21 20:01:02 +00:00
Родитель b6afde59b9
Коммит 2cc9e9df9e
3 изменённых файлов: 17 добавлений и 9 удалений

Просмотреть файл

@ -54,7 +54,7 @@ static const float glinearRGBTosRGBMap[256] = {
// c = n / 255
// c <= 0.04045f ? c / 12.92f : powf((c + 0.055f) / 1.055f, 2.4f)
static const float gsRGBToLinearRGBMap[256] = {
extern const float gsRGBToLinearRGBMap[256] = {
0.000f, 0.000f, 0.001f, 0.001f, 0.001f, 0.002f, 0.002f, 0.002f, 0.002f,
0.003f, 0.003f, 0.003f, 0.004f, 0.004f, 0.004f, 0.005f, 0.005f, 0.006f,
0.006f, 0.007f, 0.007f, 0.007f, 0.008f, 0.009f, 0.009f, 0.010f, 0.010f,

Просмотреть файл

@ -24,6 +24,8 @@ class FilterPrimitiveDescription;
DECLARE_USE_COPY_CONSTRUCTORS(mozilla::gfx::FilterPrimitiveDescription)
extern const float gsRGBToLinearRGBMap[256];
namespace mozilla {
namespace gfx {

Просмотреть файл

@ -150,14 +150,14 @@ bool nsFilterInstance::BuildWebRenderFilters(nsIFrame* aFilteredFrame,
return false;
}
bool primIsSrgb = primitive.OutputColorSpace() == gfx::ColorSpace::SRGB;
if (srgb && !primIsSrgb) {
bool previousSrgb = srgb;
bool primNeedsSrgb = primitive.InputColorSpace(0) == gfx::ColorSpace::SRGB;
if (srgb && !primNeedsSrgb) {
aWrFilters.AppendElement(wr::FilterOp::SrgbToLinear());
srgb = false;
} else if (!srgb && primIsSrgb) {
} else if (!srgb && primNeedsSrgb) {
aWrFilters.AppendElement(wr::FilterOp::LinearToSrgb());
srgb = true;
}
srgb = primitive.OutputColorSpace() == gfx::ColorSpace::SRGB;
const PrimitiveAttributes& attr = primitive.Attributes();
@ -237,8 +237,14 @@ bool nsFilterInstance::BuildWebRenderFilters(nsIFrame* aFilteredFrame,
wr::LayoutVector2D offset = {(float)shadow.mOffset.x,
(float)shadow.mOffset.y};
float radius = stdDev.width;
wr::FilterOp filterOp =
wr::FilterOp::DropShadow(offset, radius, wr::ToColorF(shadow.mColor));
Color color = shadow.mColor;
if (!primNeedsSrgb) {
color = Color(gsRGBToLinearRGBMap[uint8_t(color.r * 255)],
gsRGBToLinearRGBMap[uint8_t(color.g * 255)],
gsRGBToLinearRGBMap[uint8_t(color.b * 255)], color.a);
}
wr::FilterOp filterOp = wr::FilterOp::DropShadow(
offset, radius, wr::ToColorF(ToDeviceColor(color)));
aWrFilters.AppendElement(filterOp);
} else {
@ -256,7 +262,7 @@ bool nsFilterInstance::BuildWebRenderFilters(nsIFrame* aFilteredFrame,
// sRGB->linear->no-op->sRGB roundtrip introduces a slight error and we
// cannot add fuzziness to the test.
Unused << aWrFilters.PopLastElement();
srgb = !srgb;
srgb = previousSrgb;
}
if (!filterIsNoop) {