Changeset 120393 in webkit


Ignore:
Timestamp:
Jun 14, 2012 7:53:17 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore: [chromium] Add iccjpeg and qcms to chromium port

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

Reviewed by Adam Barth.

Covered by existing layout tests which will be rebaselined.

  • WebCore.gyp/WebCore.gyp: Add qcms to the build.
  • platform/image-decoders/ImageDecoder.h: (WebCore::ImageDecoder::qcmsOutputDeviceProfile): Return an sRGB profile. On OSX, return the default RGB profile. Add FIXME to use the user's monitor profile and verify that profile for other platforms.
  • platform/image-decoders/jpeg/JPEGImageDecoder.cpp: (turboSwizzled): For libjpeg-turbo, JCS_EXT_BGRA and JCS_EXT_RGBA are the two known output color spaces for which the decoder uses a data swizzle. (colorSpaceHasAlpha): JPEG's have no alpha in the output color space. For libjpeg-turbo, alpha may be present in the swizzled output color space.

(WebCore::JPEGImageReader::JPEGImageReader):
(WebCore::JPEGImageReader::close):
(WebCore::JPEGImageReader::decode): For QCMSLIB, create the color transform
to use during decoding, and ensure we switch to inputing RGBA data to qcms
even if the desired output data is BGRA: outputScanlines() sends BGRA data
to the frame buffer following color correction if needed.
(JPEGImageReader):
(WebCore::JPEGImageReader::colorTransform): qcms color transform getter.
(WebCore::JPEGImageReader::createColorTransform): Create color transform.
Release the existing transform (if any) and assign to the color transform
created from the color profile data.
(WebCore::JPEGImageDecoder::outputScanlines): Minor style fix. Apply color
transform to each decoded image row.

  • platform/image-decoders/png/PNGImageDecoder.cpp: (WebCore::PNGImageReader::PNGImageReader): (WebCore::PNGImageReader::close): (WebCore::PNGImageReader::currentBufferSize): Move this adjacent to other setters and getters. (WebCore::PNGImageReader::decodingSizeOnly): Ditto. (WebCore::PNGImageReader::setHasAlpha): Ditto. (WebCore::PNGImageReader::hasAlpha): Ditto. (WebCore::PNGImageReader::interlaceBuffer): Ditto. (WebCore::PNGImageReader::createRowBuffer): Creates a temporary row buffer, used when a color transform is applied to the decoded image pixels. (WebCore::PNGImageReader::rowBuffer): Return the temporary row buffer. (WebCore::PNGImageReader::colorTransform): qcms color transform getter. (WebCore::PNGImageReader::createColorTransform): Create color transform. Release the existing transform (if any) and assign to the color transform created from the color profile data. (WebCore::PNGImageDecoder::headerAvailable): For QCMSLIB, create the color transform to use for decoding. Clear m_colorProfile (not used anymore). (WebCore::PNGImageDecoder::rowAvailable): Create temporary row buffer if a color transform is needed for decoding. Apply color transform to each decoded image row.
  • platform/image-decoders/skia/ImageDecoderSkia.cpp: (WebCore::ImageFrame::setColorProfile): Old method of colorProfiles is no longer used. Add a FIXME to remove the old implementation. (WebCore::ImageFrame::setStatus): Remove old color correction code.

Patch by Tony Payne <tpayne@chromium.org> on 2012-06-14

Source/WTF: [chromium] Add iccjpeg and qcms to chromium port.
https://bugs.webkit.org/show_bug.cgi?id=81974

Patch by Tony Payne <tpayne@chromium.org> on 2012-06-14

  • wtf/Platform.h: Add Chromium USE defines for ICCJPEG and QCMSLIB

to each Chromium platform, excluding Android.

Reviewed by Adam Barth.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r120387 r120393  
    11751175BUGCR62433 WIN : fast/images/gif-loop-count.html = IMAGE
    11761176
    1177 // Implement color profile support.
    1178 BUGCR143 : fast/images/jpeg-with-color-profile.html = MISSING
    1179 BUGCR143 : fast/images/png-with-color-profile.html = MISSING
    1180 
    11811177// -----------------------------------------------------------------
    11821178// SVG TESTS
     
    35383534BUGWK68744 : fast/block/float/float-not-removed-from-next-sibling4.html = IMAGE
    35393535
     3536// Needs to be rebaselined.
     3537BUGWK87761 MAC LINUX WIN : compositing/color-matching/image-color-matching.html = IMAGE
     3538BUGWK87761 MAC : compositing/masks/direct-image-mask.html = IMAGE
     3539BUGWK87761 MAC : compositing/reflections/simple-composited-reflections.html = IMAGE
     3540BUGWK87761 MAC : compositing/visibility/visibility-image-layers.html = IMAGE
     3541BUGWK87761 MAC LINUX WIN : css3/filters/crash-filter-change.html = IMAGE
     3542BUGWK87761 MAC LINUX WIN : css3/filters/crash-hw-sw-switch.html = IMAGE
     3543BUGWK87761 LINUX : css3/filters/custom/custom-filter-shader-cache.html = IMAGE
     3544BUGWK87761 MAC : css3/filters/custom/effect-color-check.html = IMAGE
     3545BUGWK87761 LINUX : css3/filters/custom/effect-custom-combined-missing.html = IMAGE
     3546BUGWK87761 LINUX : css3/filters/custom/effect-custom.html = IMAGE
     3547BUGWK87761 MAC LINUX : css3/filters/custom/missing-custom-filter-shader.html = IMAGE
     3548BUGWK87761 MAC LINUX WIN : css3/filters/effect-blur-hw.html = IMAGE
     3549BUGWK87761 MAC LINUX WIN : css3/filters/effect-blur.html = IMAGE
     3550BUGWK87761 MAC LINUX WIN : css3/filters/effect-brightness-hw.html = IMAGE
     3551BUGWK87761 MAC LINUX WIN : css3/filters/effect-brightness.html = IMAGE
     3552BUGWK87761 MAC LINUX WIN : css3/filters/effect-combined-hw.html = IMAGE
     3553BUGWK87761 MAC LINUX WIN : css3/filters/effect-combined.html = IMAGE
     3554BUGWK87761 MAC LINUX WIN : css3/filters/effect-contrast-hw.html = IMAGE
     3555BUGWK87761 MAC LINUX WIN : css3/filters/effect-contrast.html = IMAGE
     3556BUGWK87761 MAC LINUX WIN : css3/filters/effect-drop-shadow-hw.html = IMAGE
     3557BUGWK87761 MAC LINUX WIN : css3/filters/effect-drop-shadow.html = IMAGE
     3558BUGWK87761 MAC LINUX WIN : css3/filters/effect-grayscale-hw.html = IMAGE
     3559BUGWK87761 MAC LINUX WIN : css3/filters/effect-grayscale.html = IMAGE
     3560BUGWK87761 MAC LINUX WIN : css3/filters/effect-hue-rotate-hw.html = IMAGE
     3561BUGWK87761 MAC LINUX WIN : css3/filters/effect-hue-rotate.html = IMAGE
     3562BUGWK87761 MAC LINUX WIN : css3/filters/effect-invert-hw.html = IMAGE
     3563BUGWK87761 MAC LINUX WIN : css3/filters/effect-invert.html = IMAGE
     3564BUGWK87761 MAC LINUX WIN : css3/filters/effect-opacity-hw.html = IMAGE
     3565BUGWK87761 MAC LINUX WIN : css3/filters/effect-opacity.html = IMAGE
     3566BUGWK87761 MAC LINUX WIN : css3/filters/effect-saturate-hw.html = IMAGE
     3567BUGWK87761 MAC LINUX WIN : css3/filters/effect-saturate.html = IMAGE
     3568BUGWK87761 MAC LINUX WIN : css3/filters/effect-sepia-hw.html = IMAGE
     3569BUGWK87761 MAC LINUX WIN : css3/filters/effect-sepia.html = IMAGE
     3570BUGWK87761 MAC LINUX WIN : css3/filters/regions-expanding.html = IMAGE
     3571BUGWK87761 MAC : fast/css/background-shorthand-invalid-url.html = IMAGE
     3572BUGWK87761 MAC : fast/css/color-correction-on-backgrounds.html = IMAGE
     3573BUGWK87761 MAC : fast/css/color-correction.html = IMAGE
     3574BUGWK87761 MAC : fast/images/color-jpeg-with-color-profile.html = IMAGE
     3575BUGWK87761 MAC : fast/media/mq-min-pixel-ratio.html = IMAGE
     3576BUGWK87761 MAC : fast/reflections/reflection-direction.html = IMAGE
     3577BUGWK87761 MAC : fast/reflections/reflection-masks-opacity.html = IMAGE
     3578BUGWK87761 MAC : fast/reflections/reflection-with-zoom.html = IMAGE
     3579// There is already an entry for MAC DEBUG
     3580BUGWK87761 MAC RELEASE : fast/reflections/reflection-masks-outset.html = IMAGE
     3581BUGWK87761 MAC : fast/reflections/reflection-masks.html = IMAGE
     3582BUGWK87761 MAC LINUX : http/tests/local/file-url-sent-as-referer.html = IMAGE
     3583BUGWK87761 MAC : platform/chromium/virtual/threaded/compositing/visibility/visibility-image-layers.html = IMAGE
     3584BUGWK87761 MAC LINUX : scrollbars/listbox-scrollbar-combinations.html = IMAGE
     3585BUGWK87761 MAC LINUX : scrollbars/overflow-scrollbar-combinations.html = IMAGE
     3586BUGWK87761 LINUX : svg/as-border-image/svg-as-border-image.html = IMAGE
     3587BUGWK87761 MAC LINUX : svg/custom/createImageElement.svg = IMAGE
     3588BUGWK87761 MAC LINUX : svg/custom/createImageElement2.xhtml = IMAGE
     3589BUGWK87761 MAC LINUX : svg/custom/focus-ring.svg = IMAGE
     3590BUGWK87761 MAC LINUX : svg/custom/group-opacity.svg = IMAGE
     3591BUGWK87761 MAC LINUX : svg/custom/image-parent-translation.xhtml = IMAGE
     3592BUGWK87761 MAC LINUX : svg/custom/image-small-width-height.svg = IMAGE
     3593BUGWK87761 MAC : svg/custom/image-with-transform-clip-filter.svg = IMAGE
     3594BUGWK87761 MAC LINUX : svg/custom/js-update-image-and-display.svg = IMAGE
     3595BUGWK87761 MAC LINUX : svg/custom/js-update-image-and-display2.svg = IMAGE
     3596BUGWK87761 MAC LINUX : svg/custom/js-update-image-and-display3.svg = IMAGE
     3597BUGWK87761 MAC LINUX : svg/custom/js-update-image.svg = IMAGE
     3598BUGWK87761 MAC : svg/custom/pointer-events-image-css-transform.svg = IMAGE
     3599BUGWK87761 MAC : svg/custom/pointer-events-image.svg = IMAGE
     3600BUGWK87761 MAC LINUX : svg/custom/text-image-opacity.svg = IMAGE
     3601BUGWK87761 MAC LINUX : svg/custom/use-on-g-containing-foreignObject-and-image.svg = IMAGE
     3602BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-dom-height-attr.html = IMAGE
     3603BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-dom-preserveAspectRatio-attr.html = IMAGE
     3604BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-dom-width-attr.html = IMAGE
     3605BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-dom-x-attr.html = IMAGE
     3606BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-dom-y-attr.html = IMAGE
     3607BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-svgdom-height-prop.html = IMAGE
     3608BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-svgdom-preserveAspectRatio-prop.html = IMAGE
     3609BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-svgdom-width-prop.html = IMAGE
     3610BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-svgdom-x-prop.html = IMAGE
     3611BUGWK87761 MAC LINUX : svg/dynamic-updates/SVGImageElement-svgdom-y-prop.html = IMAGE
     3612BUGWK87761 MAC LINUX : svg/filters/feImage-subregions-preseveAspectRatio-none-with-viewBox.svg = IMAGE
     3613BUGWK87761 MAC LINUX : svg/filters/feImage-subregions-preseveAspectRatio-none.svg = IMAGE
     3614BUGWK87761 MAC LINUX : svg/filters/feImage-subregions.svg = IMAGE
     3615BUGWK87761 MAC LINUX : svg/filters/filter-source-position.svg = IMAGE
     3616BUGWK87761 MAC LINUX : svg/repaint/image-href-change.svg = IMAGE
     3617BUGWK87761 MAC LINUX : svg/transforms/animated-path-inside-transformed-html.xhtml = IMAGE
     3618BUGWK87761 MAC : svg/wicd/test-rightsizing-b.xhtml = IMAGE
     3619BUGWK87761 MAC LINUX : svg/zoom/page/zoom-background-images.html = IMAGE
     3620BUGWK87761 MAC LINUX : svg/zoom/page/zoom-svg-through-object-with-absolute-size-2.xhtml = IMAGE
     3621BUGWK87761 MAC LINUX : svg/zoom/page/zoom-svg-through-object-with-absolute-size.xhtml = IMAGE
     3622BUGWK87761 MAC LINUX : svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml = IMAGE
     3623BUGWK87761 MAC : tables/mozilla/bugs/bug82946-2.html = IMAGE
     3624BUGWK87761 MAC LINUX WIN : fast/images/jpeg-with-color-profile.html = MISSING
     3625BUGWK87761 MAC LINUX WIN : fast/images/png-with-color-profile.html = MISSING
     3626
     3627
    35403628BUGWK83076 SNOWLEOPARD RELEASE : compositing/geometry/outline-change.html = TIMEOUT PASS
    35413629BUGWK83076 SNOWLEOPARD RELEASE : css3/selectors3/xml/css3-modsel-161.xml = TIMEOUT PASS
  • trunk/Source/WTF/ChangeLog

    r120368 r120393  
     12012-06-14  Tony Payne  <tpayne@chromium.org>
     2
     3        [chromium] Add iccjpeg and qcms to chromium port.
     4        https://bugs.webkit.org/show_bug.cgi?id=81974
     5
     6        * wtf/Platform.h: Add Chromium USE defines for ICCJPEG and QCMSLIB
     7        to each Chromium platform, excluding Android.
     8
     9        Reviewed by Adam Barth.
     10
    1112012-06-14  Yong Li  <yoli@rim.com>
    212
  • trunk/Source/WTF/wtf/Platform.h

    r120356 r120393  
    468468#if PLATFORM(CHROMIUM)
    469469#if OS(DARWIN)
    470 #if USE(SKIA_ON_MAC_CHROMIUM)
    471470#define WTF_USE_SKIA 1
    472 #else
    473 #define WTF_USE_CG 1
    474 #endif
    475471#define WTF_USE_ATSUI 1
    476472#define WTF_USE_CORE_TEXT 1
    477473#define WTF_USE_ICCJPEG 1
     474#define WTF_USE_QCMSLIB 1
    478475#elif OS(ANDROID)
    479476#define WTF_USE_SKIA 1
     
    481478#define WTF_USE_SKIA 1
    482479#define WTF_USE_CHROMIUM_NET 1
     480#define WTF_USE_ICCJPEG 1
     481#define WTF_USE_QCMSLIB 1
    483482#endif
    484483#endif
  • trunk/Source/WebCore/ChangeLog

    r120392 r120393  
     12012-06-14  Tony Payne  <tpayne@chromium.org>
     2
     3       [chromium] Add iccjpeg and qcms to chromium port
     4       https://bugs.webkit.org/show_bug.cgi?id=81974
     5
     6       Reviewed by Adam Barth.
     7
     8       Covered by existing layout tests which will be rebaselined.
     9
     10       * WebCore.gyp/WebCore.gyp: Add qcms to the build.
     11       * platform/image-decoders/ImageDecoder.h:
     12       (WebCore::ImageDecoder::qcmsOutputDeviceProfile): Return an sRGB profile.
     13       On OSX, return the default RGB profile. Add FIXME to use the user's
     14       monitor profile and verify that profile for other platforms.
     15
     16       * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
     17       (turboSwizzled): For libjpeg-turbo, JCS_EXT_BGRA and JCS_EXT_RGBA are the
     18       two known output color spaces for which the decoder uses a data swizzle.
     19       (colorSpaceHasAlpha): JPEG's have no alpha in the output color space. For
     20       libjpeg-turbo, alpha may be present in the swizzled output color space.
     21
     22       (WebCore::JPEGImageReader::JPEGImageReader):
     23       (WebCore::JPEGImageReader::close):
     24       (WebCore::JPEGImageReader::decode): For QCMSLIB, create the color transform
     25       to use during decoding, and ensure we switch to inputing RGBA data to qcms
     26       even if the desired output data is BGRA: outputScanlines() sends BGRA data
     27       to the frame buffer following color correction if needed.
     28       (JPEGImageReader):
     29       (WebCore::JPEGImageReader::colorTransform): qcms color transform getter.
     30       (WebCore::JPEGImageReader::createColorTransform): Create color transform.
     31       Release the existing transform (if any) and assign to the color transform
     32       created from the color profile data.
     33       (WebCore::JPEGImageDecoder::outputScanlines): Minor style fix. Apply color
     34       transform to each decoded image row.
     35
     36       * platform/image-decoders/png/PNGImageDecoder.cpp:
     37       (WebCore::PNGImageReader::PNGImageReader):
     38       (WebCore::PNGImageReader::close):
     39       (WebCore::PNGImageReader::currentBufferSize): Move this adjacent to other
     40       setters and getters.
     41       (WebCore::PNGImageReader::decodingSizeOnly): Ditto.
     42       (WebCore::PNGImageReader::setHasAlpha): Ditto.
     43       (WebCore::PNGImageReader::hasAlpha): Ditto.
     44       (WebCore::PNGImageReader::interlaceBuffer): Ditto.
     45       (WebCore::PNGImageReader::createRowBuffer): Creates a temporary row buffer,
     46       used when a color transform is applied to the decoded image pixels.
     47       (WebCore::PNGImageReader::rowBuffer): Return the temporary row buffer.
     48       (WebCore::PNGImageReader::colorTransform): qcms color transform getter.
     49       (WebCore::PNGImageReader::createColorTransform): Create color transform.
     50       Release the existing transform (if any) and assign to the color transform
     51       created from the color profile data.
     52       (WebCore::PNGImageDecoder::headerAvailable): For QCMSLIB, create the color
     53       transform to use for decoding. Clear m_colorProfile (not used anymore).
     54       (WebCore::PNGImageDecoder::rowAvailable): Create temporary row buffer if
     55       a color transform is needed for decoding. Apply color transform to each
     56       decoded image row.
     57
     58       * platform/image-decoders/skia/ImageDecoderSkia.cpp:
     59       (WebCore::ImageFrame::setColorProfile): Old method of colorProfiles is no
     60       longer used. Add a FIXME to remove the old implementation.
     61       (WebCore::ImageFrame::setStatus): Remove old color correction code.
     62
    1632012-06-14  Sheriff Bot  <webkit.review.bot@gmail.com>
    264
  • trunk/Source/WebCore/WebCore.gyp/WebCore.gyp

    r120160 r120393  
    11131113        '<(chromium_src_dir)/third_party/libwebp/libwebp.gyp:libwebp',
    11141114        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
     1115        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    11151116        '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
    11161117        '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
     
    12411242        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
    12421243        '<(chromium_src_dir)/third_party/ots/ots.gyp:ots',
     1244        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    12431245        '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
    12441246        '<(chromium_src_dir)/third_party/angle/src/build_angle.gyp:translator_glsl',
     
    12601262        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
    12611263        '<(chromium_src_dir)/third_party/ots/ots.gyp:ots',
     1264        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    12621265        '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
    12631266        '<(chromium_src_dir)/third_party/angle/src/build_angle.gyp:translator_glsl',
     
    20122015        '<(chromium_src_dir)/skia/skia.gyp:skia',
    20132016        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
     2017        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    20142018        '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
    20152019      ],
     
    20202024        '<(chromium_src_dir)/skia/skia.gyp:skia',
    20212025        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
     2026        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    20222027        '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
    20232028      ],
  • trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h

    r118909 r120393  
    4343#endif
    4444
     45#if USE(QCMSLIB)
     46#include "qcms.h"
     47#include <wtf/MainThread.h>
     48#if OS(DARWIN)
     49#include "GraphicsContextCG.h"
     50#include <CoreGraphics/CGColorSpace.h>
     51#include <CoreGraphics/CGDirectDisplay.h>
     52#include <CoreGraphics/CGDisplayConfiguration.h>
     53#include <wtf/RetainPtr.h>
     54#endif
     55#endif
     56
    4557namespace WebCore {
    4658
     
    166178#if USE(SKIA)
    167179        NativeImageSkia m_bitmap;
    168 #if PLATFORM(CHROMIUM) && OS(DARWIN)
    169         ColorProfile m_colorProfile;
    170 #endif
    171180#else
    172181        Vector<PixelData> m_backingStore;
     
    174183        IntSize m_size;
    175184        bool m_hasAlpha;
     185        // FIXME: Do we need m_colorProfile anymore?
    176186        ColorProfile m_colorProfile;
    177187#endif
     
    290300        }
    291301
     302#if USE(QCMSLIB)
     303        static qcms_profile* qcmsOutputDeviceProfile()
     304        {
     305            static qcms_profile* outputDeviceProfile = 0;
     306
     307            static bool qcmsInitialized = false;
     308            if (!qcmsInitialized) {
     309                ASSERT(isMainThread());
     310                qcmsInitialized = true;
     311                // FIXME: Add optional ICCv4 support.
     312#if OS(DARWIN)
     313                RetainPtr<CGColorSpaceRef> monitorColorSpace(AdoptCF, CGDisplayCopyColorSpace(CGMainDisplayID()));
     314                CFDataRef iccProfile(CGColorSpaceCopyICCProfile(monitorColorSpace.get()));
     315                if (iccProfile) {
     316                    size_t length = CFDataGetLength(iccProfile);
     317                    const unsigned char* systemProfile = CFDataGetBytePtr(iccProfile);
     318                    outputDeviceProfile = qcms_profile_from_memory(systemProfile, length);
     319                    if (outputDeviceProfile && qcms_profile_is_bogus(outputDeviceProfile)) {
     320                        qcms_profile_release(outputDeviceProfile);
     321                        outputDeviceProfile = 0;
     322                    }
     323                }
     324                if (!outputDeviceProfile)
     325                    outputDeviceProfile = qcms_profile_sRGB();
     326#else
     327                // FIXME: sRGB profiles don't add much value. Use the user's monitor profile.
     328                outputDeviceProfile = qcms_profile_sRGB();
     329#endif
     330                // FIXME: Check that the profile is valid. Fallback to sRGB if not?
     331                if (outputDeviceProfile)
     332                    qcms_profile_precache_output_transform(outputDeviceProfile);
     333            }
     334            return outputDeviceProfile;
     335        }
     336#endif
     337
    292338        // Sets the "decode failure" flag.  For caller convenience (since so
    293339        // many callers want to return false after calling this), returns false
     
    321367        RefPtr<SharedBuffer> m_data; // The encoded data.
    322368        Vector<ImageFrame> m_frameBufferCache;
     369        // FIXME: Do we need m_colorProfile any more, for any port?
    323370        ColorProfile m_colorProfile;
    324371        bool m_scaled;
  • trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

    r120044 r120393  
    6161#include "iccjpeg.h"
    6262#endif
     63#if USE(QCMSLIB)
     64#include "qcms.h"
     65#endif
    6366#include <setjmp.h>
    6467}
     
    7780inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_EXT_BGRA; }
    7881#endif
    79 inline bool turboSwizzled(J_COLOR_SPACE colorSpace) { return colorSpace == rgbOutputColorSpace(); }
     82inline bool turboSwizzled(J_COLOR_SPACE colorSpace) { return colorSpace == JCS_EXT_RGBA || colorSpace == JCS_EXT_BGRA; }
     83inline bool colorSpaceHasAlpha(J_COLOR_SPACE colorSpace) { return turboSwizzled(colorSpace); }
    8084#else
    8185inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_RGB; }
     86inline bool colorSpaceHasAlpha(J_COLOR_SPACE) { return false; }
    8287#endif
    8388
     
    164169        , m_state(JPEG_HEADER)
    165170        , m_samples(0)
     171#if USE(QCMSLIB)
     172        , m_transform(0)
     173#endif
    166174    {
    167175        memset(&m_info, 0, sizeof(jpeg_decompress_struct));
     
    211219        m_info.src = 0;
    212220
     221#if USE(QCMSLIB)
     222        if (m_transform)
     223            qcms_transform_release(m_transform);
     224        m_transform = 0;
     225#endif
    213226        jpeg_destroy_decompress(&m_info);
    214227    }
     
    299312                if (!rgbInputDeviceColorProfile.isEmpty())
    300313                    m_decoder->setColorProfile(rgbInputDeviceColorProfile);
     314#if USE(QCMSLIB)
     315                createColorTransform(rgbInputDeviceColorProfile, colorSpaceHasAlpha(m_info.out_color_space));
     316#if defined(TURBO_JPEG_RGB_SWIZZLE)
     317                // Input RGBA data to qcms. Note: restored to BGRA on output.
     318                if (m_transform && m_info.out_color_space == JCS_EXT_BGRA)
     319                    m_info.out_color_space = JCS_EXT_RGBA;
     320#endif
     321#endif
    301322            }
    302323
     
    403424    JSAMPARRAY samples() const { return m_samples; }
    404425    JPEGImageDecoder* decoder() { return m_decoder; }
     426#if USE(QCMSLIB)
     427    qcms_transform* colorTransform() const { return m_transform; }
     428
     429    void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
     430    {
     431        if (m_transform)
     432            qcms_transform_release(m_transform);
     433        m_transform = 0;
     434
     435        if (colorProfile.isEmpty())
     436            return;
     437        qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
     438        if (!deviceProfile)
     439            return;
     440        qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
     441        if (!inputProfile)
     442            return;
     443        // We currently only support color profiles for RGB profiled images.
     444        ASSERT(icSigRgbData == qcms_profile_get_color_space(inputProfile));
     445        qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
     446        // FIXME: Don't force perceptual intent if the image profile contains an intent.
     447        m_transform = qcms_transform_create(inputProfile, dataFormat, deviceProfile, dataFormat, QCMS_INTENT_PERCEPTUAL);
     448        qcms_profile_release(inputProfile);
     449    }
     450#endif
    405451
    406452private:
     
    415461
    416462    JSAMPARRAY m_samples;
     463
     464#if USE(QCMSLIB)
     465    qcms_transform* m_transform;
     466#endif
    417467};
    418468
     
    522572#if !ENABLE(IMAGE_DECODER_DOWN_SAMPLING) && defined(TURBO_JPEG_RGB_SWIZZLE)
    523573    if (turboSwizzled(info->out_color_space)) {
    524          ASSERT(!m_scaled);
    525          while (info->output_scanline < info->output_height) {
    526              unsigned char* row = reinterpret_cast<unsigned char*>(buffer.getAddr(0, info->output_scanline));
    527              if (jpeg_read_scanlines(info, &row, 1) != 1)
    528                   return false;
     574        ASSERT(!m_scaled);
     575        while (info->output_scanline < info->output_height) {
     576            unsigned char* row = reinterpret_cast<unsigned char*>(buffer.getAddr(0, info->output_scanline));
     577            if (jpeg_read_scanlines(info, &row, 1) != 1)
     578                return false;
     579#if USE(QCMSLIB)
     580            if (qcms_transform* transform = m_reader->colorTransform())
     581                qcms_transform_data_type(transform, row, row, info->output_width, rgbOutputColorSpace() == JCS_EXT_BGRA ? QCMS_OUTPUT_BGRX : QCMS_OUTPUT_RGBX);
     582#endif
    529583         }
    530584         return true;
     
    545599        if (destY < 0)
    546600            continue;
     601#if USE(QCMSLIB)
     602        if (m_reader->colorTransform() && info->out_color_space == JCS_RGB)
     603            qcms_transform_data(m_reader->colorTransform(), *samples, *samples, info->output_width);
     604#endif
    547605        int width = m_scaled ? m_scaledColumns.size() : info->output_width;
    548606        for (int x = 0; x < width; ++x) {
  • trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp

    r116059 r120393  
    4242
    4343#include "png.h"
     44#include <wtf/OwnArrayPtr.h>
    4445#include <wtf/PassOwnPtr.h>
    4546
    4647#if PLATFORM(CHROMIUM)
    4748#include "TraceEvent.h"
     49#endif
     50
     51#if USE(QCMSLIB)
     52#include "qcms.h"
    4853#endif
    4954
     
    108113    PNGImageReader(PNGImageDecoder* decoder)
    109114        : m_readOffset(0)
     115        , m_currentBufferSize(0)
    110116        , m_decodingSizeOnly(false)
     117        , m_hasAlpha(false)
    111118        , m_interlaceBuffer(0)
    112         , m_hasAlpha(false)
    113         , m_currentBufferSize(0)
     119#if USE(QCMSLIB)
     120        , m_transform(0)
     121        , m_rowBuffer()
     122#endif
    114123    {
    115124        m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, decodingFailed, decodingWarning);
     
    128137            // This will zero the pointers.
    129138            png_destroy_read_struct(&m_png, &m_info, 0);
     139#if USE(QCMSLIB)
     140        if (m_transform)
     141            qcms_transform_release(m_transform);
     142        m_transform = 0;
     143#endif
    130144        delete[] m_interlaceBuffer;
    131145        m_interlaceBuffer = 0;
    132146        m_readOffset = 0;
    133147    }
    134 
    135     unsigned currentBufferSize() const { return m_currentBufferSize; }
    136148
    137149    bool decode(const SharedBuffer& data, bool sizeOnly)
     
    158170    }
    159171
    160     bool decodingSizeOnly() const { return m_decodingSizeOnly; }
    161172    png_structp pngPtr() const { return m_png; }
    162173    png_infop infoPtr() const { return m_info; }
     174
     175    void setReadOffset(unsigned offset) { m_readOffset = offset; }
     176    unsigned currentBufferSize() const { return m_currentBufferSize; }
     177    bool decodingSizeOnly() const { return m_decodingSizeOnly; }
     178    void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
     179    bool hasAlpha() const { return m_hasAlpha; }
     180
    163181    png_bytep interlaceBuffer() const { return m_interlaceBuffer; }
    164     bool hasAlpha() const { return m_hasAlpha; }
    165 
    166     void setReadOffset(unsigned offset) { m_readOffset = offset; }
    167     void setHasAlpha(bool b) { m_hasAlpha = b; }
    168 
    169182    void createInterlaceBuffer(int size) { m_interlaceBuffer = new png_byte[size]; }
     183#if USE(QCMSLIB)
     184    png_bytep rowBuffer() const { return m_rowBuffer.get(); }
     185    void createRowBuffer(int size) { m_rowBuffer = adoptArrayPtr(new png_byte[size]); }
     186    qcms_transform* colorTransform() const { return m_transform; }
     187
     188    void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
     189    {
     190        if (m_transform)
     191            qcms_transform_release(m_transform);
     192        m_transform = 0;
     193
     194        if (colorProfile.isEmpty())
     195            return;
     196        qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
     197        if (!deviceProfile)
     198            return;
     199        qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
     200        if (!inputProfile)
     201            return;
     202        // We currently only support color profiles for RGB and RGBA images.
     203        ASSERT(icSigRgbData == qcms_profile_get_color_space(inputProfile));
     204        qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
     205        // FIXME: Don't force perceptual intent if the image profile contains an intent.
     206        m_transform = qcms_transform_create(inputProfile, dataFormat, deviceProfile, dataFormat, QCMS_INTENT_PERCEPTUAL);
     207        qcms_profile_release(inputProfile);
     208    }
     209#endif
    170210
    171211private:
    172     unsigned m_readOffset;
    173     bool m_decodingSizeOnly;
    174212    png_structp m_png;
    175213    png_infop m_info;
     214    unsigned m_readOffset;
     215    unsigned m_currentBufferSize;
     216    bool m_decodingSizeOnly;
     217    bool m_hasAlpha;
    176218    png_bytep m_interlaceBuffer;
    177     bool m_hasAlpha;
    178     unsigned m_currentBufferSize;
     219#if USE(QCMSLIB)
     220    qcms_transform* m_transform;
     221    OwnArrayPtr<png_byte> m_rowBuffer;
     222#endif
    179223};
    180224
     
    299343        // hand that to CoreGraphics.
    300344        readColorProfile(png, info, m_colorProfile);
     345#if USE(QCMSLIB)
     346        m_reader->createColorTransform(m_colorProfile, colorType & PNG_COLOR_MASK_ALPHA);
     347        m_colorProfile.clear();
     348#endif
    301349    }
    302350
     
    368416        }
    369417
     418        unsigned colorChannels = m_reader->hasAlpha() ? 4 : 3;
    370419        if (PNG_INTERLACE_ADAM7 == png_get_interlace_type(png, m_reader->infoPtr())) {
    371             unsigned colorChannels = m_reader->hasAlpha() ? 4 : 3;
    372420            m_reader->createInterlaceBuffer(colorChannels * size().width() * size().height());
    373421            if (!m_reader->interlaceBuffer()) {
     
    377425        }
    378426
     427#if USE(QCMSLIB)
     428        if (m_reader->colorTransform()) {
     429            m_reader->createRowBuffer(colorChannels * size().width());
     430            if (!m_reader->rowBuffer()) {
     431                longjmp(JMPBUF(png), 1);
     432                return;
     433            }
     434        }
     435#endif
    379436        buffer.setStatus(ImageFrame::FramePartial);
    380437        buffer.setHasAlpha(false);
     
    434491    }
    435492
     493#if USE(QCMSLIB)
     494    if (qcms_transform* transform = m_reader->colorTransform()) {
     495        qcms_transform_data(transform, row, m_reader->rowBuffer(), size().width());
     496        row = m_reader->rowBuffer();
     497    }
     498#endif
     499
    436500    // Write the decoded row pixels to the frame buffer.
    437501    int width = scaledSize().width();
  • trunk/Source/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp

    r110499 r120393  
    2727#include "config.h"
    2828#include "ImageDecoder.h"
    29 
    30 #include "NotImplemented.h"
    31 
    32 #if PLATFORM(CHROMIUM) && OS(DARWIN)
    33 #include "GraphicsContextCG.h"
    34 #include "SkCGUtils.h"
    35 #endif
    3629
    3730namespace WebCore {
     
    115108}
    116109
    117 #if PLATFORM(CHROMIUM) && OS(DARWIN)
    118 static void resolveColorSpace(const SkBitmap& bitmap, CGColorSpaceRef colorSpace)
    119 {
    120     int width = bitmap.width();
    121     int height = bitmap.height();
    122     RetainPtr<CGImageRef> srcImage(AdoptCF, SkCreateCGImageRefWithColorspace(bitmap, colorSpace));
    123     SkAutoLockPixels lock(bitmap);
    124     void* pixels = bitmap.getPixels();
    125     RetainPtr<CGContextRef> cgBitmap(AdoptCF, CGBitmapContextCreate(pixels, width, height, 8, width * 4, deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst));
    126     if (!cgBitmap)
    127         return;
    128     CGContextSetBlendMode(cgBitmap.get(), kCGBlendModeCopy);
    129     CGRect bounds = { {0, 0}, {width, height} };
    130     CGContextDrawImage(cgBitmap.get(), bounds, srcImage.get());
    131 }
    132 
    133 static CGColorSpaceRef createColorSpace(const ColorProfile& colorProfile)
    134 {
    135     RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(colorProfile.data()), colorProfile.size()));
    136 #ifndef TARGETING_LEOPARD
    137     return CGColorSpaceCreateWithICCProfile(data.get());
    138 #else
    139     RetainPtr<CGDataProviderRef> profileDataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get()));
    140     CGFloat ranges[] = {0.0, 255.0, 0.0, 255.0, 0.0, 255.0};
    141     return CGColorSpaceCreateICCBased(3, ranges, profileDataProvider.get(), deviceRGBColorSpaceRef());
    142 #endif
    143 }
    144 #endif
    145 
    146110void ImageFrame::setColorProfile(const ColorProfile& colorProfile)
    147111{
    148 #if PLATFORM(CHROMIUM) && OS(DARWIN)
    149     m_colorProfile = colorProfile;
    150 #else
    151     notImplemented();
    152 #endif
     112    // FIXME: Do we need this ImageFrame function anymore, on any port?
     113    UNUSED_PARAM(colorProfile);
    153114}
    154115
     
    156117{
    157118    m_status = status;
    158     if (m_status == FrameComplete) {
     119    if (m_status == FrameComplete)
    159120        m_bitmap.setDataComplete();  // Tell the bitmap it's done.
    160 #if PLATFORM(CHROMIUM) && OS(DARWIN)
    161         // resolveColorSpace() and callees assume that the alpha channel is
    162         // premultiplied, so don't apply the color profile if it isn't.
    163         if (m_colorProfile.isEmpty() || (!m_premultiplyAlpha && hasAlpha()))
    164             return;
    165         RetainPtr<CGColorSpaceRef> cgColorSpace(AdoptCF, createColorSpace(m_colorProfile));
    166         resolveColorSpace(m_bitmap.bitmap(), cgColorSpace.get());
    167 #endif
    168     }
    169121}
    170122
Note: See TracChangeset for help on using the changeset viewer.