fix uniform buffer size, scale by paint alpha

Brace initilaization of a std::vector was starting our uniform buffer
out as a single byte, holding sizeof(Uniforms).  I meant it to be
sizeof(Uniform) bytes, all zero...

That's fixed here, and was why scaling by paint alpha wasn't working.

Change-Id: Iad30d701aa175c74c9c5aaed8baf8279479188b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251753
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2019-10-30 12:39:32 -05:00 committed by Skia Commit-Bot
parent ac8a16ca52
commit e2333d7714

View File

@ -191,14 +191,11 @@ namespace {
key.colorSpace.get(),
uniforms, sizeof(Uniforms),
&src.r, &src.g, &src.b, &src.a));
// TODO: skip when paint is opaque.
if (false) {
src.r = scale_unorm8(src.r, paint_alpha);
src.g = scale_unorm8(src.g, paint_alpha);
src.b = scale_unorm8(src.b, paint_alpha);
src.a = scale_unorm8(src.a, paint_alpha);
}
src.r = scale_unorm8(src.r, paint_alpha);
src.g = scale_unorm8(src.g, paint_alpha);
src.b = scale_unorm8(src.b, paint_alpha);
src.a = scale_unorm8(src.a, paint_alpha);
}
if (key.coverage == Coverage::Mask3D) {
@ -330,6 +327,7 @@ namespace {
device.refColorSpace(),
paint.refShader(),
}
, fUniforms(sizeof(Uniforms))
{
// Color filters have been folded back into shader and/or paint color by now.
SkASSERT(!paint.getColorFilter());
@ -370,7 +368,7 @@ namespace {
private:
SkPixmap fDevice; // TODO: can this be const&?
const Key fKey;
std::vector<uint8_t> fUniforms{sizeof(Uniforms)};
std::vector<uint8_t> fUniforms;
skvm::Program fBlitH,
fBlitAntiH,
fBlitMaskA8,