2010-12-13 Noel Gordon <noel.gordon@gmail.com>

        Reviewed by Eric Seidel.

        [chromium] Reduce canvas.toDataURL("image/jpeg") run-time cost by 10%
        https://bugs.webkit.org/show_bug.cgi?id=50804

        Follow on from r73173, unroll the SkUnPreMultiply::PMColorToColor() call
        viz., compute the unpremultiplatcion in-place. This reduces the run-time
        cost of jpeg encoding by 10-15% for my image test set.

        No new tests: canvas.toDataURL() is covered by existing tests.

        * platform/image-encoders/skia/JPEGImageEncoder.cpp:
        (WebCore::preMultipliedBGRAtoRGB):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73890 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 240961ae
2010-12-13 Noel Gordon <noel.gordon@gmail.com>
Reviewed by Eric Seidel.
[chromium] Reduce canvas.toDataURL("image/jpeg") run-time cost by 10%
https://bugs.webkit.org/show_bug.cgi?id=50804
Follow on from r73173, unroll the SkUnPreMultiply::PMColorToColor() call
viz., compute the unpremultiplatcion in-place. This reduces the run-time
cost of jpeg encoding by 10-15% for my image test set.
No new tests: canvas.toDataURL() is covered by existing tests.
* platform/image-encoders/skia/JPEGImageEncoder.cpp:
(WebCore::preMultipliedBGRAtoRGB):
2010-12-13 Helder Correia <helder@sencha.com>
Reviewed by Eric Seidel.
......
......@@ -34,6 +34,7 @@
#include "IntSize.h"
#include "SkBitmap.h"
#include "SkUnPreMultiply.h"
#include "SkColorPriv.h"
extern "C" {
#include <stdio.h> // jpeglib.h needs stdio.h FILE
#include "jpeglib.h"
......@@ -82,11 +83,19 @@ static void handleError(j_common_ptr common)
// be ignored? See bug http://webkit.org/b/40147.
void preMultipliedBGRAtoRGB(const SkPMColor* input, unsigned int pixels, unsigned char* output)
{
while (pixels-- > 0) {
SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(*input++);
*output++ = SkColorGetR(unmultiplied);
*output++ = SkColorGetG(unmultiplied);
*output++ = SkColorGetB(unmultiplied);
static const SkUnPreMultiply::Scale* scale = SkUnPreMultiply::GetScaleTable();
for (; pixels-- > 0; ++input) {
const unsigned alpha = SkGetPackedA32(*input);
if ((alpha != 0) && (alpha != 255)) {
*output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedR32(*input));
*output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedG32(*input));
*output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedB32(*input));
} else {
*output++ = SkGetPackedR32(*input);
*output++ = SkGetPackedG32(*input);
*output++ = SkGetPackedB32(*input);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment