Fix premul alpha problems w/matrix convolution filter, and re-enable the bench.

http://codereview.appspot.com/6541043/



git-svn-id: http://skia.googlecode.com/svn/trunk@5610 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
senorblanco@chromium.org 2012-09-20 17:59:49 +00:00
parent fc641d09e5
commit cc9471c36d
2 changed files with 6 additions and 10 deletions

View File

@ -20,8 +20,7 @@
'../bench/InterpBench.cpp',
'../bench/MathBench.cpp',
'../bench/MatrixBench.cpp',
#Disable this benchmark until non-premul alpha problems are figured out
#'../bench/MatrixConvolutionBench.cpp',
'../bench/MatrixConvolutionBench.cpp',
'../bench/MemoryBench.cpp',
'../bench/MorphologyBench.cpp',
'../bench/MutexBench.cpp',

View File

@ -113,14 +113,11 @@ void SkMatrixConvolutionImageFilter::filterPixels(const SkBitmap& src, SkBitmap*
sumB += SkScalarMul(SkIntToScalar(SkGetPackedB32(s)), k);
}
}
int a = SkScalarFloorToInt(SkScalarMul(sumA, fGain) + fBias);
int r = SkScalarFloorToInt(SkScalarMul(sumR, fGain) + fBias);
int g = SkScalarFloorToInt(SkScalarMul(sumG, fGain) + fBias);
int b = SkScalarFloorToInt(SkScalarMul(sumB, fGain) + fBias);
*dptr++ = SkPackARGB32(SkClampMax(a, 255),
SkClampMax(r, 255),
SkClampMax(g, 255),
SkClampMax(b, 255));
int a = SkClampMax(SkScalarFloorToInt(SkScalarMul(sumA, fGain) + fBias), 255);
int r = SkClampMax(SkScalarFloorToInt(SkScalarMul(sumR, fGain) + fBias), a);
int g = SkClampMax(SkScalarFloorToInt(SkScalarMul(sumG, fGain) + fBias), a);
int b = SkClampMax(SkScalarFloorToInt(SkScalarMul(sumB, fGain) + fBias), a);
*dptr++ = SkPackARGB32(a, r, g, b);
}
}
}