fix the visual diff of raster vs gpu -- vertices_80. The sw-raster is correct, all images are blurry.

While some images generated by gpu doesn't respect SkPaint's alpha value.

In gpu path, when pass SkPaint's alpha and color to GrPaint by SkPaint2GrPaintNoShader,
either alpha or colors can't not be passed. We can't pass both of them by the API.
Premultiply paint's alpha to colors's alpha in drawVertices, and pass colors to GrPaint.
The rendering result will respect colors in drawVertices, and the alpha value set in SkPaint as well.

BUG=skia:2592
R=bsalomon@google.com

Author: yunchao.he@intel.com

Review URL: https://codereview.chromium.org/292943002

git-svn-id: http://skia.googlecode.com/svn/trunk@14863 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-05-23 08:09:26 +00:00
parent 7693dbf46e
commit c93e68161f
2 changed files with 10 additions and 1 deletions

View File

@ -68,3 +68,7 @@ shadertext2
# Changing this GM to add more test cases (failing at the moment)
# Need to rebaseline when they are fixed
stroketext
# yunchao: https://codereview.chromium.org/292943002/
# changed the rendering result of this gm case to respect paint's alpha
vertices_80

View File

@ -1649,8 +1649,13 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
if (NULL != colors) {
// need to convert byte order and from non-PM to PM
convertedColors.reset(vertexCount);
SkColor color;
for (int i = 0; i < vertexCount; ++i) {
convertedColors[i] = SkColor2GrColor(colors[i]);
color = colors[i];
if (paint.getAlpha() != 255) {
color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), paint.getAlpha()));
}
convertedColors[i] = SkColor2GrColor(color);
}
colors = convertedColors.get();
}