Changeset 120591 in webkit


Ignore:
Timestamp:
Jun 18, 2012 6:46:26 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r120485 and r120582.
http://trac.webkit.org/changeset/120485
http://trac.webkit.org/changeset/120582
https://bugs.webkit.org/show_bug.cgi?id=89345

chromeos tree breakage (Requested by morrita on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-06-18

Source/WebCore:

  • WebCore.gyp/WebCore.gyp:
  • platform/image-decoders/ImageDecoder.h:

(ImageFrame):
(ImageDecoder):

  • platform/image-decoders/jpeg/JPEGImageDecoder.cpp:

(turboSwizzled):
(WebCore::JPEGImageReader::JPEGImageReader):
(WebCore::JPEGImageReader::close):
(WebCore::JPEGImageReader::decode):
(JPEGImageReader):
(WebCore::JPEGImageDecoder::outputScanlines):

  • platform/image-decoders/png/PNGImageDecoder.cpp:

(WebCore::PNGImageReader::PNGImageReader):
(WebCore::PNGImageReader::close):
(WebCore::PNGImageReader::currentBufferSize):
(PNGImageReader):
(WebCore::PNGImageReader::decodingSizeOnly):
(WebCore::PNGImageReader::interlaceBuffer):
(WebCore::PNGImageReader::hasAlpha):
(WebCore::PNGImageReader::setHasAlpha):
(WebCore::PNGImageDecoder::headerAvailable):
(WebCore::PNGImageDecoder::rowAvailable):

  • platform/image-decoders/skia/ImageDecoderSkia.cpp:

(WebCore):
(WebCore::resolveColorSpace):
(WebCore::createColorSpace):
(WebCore::ImageFrame::setColorProfile):
(WebCore::ImageFrame::setStatus):

Source/WTF:

  • wtf/Platform.h:

LayoutTests:

  • platform/chromium/TestExpectations:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120590 r120591  
     12012-06-18  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r120485 and r120582.
     4        http://trac.webkit.org/changeset/120485
     5        http://trac.webkit.org/changeset/120582
     6        https://bugs.webkit.org/show_bug.cgi?id=89345
     7
     8        chromeos tree breakage (Requested by morrita on #webkit).
     9
     10        * platform/chromium/TestExpectations:
     11
    1122012-06-18  János Badics  <jbadics@inf.u-szeged.hu>
    213
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r120580 r120591  
    11751175BUGCR62433 WIN : fast/images/gif-loop-count.html = IMAGE
    11761176
     1177// Implement color profile support.
     1178BUGCR143 : fast/images/jpeg-with-color-profile.html = MISSING
     1179BUGCR143 : fast/images/png-with-color-profile.html = MISSING
     1180
    11771181// -----------------------------------------------------------------
    11781182// SVG TESTS
  • trunk/Source/WTF/ChangeLog

    r120552 r120591  
     12012-06-18  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r120485 and r120582.
     4        http://trac.webkit.org/changeset/120485
     5        http://trac.webkit.org/changeset/120582
     6        https://bugs.webkit.org/show_bug.cgi?id=89345
     7
     8        chromeos tree breakage (Requested by morrita on #webkit).
     9
     10        * wtf/Platform.h:
     11
    1122012-06-17  Patrick Gansterer  <paroga@webkit.org>
    213
  • trunk/Source/WTF/wtf/Platform.h

    r120485 r120591  
    468468#if PLATFORM(CHROMIUM)
    469469#if OS(DARWIN)
     470#if USE(SKIA_ON_MAC_CHROMIUM)
    470471#define WTF_USE_SKIA 1
     472#else
     473#define WTF_USE_CG 1
     474#endif
    471475#define WTF_USE_ATSUI 1
    472476#define WTF_USE_CORE_TEXT 1
    473477#define WTF_USE_ICCJPEG 1
    474 #define WTF_USE_QCMSLIB 1
    475478#elif OS(ANDROID)
    476479#define WTF_USE_SKIA 1
     
    478481#define WTF_USE_SKIA 1
    479482#define WTF_USE_CHROMIUM_NET 1
    480 #define WTF_USE_ICCJPEG 1
    481 #define WTF_USE_QCMSLIB 1
    482483#endif
    483484#endif
  • trunk/Source/WebCore/ChangeLog

    r120589 r120591  
     12012-06-18  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r120485 and r120582.
     4        http://trac.webkit.org/changeset/120485
     5        http://trac.webkit.org/changeset/120582
     6        https://bugs.webkit.org/show_bug.cgi?id=89345
     7
     8        chromeos tree breakage (Requested by morrita on #webkit).
     9
     10        * WebCore.gyp/WebCore.gyp:
     11        * platform/image-decoders/ImageDecoder.h:
     12        (ImageFrame):
     13        (ImageDecoder):
     14        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
     15        (turboSwizzled):
     16        (WebCore::JPEGImageReader::JPEGImageReader):
     17        (WebCore::JPEGImageReader::close):
     18        (WebCore::JPEGImageReader::decode):
     19        (JPEGImageReader):
     20        (WebCore::JPEGImageDecoder::outputScanlines):
     21        * platform/image-decoders/png/PNGImageDecoder.cpp:
     22        (WebCore::PNGImageReader::PNGImageReader):
     23        (WebCore::PNGImageReader::close):
     24        (WebCore::PNGImageReader::currentBufferSize):
     25        (PNGImageReader):
     26        (WebCore::PNGImageReader::decodingSizeOnly):
     27        (WebCore::PNGImageReader::interlaceBuffer):
     28        (WebCore::PNGImageReader::hasAlpha):
     29        (WebCore::PNGImageReader::setHasAlpha):
     30        (WebCore::PNGImageDecoder::headerAvailable):
     31        (WebCore::PNGImageDecoder::rowAvailable):
     32        * platform/image-decoders/skia/ImageDecoderSkia.cpp:
     33        (WebCore):
     34        (WebCore::resolveColorSpace):
     35        (WebCore::createColorSpace):
     36        (WebCore::ImageFrame::setColorProfile):
     37        (WebCore::ImageFrame::setStatus):
     38
    1392012-06-18  Alexei Filippov  <alexeif@chromium.org>
    240
  • trunk/Source/WebCore/WebCore.gyp/WebCore.gyp

    r120485 r120591  
    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',
    11161115        '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
    11171116        '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
     
    12421241        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
    12431242        '<(chromium_src_dir)/third_party/ots/ots.gyp:ots',
    1244         '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    12451243        '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
    12461244        '<(chromium_src_dir)/third_party/angle/src/build_angle.gyp:translator_glsl',
     
    12621260        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
    12631261        '<(chromium_src_dir)/third_party/ots/ots.gyp:ots',
    1264         '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    12651262        '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
    12661263        '<(chromium_src_dir)/third_party/angle/src/build_angle.gyp:translator_glsl',
     
    20152012        '<(chromium_src_dir)/skia/skia.gyp:skia',
    20162013        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
    2017         '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    20182014        '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
    20192015      ],
     
    20242020        '<(chromium_src_dir)/skia/skia.gyp:skia',
    20252021        '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
    2026         '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
    20272022        '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
    20282023      ],
  • trunk/Source/WebCore/platform/image-decoders/ImageDecoder.h

    r120582 r120591  
    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 <ApplicationServices/ApplicationServices.h>
    51 #include <wtf/RetainPtr.h>
    52 #endif
    53 #endif
    54 
    5545namespace WebCore {
    5646
     
    176166#if USE(SKIA)
    177167        NativeImageSkia m_bitmap;
     168#if PLATFORM(CHROMIUM) && OS(DARWIN)
     169        ColorProfile m_colorProfile;
     170#endif
    178171#else
    179172        Vector<PixelData> m_backingStore;
     
    181174        IntSize m_size;
    182175        bool m_hasAlpha;
    183         // FIXME: Do we need m_colorProfile anymore?
    184176        ColorProfile m_colorProfile;
    185177#endif
     
    298290        }
    299291
    300 #if USE(QCMSLIB)
    301         static qcms_profile* qcmsOutputDeviceProfile()
    302         {
    303             static qcms_profile* outputDeviceProfile = 0;
    304 
    305             static bool qcmsInitialized = false;
    306             if (!qcmsInitialized) {
    307                 // FIXME: Chromium's browser_tests hits this. https://bugs.webkit.org/show_bug.cgi?id=89341
    308                 // ASSERT(isMainThread());
    309                 qcmsInitialized = true;
    310                 // FIXME: Add optional ICCv4 support.
    311 #if OS(DARWIN)
    312                 RetainPtr<CGColorSpaceRef> monitorColorSpace(AdoptCF, CGDisplayCopyColorSpace(CGMainDisplayID()));
    313                 CFDataRef iccProfile(CGColorSpaceCopyICCProfile(monitorColorSpace.get()));
    314                 if (iccProfile) {
    315                     size_t length = CFDataGetLength(iccProfile);
    316                     const unsigned char* systemProfile = CFDataGetBytePtr(iccProfile);
    317                     outputDeviceProfile = qcms_profile_from_memory(systemProfile, length);
    318                     if (outputDeviceProfile && qcms_profile_is_bogus(outputDeviceProfile)) {
    319                         qcms_profile_release(outputDeviceProfile);
    320                         outputDeviceProfile = 0;
    321                     }
    322                 }
    323                 if (!outputDeviceProfile)
    324                     outputDeviceProfile = qcms_profile_sRGB();
    325 #else
    326                 // FIXME: sRGB profiles don't add much value. Use the user's monitor profile.
    327                 outputDeviceProfile = qcms_profile_sRGB();
    328 #endif
    329                 // FIXME: Check that the profile is valid. Fallback to sRGB if not?
    330                 if (outputDeviceProfile)
    331                     qcms_profile_precache_output_transform(outputDeviceProfile);
    332             }
    333             return outputDeviceProfile;
    334         }
    335 #endif
    336 
    337292        // Sets the "decode failure" flag.  For caller convenience (since so
    338293        // many callers want to return false after calling this), returns false
     
    366321        RefPtr<SharedBuffer> m_data; // The encoded data.
    367322        Vector<ImageFrame> m_frameBufferCache;
    368         // FIXME: Do we need m_colorProfile any more, for any port?
    369323        ColorProfile m_colorProfile;
    370324        bool m_scaled;
  • trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

    r120485 r120591  
    6161#include "iccjpeg.h"
    6262#endif
    63 #if USE(QCMSLIB)
    64 #include "qcms.h"
    65 #endif
    6663#include <setjmp.h>
    6764}
     
    8077inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_EXT_BGRA; }
    8178#endif
    82 inline bool turboSwizzled(J_COLOR_SPACE colorSpace) { return colorSpace == JCS_EXT_RGBA || colorSpace == JCS_EXT_BGRA; }
    83 inline bool colorSpaceHasAlpha(J_COLOR_SPACE colorSpace) { return turboSwizzled(colorSpace); }
     79inline bool turboSwizzled(J_COLOR_SPACE colorSpace) { return colorSpace == rgbOutputColorSpace(); }
    8480#else
    8581inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_RGB; }
    86 inline bool colorSpaceHasAlpha(J_COLOR_SPACE) { return false; }
    8782#endif
    8883
     
    169164        , m_state(JPEG_HEADER)
    170165        , m_samples(0)
    171 #if USE(QCMSLIB)
    172         , m_transform(0)
    173 #endif
    174166    {
    175167        memset(&m_info, 0, sizeof(jpeg_decompress_struct));
     
    219211        m_info.src = 0;
    220212
    221 #if USE(QCMSLIB)
    222         if (m_transform)
    223             qcms_transform_release(m_transform);
    224         m_transform = 0;
    225 #endif
    226213        jpeg_destroy_decompress(&m_info);
    227214    }
     
    312299                if (!rgbInputDeviceColorProfile.isEmpty())
    313300                    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
    322301            }
    323302
     
    424403    JSAMPARRAY samples() const { return m_samples; }
    425404    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
    451405
    452406private:
     
    461415
    462416    JSAMPARRAY m_samples;
    463 
    464 #if USE(QCMSLIB)
    465     qcms_transform* m_transform;
    466 #endif
    467417};
    468418
     
    572522#if !ENABLE(IMAGE_DECODER_DOWN_SAMPLING) && defined(TURBO_JPEG_RGB_SWIZZLE)
    573523    if (turboSwizzled(info->out_color_space)) {
    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
     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;
    583529         }
    584530         return true;
     
    599545        if (destY < 0)
    600546            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
    605547        int width = m_scaled ? m_scaledColumns.size() : info->output_width;
    606548        for (int x = 0; x < width; ++x) {
  • trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp

    r120485 r120591  
    4242
    4343#include "png.h"
    44 #include <wtf/OwnArrayPtr.h>
    4544#include <wtf/PassOwnPtr.h>
    4645
    4746#if PLATFORM(CHROMIUM)
    4847#include "TraceEvent.h"
    49 #endif
    50 
    51 #if USE(QCMSLIB)
    52 #include "qcms.h"
    5348#endif
    5449
     
    113108    PNGImageReader(PNGImageDecoder* decoder)
    114109        : m_readOffset(0)
     110        , m_decodingSizeOnly(false)
     111        , m_interlaceBuffer(0)
     112        , m_hasAlpha(false)
    115113        , m_currentBufferSize(0)
    116         , m_decodingSizeOnly(false)
    117         , m_hasAlpha(false)
    118         , m_interlaceBuffer(0)
    119 #if USE(QCMSLIB)
    120         , m_transform(0)
    121         , m_rowBuffer()
    122 #endif
    123114    {
    124115        m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, decodingFailed, decodingWarning);
     
    137128            // This will zero the pointers.
    138129            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
    144130        delete[] m_interlaceBuffer;
    145131        m_interlaceBuffer = 0;
    146132        m_readOffset = 0;
    147133    }
     134
     135    unsigned currentBufferSize() const { return m_currentBufferSize; }
    148136
    149137    bool decode(const SharedBuffer& data, bool sizeOnly)
     
    170158    }
    171159
     160    bool decodingSizeOnly() const { return m_decodingSizeOnly; }
    172161    png_structp pngPtr() const { return m_png; }
    173162    png_infop infoPtr() const { return m_info; }
     163    png_bytep interlaceBuffer() const { return m_interlaceBuffer; }
     164    bool hasAlpha() const { return m_hasAlpha; }
    174165
    175166    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 
    181     png_bytep interlaceBuffer() const { return m_interlaceBuffer; }
     167    void setHasAlpha(bool b) { m_hasAlpha = b; }
     168
    182169    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
    210170
    211171private:
     172    unsigned m_readOffset;
     173    bool m_decodingSizeOnly;
    212174    png_structp m_png;
    213175    png_infop m_info;
    214     unsigned m_readOffset;
     176    png_bytep m_interlaceBuffer;
     177    bool m_hasAlpha;
    215178    unsigned m_currentBufferSize;
    216     bool m_decodingSizeOnly;
    217     bool m_hasAlpha;
    218     png_bytep m_interlaceBuffer;
    219 #if USE(QCMSLIB)
    220     qcms_transform* m_transform;
    221     OwnArrayPtr<png_byte> m_rowBuffer;
    222 #endif
    223179};
    224180
     
    343299        // hand that to CoreGraphics.
    344300        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
    349301    }
    350302
     
    416368        }
    417369
    418         unsigned colorChannels = m_reader->hasAlpha() ? 4 : 3;
    419370        if (PNG_INTERLACE_ADAM7 == png_get_interlace_type(png, m_reader->infoPtr())) {
     371            unsigned colorChannels = m_reader->hasAlpha() ? 4 : 3;
    420372            m_reader->createInterlaceBuffer(colorChannels * size().width() * size().height());
    421373            if (!m_reader->interlaceBuffer()) {
     
    425377        }
    426378
    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
    436379        buffer.setStatus(ImageFrame::FramePartial);
    437380        buffer.setHasAlpha(false);
     
    491434    }
    492435
    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 
    500436    // Write the decoded row pixels to the frame buffer.
    501437    int width = scaledSize().width();
  • trunk/Source/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp

    r120485 r120591  
    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
    2936
    3037namespace WebCore {
     
    108115}
    109116
     117#if PLATFORM(CHROMIUM) && OS(DARWIN)
     118static 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
     133static 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
    110146void ImageFrame::setColorProfile(const ColorProfile& colorProfile)
    111147{
    112     // FIXME: Do we need this ImageFrame function anymore, on any port?
    113     UNUSED_PARAM(colorProfile);
     148#if PLATFORM(CHROMIUM) && OS(DARWIN)
     149    m_colorProfile = colorProfile;
     150#else
     151    notImplemented();
     152#endif
    114153}
    115154
     
    117156{
    118157    m_status = status;
    119     if (m_status == FrameComplete)
     158    if (m_status == FrameComplete) {
    120159        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    }
    121169}
    122170
Note: See TracChangeset for help on using the changeset viewer.