Unreviewed, rolling out r120485 and r120582.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2012 13:46:26 +0000 (13:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2012 13:46:26 +0000 (13:46 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120591 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/chromium/TestExpectations
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gyp/WebCore.gyp
Source/WebCore/platform/image-decoders/ImageDecoder.h
Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
Source/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp

index 2b89448..fffbc9d 100644 (file)
@@ -1,3 +1,14 @@
+2012-06-18  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        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).
+
+        * platform/chromium/TestExpectations:
+
 2012-06-18  J├ínos Badics  <jbadics@inf.u-szeged.hu>
 
         [Qt] Gardening after r120311. It made inspector/extensions/extensions-panel.html flakey.
index 40443b7..ab08ef8 100644 (file)
@@ -1174,6 +1174,10 @@ BUGCR11153 LINUX WIN : platform/chromium/virtual/gpu/fast/canvas/canvas-incremen
 // test_shell, DRT do not correctly schedule paints when invalidating.
 BUGCR62433 WIN : fast/images/gif-loop-count.html = IMAGE
 
+// Implement color profile support.
+BUGCR143 : fast/images/jpeg-with-color-profile.html = MISSING
+BUGCR143 : fast/images/png-with-color-profile.html = MISSING
+
 // -----------------------------------------------------------------
 // SVG TESTS
 // -----------------------------------------------------------------
index 3a87598..1e44ec2 100644 (file)
@@ -1,3 +1,14 @@
+2012-06-18  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        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).
+
+        * wtf/Platform.h:
+
 2012-06-17  Patrick Gansterer  <paroga@webkit.org>
 
         [WIN] Simplify implementation of currentTime()
index 2bc58f3..51a87b2 100644 (file)
 /* USE(SKIA) for Win/Linux/Mac/Android */
 #if PLATFORM(CHROMIUM)
 #if OS(DARWIN)
+#if USE(SKIA_ON_MAC_CHROMIUM)
 #define WTF_USE_SKIA 1
+#else
+#define WTF_USE_CG 1
+#endif
 #define WTF_USE_ATSUI 1
 #define WTF_USE_CORE_TEXT 1
 #define WTF_USE_ICCJPEG 1
-#define WTF_USE_QCMSLIB 1
 #elif OS(ANDROID)
 #define WTF_USE_SKIA 1
 #else
 #define WTF_USE_SKIA 1
 #define WTF_USE_CHROMIUM_NET 1
-#define WTF_USE_ICCJPEG 1
-#define WTF_USE_QCMSLIB 1
 #endif
 #endif
 
index a646202..d24ac81 100644 (file)
@@ -1,3 +1,41 @@
+2012-06-18  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        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).
+
+        * 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):
+
 2012-06-18  Alexei Filippov  <alexeif@chromium.org>
 
         Web Inspector: Add heap profiler owned memory to the pie chart
index d95f4cd..7d8f957 100644 (file)
         '<(chromium_src_dir)/third_party/libxslt/libxslt.gyp:libxslt',
         '<(chromium_src_dir)/third_party/libwebp/libwebp.gyp:libwebp',
         '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
-        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
         '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
         '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
         '<(libjpeg_gyp_path):libjpeg',
         '<(chromium_src_dir)/third_party/libxslt/libxslt.gyp:libxslt',
         '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
         '<(chromium_src_dir)/third_party/ots/ots.gyp:ots',
-        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
         '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
         '<(chromium_src_dir)/third_party/angle/src/build_angle.gyp:translator_glsl',
         '<(chromium_src_dir)/third_party/zlib/zlib.gyp:zlib',
         '<(chromium_src_dir)/third_party/libxslt/libxslt.gyp:libxslt',
         '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
         '<(chromium_src_dir)/third_party/ots/ots.gyp:ots',
-        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
         '<(chromium_src_dir)/third_party/sqlite/sqlite.gyp:sqlite',
         '<(chromium_src_dir)/third_party/angle/src/build_angle.gyp:translator_glsl',
         '<(chromium_src_dir)/third_party/zlib/zlib.gyp:zlib',
         '<(chromium_src_dir)/build/temp_gyp/googleurl.gyp:googleurl',
         '<(chromium_src_dir)/skia/skia.gyp:skia',
         '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
-        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
         '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
       ],
       'export_dependent_settings': [
         '<(chromium_src_dir)/build/temp_gyp/googleurl.gyp:googleurl',
         '<(chromium_src_dir)/skia/skia.gyp:skia',
         '<(chromium_src_dir)/third_party/npapi/npapi.gyp:npapi',
-        '<(chromium_src_dir)/third_party/qcms/qcms.gyp:qcms',
         '<(chromium_src_dir)/v8/tools/gyp/v8.gyp:v8',
       ],
       'direct_dependent_settings': {
index 96d99e6..a6bc188 100644 (file)
 #include "SkColorPriv.h"
 #endif
 
-#if USE(QCMSLIB)
-#include "qcms.h"
-#include <wtf/MainThread.h>
-#if OS(DARWIN)
-#include "GraphicsContextCG.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include <wtf/RetainPtr.h>
-#endif
-#endif
-
 namespace WebCore {
 
     typedef Vector<char> ColorProfile;
@@ -175,12 +165,14 @@ namespace WebCore {
 
 #if USE(SKIA)
         NativeImageSkia m_bitmap;
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+        ColorProfile m_colorProfile;
+#endif
 #else
         Vector<PixelData> m_backingStore;
         PixelData* m_bytes; // The memory is backed by m_backingStore.
         IntSize m_size;
         bool m_hasAlpha;
-        // FIXME: Do we need m_colorProfile anymore?
         ColorProfile m_colorProfile;
 #endif
         IntRect m_originalFrameRect; // This will always just be the entire
@@ -297,43 +289,6 @@ namespace WebCore {
             return !memcmp(&profileData[12], "mntr", 4) || !memcmp(&profileData[12], "scnr", 4);
         }
 
-#if USE(QCMSLIB)
-        static qcms_profile* qcmsOutputDeviceProfile()
-        {
-            static qcms_profile* outputDeviceProfile = 0;
-
-            static bool qcmsInitialized = false;
-            if (!qcmsInitialized) {
-                // FIXME: Chromium's browser_tests hits this. https://bugs.webkit.org/show_bug.cgi?id=89341
-                // ASSERT(isMainThread());
-                qcmsInitialized = true;
-                // FIXME: Add optional ICCv4 support.
-#if OS(DARWIN)
-                RetainPtr<CGColorSpaceRef> monitorColorSpace(AdoptCF, CGDisplayCopyColorSpace(CGMainDisplayID()));
-                CFDataRef iccProfile(CGColorSpaceCopyICCProfile(monitorColorSpace.get()));
-                if (iccProfile) {
-                    size_t length = CFDataGetLength(iccProfile);
-                    const unsigned char* systemProfile = CFDataGetBytePtr(iccProfile);
-                    outputDeviceProfile = qcms_profile_from_memory(systemProfile, length);
-                    if (outputDeviceProfile && qcms_profile_is_bogus(outputDeviceProfile)) {
-                        qcms_profile_release(outputDeviceProfile);
-                        outputDeviceProfile = 0;
-                    }
-                }
-                if (!outputDeviceProfile)
-                    outputDeviceProfile = qcms_profile_sRGB();
-#else
-                // FIXME: sRGB profiles don't add much value. Use the user's monitor profile.
-                outputDeviceProfile = qcms_profile_sRGB();
-#endif
-                // FIXME: Check that the profile is valid. Fallback to sRGB if not?
-                if (outputDeviceProfile)
-                    qcms_profile_precache_output_transform(outputDeviceProfile);
-            }
-            return outputDeviceProfile;
-        }
-#endif
-
         // Sets the "decode failure" flag.  For caller convenience (since so
         // many callers want to return false after calling this), returns false
         // to enable easy tailcalling.  Subclasses may override this to also
@@ -365,7 +320,6 @@ namespace WebCore {
 
         RefPtr<SharedBuffer> m_data; // The encoded data.
         Vector<ImageFrame> m_frameBufferCache;
-        // FIXME: Do we need m_colorProfile any more, for any port?
         ColorProfile m_colorProfile;
         bool m_scaled;
         Vector<int> m_scaledColumns;
index ec8de28..46a28ba 100644 (file)
@@ -60,9 +60,6 @@ extern "C" {
 #if USE(ICCJPEG)
 #include "iccjpeg.h"
 #endif
-#if USE(QCMSLIB)
-#include "qcms.h"
-#endif
 #include <setjmp.h>
 }
 
@@ -79,11 +76,9 @@ inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_EXT_RGBA; }
 #else
 inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_EXT_BGRA; }
 #endif
-inline bool turboSwizzled(J_COLOR_SPACE colorSpace) { return colorSpace == JCS_EXT_RGBA || colorSpace == JCS_EXT_BGRA; }
-inline bool colorSpaceHasAlpha(J_COLOR_SPACE colorSpace) { return turboSwizzled(colorSpace); }
+inline bool turboSwizzled(J_COLOR_SPACE colorSpace) { return colorSpace == rgbOutputColorSpace(); }
 #else
 inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_RGB; }
-inline bool colorSpaceHasAlpha(J_COLOR_SPACE) { return false; }
 #endif
 
 #if OS(ANDROID)
@@ -168,9 +163,6 @@ public:
         , m_bytesToSkip(0)
         , m_state(JPEG_HEADER)
         , m_samples(0)
-#if USE(QCMSLIB)
-        , m_transform(0)
-#endif
     {
         memset(&m_info, 0, sizeof(jpeg_decompress_struct));
 
@@ -218,11 +210,6 @@ public:
             fastFree(src);
         m_info.src = 0;
 
-#if USE(QCMSLIB)
-        if (m_transform)
-            qcms_transform_release(m_transform);
-        m_transform = 0;
-#endif
         jpeg_destroy_decompress(&m_info);
     }
 
@@ -311,14 +298,6 @@ public:
                 ColorProfile rgbInputDeviceColorProfile = readColorProfile(info());
                 if (!rgbInputDeviceColorProfile.isEmpty())
                     m_decoder->setColorProfile(rgbInputDeviceColorProfile);
-#if USE(QCMSLIB)
-                createColorTransform(rgbInputDeviceColorProfile, colorSpaceHasAlpha(m_info.out_color_space));
-#if defined(TURBO_JPEG_RGB_SWIZZLE)
-                // Input RGBA data to qcms. Note: restored to BGRA on output.
-                if (m_transform && m_info.out_color_space == JCS_EXT_BGRA)
-                    m_info.out_color_space = JCS_EXT_RGBA;
-#endif
-#endif
             }
 
             if (m_decodingSizeOnly) {
@@ -423,31 +402,6 @@ public:
     jpeg_decompress_struct* info() { return &m_info; }
     JSAMPARRAY samples() const { return m_samples; }
     JPEGImageDecoder* decoder() { return m_decoder; }
-#if USE(QCMSLIB)
-    qcms_transform* colorTransform() const { return m_transform; }
-
-    void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
-    {
-        if (m_transform)
-            qcms_transform_release(m_transform);
-        m_transform = 0;
-
-        if (colorProfile.isEmpty())
-            return;
-        qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
-        if (!deviceProfile)
-            return;
-        qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
-        if (!inputProfile)
-            return;
-        // We currently only support color profiles for RGB profiled images.
-        ASSERT(icSigRgbData == qcms_profile_get_color_space(inputProfile));
-        qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
-        // FIXME: Don't force perceptual intent if the image profile contains an intent.
-        m_transform = qcms_transform_create(inputProfile, dataFormat, deviceProfile, dataFormat, QCMS_INTENT_PERCEPTUAL);
-        qcms_profile_release(inputProfile);
-    }
-#endif
 
 private:
     JPEGImageDecoder* m_decoder;
@@ -460,10 +414,6 @@ private:
     jstate m_state;
 
     JSAMPARRAY m_samples;
-
-#if USE(QCMSLIB)
-    qcms_transform* m_transform;
-#endif
 };
 
 // Override the standard error method in the IJG JPEG decoder code.
@@ -571,15 +521,11 @@ bool JPEGImageDecoder::outputScanlines()
 
 #if !ENABLE(IMAGE_DECODER_DOWN_SAMPLING) && defined(TURBO_JPEG_RGB_SWIZZLE)
     if (turboSwizzled(info->out_color_space)) {
-        ASSERT(!m_scaled);
-        while (info->output_scanline < info->output_height) {
-            unsigned char* row = reinterpret_cast<unsigned char*>(buffer.getAddr(0, info->output_scanline));
-            if (jpeg_read_scanlines(info, &row, 1) != 1)
-                return false;
-#if USE(QCMSLIB)
-            if (qcms_transform* transform = m_reader->colorTransform())
-                qcms_transform_data_type(transform, row, row, info->output_width, rgbOutputColorSpace() == JCS_EXT_BGRA ? QCMS_OUTPUT_BGRX : QCMS_OUTPUT_RGBX);
-#endif
+         ASSERT(!m_scaled);
+         while (info->output_scanline < info->output_height) {
+             unsigned char* row = reinterpret_cast<unsigned char*>(buffer.getAddr(0, info->output_scanline));
+             if (jpeg_read_scanlines(info, &row, 1) != 1)
+                  return false;
          }
          return true;
      }
@@ -598,10 +544,6 @@ bool JPEGImageDecoder::outputScanlines()
         int destY = scaledY(sourceY);
         if (destY < 0)
             continue;
-#if USE(QCMSLIB)
-        if (m_reader->colorTransform() && info->out_color_space == JCS_RGB)
-            qcms_transform_data(m_reader->colorTransform(), *samples, *samples, info->output_width);
-#endif
         int width = m_scaled ? m_scaledColumns.size() : info->output_width;
         for (int x = 0; x < width; ++x) {
             JSAMPLE* jsample = *samples + (m_scaled ? m_scaledColumns[x] : x) * ((info->out_color_space == JCS_RGB) ? 3 : 4);
index 138d5c5..815b096 100644 (file)
 #include "PNGImageDecoder.h"
 
 #include "png.h"
-#include <wtf/OwnArrayPtr.h>
 #include <wtf/PassOwnPtr.h>
 
 #if PLATFORM(CHROMIUM)
 #include "TraceEvent.h"
 #endif
 
-#if USE(QCMSLIB)
-#include "qcms.h"
-#endif
-
 #if defined(PNG_LIBPNG_VER_MAJOR) && defined(PNG_LIBPNG_VER_MINOR) && (PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4))
 #define JMPBUF(png_ptr) png_jmpbuf(png_ptr)
 #else
@@ -112,14 +107,10 @@ class PNGImageReader
 public:
     PNGImageReader(PNGImageDecoder* decoder)
         : m_readOffset(0)
-        , m_currentBufferSize(0)
         , m_decodingSizeOnly(false)
-        , m_hasAlpha(false)
         , m_interlaceBuffer(0)
-#if USE(QCMSLIB)
-        , m_transform(0)
-        , m_rowBuffer()
-#endif
+        , m_hasAlpha(false)
+        , m_currentBufferSize(0)
     {
         m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, decodingFailed, decodingWarning);
         m_info = png_create_info_struct(m_png);
@@ -136,16 +127,13 @@ public:
         if (m_png && m_info)
             // This will zero the pointers.
             png_destroy_read_struct(&m_png, &m_info, 0);
-#if USE(QCMSLIB)
-        if (m_transform)
-            qcms_transform_release(m_transform);
-        m_transform = 0;
-#endif
         delete[] m_interlaceBuffer;
         m_interlaceBuffer = 0;
         m_readOffset = 0;
     }
 
+    unsigned currentBufferSize() const { return m_currentBufferSize; }
+
     bool decode(const SharedBuffer& data, bool sizeOnly)
     {
         m_decodingSizeOnly = sizeOnly;
@@ -169,57 +157,25 @@ public:
         return false;
     }
 
+    bool decodingSizeOnly() const { return m_decodingSizeOnly; }
     png_structp pngPtr() const { return m_png; }
     png_infop infoPtr() const { return m_info; }
+    png_bytep interlaceBuffer() const { return m_interlaceBuffer; }
+    bool hasAlpha() const { return m_hasAlpha; }
 
     void setReadOffset(unsigned offset) { m_readOffset = offset; }
-    unsigned currentBufferSize() const { return m_currentBufferSize; }
-    bool decodingSizeOnly() const { return m_decodingSizeOnly; }
-    void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
-    bool hasAlpha() const { return m_hasAlpha; }
+    void setHasAlpha(bool b) { m_hasAlpha = b; }
 
-    png_bytep interlaceBuffer() const { return m_interlaceBuffer; }
     void createInterlaceBuffer(int size) { m_interlaceBuffer = new png_byte[size]; }
-#if USE(QCMSLIB)
-    png_bytep rowBuffer() const { return m_rowBuffer.get(); }
-    void createRowBuffer(int size) { m_rowBuffer = adoptArrayPtr(new png_byte[size]); }
-    qcms_transform* colorTransform() const { return m_transform; }
-
-    void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
-    {
-        if (m_transform)
-            qcms_transform_release(m_transform);
-        m_transform = 0;
-
-        if (colorProfile.isEmpty())
-            return;
-        qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
-        if (!deviceProfile)
-            return;
-        qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
-        if (!inputProfile)
-            return;
-        // We currently only support color profiles for RGB and RGBA images.
-        ASSERT(icSigRgbData == qcms_profile_get_color_space(inputProfile));
-        qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
-        // FIXME: Don't force perceptual intent if the image profile contains an intent.
-        m_transform = qcms_transform_create(inputProfile, dataFormat, deviceProfile, dataFormat, QCMS_INTENT_PERCEPTUAL);
-        qcms_profile_release(inputProfile);
-    }
-#endif
 
 private:
-    png_structp m_png;
-    png_infop m_info;
     unsigned m_readOffset;
-    unsigned m_currentBufferSize;
     bool m_decodingSizeOnly;
-    bool m_hasAlpha;
+    png_structp m_png;
+    png_infop m_info;
     png_bytep m_interlaceBuffer;
-#if USE(QCMSLIB)
-    qcms_transform* m_transform;
-    OwnArrayPtr<png_byte> m_rowBuffer;
-#endif
+    bool m_hasAlpha;
+    unsigned m_currentBufferSize;
 };
 
 PNGImageDecoder::PNGImageDecoder(ImageSource::AlphaOption alphaOption,
@@ -342,10 +298,6 @@ void PNGImageDecoder::headerAvailable()
         // the color profile or we'd need to decode into a gray-scale image buffer and
         // hand that to CoreGraphics.
         readColorProfile(png, info, m_colorProfile);
-#if USE(QCMSLIB)
-        m_reader->createColorTransform(m_colorProfile, colorType & PNG_COLOR_MASK_ALPHA);
-        m_colorProfile.clear();
-#endif
     }
 
     // The options we set here match what Mozilla does.
@@ -415,8 +367,8 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
             return;
         }
 
-        unsigned colorChannels = m_reader->hasAlpha() ? 4 : 3;
         if (PNG_INTERLACE_ADAM7 == png_get_interlace_type(png, m_reader->infoPtr())) {
+            unsigned colorChannels = m_reader->hasAlpha() ? 4 : 3;
             m_reader->createInterlaceBuffer(colorChannels * size().width() * size().height());
             if (!m_reader->interlaceBuffer()) {
                 longjmp(JMPBUF(png), 1);
@@ -424,15 +376,6 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
             }
         }
 
-#if USE(QCMSLIB)
-        if (m_reader->colorTransform()) {
-            m_reader->createRowBuffer(colorChannels * size().width());
-            if (!m_reader->rowBuffer()) {
-                longjmp(JMPBUF(png), 1);
-                return;
-            }
-        }
-#endif
         buffer.setStatus(ImageFrame::FramePartial);
         buffer.setHasAlpha(false);
         buffer.setColorProfile(m_colorProfile);
@@ -490,13 +433,6 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
         png_progressive_combine_row(m_reader->pngPtr(), row, rowBuffer);
     }
 
-#if USE(QCMSLIB)
-    if (qcms_transform* transform = m_reader->colorTransform()) {
-        qcms_transform_data(transform, row, m_reader->rowBuffer(), size().width());
-        row = m_reader->rowBuffer();
-    }
-#endif
-
     // Write the decoded row pixels to the frame buffer.
     int width = scaledSize().width();
     bool nonTrivialAlpha = false;
index 5cc132c..d2f06d9 100644 (file)
 #include "config.h"
 #include "ImageDecoder.h"
 
+#include "NotImplemented.h"
+
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+#include "GraphicsContextCG.h"
+#include "SkCGUtils.h"
+#endif
+
 namespace WebCore {
 
 ImageFrame::ImageFrame()
@@ -107,17 +114,58 @@ void ImageFrame::setHasAlpha(bool alpha)
     m_bitmap.bitmap().setIsOpaque(!alpha);
 }
 
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+static void resolveColorSpace(const SkBitmap& bitmap, CGColorSpaceRef colorSpace)
+{
+    int width = bitmap.width();
+    int height = bitmap.height();
+    RetainPtr<CGImageRef> srcImage(AdoptCF, SkCreateCGImageRefWithColorspace(bitmap, colorSpace));
+    SkAutoLockPixels lock(bitmap);
+    void* pixels = bitmap.getPixels();
+    RetainPtr<CGContextRef> cgBitmap(AdoptCF, CGBitmapContextCreate(pixels, width, height, 8, width * 4, deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst));
+    if (!cgBitmap)
+        return;
+    CGContextSetBlendMode(cgBitmap.get(), kCGBlendModeCopy);
+    CGRect bounds = { {0, 0}, {width, height} };
+    CGContextDrawImage(cgBitmap.get(), bounds, srcImage.get());
+}
+
+static CGColorSpaceRef createColorSpace(const ColorProfile& colorProfile)
+{
+    RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(colorProfile.data()), colorProfile.size()));
+#ifndef TARGETING_LEOPARD
+    return CGColorSpaceCreateWithICCProfile(data.get());
+#else
+    RetainPtr<CGDataProviderRef> profileDataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get()));
+    CGFloat ranges[] = {0.0, 255.0, 0.0, 255.0, 0.0, 255.0};
+    return CGColorSpaceCreateICCBased(3, ranges, profileDataProvider.get(), deviceRGBColorSpaceRef());
+#endif
+}
+#endif
+
 void ImageFrame::setColorProfile(const ColorProfile& colorProfile)
 {
-    // FIXME: Do we need this ImageFrame function anymore, on any port?
-    UNUSED_PARAM(colorProfile);
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+    m_colorProfile = colorProfile;
+#else
+    notImplemented();
+#endif
 }
 
 void ImageFrame::setStatus(FrameStatus status)
 {
     m_status = status;
-    if (m_status == FrameComplete)
+    if (m_status == FrameComplete) {
         m_bitmap.setDataComplete();  // Tell the bitmap it's done.
+#if PLATFORM(CHROMIUM) && OS(DARWIN)
+        // resolveColorSpace() and callees assume that the alpha channel is
+        // premultiplied, so don't apply the color profile if it isn't.
+        if (m_colorProfile.isEmpty() || (!m_premultiplyAlpha && hasAlpha()))
+            return;
+        RetainPtr<CGColorSpaceRef> cgColorSpace(AdoptCF, createColorSpace(m_colorProfile));
+        resolveColorSpace(m_bitmap.bitmap(), cgColorSpace.get());
+#endif
+    }
 }
 
 int ImageFrame::width() const