fix SkMatrixConvolutionImageFilter unpremul
Caveat... I have no idea what this filter does. I just looked at some code that appeared to be unpremultiplying in a dodgy way and rewrote it to be simpler. This fixes the GM on Mac. PS2 unpremultiplies in place, and leaves the bitmap tagged premul. This feels funny, but I think it's consistent with the old behavior. I want to see if this is why the layout tests fail. PS3 reverts an unimportant diff. Bug: skia:9784 Change-Id: Id5ddbc6424833706d21f279f6adfce71f6d9f9e8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264577 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
3c9d77622c
commit
7dd6098747
@ -359,29 +359,6 @@ void SkMatrixConvolutionImageFilterImpl::filterBorderPixels(const SkBitmap& src,
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: This should be refactored to SkImageFilterUtils for
|
||||
// use by other filters. For now, we assume the input is always
|
||||
// premultiplied and unpremultiply it
|
||||
static SkBitmap unpremultiply_bitmap(const SkBitmap& src) {
|
||||
if (!src.getPixels()) {
|
||||
return SkBitmap();
|
||||
}
|
||||
|
||||
const SkImageInfo info = SkImageInfo::MakeN32(src.width(), src.height(), src.alphaType());
|
||||
SkBitmap result;
|
||||
if (!result.tryAllocPixels(info)) {
|
||||
return SkBitmap();
|
||||
}
|
||||
for (int y = 0; y < src.height(); ++y) {
|
||||
const uint32_t* srcRow = src.getAddr32(0, y);
|
||||
uint32_t* dstRow = result.getAddr32(0, y);
|
||||
for (int x = 0; x < src.width(); ++x) {
|
||||
dstRow[x] = SkUnPreMultiply::PMColorToColor(srcRow[x]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
static GrTextureDomain::Mode convert_tilemodes(SkTileMode tileMode) {
|
||||
@ -489,7 +466,10 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilterImpl::onFilterImage(const Co
|
||||
}
|
||||
|
||||
if (!fConvolveAlpha && !inputBM.isOpaque()) {
|
||||
inputBM = unpremultiply_bitmap(inputBM);
|
||||
// This leaves the bitmap tagged as premul, which seems weird to me,
|
||||
// but is consistent with old behavior.
|
||||
inputBM.readPixels(inputBM.info().makeAlphaType(kUnpremul_SkAlphaType),
|
||||
inputBM.getPixels(), inputBM.rowBytes(), 0,0);
|
||||
}
|
||||
|
||||
if (!inputBM.getPixels()) {
|
||||
|
Loading…
Reference in New Issue
Block a user