[Webkit-unassigned] [Bug 27933] SVG Filter premultiplied color support for getImageDate/putImageData

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 12 12:59:20 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=27933





--- Comment #12 from Brett Wilson (Google) <brettw at chromium.org>  2009-08-12 12:59:18 PDT ---
(From update of attachment 34651)
> Index: WebCore/platform/graphics/skia/SkiaUtils.cpp
> ===================================================================
> --- WebCore/platform/graphics/skia/SkiaUtils.cpp	(revision 47098)
> +++ WebCore/platform/graphics/skia/SkiaUtils.cpp	(working copy)
> @@ -80,7 +80,7 @@ static U8CPU InvScaleByte(U8CPU componen
>      return (component * scale + 0x8000) >> 16;
>  }
>  
> -SkColor SkPMColorToColor(SkPMColor pm)
> +SkColor SkUMColorToColor(SkPMColor pm)
>  {
>      if (0 == pm)
>          return 0;
> @@ -94,6 +94,17 @@ SkColor SkPMColorToColor(SkPMColor pm)
>                            InvScaleByte(SkGetPackedB32(pm), scale));
>  }
>  
> +SkColor SkPMColorToColor(SkPMColor pm)
> +{
> +    if (0 == pm)
> +        return 0;
> +    
> +    return SkColorSetARGB(SkGetPackedA32(pm),
> +                          SkGetPackedR32(pm),
> +                          SkGetPackedG32(pm),
> +                          SkGetPackedB32(pm));
> +}


It seems like you have the name of this function backwards. UMColor->Color
should just be re-ordering the bytes, PMColor->Color needs scaling.

Also, having SKUMColorToColor take a PMColor argument is a bit confusing. I
actually think writing it out like this is easier to follow, even though it
looks longer:

unsigned char* destPixel = &destRow[x * 4];
if (multiplied == Unmultiplied) {
    SkColor color = SkPMColorToColor(srcRow[x]);
    destPixel[0] = SkColorGetR(color);
    destPixel[1] = SkColorGetG(color);
    destPixel[2] = SkColorGetB(color);
    destPixel[3] = SkColorGetA(color);
} else {
    // Input and output are both pre-multiplied, we just need to re-arrange the
bytes from the bitmap format to RGBA.
    destPixel[0] = SkGetPackedR32(srcRow[x]);
    destPixel[1] = SkGetPackedG32(srcRow[x]);
    destPixel[2] = SkGetPackedB32(srcRow[x]);
    destPixel[3] = SkGetPackedA32(srcRow[x]);
}

When we want pre-multiplied case, we just need to re-arrange the output. Having
the extra function in there (especially one that takes the "wrong" type) makes
this harder to see.

Brett

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list