Changeset 73890 in webkit


Ignore:
Timestamp:
Dec 13, 2010 1:11:59 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

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):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r73889 r73890  
     12010-12-13  Noel Gordon  <noel.gordon@gmail.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [chromium] Reduce canvas.toDataURL("image/jpeg") run-time cost by 10%
     6        https://bugs.webkit.org/show_bug.cgi?id=50804
     7
     8        Follow on from r73173, unroll the SkUnPreMultiply::PMColorToColor() call
     9        viz., compute the unpremultiplatcion in-place. This reduces the run-time
     10        cost of jpeg encoding by 10-15% for my image test set.
     11
     12        No new tests: canvas.toDataURL() is covered by existing tests.
     13
     14        * platform/image-encoders/skia/JPEGImageEncoder.cpp:
     15        (WebCore::preMultipliedBGRAtoRGB):
     16
    1172010-12-13  Helder Correia  <helder@sencha.com>
    218
  • trunk/WebCore/platform/image-encoders/skia/JPEGImageEncoder.cpp

    r73173 r73890  
    3535#include "SkBitmap.h"
    3636#include "SkUnPreMultiply.h"
     37#include "SkColorPriv.h"
    3738extern "C" {
    3839#include <stdio.h> // jpeglib.h needs stdio.h FILE
     
    8384void preMultipliedBGRAtoRGB(const SkPMColor* input, unsigned int pixels, unsigned char* output)
    8485{
    85     while (pixels-- > 0) {
    86         SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(*input++);
    87         *output++ = SkColorGetR(unmultiplied);
    88         *output++ = SkColorGetG(unmultiplied);
    89         *output++ = SkColorGetB(unmultiplied);
     86    static const SkUnPreMultiply::Scale* scale = SkUnPreMultiply::GetScaleTable();
     87
     88    for (; pixels-- > 0; ++input) {
     89        const unsigned alpha = SkGetPackedA32(*input);
     90        if ((alpha != 0) && (alpha != 255)) {
     91            *output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedR32(*input));
     92            *output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedG32(*input));
     93            *output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedB32(*input));
     94        } else {
     95            *output++ = SkGetPackedR32(*input);
     96            *output++ = SkGetPackedG32(*input);
     97            *output++ = SkGetPackedB32(*input);
     98        }
    9099    }
    91100}
Note: See TracChangeset for help on using the changeset viewer.