[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
abarth at webkit.org
abarth at webkit.org
Wed Dec 22 14:53:17 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit ea8e8811b77243d57bacc54627eb28398feea014
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Oct 23 00:00:29 2010 +0000
2010-10-21 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel, Peter Kasting, and Darin Fisher.
(Eric reviewed the CoreGraphics interactions, Peter reviewed the image
decoder interaction, and Darin Fisher SGTMed the policy decision.)
[chromium] Chromium Mac should use WebKit's image decoders
https://bugs.webkit.org/show_bug.cgi?id=47974
This patch teaches WebKit's image decoders how to talk to CoreGraphics.
This patch doesn't handle color profiles, but that will come in a
subsequent patch.
* WebCore.gyp/WebCore.gyp:
* WebCore.gypi:
* loader/CachedImage.cpp:
(WebCore::CachedImage::createImage):
* platform/graphics/ImageSource.h:
* platform/image-decoders/ImageDecoder.cpp:
(WebCore::RGBA32Buffer::clear):
(WebCore::RGBA32Buffer::zeroFill):
(WebCore::RGBA32Buffer::copyBitmapData):
(WebCore::RGBA32Buffer::setSize):
* platform/image-decoders/ImageDecoder.h:
(WebCore::RGBA32Buffer::getAddr):
* platform/image-decoders/cg: Added.
* platform/image-decoders/cg/ImageDecoderCG.cpp: Added.
(WebCore::RGBA32Buffer::copyBitmapData):
(WebCore::RGBA32Buffer::setSize):
(WebCore::RGBA32Buffer::asNewNativeImage):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70369 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h
index 946192b..842d812 100644
--- a/JavaScriptCore/wtf/Platform.h
+++ b/JavaScriptCore/wtf/Platform.h
@@ -531,6 +531,10 @@
#endif
#endif
+#if PLATFORM(CHROMIUM)
+#define WTF_USE_WEBKIT_IMAGE_DECODERS 1
+#endif
+
#if PLATFORM(BREWMP)
#define WTF_PLATFORM_SKIA 1
#endif
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e2d0c09..57674c7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-10-21 Adam Barth <abarth at webkit.org>
+
+ Reviewed by Eric Seidel, Peter Kasting, and Darin Fisher.
+ (Eric reviewed the CoreGraphics interactions, Peter reviewed the image
+ decoder interaction, and Darin Fisher SGTMed the policy decision.)
+
+ [chromium] Chromium Mac should use WebKit's image decoders
+ https://bugs.webkit.org/show_bug.cgi?id=47974
+
+ This patch teaches WebKit's image decoders how to talk to CoreGraphics.
+ This patch doesn't handle color profiles, but that will come in a
+ subsequent patch.
+
+ * WebCore.gyp/WebCore.gyp:
+ * WebCore.gypi:
+ * loader/CachedImage.cpp:
+ (WebCore::CachedImage::createImage):
+ * platform/graphics/ImageSource.h:
+ * platform/image-decoders/ImageDecoder.cpp:
+ (WebCore::RGBA32Buffer::clear):
+ (WebCore::RGBA32Buffer::zeroFill):
+ (WebCore::RGBA32Buffer::copyBitmapData):
+ (WebCore::RGBA32Buffer::setSize):
+ * platform/image-decoders/ImageDecoder.h:
+ (WebCore::RGBA32Buffer::getAddr):
+ * platform/image-decoders/cg: Added.
+ * platform/image-decoders/cg/ImageDecoderCG.cpp: Added.
+ (WebCore::RGBA32Buffer::copyBitmapData):
+ (WebCore::RGBA32Buffer::setSize):
+ (WebCore::RGBA32Buffer::asNewNativeImage):
+
2010-10-20 Anders Carlsson <andersca at apple.com>
Reviewed by Adam Barth and Darin Adler.
diff --git a/WebCore/WebCore.gyp/WebCore.gyp b/WebCore/WebCore.gyp/WebCore.gyp
index 7c28ba7..ce77c8f 100644
--- a/WebCore/WebCore.gyp/WebCore.gyp
+++ b/WebCore/WebCore.gyp/WebCore.gyp
@@ -1164,23 +1164,14 @@
# platform/graphics/chromium, included by regex above, instead.
['exclude', 'platform/graphics/chromium/ImageChromium\\.cpp$'],
- # The Mac uses ImageSourceCG.cpp from platform/graphics/cg, included
- # by regex above, instead.
- ['exclude', 'platform/graphics/ImageSource\\.cpp$'],
+ # The Mac does not use ImageSourceCG.cpp from platform/graphics/cg
+ # even though it is included by regex above.
+ ['exclude', 'platform/graphics/cg/ImageSourceCG\\.cpp$'],
+ ['exclude', 'platform/graphics/cg/PDFDocumentImage\\.cpp$'],
- # Skia image-decoders are also not used on mac. CoreGraphics
- # is used directly instead.
- ['exclude', 'platform/image-decoders/ImageDecoder\\.h$'],
- ['exclude', 'platform/image-decoders/bmp/BMPImageDecoder\\.(cpp|h)$'],
- ['exclude', 'platform/image-decoders/bmp/BMPImageReader\\.(cpp|h)$'],
- ['exclude', 'platform/image-decoders/gif/GIFImageDecoder\\.(cpp|h)$'],
- ['exclude', 'platform/image-decoders/gif/GIFImageReader\\.(cpp|h)$'],
- ['exclude', 'platform/image-decoders/ico/ICOImageDecoder\\.(cpp|h)$'],
- ['exclude', 'platform/image-decoders/jpeg/JPEGImageDecoder\\.(cpp|h)$'],
- ['exclude', 'platform/image-decoders/webp/WEBPImageDecoder\\.(cpp|h)$'],
- ['exclude', 'platform/image-decoders/png/PNGImageDecoder\\.(cpp|h)$'],
+ # ImageDecoderSkia is not used on mac. ImageDecoderCG is used instead.
['exclude', 'platform/image-decoders/skia/ImageDecoderSkia\\.cpp$'],
- ['exclude', 'platform/image-decoders/xbm/XBMImageDecoder\\.(cpp|h)$'],
+ ['include', 'platform/image-decoders/cg/ImageDecoderCG\\.cpp$'],
# Again, Skia is not used on Mac.
['exclude', 'platform/chromium/DragImageChromiumSkia\\.cpp$'],
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 4a417f3..c5ef729 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2845,6 +2845,7 @@
'platform/image-decoders/bmp/BMPImageReader.cpp',
'platform/image-decoders/bmp/BMPImageReader.h',
'platform/image-decoders/cairo/ImageDecoderCairo.cpp',
+ 'platform/image-decoders/cg/ImageDecoderCG.cpp',
'platform/image-decoders/gif/GIFImageDecoder.cpp',
'platform/image-decoders/gif/GIFImageDecoder.h',
'platform/image-decoders/gif/GIFImageReader.cpp',
diff --git a/WebCore/loader/CachedImage.cpp b/WebCore/loader/CachedImage.cpp
index 2c18f35..9f6abef 100644
--- a/WebCore/loader/CachedImage.cpp
+++ b/WebCore/loader/CachedImage.cpp
@@ -237,7 +237,7 @@ inline void CachedImage::createImage()
// Create the image if it doesn't yet exist.
if (m_image)
return;
-#if PLATFORM(CG)
+#if PLATFORM(CG) && !USE(WEBKIT_IMAGE_DECODERS)
if (m_response.mimeType() == "application/pdf") {
m_image = PDFDocumentImage::create();
return;
diff --git a/WebCore/platform/graphics/ImageSource.h b/WebCore/platform/graphics/ImageSource.h
index 19952b1..899ed38 100644
--- a/WebCore/platform/graphics/ImageSource.h
+++ b/WebCore/platform/graphics/ImageSource.h
@@ -63,7 +63,12 @@ class IntSize;
class SharedBuffer;
#if PLATFORM(CG)
+#if USE(WEBKIT_IMAGE_DECODERS)
+class ImageDecoder;
+typedef ImageDecoder* NativeImageSourcePtr;
+#else
typedef CGImageSourceRef NativeImageSourcePtr;
+#endif
typedef CGImageRef NativeImagePtr;
#elif PLATFORM(OPENVG)
class ImageDecoder;
diff --git a/WebCore/platform/image-decoders/ImageDecoder.cpp b/WebCore/platform/image-decoders/ImageDecoder.cpp
index 58c71f8..9ffbbf5 100644
--- a/WebCore/platform/image-decoders/ImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/ImageDecoder.cpp
@@ -117,7 +117,7 @@ RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
if (this == &other)
return *this;
- copyBitmapData(other);
+ copyReferenceToBitmapData(other);
setRect(other.rect());
setStatus(other.status());
setDuration(other.duration());
@@ -128,7 +128,8 @@ RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
void RGBA32Buffer::clear()
{
- m_bytes.clear();
+ m_backingStore.clear();
+ m_bytes = 0;
m_status = FrameEmpty;
// NOTE: Do not reset other members here; clearFrameBufferCache() calls this
// to free the bitmap data, but other functions like initFrameBuffer() and
@@ -138,16 +139,25 @@ void RGBA32Buffer::clear()
void RGBA32Buffer::zeroFill()
{
- m_bytes.fill(0);
+ memset(m_bytes, 0, m_size.width() * m_size.height() * sizeof(PixelData));
m_hasAlpha = true;
}
+#if !PLATFORM(CF)
+
+void RGBA32Buffer::copyReferenceToBitmapData(const RGBA32Buffer& other)
+{
+ ASSERT(this != &other);
+ copyBitmapData(other);
+}
+
bool RGBA32Buffer::copyBitmapData(const RGBA32Buffer& other)
{
if (this == &other)
return true;
- m_bytes = other.m_bytes;
+ m_backingStore = other.m_backingStore;
+ m_bytes = m_backingStore.data();
m_size = other.m_size;
setHasAlpha(other.m_hasAlpha);
return true;
@@ -157,7 +167,8 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight)
{
// NOTE: This has no way to check for allocation failure if the requested
// size was too big...
- m_bytes.resize(newWidth * newHeight);
+ m_backingStore.resize(newWidth * newHeight);
+ m_bytes = m_backingStore.data();
m_size = IntSize(newWidth, newHeight);
// Zero the image.
@@ -166,6 +177,8 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight)
return true;
}
+#endif
+
bool RGBA32Buffer::hasAlpha() const
{
return m_hasAlpha;
diff --git a/WebCore/platform/image-decoders/ImageDecoder.h b/WebCore/platform/image-decoders/ImageDecoder.h
index b97d864..b07c72b 100644
--- a/WebCore/platform/image-decoders/ImageDecoder.h
+++ b/WebCore/platform/image-decoders/ImageDecoder.h
@@ -85,7 +85,11 @@ namespace WebCore {
// Creates a new copy of the image data in |other|, so the two images
// can be modified independently. Returns whether the copy succeeded.
- bool copyBitmapData(const RGBA32Buffer& other);
+ bool copyBitmapData(const RGBA32Buffer&);
+
+ // Creates a new reference to the image data in |other|. The two images
+ // share a common backing store.
+ void copyReferenceToBitmapData(const RGBA32Buffer&);
// Copies the pixel data at [(startX, startY), (endX, startY)) to the
// same X-coordinates on each subsequent row up to but not including
@@ -137,6 +141,12 @@ namespace WebCore {
#endif
private:
+#if PLATFORM(CF)
+ typedef RetainPtr<CFMutableDataRef> NativeBackingStore;
+#else
+ typedef Vector<PixelData> NativeBackingStore;
+#endif
+
int width() const;
int height() const;
@@ -149,7 +159,7 @@ namespace WebCore {
m_pixmap = QPixmap();
return reinterpret_cast_ptr<QRgb*>(m_image.scanLine(y)) + x;
#else
- return m_bytes.data() + (y * width()) + x;
+ return m_bytes + (y * width()) + x;
#endif
}
@@ -176,26 +186,25 @@ namespace WebCore {
bool m_hasAlpha;
IntSize m_size;
#else
- Vector<PixelData> m_bytes;
- IntSize m_size; // The size of the buffer. This should be the
- // same as ImageDecoder::m_size.
- bool m_hasAlpha; // Whether or not any of the pixels in the buffer
- // have transparency.
+ NativeBackingStore m_backingStore;
+ PixelData* m_bytes; // The memory is backed by m_backingStore.
+ IntSize m_size; // The size of the buffer. This should be the
+ // same as ImageDecoder::m_size.
+ bool m_hasAlpha; // Whether or not any of the pixels in the buffer
+ // have transparency.
#endif
- IntRect m_rect; // The rect of the original specified frame within
- // the overall buffer. This will always just be
- // the entire buffer except for GIF frames whose
- // original rect was smaller than the overall
- // image size.
+ IntRect m_rect; // The rect of the original specified frame within
+ // the overall buffer. This will always just be
+ // the entire buffer except for GIF frames whose
+ // original rect was smaller than the overall
+ // image size.
FrameStatus m_status; // Whether or not this frame is completely
// finished decoding.
- unsigned m_duration; // The animation delay.
- FrameDisposalMethod m_disposalMethod;
- // What to do with this frame's data when
- // initializing the next frame.
- bool m_premultiplyAlpha;
- // Whether to premultiply alpha into R, G, B
- // channels; by default it's true.
+ unsigned m_duration; // The animation delay.
+ FrameDisposalMethod m_disposalMethod; // What to do with this frame's data when
+ // initializing the next frame.
+ bool m_premultiplyAlpha; // Whether to premultiply alpha into R, G, B
+ // channels; by default it's true.
};
// The ImageDecoder class represents a base class for specific image format
diff --git a/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp b/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp
index 203205d..d741882 100644
--- a/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp
+++ b/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp
@@ -34,7 +34,7 @@ NativeImagePtr RGBA32Buffer::asNewNativeImage() const
{
return cairo_image_surface_create_for_data(
reinterpret_cast<unsigned char*>(const_cast<PixelData*>(
- m_bytes.data())), CAIRO_FORMAT_ARGB32, width(), height(),
+ m_bytes)), CAIRO_FORMAT_ARGB32, width(), height(),
width() * sizeof(PixelData));
}
diff --git a/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp b/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp
new file mode 100644
index 0000000..2fac7da
--- /dev/null
+++ b/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ImageDecoder.h"
+
+#include <CoreGraphics/CGColorSpace.h>
+#include <CoreGraphics/CGImage.h>
+
+namespace WebCore {
+
+void RGBA32Buffer::copyReferenceToBitmapData(const RGBA32Buffer& other)
+{
+ ASSERT(this != &other);
+ m_backingStore = other.m_backingStore;
+ m_bytes = reinterpret_cast<PixelData*>(CFDataGetMutableBytePtr(m_backingStore.get()));
+ // FIXME: The rest of this function seems redundant with RGBA32Buffer::copyBitmapData.
+ m_size = other.m_size;
+ setHasAlpha(other.m_hasAlpha);
+}
+
+bool RGBA32Buffer::copyBitmapData(const RGBA32Buffer& other)
+{
+ if (this == &other)
+ return true;
+
+ m_backingStore.adoptCF(CFDataCreateMutableCopy(kCFAllocatorDefault, 0, other.m_backingStore.get()));
+ m_bytes = reinterpret_cast<PixelData*>(CFDataGetMutableBytePtr(m_backingStore.get()));
+ m_size = other.m_size;
+ setHasAlpha(other.m_hasAlpha);
+ return true;
+}
+
+bool RGBA32Buffer::setSize(int newWidth, int newHeight)
+{
+ m_backingStore.adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0));
+ CFDataSetLength(m_backingStore.get(), newWidth * newHeight * sizeof(PixelData));
+ m_bytes = reinterpret_cast<PixelData*>(CFDataGetMutableBytePtr(m_backingStore.get()));
+ m_size = IntSize(newWidth, newHeight);
+
+ zeroFill();
+ return true;
+}
+
+NativeImagePtr RGBA32Buffer::asNewNativeImage() const
+{
+ // FIXME: Figure out the right color space.
+ DEFINE_STATIC_LOCAL(RetainPtr<CGColorSpaceRef>, deviceColorSpace, (AdoptCF, CGColorSpaceCreateDeviceRGB()));
+ RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(m_backingStore.get()));
+
+ CGImageAlphaInfo alphaInfo = m_premultiplyAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaFirst;
+
+ return CGImageCreate(width(), height(), 8, 32, width() * sizeof(PixelData), deviceColorSpace.get(),
+ alphaInfo | kCGBitmapByteOrder32Host, dataProvider.get(), 0, false, kCGRenderingIntentDefault);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp b/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
index 7f00db2..47302f7 100644
--- a/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
+++ b/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
@@ -36,7 +36,7 @@ NativeImagePtr RGBA32Buffer::asNewNativeImage() const
int bytesPerRow = width() * sizeof(PixelData);
OwnPtr<BBitmap> bitmap(new BBitmap(BRect(0, 0, width() - 1, height() - 1), 0, B_RGBA32, bytesPerRow));
- const uint8* source = reinterpret_cast<const uint8*>(m_bytes.data());
+ const uint8* source = reinterpret_cast<const uint8*>(m_bytes);
uint8* destination = reinterpret_cast<uint8*>(bitmap->Bits());
int h = height();
int w = width();
diff --git a/WebCore/platform/image-decoders/openvg/ImageDecoderOpenVG.cpp b/WebCore/platform/image-decoders/openvg/ImageDecoderOpenVG.cpp
index 3d8f749..061c5ab 100644
--- a/WebCore/platform/image-decoders/openvg/ImageDecoderOpenVG.cpp
+++ b/WebCore/platform/image-decoders/openvg/ImageDecoderOpenVG.cpp
@@ -59,7 +59,7 @@ NativeImagePtr RGBA32Buffer::asNewNativeImage() const
tileRect.width(), tileRect.height(), VG_IMAGE_QUALITY_FASTER);
ASSERT_VG_NO_ERROR();
- PixelData* pixelData = const_cast<PixelData*>(m_bytes.data());
+ PixelData* pixelData = const_cast<PixelData*>(m_bytes);
pixelData += (tileRect.y() * width()) + tileRect.x();
vgImageSubData(image, reinterpret_cast<unsigned char*>(pixelData),
diff --git a/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp b/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp
index e6e45b7..966eb90 100644
--- a/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp
+++ b/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp
@@ -48,12 +48,12 @@ NativeImagePtr RGBA32Buffer::asNewNativeImage() const
// NB: It appears that the data is in BGRA format instead of RGBA format.
// This code works properly on both ppc and intel, meaning the issue is
// likely not an issue of byte order getting mixed up on different archs.
- const unsigned char* bytes = (const unsigned char*)m_bytes.data();
+ const unsigned char* bytes = (const unsigned char*)m_bytes;
int rowCounter = 0;
long pixelCounter = 0;
WxPixelData::Iterator p(data);
WxPixelData::Iterator rowStart = p;
- for (size_t i = 0; i < m_bytes.size() * sizeof(PixelData); i += sizeof(PixelData)) {
+ for (size_t i = 0; i < m_size.width() * m_size.height() * sizeof(PixelData); i += sizeof(PixelData)) {
p.Red() = bytes[i + 2];
p.Green() = bytes[i + 1];
p.Blue() = bytes[i + 0];
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list