[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e
krit at webkit.org
krit at webkit.org
Fri Jan 21 14:50:59 UTC 2011
The following commit has been merged in the debian/experimental branch:
commit 6f239b269631e87a324344be4e5a90b03b664302
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Jan 2 10:38:27 2011 +0000
2011-01-02 Dirk Schulze <krit at webkit.org>
Reviewed by Simon Fraser.
Clarify ImageBuffer and ImageData relationship
https://bugs.webkit.org/show_bug.cgi?id=51297
Use ByteArray instead of ImageData.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::doPixelReadbackToCanvas):
2011-01-02 Dirk Schulze <krit at webkit.org>
Reviewed by Simon Fraser.
Clarify ImageBuffer and ImageData relationship
https://bugs.webkit.org/show_bug.cgi?id=51297
Remove references to ImageData and CanvasPixelArray from ImageBuffer and SVG filter/masker code,
since this was a layering violation, and replaced it by ByteArray.
No change of functionality, so no new test added.
* html/ImageData.cpp:
(WebCore::ImageData::create):
(WebCore::ImageData::ImageData):
* html/ImageData.h: Added new constructor with ByteArray input.
(WebCore::ImageData::width):
(WebCore::ImageData::height):
(WebCore::ImageData::data):
* html/canvas/CanvasPixelArray.cpp:
(WebCore::CanvasPixelArray::create):
(WebCore::CanvasPixelArray::CanvasPixelArray):
* html/canvas/CanvasPixelArray.h: New conctructor with ByteArray input, used by HTML Canvas.
(WebCore::CanvasPixelArray::data):
(WebCore::CanvasPixelArray::length):
(WebCore::CanvasPixelArray::set):
(WebCore::CanvasPixelArray::get):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::getImageData):
(WebCore::CanvasRenderingContext2D::putImageData):
* platform/graphics/ImageBuffer.h:
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::putImageData):
(WebCore::ImageBuffer::putUnmultipliedImageData):
(WebCore::ImageBuffer::putPremultipliedImageData):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::putImageData):
(WebCore::ImageBuffer::putUnmultipliedImageData):
(WebCore::ImageBuffer::putPremultipliedImageData):
* platform/graphics/filters/FEBlend.cpp:
(WebCore::FEBlend::apply):
* platform/graphics/filters/FEColorMatrix.cpp:
(WebCore::FEColorMatrix::apply):
* platform/graphics/filters/FEComponentTransfer.cpp:
(WebCore::FEComponentTransfer::apply):
* platform/graphics/filters/FEComposite.cpp:
(WebCore::FEComposite::apply):
* platform/graphics/filters/FEConvolveMatrix.cpp:
(WebCore::setDestinationPixels):
(WebCore::FEConvolveMatrix::apply):
* platform/graphics/filters/FEConvolveMatrix.h:
* platform/graphics/filters/FEDisplacementMap.cpp:
(WebCore::FEDisplacementMap::apply):
* platform/graphics/filters/FEGaussianBlur.cpp:
(WebCore::FEGaussianBlur::apply):
* platform/graphics/filters/FELighting.cpp:
(WebCore::FELighting::apply):
* platform/graphics/filters/FEMorphology.cpp:
(WebCore::FEMorphology::apply):
* platform/graphics/filters/FETurbulence.cpp:
(WebCore::FETurbulence::apply):
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::asImageBuffer):
(WebCore::FilterEffect::asUnmultipliedImage):
(WebCore::FilterEffect::asPremultipliedImage):
(WebCore::FilterEffect::copyImageBytes):
(WebCore::FilterEffect::copyUnmultipliedImage):
(WebCore::FilterEffect::copyPremultipliedImage):
(WebCore::FilterEffect::createUnmultipliedImageResult):
(WebCore::FilterEffect::createPremultipliedImageResult):
* platform/graphics/filters/FilterEffect.h:
* platform/graphics/qt/ImageBufferQt.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::putImageData):
(WebCore::ImageBuffer::putUnmultipliedImageData):
(WebCore::ImageBuffer::putPremultipliedImageData):
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::putImageData):
(WebCore::ImageBuffer::putUnmultipliedImageData):
(WebCore::ImageBuffer::putPremultipliedImageData):
* platform/graphics/wince/ImageBufferWinCE.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::putImageData):
(WebCore::ImageBuffer::putUnmultipliedImageData):
(WebCore::ImageBuffer::putPremultipliedImageData):
* platform/graphics/wx/ImageBufferWx.cpp:
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putUnmultipliedImageData):
(WebCore::ImageBuffer::putPremultipliedImageData):
* rendering/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 59eab6c..4256c93 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,109 @@
+2011-01-02 Dirk Schulze <krit at webkit.org>
+
+ Reviewed by Simon Fraser.
+
+ Clarify ImageBuffer and ImageData relationship
+ https://bugs.webkit.org/show_bug.cgi?id=51297
+
+ Remove references to ImageData and CanvasPixelArray from ImageBuffer and SVG filter/masker code,
+ since this was a layering violation, and replaced it by ByteArray.
+
+ No change of functionality, so no new test added.
+
+ * html/ImageData.cpp:
+ (WebCore::ImageData::create):
+ (WebCore::ImageData::ImageData):
+ * html/ImageData.h: Added new constructor with ByteArray input.
+ (WebCore::ImageData::width):
+ (WebCore::ImageData::height):
+ (WebCore::ImageData::data):
+ * html/canvas/CanvasPixelArray.cpp:
+ (WebCore::CanvasPixelArray::create):
+ (WebCore::CanvasPixelArray::CanvasPixelArray):
+ * html/canvas/CanvasPixelArray.h: New conctructor with ByteArray input, used by HTML Canvas.
+ (WebCore::CanvasPixelArray::data):
+ (WebCore::CanvasPixelArray::length):
+ (WebCore::CanvasPixelArray::set):
+ (WebCore::CanvasPixelArray::get):
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::getImageData):
+ (WebCore::CanvasRenderingContext2D::putImageData):
+ * platform/graphics/ImageBuffer.h:
+ * platform/graphics/cairo/ImageBufferCairo.cpp:
+ (WebCore::getImageData):
+ (WebCore::ImageBuffer::getUnmultipliedImageData):
+ (WebCore::ImageBuffer::getPremultipliedImageData):
+ (WebCore::putImageData):
+ (WebCore::ImageBuffer::putUnmultipliedImageData):
+ (WebCore::ImageBuffer::putPremultipliedImageData):
+ * platform/graphics/cg/ImageBufferCG.cpp:
+ (WebCore::getImageData):
+ (WebCore::ImageBuffer::getUnmultipliedImageData):
+ (WebCore::ImageBuffer::getPremultipliedImageData):
+ (WebCore::putImageData):
+ (WebCore::ImageBuffer::putUnmultipliedImageData):
+ (WebCore::ImageBuffer::putPremultipliedImageData):
+ * platform/graphics/filters/FEBlend.cpp:
+ (WebCore::FEBlend::apply):
+ * platform/graphics/filters/FEColorMatrix.cpp:
+ (WebCore::FEColorMatrix::apply):
+ * platform/graphics/filters/FEComponentTransfer.cpp:
+ (WebCore::FEComponentTransfer::apply):
+ * platform/graphics/filters/FEComposite.cpp:
+ (WebCore::FEComposite::apply):
+ * platform/graphics/filters/FEConvolveMatrix.cpp:
+ (WebCore::setDestinationPixels):
+ (WebCore::FEConvolveMatrix::apply):
+ * platform/graphics/filters/FEConvolveMatrix.h:
+ * platform/graphics/filters/FEDisplacementMap.cpp:
+ (WebCore::FEDisplacementMap::apply):
+ * platform/graphics/filters/FEGaussianBlur.cpp:
+ (WebCore::FEGaussianBlur::apply):
+ * platform/graphics/filters/FELighting.cpp:
+ (WebCore::FELighting::apply):
+ * platform/graphics/filters/FEMorphology.cpp:
+ (WebCore::FEMorphology::apply):
+ * platform/graphics/filters/FETurbulence.cpp:
+ (WebCore::FETurbulence::apply):
+ * platform/graphics/filters/FilterEffect.cpp:
+ (WebCore::FilterEffect::asImageBuffer):
+ (WebCore::FilterEffect::asUnmultipliedImage):
+ (WebCore::FilterEffect::asPremultipliedImage):
+ (WebCore::FilterEffect::copyImageBytes):
+ (WebCore::FilterEffect::copyUnmultipliedImage):
+ (WebCore::FilterEffect::copyPremultipliedImage):
+ (WebCore::FilterEffect::createUnmultipliedImageResult):
+ (WebCore::FilterEffect::createPremultipliedImageResult):
+ * platform/graphics/filters/FilterEffect.h:
+ * platform/graphics/qt/ImageBufferQt.cpp:
+ (WebCore::getImageData):
+ (WebCore::ImageBuffer::getUnmultipliedImageData):
+ (WebCore::ImageBuffer::getPremultipliedImageData):
+ (WebCore::putImageData):
+ (WebCore::ImageBuffer::putUnmultipliedImageData):
+ (WebCore::ImageBuffer::putPremultipliedImageData):
+ * platform/graphics/skia/ImageBufferSkia.cpp:
+ (WebCore::getImageData):
+ (WebCore::ImageBuffer::getUnmultipliedImageData):
+ (WebCore::ImageBuffer::getPremultipliedImageData):
+ (WebCore::putImageData):
+ (WebCore::ImageBuffer::putUnmultipliedImageData):
+ (WebCore::ImageBuffer::putPremultipliedImageData):
+ * platform/graphics/wince/ImageBufferWinCE.cpp:
+ (WebCore::getImageData):
+ (WebCore::ImageBuffer::getUnmultipliedImageData):
+ (WebCore::ImageBuffer::getPremultipliedImageData):
+ (WebCore::putImageData):
+ (WebCore::ImageBuffer::putUnmultipliedImageData):
+ (WebCore::ImageBuffer::putPremultipliedImageData):
+ * platform/graphics/wx/ImageBufferWx.cpp:
+ (WebCore::ImageBuffer::getUnmultipliedImageData):
+ (WebCore::ImageBuffer::getPremultipliedImageData):
+ (WebCore::ImageBuffer::putUnmultipliedImageData):
+ (WebCore::ImageBuffer::putPremultipliedImageData):
+ * rendering/RenderSVGResourceMasker.cpp:
+ (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
+
2011-01-01 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
diff --git a/WebCore/html/ImageData.cpp b/WebCore/html/ImageData.cpp
index 104ffb5..2584d6c 100644
--- a/WebCore/html/ImageData.cpp
+++ b/WebCore/html/ImageData.cpp
@@ -36,6 +36,11 @@ PassRefPtr<ImageData> ImageData::create(unsigned width, unsigned height)
return adoptRef(new ImageData(width, height));
}
+PassRefPtr<ImageData> ImageData::create(unsigned width, unsigned height, PassRefPtr<ByteArray> byteArray)
+{
+ return adoptRef(new ImageData(width, height, byteArray));
+}
+
ImageData::ImageData(unsigned width, unsigned height)
: m_width(width)
, m_height(height)
@@ -43,5 +48,12 @@ ImageData::ImageData(unsigned width, unsigned height)
{
}
+ImageData::ImageData(unsigned width, unsigned height, PassRefPtr<ByteArray> byteArray)
+ : m_width(width)
+ , m_height(height)
+ , m_data(CanvasPixelArray::create(byteArray))
+{
+}
+
}
diff --git a/WebCore/html/ImageData.h b/WebCore/html/ImageData.h
index fe79f66..f7daf0e 100644
--- a/WebCore/html/ImageData.h
+++ b/WebCore/html/ImageData.h
@@ -30,25 +30,29 @@
#define ImageData_h
#include "CanvasPixelArray.h"
+#include <wtf/ByteArray.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
- class ImageData : public RefCounted<ImageData> {
- public:
- static PassRefPtr<ImageData> create(unsigned width, unsigned height);
+class ImageData : public RefCounted<ImageData> {
+public:
+ static PassRefPtr<ImageData> create(unsigned width, unsigned height);
+ static PassRefPtr<ImageData> create(unsigned width, unsigned height, PassRefPtr<ByteArray>);
- unsigned width() const { return m_width; }
- unsigned height() const { return m_height; }
- CanvasPixelArray* data() const { return m_data.get(); }
+ unsigned width() const { return m_width; }
+ unsigned height() const { return m_height; }
+ CanvasPixelArray* data() const { return m_data.get(); }
- private:
- ImageData(unsigned width, unsigned height);
- unsigned m_width;
- unsigned m_height;
- RefPtr<CanvasPixelArray> m_data;
- };
+private:
+ ImageData(unsigned width, unsigned height);
+ ImageData(unsigned width, unsigned height, PassRefPtr<ByteArray>);
+
+ unsigned m_width;
+ unsigned m_height;
+ RefPtr<CanvasPixelArray> m_data;
+};
} // namespace WebCore
diff --git a/WebCore/html/canvas/CanvasPixelArray.cpp b/WebCore/html/canvas/CanvasPixelArray.cpp
index a377c83..65ac7ec 100644
--- a/WebCore/html/canvas/CanvasPixelArray.cpp
+++ b/WebCore/html/canvas/CanvasPixelArray.cpp
@@ -31,14 +31,24 @@
namespace WebCore {
- PassRefPtr<CanvasPixelArray> CanvasPixelArray::create(unsigned length)
- {
- return adoptRef(new CanvasPixelArray(length));
- }
-
- CanvasPixelArray::CanvasPixelArray(unsigned length)
- : m_data(WTF::ByteArray::create(length))
- {
- }
-
+PassRefPtr<CanvasPixelArray> CanvasPixelArray::create(unsigned length)
+{
+ return adoptRef(new CanvasPixelArray(length));
+}
+
+PassRefPtr<CanvasPixelArray> CanvasPixelArray::create(PassRefPtr<ByteArray> byteArray)
+{
+ return adoptRef(new CanvasPixelArray(byteArray));
+}
+
+CanvasPixelArray::CanvasPixelArray(unsigned length)
+ : m_data(ByteArray::create(length))
+{
+}
+
+CanvasPixelArray::CanvasPixelArray(PassRefPtr<ByteArray> byteArray)
+ : m_data(byteArray)
+{
+}
+
}
diff --git a/WebCore/html/canvas/CanvasPixelArray.h b/WebCore/html/canvas/CanvasPixelArray.h
index 25eb92a..7a94b1f 100644
--- a/WebCore/html/canvas/CanvasPixelArray.h
+++ b/WebCore/html/canvas/CanvasPixelArray.h
@@ -37,38 +37,41 @@
namespace WebCore {
- class CanvasPixelArray : public RefCounted<CanvasPixelArray> {
- public:
- static PassRefPtr<CanvasPixelArray> create(unsigned length);
-
- WTF::ByteArray* data() { return m_data.get(); }
- const WTF::ByteArray* data() const { return m_data.get(); }
- unsigned length() const { return m_data->length(); }
-
- void set(unsigned index, double value)
- {
- m_data->set(index, value);
- }
+class CanvasPixelArray : public RefCounted<CanvasPixelArray> {
+public:
+ static PassRefPtr<CanvasPixelArray> create(unsigned length);
+ static PassRefPtr<CanvasPixelArray> create(PassRefPtr<ByteArray>);
- void set(unsigned index, unsigned char value)
- {
- m_data->set(index, value);
- }
-
- bool get(unsigned index, unsigned char& result) const
- {
- return m_data->get(index, result);
- }
+ ByteArray* data() { return m_data.get(); }
+ const ByteArray* data() const { return m_data.get(); }
+ unsigned length() const { return m_data->length(); }
+
+ void set(unsigned index, double value)
+ {
+ m_data->set(index, value);
+ }
+
+ void set(unsigned index, unsigned char value)
+ {
+ m_data->set(index, value);
+ }
+
+ bool get(unsigned index, unsigned char& result) const
+ {
+ return m_data->get(index, result);
+ }
+
+ unsigned char get(unsigned index) const
+ {
+ return m_data->get(index);
+ }
- unsigned char get(unsigned index) const
- {
- return m_data->get(index);
- }
+private:
+ CanvasPixelArray(unsigned length);
+ CanvasPixelArray(PassRefPtr<ByteArray>);
- private:
- CanvasPixelArray(unsigned length);
- RefPtr<WTF::ByteArray> m_data;
- };
+ RefPtr<ByteArray> m_data;
+};
} // namespace WebCore
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index bd90697..bbb478f 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -1587,7 +1587,7 @@ PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy,
ImageBuffer* buffer = canvas()->buffer();
if (!buffer)
return createEmptyImageData(scaledRect.size());
- return buffer->getUnmultipliedImageData(scaledRect);
+ return ImageData::create(scaledRect.width(), scaledRect.height(), buffer->getUnmultipliedImageData(scaledRect));
}
void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, ExceptionCode& ec)
@@ -1636,7 +1636,7 @@ void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
IntRect sourceRect(destRect);
sourceRect.move(-destOffset);
- buffer->putUnmultipliedImageData(data, sourceRect, IntPoint(destOffset));
+ buffer->putUnmultipliedImageData(data->data()->data(), IntSize(data->width(), data->height()), sourceRect, IntPoint(destOffset));
didDraw(destRect, CanvasDidDrawApplyNone); // ignore transform, shadow and clip
}
diff --git a/WebCore/platform/graphics/ImageBuffer.h b/WebCore/platform/graphics/ImageBuffer.h
index 56519dd..338e3f8 100644
--- a/WebCore/platform/graphics/ImageBuffer.h
+++ b/WebCore/platform/graphics/ImageBuffer.h
@@ -34,6 +34,7 @@
#include "Image.h"
#include "IntSize.h"
#include "ImageBufferData.h"
+#include <wtf/ByteArray.h>
#include <wtf/Forward.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
@@ -83,11 +84,11 @@ namespace WebCore {
bool drawsUsingCopy() const; // If the image buffer has to render using a copied image, it will return true.
PassRefPtr<Image> copyImage() const; // Return a new image that is a copy of the buffer.
- PassRefPtr<ImageData> getUnmultipliedImageData(const IntRect&) const;
- PassRefPtr<ImageData> getPremultipliedImageData(const IntRect&) const;
+ PassRefPtr<ByteArray> getUnmultipliedImageData(const IntRect&) const;
+ PassRefPtr<ByteArray> getPremultipliedImageData(const IntRect&) const;
- void putUnmultipliedImageData(ImageData*, const IntRect& sourceRect, const IntPoint& destPoint);
- void putPremultipliedImageData(ImageData*, const IntRect& sourceRect, const IntPoint& destPoint);
+ void putUnmultipliedImageData(ByteArray*, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint);
+ void putPremultipliedImageData(ByteArray*, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint);
String toDataURL(const String& mimeType, const double* quality = 0) const;
#if !PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
index b353943..ac5da3d 100644
--- a/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
+++ b/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
@@ -151,16 +151,16 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
}
template <Multiply multiplied>
-PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& data, const IntSize& size)
+PassRefPtr<ByteArray> getImageData(const IntRect& rect, const ImageBufferData& data, const IntSize& size)
{
ASSERT(cairo_surface_get_type(data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);
- PassRefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
+ RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);
unsigned char* dataSrc = cairo_image_surface_get_data(data.m_surface);
- unsigned char* dataDst = result->data()->data()->data();
+ unsigned char* dataDst = result->data();
if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > size.width() || (rect.y() + rect.height()) > size.height())
- memset(dataDst, 0, result->data()->length());
+ memset(dataDst, 0, result->length());
int originx = rect.x();
int destx = 0;
@@ -168,7 +168,7 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& d
destx = -originx;
originx = 0;
}
- int endx = rect.x() + rect.width();
+ int endx = rect.right();
if (endx > size.width())
endx = size.width();
int numColumns = endx - originx;
@@ -179,7 +179,7 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& d
desty = -originy;
originy = 0;
}
- int endy = rect.y() + rect.height();
+ int endy = rect.bottom();
if (endy > size.height())
endy = size.height();
int numRows = endy - originy;
@@ -206,21 +206,21 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& d
destRows += destBytesPerRow;
}
- return result;
+ return result.release();
}
-PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
{
return getImageData<Unmultiplied>(rect, m_data, m_size);
}
-PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
{
return getImageData<Premultiplied>(rect, m_data, m_size);
}
template <Multiply multiplied>
-void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& destPoint, ImageBufferData& data, const IntSize& size)
+void putImageData(ByteArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, ImageBufferData& data, const IntSize& size)
{
ASSERT(cairo_surface_get_type(data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);
@@ -252,10 +252,10 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
ASSERT(endy <= size.height());
int numRows = endy - desty;
- unsigned srcBytesPerRow = 4 * source->width();
+ unsigned srcBytesPerRow = 4 * sourceSize.width();
int stride = cairo_image_surface_get_stride(data.m_surface);
- unsigned char* srcRows = source->data()->data()->data() + originy * srcBytesPerRow + originx * 4;
+ unsigned char* srcRows = source->data() + originy * srcBytesPerRow + originx * 4;
for (int y = 0; y < numRows; ++y) {
unsigned* row = reinterpret_cast<unsigned*>(dataDst + stride * (y + desty));
for (int x = 0; x < numColumns; x++) {
@@ -277,14 +277,14 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
numColumns, numRows);
}
-void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
- putImageData<Unmultiplied>(source, sourceRect, destPoint, m_data, m_size);
+ putImageData<Unmultiplied>(source, sourceSize, sourceRect, destPoint, m_data, m_size);
}
-void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
- putImageData<Premultiplied>(source, sourceRect, destPoint, m_data, m_size);
+ putImageData<Premultiplied>(source, sourceSize, sourceRect, destPoint, m_data, m_size);
}
#if !PLATFORM(GTK)
diff --git a/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/WebCore/platform/graphics/cg/ImageBufferCG.cpp
index 9c553b9..75a36e5 100644
--- a/WebCore/platform/graphics/cg/ImageBufferCG.cpp
+++ b/WebCore/platform/graphics/cg/ImageBufferCG.cpp
@@ -32,7 +32,6 @@
#include "BitmapImage.h"
#include "GraphicsContext.h"
#include "GraphicsContextCG.h"
-#include "ImageData.h"
#include "MIMETypeRegistry.h"
#include <ApplicationServices/ApplicationServices.h>
#include <wtf/Assertions.h>
@@ -253,13 +252,13 @@ void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
}
template <Multiply multiplied>
-PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& imageData, const IntSize& size, bool accelerateRendering)
+PassRefPtr<ByteArray> getImageData(const IntRect& rect, const ImageBufferData& imageData, const IntSize& size, bool accelerateRendering)
{
- PassRefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
- unsigned char* data = result->data()->data()->data();
+ RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);
+ unsigned char* data = result->data();
- if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > size.width() || (rect.y() + rect.height()) > size.height())
- memset(data, 0, result->data()->length());
+ if (rect.x() < 0 || rect.y() < 0 || rect.right() > size.width() || rect.bottom() > size.height())
+ memset(data, 0, result->length());
int originx = rect.x();
int destx = 0;
@@ -267,7 +266,7 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& i
destx = -originx;
originx = 0;
}
- int endx = rect.x() + rect.width();
+ int endx = rect.right();
if (endx > size.width())
endx = size.width();
int numColumns = endx - originx;
@@ -278,7 +277,7 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& i
desty = -originy;
originy = 0;
}
- int endy = rect.y() + rect.height();
+ int endy = rect.bottom();
if (endy > size.height())
endy = size.height();
int numRows = endy - originy;
@@ -340,17 +339,17 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& i
#endif
}
- return result;
+ return result.release();
}
-PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
{
if (m_accelerateRendering)
CGContextFlush(context()->platformContext());
return getImageData<Unmultiplied>(rect, m_data, m_size, m_accelerateRendering);
}
-PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
{
if (m_accelerateRendering)
CGContextFlush(context()->platformContext());
@@ -358,7 +357,7 @@ PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect
}
template <Multiply multiplied>
-void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& destPoint, ImageBufferData& imageData, const IntSize& size, bool accelerateRendering)
+void putImageData(ByteArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, ImageBufferData& imageData, const IntSize& size, bool accelerateRendering)
{
ASSERT(sourceRect.width() > 0);
ASSERT(sourceRect.height() > 0);
@@ -386,8 +385,8 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
ASSERT(endy <= size.height());
int numRows = endy - desty;
- unsigned srcBytesPerRow = 4 * source->width();
- unsigned char* srcRows = source->data()->data()->data() + originy * srcBytesPerRow + originx * 4;
+ unsigned srcBytesPerRow = 4 * sourceSize.width();
+ unsigned char* srcRows = source->data() + originy * srcBytesPerRow + originx * 4;
unsigned destBytesPerRow;
unsigned char* destRows;
@@ -442,18 +441,18 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
}
}
-void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
if (m_accelerateRendering)
CGContextFlush(context()->platformContext());
- putImageData<Unmultiplied>(source, sourceRect, destPoint, m_data, m_size, m_accelerateRendering);
+ putImageData<Unmultiplied>(source, sourceSize, sourceRect, destPoint, m_data, m_size, m_accelerateRendering);
}
-void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
if (m_accelerateRendering)
CGContextFlush(context()->platformContext());
- putImageData<Premultiplied>(source, sourceRect, destPoint, m_data, m_size, m_accelerateRendering);
+ putImageData<Premultiplied>(source, sourceSize, sourceRect, destPoint, m_data, m_size, m_accelerateRendering);
}
static inline CFStringRef jpegUTI()
diff --git a/WebCore/platform/graphics/filters/FEBlend.cpp b/WebCore/platform/graphics/filters/FEBlend.cpp
index f863487..7eeb128 100644
--- a/WebCore/platform/graphics/filters/FEBlend.cpp
+++ b/WebCore/platform/graphics/filters/FEBlend.cpp
@@ -25,11 +25,11 @@
#if ENABLE(FILTERS)
#include "FEBlend.h"
-#include "CanvasPixelArray.h"
#include "Filter.h"
#include "FloatPoint.h"
#include "GraphicsContext.h"
-#include "ImageData.h"
+
+#include <wtf/ByteArray.h>
typedef unsigned char (*BlendType)(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB);
@@ -100,19 +100,15 @@ void FEBlend::apply()
if (m_mode <= FEBLEND_MODE_UNKNOWN || m_mode > FEBLEND_MODE_LIGHTEN)
return;
- ImageData* resultImage = createPremultipliedImageResult();
- if (!resultImage)
+ ByteArray* dstPixelArray = createPremultipliedImageResult();
+ if (!dstPixelArray)
return;
IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- RefPtr<ImageData> srcImageDataA = in->asPremultipliedImage(effectADrawingRect);
- ByteArray* srcPixelArrayA = srcImageDataA->data()->data();
+ RefPtr<ByteArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);
IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
- RefPtr<ImageData> srcImageDataB = in2->asPremultipliedImage(effectBDrawingRect);
- ByteArray* srcPixelArrayB = srcImageDataB->data()->data();
-
- ByteArray* dstPixelArray = resultImage->data()->data();
+ RefPtr<ByteArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect);
// Keep synchronized with BlendModeType
static const BlendType callEffect[] = {unknown, normal, multiply, screen, darken, lighten};
diff --git a/WebCore/platform/graphics/filters/FEColorMatrix.cpp b/WebCore/platform/graphics/filters/FEColorMatrix.cpp
index d316dfb..e0b15d1 100644
--- a/WebCore/platform/graphics/filters/FEColorMatrix.cpp
+++ b/WebCore/platform/graphics/filters/FEColorMatrix.cpp
@@ -27,8 +27,8 @@
#include "Filter.h"
#include "GraphicsContext.h"
-#include "ImageData.h"
+#include <wtf/ByteArray.h>
#include <wtf/MathExtras.h>
namespace WebCore {
@@ -164,28 +164,27 @@ void FEColorMatrix::apply()
resultImage->context()->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
IntRect imageRect(IntPoint(), absolutePaintRect().size());
- RefPtr<ImageData> imageData = resultImage->getUnmultipliedImageData(imageRect);
- ByteArray* pixelArray = imageData->data()->data();
+ RefPtr<ByteArray> pixelArray = resultImage->getUnmultipliedImageData(imageRect);
switch (m_type) {
- case FECOLORMATRIX_TYPE_UNKNOWN:
- break;
- case FECOLORMATRIX_TYPE_MATRIX:
- effectType<FECOLORMATRIX_TYPE_MATRIX>(pixelArray, m_values);
- break;
- case FECOLORMATRIX_TYPE_SATURATE:
- effectType<FECOLORMATRIX_TYPE_SATURATE>(pixelArray, m_values);
- break;
- case FECOLORMATRIX_TYPE_HUEROTATE:
- effectType<FECOLORMATRIX_TYPE_HUEROTATE>(pixelArray, m_values);
- break;
- case FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
- effectType<FECOLORMATRIX_TYPE_LUMINANCETOALPHA>(pixelArray, m_values);
- setIsAlphaImage(true);
- break;
+ case FECOLORMATRIX_TYPE_UNKNOWN:
+ break;
+ case FECOLORMATRIX_TYPE_MATRIX:
+ effectType<FECOLORMATRIX_TYPE_MATRIX>(pixelArray.get(), m_values);
+ break;
+ case FECOLORMATRIX_TYPE_SATURATE:
+ effectType<FECOLORMATRIX_TYPE_SATURATE>(pixelArray.get(), m_values);
+ break;
+ case FECOLORMATRIX_TYPE_HUEROTATE:
+ effectType<FECOLORMATRIX_TYPE_HUEROTATE>(pixelArray.get(), m_values);
+ break;
+ case FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
+ effectType<FECOLORMATRIX_TYPE_LUMINANCETOALPHA>(pixelArray.get(), m_values);
+ setIsAlphaImage(true);
+ break;
}
- resultImage->putUnmultipliedImageData(imageData.get(), imageRect, IntPoint());
+ resultImage->putUnmultipliedImageData(pixelArray.get(), imageRect.size(), imageRect, IntPoint());
}
void FEColorMatrix::dump()
diff --git a/WebCore/platform/graphics/filters/FEComponentTransfer.cpp b/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
index f8f651c..ca8e5d3 100644
--- a/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
+++ b/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
@@ -28,8 +28,8 @@
#include "Filter.h"
#include "GraphicsContext.h"
-#include "ImageData.h"
+#include <wtf/ByteArray.h>
#include <wtf/MathExtras.h>
namespace WebCore {
@@ -156,8 +156,8 @@ void FEComponentTransfer::apply()
if (!in->hasResult())
return;
- ImageData* imageData = createUnmultipliedImageResult();
- if (!imageData)
+ ByteArray* pixelArray = createUnmultipliedImageResult();
+ if (!pixelArray)
return;
unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
@@ -171,8 +171,7 @@ void FEComponentTransfer::apply()
(*callEffect[transferFunction[channel].type])(tables[channel], transferFunction[channel]);
IntRect drawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- in->copyUnmultipliedImage(imageData, drawingRect);
- ByteArray* pixelArray = imageData->data()->data();
+ in->copyUnmultipliedImage(pixelArray, drawingRect);
unsigned pixelArrayLength = pixelArray->length();
for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) {
diff --git a/WebCore/platform/graphics/filters/FEComposite.cpp b/WebCore/platform/graphics/filters/FEComposite.cpp
index 5ecd69b..80cb2b2 100644
--- a/WebCore/platform/graphics/filters/FEComposite.cpp
+++ b/WebCore/platform/graphics/filters/FEComposite.cpp
@@ -28,7 +28,8 @@
#include "Filter.h"
#include "GraphicsContext.h"
-#include "ImageData.h"
+
+#include <wtf/ByteArray.h>
namespace WebCore {
@@ -190,17 +191,17 @@ void FEComposite::apply()
return;
if (m_type == FECOMPOSITE_OPERATOR_ARITHMETIC) {
- ImageData* resultImage = createPremultipliedImageResult();
- if (!resultImage)
+ ByteArray* dstPixelArray = createPremultipliedImageResult();
+ if (!dstPixelArray)
return;
IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- RefPtr<ImageData> srcImageData = in->asPremultipliedImage(effectADrawingRect);
+ RefPtr<ByteArray> srcPixelArray = in->asPremultipliedImage(effectADrawingRect);
IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
- in2->copyPremultipliedImage(resultImage, effectBDrawingRect);
+ in2->copyPremultipliedImage(dstPixelArray, effectBDrawingRect);
- arithmetic(srcImageData->data()->data(), resultImage->data()->data(), m_k1, m_k2, m_k3, m_k4);
+ arithmetic(srcPixelArray.get(), dstPixelArray, m_k1, m_k2, m_k3, m_k4);
return;
}
diff --git a/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp b/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp
index d1f9c7b..b8f8aea 100644
--- a/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp
+++ b/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp
@@ -26,9 +26,9 @@
#if ENABLE(FILTERS)
#include "FEConvolveMatrix.h"
-#include "CanvasPixelArray.h"
#include "Filter.h"
-#include "ImageData.h"
+
+#include <wtf/ByteArray.h>
namespace WebCore {
@@ -202,7 +202,7 @@ static ALWAYS_INLINE unsigned char clampRGBAValue(float channel, unsigned char m
}
template<bool preserveAlphaValues>
-ALWAYS_INLINE void setDestinationPixels(CanvasPixelArray* image, int& pixel, float* totals, float divisor, float bias, CanvasPixelArray* src)
+ALWAYS_INLINE void setDestinationPixels(ByteArray* image, int& pixel, float* totals, float divisor, float bias, ByteArray* src)
{
unsigned char maxAlpha = preserveAlphaValues ? 255 : clampRGBAValue(totals[3] / divisor + bias);
for (int i = 0; i < 3; ++i)
@@ -379,7 +379,7 @@ void FEConvolveMatrix::apply()
if (!in->hasResult())
return;
- ImageData* resultImage;
+ ByteArray* resultImage;
if (m_preserveAlpha)
resultImage = createUnmultipliedImageResult();
else
@@ -389,16 +389,16 @@ void FEConvolveMatrix::apply()
IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- RefPtr<CanvasPixelArray> srcPixelArray;
+ RefPtr<ByteArray> srcPixelArray;
if (m_preserveAlpha)
- srcPixelArray = in->asUnmultipliedImage(effectDrawingRect)->data();
+ srcPixelArray = in->asUnmultipliedImage(effectDrawingRect);
else
- srcPixelArray = in->asPremultipliedImage(effectDrawingRect)->data();
+ srcPixelArray = in->asPremultipliedImage(effectDrawingRect);
IntSize paintSize = absolutePaintRect().size();
PaintingData paintingData;
paintingData.srcPixelArray = srcPixelArray.get();
- paintingData.dstPixelArray = resultImage->data();
+ paintingData.dstPixelArray = resultImage;
paintingData.width = paintSize.width();
paintingData.height = paintSize.height();
paintingData.bias = m_bias * 255;
diff --git a/WebCore/platform/graphics/filters/FEConvolveMatrix.h b/WebCore/platform/graphics/filters/FEConvolveMatrix.h
index 6811a1b..05d1199 100644
--- a/WebCore/platform/graphics/filters/FEConvolveMatrix.h
+++ b/WebCore/platform/graphics/filters/FEConvolveMatrix.h
@@ -84,8 +84,8 @@ private:
const IntPoint&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&);
struct PaintingData {
- CanvasPixelArray* srcPixelArray;
- CanvasPixelArray* dstPixelArray;
+ ByteArray* srcPixelArray;
+ ByteArray* dstPixelArray;
int width;
int height;
float bias;
diff --git a/WebCore/platform/graphics/filters/FEDisplacementMap.cpp b/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
index 93239c4..b5151bf 100644
--- a/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
+++ b/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
@@ -28,7 +28,8 @@
#include "Filter.h"
#include "GraphicsContext.h"
-#include "ImageData.h"
+
+#include <wtf/ByteArray.h>
namespace WebCore {
@@ -90,19 +91,15 @@ void FEDisplacementMap::apply()
if (m_xChannelSelector == CHANNEL_UNKNOWN || m_yChannelSelector == CHANNEL_UNKNOWN)
return;
- ImageData* resultImage = createPremultipliedImageResult();
- if (!resultImage)
+ ByteArray* dstPixelArray = createPremultipliedImageResult();
+ if (!dstPixelArray)
return;
IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- RefPtr<ImageData> srcImageDataA = in->asPremultipliedImage(effectADrawingRect);
- ByteArray* srcPixelArrayA = srcImageDataA->data()->data();
+ RefPtr<ByteArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);
IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
- RefPtr<ImageData> srcImageDataB = in2->asUnmultipliedImage(effectBDrawingRect);
- ByteArray* srcPixelArrayB = srcImageDataB->data()->data();
-
- ByteArray* dstPixelArray = resultImage->data()->data();
+ RefPtr<ByteArray> srcPixelArrayB = in2->asUnmultipliedImage(effectBDrawingRect);
ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length());
diff --git a/WebCore/platform/graphics/filters/FEGaussianBlur.cpp b/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
index e1ffcb7..37b5992 100644
--- a/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
+++ b/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
@@ -29,8 +29,8 @@
#include "Filter.h"
#include "GraphicsContext.h"
-#include "ImageData.h"
+#include <wtf/ByteArray.h>
#include <wtf/MathExtras.h>
using std::max;
@@ -171,14 +171,14 @@ void FEGaussianBlur::apply()
if (!in->hasResult())
return;
- ImageData* resultImage = createPremultipliedImageResult();
- if (!resultImage)
+ ByteArray* srcPixelArray = createPremultipliedImageResult();
+ if (!srcPixelArray)
return;
setIsAlphaImage(in->isAlphaImage());
IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- in->copyPremultipliedImage(resultImage, effectDrawingRect);
+ in->copyPremultipliedImage(srcPixelArray, effectDrawingRect);
if (!m_stdX && !m_stdY)
return;
@@ -188,9 +188,8 @@ void FEGaussianBlur::apply()
calculateKernelSize(filter(), kernelSizeX, kernelSizeY, m_stdX, m_stdY);
IntSize paintSize = absolutePaintRect().size();
- ByteArray* srcPixelArray = resultImage->data()->data();
- RefPtr<ImageData> tmpImageData = ImageData::create(paintSize.width(), paintSize.height());
- ByteArray* tmpPixelArray = tmpImageData->data()->data();
+ RefPtr<ByteArray> tmpImageData = ByteArray::create(paintSize.width() * paintSize.height() * 4);
+ ByteArray* tmpPixelArray = tmpImageData.get();
int stride = 4 * paintSize.width();
int dxLeft = 0;
diff --git a/WebCore/platform/graphics/filters/FELighting.cpp b/WebCore/platform/graphics/filters/FELighting.cpp
index 4db40f1..ec1ca88 100644
--- a/WebCore/platform/graphics/filters/FELighting.cpp
+++ b/WebCore/platform/graphics/filters/FELighting.cpp
@@ -29,8 +29,6 @@
#if ENABLE(FILTERS)
#include "FELighting.h"
-#include "CanvasPixelArray.h"
-#include "ImageData.h"
#include "LightSource.h"
namespace WebCore {
@@ -338,15 +336,14 @@ void FELighting::apply()
if (!in->hasResult())
return;
- ImageData* resultImage = createUnmultipliedImageResult();
- if (!resultImage)
+ ByteArray* srcPixelArray = createUnmultipliedImageResult();
+ if (!srcPixelArray)
return;
setIsAlphaImage(false);
IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- in->copyUnmultipliedImage(resultImage, effectDrawingRect);
- ByteArray* srcPixelArray = resultImage->data()->data();
+ in->copyUnmultipliedImage(srcPixelArray, effectDrawingRect);
// FIXME: support kernelUnitLengths other than (1,1). The issue here is that the W3
// standard has no test case for them, and other browsers (like Firefox) has strange
diff --git a/WebCore/platform/graphics/filters/FEMorphology.cpp b/WebCore/platform/graphics/filters/FEMorphology.cpp
index b20adc5..45c7edb 100644
--- a/WebCore/platform/graphics/filters/FEMorphology.cpp
+++ b/WebCore/platform/graphics/filters/FEMorphology.cpp
@@ -27,8 +27,8 @@
#include "FEMorphology.h"
#include "Filter.h"
-#include "ImageData.h"
+#include <wtf/ByteArray.h>
#include <wtf/Vector.h>
using std::min;
@@ -98,8 +98,8 @@ void FEMorphology::apply()
if (!in->hasResult())
return;
- ImageData* resultImage = createPremultipliedImageResult();
- if (!resultImage)
+ ByteArray* dstPixelArray = createPremultipliedImageResult();
+ if (!dstPixelArray)
return;
setIsAlphaImage(in->isAlphaImage());
@@ -111,9 +111,7 @@ void FEMorphology::apply()
int radiusY = static_cast<int>(floorf(filter->applyVerticalScale(m_radiusY)));
IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
- RefPtr<ImageData> srcImageData = in->asPremultipliedImage(effectDrawingRect);
- ByteArray* srcPixelArray = srcImageData->data()->data();
- ByteArray* dstPixelArray = resultImage->data()->data();
+ RefPtr<ByteArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect);
int effectWidth = effectDrawingRect.width() * 4;
diff --git a/WebCore/platform/graphics/filters/FETurbulence.cpp b/WebCore/platform/graphics/filters/FETurbulence.cpp
index becf784..f1a159b 100644
--- a/WebCore/platform/graphics/filters/FETurbulence.cpp
+++ b/WebCore/platform/graphics/filters/FETurbulence.cpp
@@ -27,8 +27,8 @@
#include "FETurbulence.h"
#include "Filter.h"
-#include "ImageData.h"
+#include <wtf/ByteArray.h>
#include <wtf/MathExtras.h>
namespace WebCore {
@@ -322,14 +322,13 @@ void FETurbulence::apply()
{
if (hasResult())
return;
- ImageData* resultImage = createUnmultipliedImageResult();
- if (!resultImage)
+ ByteArray* pixelArray = createUnmultipliedImageResult();
+ if (!pixelArray)
return;
if (absolutePaintRect().isEmpty())
return;
- ByteArray* pixelArray = resultImage->data()->data();
PaintingData paintingData(m_seed, roundedIntSize(filterPrimitiveSubregion().size()));
initPaint(paintingData);
diff --git a/WebCore/platform/graphics/filters/FilterEffect.cpp b/WebCore/platform/graphics/filters/FilterEffect.cpp
index ebc6af0..05c2a47 100644
--- a/WebCore/platform/graphics/filters/FilterEffect.cpp
+++ b/WebCore/platform/graphics/filters/FilterEffect.cpp
@@ -23,7 +23,8 @@
#if ENABLE(FILTERS)
#include "FilterEffect.h"
-#include "ImageData.h"
+
+#include <wtf/ByteArray.h>
namespace WebCore {
@@ -82,32 +83,31 @@ ImageBuffer* FilterEffect::asImageBuffer()
m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), ColorSpaceLinearRGB);
IntRect destinationRect(IntPoint(), m_absolutePaintRect.size());
if (m_premultipliedImageResult)
- m_imageBufferResult->putPremultipliedImageData(m_premultipliedImageResult.get(), destinationRect, IntPoint());
+ m_imageBufferResult->putPremultipliedImageData(m_premultipliedImageResult.get(), destinationRect.size(), destinationRect, IntPoint());
else
- m_imageBufferResult->putUnmultipliedImageData(m_unmultipliedImageResult.get(), destinationRect, IntPoint());
+ m_imageBufferResult->putUnmultipliedImageData(m_unmultipliedImageResult.get(), destinationRect.size(), destinationRect, IntPoint());
return m_imageBufferResult.get();
}
-PassRefPtr<ImageData> FilterEffect::asUnmultipliedImage(const IntRect& rect)
+PassRefPtr<ByteArray> FilterEffect::asUnmultipliedImage(const IntRect& rect)
{
- RefPtr<ImageData> imageData = ImageData::create(rect.width(), rect.height());
+ RefPtr<ByteArray> imageData = ByteArray::create(rect.width() * rect.height() * 4);
copyUnmultipliedImage(imageData.get(), rect);
return imageData.release();
}
-PassRefPtr<ImageData> FilterEffect::asPremultipliedImage(const IntRect& rect)
+PassRefPtr<ByteArray> FilterEffect::asPremultipliedImage(const IntRect& rect)
{
- RefPtr<ImageData> imageData = ImageData::create(rect.width(), rect.height());
+ RefPtr<ByteArray> imageData = ByteArray::create(rect.width() * rect.height() * 4);
copyPremultipliedImage(imageData.get(), rect);
return imageData.release();
}
-inline void FilterEffect::copyImageBytes(ImageData* source, ImageData* destination, const IntRect& rect)
+inline void FilterEffect::copyImageBytes(ByteArray* source, ByteArray* destination, const IntRect& rect)
{
// Copy the necessary lines.
- ASSERT(IntSize(destination->width(), destination->height()) == rect.size());
if (rect.x() < 0 || rect.y() < 0 || rect.bottom() > m_absolutePaintRect.width() || rect.bottom() > m_absolutePaintRect.height())
- memset(destination->data()->data()->data(), 0, destination->data()->length());
+ memset(destination->data(), 0, destination->length());
int xOrigin = rect.x();
int xDest = 0;
@@ -132,8 +132,8 @@ inline void FilterEffect::copyImageBytes(ImageData* source, ImageData* destinati
int size = (xEnd - xOrigin) * 4;
int destinationScanline = rect.width() * 4;
int sourceScanline = m_absolutePaintRect.width() * 4;
- unsigned char *destinationPixel = destination->data()->data()->data() + ((yDest * rect.width()) + xDest) * 4;
- unsigned char *sourcePixel = source->data()->data()->data() + ((yOrigin * m_absolutePaintRect.width()) + xOrigin) * 4;
+ unsigned char *destinationPixel = destination->data() + ((yDest * rect.width()) + xDest) * 4;
+ unsigned char *sourcePixel = source->data() + ((yOrigin * m_absolutePaintRect.width()) + xOrigin) * 4;
while (yOrigin < yEnd) {
memcpy(destinationPixel, sourcePixel, size);
@@ -143,7 +143,7 @@ inline void FilterEffect::copyImageBytes(ImageData* source, ImageData* destinati
}
}
-void FilterEffect::copyUnmultipliedImage(ImageData* destination, const IntRect& rect)
+void FilterEffect::copyUnmultipliedImage(ByteArray* destination, const IntRect& rect)
{
ASSERT(hasResult());
@@ -152,9 +152,9 @@ void FilterEffect::copyUnmultipliedImage(ImageData* destination, const IntRect&
if (m_imageBufferResult)
m_unmultipliedImageResult = m_imageBufferResult->getUnmultipliedImageData(IntRect(IntPoint(), m_absolutePaintRect.size()));
else {
- m_unmultipliedImageResult = ImageData::create(m_absolutePaintRect.width(), m_absolutePaintRect.height());
- unsigned char* sourceComponent = m_premultipliedImageResult->data()->data()->data();
- unsigned char* destinationComponent = m_unmultipliedImageResult->data()->data()->data();
+ m_unmultipliedImageResult = ByteArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);
+ unsigned char* sourceComponent = m_premultipliedImageResult->data();
+ unsigned char* destinationComponent = m_unmultipliedImageResult->data();
unsigned char* end = sourceComponent + (m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);
while (sourceComponent < end) {
int alpha = sourceComponent[3];
@@ -176,7 +176,7 @@ void FilterEffect::copyUnmultipliedImage(ImageData* destination, const IntRect&
copyImageBytes(m_unmultipliedImageResult.get(), destination, rect);
}
-void FilterEffect::copyPremultipliedImage(ImageData* destination, const IntRect& rect)
+void FilterEffect::copyPremultipliedImage(ByteArray* destination, const IntRect& rect)
{
ASSERT(hasResult());
@@ -185,9 +185,9 @@ void FilterEffect::copyPremultipliedImage(ImageData* destination, const IntRect&
if (m_imageBufferResult)
m_premultipliedImageResult = m_imageBufferResult->getPremultipliedImageData(IntRect(IntPoint(), m_absolutePaintRect.size()));
else {
- m_premultipliedImageResult = ImageData::create(m_absolutePaintRect.width(), m_absolutePaintRect.height());
- unsigned char* sourceComponent = m_unmultipliedImageResult->data()->data()->data();
- unsigned char* destinationComponent = m_premultipliedImageResult->data()->data()->data();
+ m_premultipliedImageResult = ByteArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);
+ unsigned char* sourceComponent = m_unmultipliedImageResult->data();
+ unsigned char* destinationComponent = m_premultipliedImageResult->data();
unsigned char* end = sourceComponent + (m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);
while (sourceComponent < end) {
int alpha = sourceComponent[3];
@@ -217,25 +217,25 @@ ImageBuffer* FilterEffect::createImageBufferResult()
return m_imageBufferResult.get();
}
-ImageData* FilterEffect::createUnmultipliedImageResult()
+ByteArray* FilterEffect::createUnmultipliedImageResult()
{
// Only one result type is allowed.
ASSERT(!hasResult());
determineAbsolutePaintRect();
if (m_absolutePaintRect.isEmpty())
return 0;
- m_unmultipliedImageResult = ImageData::create(m_absolutePaintRect.width(), m_absolutePaintRect.height());
+ m_unmultipliedImageResult = ByteArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);
return m_unmultipliedImageResult.get();
}
-ImageData* FilterEffect::createPremultipliedImageResult()
+ByteArray* FilterEffect::createPremultipliedImageResult()
{
// Only one result type is allowed.
ASSERT(!hasResult());
determineAbsolutePaintRect();
if (m_absolutePaintRect.isEmpty())
return 0;
- m_premultipliedImageResult = ImageData::create(m_absolutePaintRect.width(), m_absolutePaintRect.height());
+ m_premultipliedImageResult = ByteArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);
return m_premultipliedImageResult.get();
}
diff --git a/WebCore/platform/graphics/filters/FilterEffect.h b/WebCore/platform/graphics/filters/FilterEffect.h
index 81d5409..2554d4b 100644
--- a/WebCore/platform/graphics/filters/FilterEffect.h
+++ b/WebCore/platform/graphics/filters/FilterEffect.h
@@ -52,10 +52,10 @@ public:
bool hasResult() const { return m_imageBufferResult || m_unmultipliedImageResult || m_premultipliedImageResult; }
ImageBuffer* asImageBuffer();
- PassRefPtr<ImageData> asUnmultipliedImage(const IntRect&);
- PassRefPtr<ImageData> asPremultipliedImage(const IntRect&);
- void copyUnmultipliedImage(ImageData* destination, const IntRect&);
- void copyPremultipliedImage(ImageData* destination, const IntRect&);
+ PassRefPtr<ByteArray> asUnmultipliedImage(const IntRect&);
+ PassRefPtr<ByteArray> asPremultipliedImage(const IntRect&);
+ void copyUnmultipliedImage(ByteArray* destination, const IntRect&);
+ void copyPremultipliedImage(ByteArray* destination, const IntRect&);
FilterEffectVector& inputEffects() { return m_inputEffects; }
FilterEffect* inputEffect(unsigned) const;
@@ -110,13 +110,13 @@ protected:
FilterEffect(Filter*);
ImageBuffer* createImageBufferResult();
- ImageData* createUnmultipliedImageResult();
- ImageData* createPremultipliedImageResult();
+ ByteArray* createUnmultipliedImageResult();
+ ByteArray* createPremultipliedImageResult();
private:
OwnPtr<ImageBuffer> m_imageBufferResult;
- RefPtr<ImageData> m_unmultipliedImageResult;
- RefPtr<ImageData> m_premultipliedImageResult;
+ RefPtr<ByteArray> m_unmultipliedImageResult;
+ RefPtr<ByteArray> m_premultipliedImageResult;
FilterEffectVector m_inputEffects;
bool m_alphaImage;
@@ -129,7 +129,7 @@ private:
Filter* m_filter;
private:
- inline void copyImageBytes(ImageData* source, ImageData* destination, const IntRect&);
+ inline void copyImageBytes(ByteArray* source, ByteArray* destination, const IntRect&);
// The following member variables are SVG specific and will move to RenderSVGResourceFilterPrimitive.
// See bug https://bugs.webkit.org/show_bug.cgi?id=45614.
diff --git a/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index 1652b5b..f56603d 100644
--- a/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -178,13 +178,13 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
}
template <Multiply multiplied>
-PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& imageData, const IntSize& size)
+PassRefPtr<ByteArray> getImageData(const IntRect& rect, const ImageBufferData& imageData, const IntSize& size)
{
- PassRefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
- unsigned char* data = result->data()->data()->data();
+ RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);
+ unsigned char* data = result->data();
- if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > size.width() || (rect.y() + rect.height()) > size.height())
- memset(data, 0, result->data()->length());
+ if (rect.x() < 0 || rect.y() < 0 || rect.right() > size.width() || rect.bottom() > size.height())
+ memset(data, 0, result->length());
int originx = rect.x();
int destx = 0;
@@ -192,7 +192,7 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& i
destx = -originx;
originx = 0;
}
- int endx = rect.x() + rect.width();
+ int endx = rect.right();
if (endx > size.width())
endx = size.width();
int numColumns = endx - originx;
@@ -203,7 +203,7 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& i
desty = -originy;
originy = 0;
}
- int endy = rect.y() + rect.height();
+ int endy = rect.bottom();
if (endy > size.height())
endy = size.height();
int numRows = endy - originy;
@@ -257,15 +257,15 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& i
}
}
- return result;
+ return result.release();
}
-PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
{
return getImageData<Unmultiplied>(rect, m_data, m_size);
}
-PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
{
return getImageData<Premultiplied>(rect, m_data, m_size);
}
@@ -287,7 +287,7 @@ static inline unsigned int premultiplyABGRtoARGB(unsigned int x)
}
template <Multiply multiplied>
-void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& destPoint, ImageBufferData& data, const IntSize& size)
+void putImageData(ByteArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, ImageBufferData& data, const IntSize& size)
{
ASSERT(sourceRect.width() > 0);
ASSERT(sourceRect.height() > 0);
@@ -315,14 +315,14 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
ASSERT(endy <= size.height());
int numRows = endy - desty;
- unsigned srcBytesPerRow = 4 * source->width();
+ unsigned srcBytesPerRow = 4 * sourceSize.width();
// NOTE: For unmultiplied input data, we do the premultiplication below.
QImage image(numColumns, numRows, QImage::Format_ARGB32_Premultiplied);
uchar* bits = image.bits();
const int bytesPerLine = image.bytesPerLine();
- const quint32* srcScanLine = reinterpret_cast_ptr<const quint32*>(source->data()->data()->data() + originy * srcBytesPerRow + originx * 4);
+ const quint32* srcScanLine = reinterpret_cast_ptr<const quint32*>(source->data() + originy * srcBytesPerRow + originx * 4);
if (multiplied == Unmultiplied) {
for (int y = 0; y < numRows; ++y) {
@@ -332,7 +332,7 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
quint32 pixel = srcScanLine[x];
destScanLine[x] = premultiplyABGRtoARGB(pixel);
}
- srcScanLine += source->width();
+ srcScanLine += sourceSize.width();
}
} else {
for (int y = 0; y < numRows; ++y) {
@@ -342,7 +342,7 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
quint32 pixel = srcScanLine[x];
destScanLine[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
}
- srcScanLine += source->width();
+ srcScanLine += sourceSize.width();
}
}
@@ -367,14 +367,14 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
data.m_painter->restore();
}
-void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
- putImageData<Unmultiplied>(source, sourceRect, destPoint, m_data, m_size);
+ putImageData<Unmultiplied>(source, sourceSize, sourceRect, destPoint, m_data, m_size);
}
-void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
- putImageData<Premultiplied>(source, sourceRect, destPoint, m_data, m_size);
+ putImageData<Premultiplied>(source, sourceSize, sourceRect, destPoint, m_data, m_size);
}
// We get a mimeType here but QImageWriter does not support mimetypes but
diff --git a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
index 468ccda..a9f6d3c 100644
--- a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
@@ -156,23 +156,24 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
}
template <Multiply multiplied>
-PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap,
+PassRefPtr<ByteArray> getImageData(const IntRect& rect, const SkBitmap& bitmap,
const IntSize& size)
{
- RefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
+ RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);
if (bitmap.config() == SkBitmap::kNo_Config) {
// This is an empty SkBitmap that could not be configured.
ASSERT(!size.width() || !size.height());
- return result;
+ return result.release();
}
- unsigned char* data = result->data()->data()->data();
+ unsigned char* data = result->data();
- if (rect.x() < 0 || rect.y() < 0 ||
- (rect.x() + rect.width()) > size.width() ||
- (rect.y() + rect.height()) > size.height())
- memset(data, 0, result->data()->length());
+ if (rect.x() < 0
+ || rect.y() < 0
+ || rect.right() > size.width()
+ || rect.bottom() > size.height())
+ memset(data, 0, result->length());
int originX = rect.x();
int destX = 0;
@@ -180,13 +181,13 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap,
destX = -originX;
originX = 0;
}
- int endX = rect.x() + rect.width();
+ int endX = rect.right();
if (endX > size.width())
endX = size.width();
int numColumns = endX - originX;
if (numColumns <= 0)
- return result;
+ return result.release();
int originY = rect.y();
int destY = 0;
@@ -194,13 +195,13 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap,
destY = -originY;
originY = 0;
}
- int endY = rect.y() + rect.height();
+ int endY = rect.bottom();
if (endY > size.height())
endY = size.height();
int numRows = endY - originY;
if (numRows <= 0)
- return result;
+ return result.release();
ASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config);
SkAutoLockPixels bitmapLock(bitmap);
@@ -231,23 +232,23 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap,
destRow += destBytesPerRow;
}
- return result;
+ return result.release();
}
-PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
{
context()->platformContext()->syncSoftwareCanvas();
return getImageData<Unmultiplied>(rect, *context()->platformContext()->bitmap(), m_size);
}
-PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
{
context()->platformContext()->syncSoftwareCanvas();
return getImageData<Premultiplied>(rect, *context()->platformContext()->bitmap(), m_size);
}
template <Multiply multiplied>
-void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& destPoint,
+void putImageData(ByteArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint,
const SkBitmap& bitmap, const IntSize& size)
{
ASSERT(sourceRect.width() > 0);
@@ -279,9 +280,9 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
ASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config);
SkAutoLockPixels bitmapLock(bitmap);
- unsigned srcBytesPerRow = 4 * source->width();
+ unsigned srcBytesPerRow = 4 * sourceSize.width();
- const unsigned char* srcRow = source->data()->data()->data() + originY * srcBytesPerRow + originX * 4;
+ const unsigned char* srcRow = source->data() + originY * srcBytesPerRow + originX * 4;
for (int y = 0; y < numRows; ++y) {
uint32_t* destRow = bitmap.getAddr32(destX, destY + y);
@@ -301,15 +302,15 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
}
}
-void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
context()->platformContext()->prepareForSoftwareDraw();
- putImageData<Unmultiplied>(source, sourceRect, destPoint, *context()->platformContext()->bitmap(), m_size);
+ putImageData<Unmultiplied>(source, sourceSize, sourceRect, destPoint, *context()->platformContext()->bitmap(), m_size);
}
-void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
- putImageData<Premultiplied>(source, sourceRect, destPoint, *context()->platformContext()->bitmap(), m_size);
+ putImageData<Premultiplied>(source, sourceSize, sourceRect, destPoint, *context()->platformContext()->bitmap(), m_size);
}
String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const
diff --git a/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp b/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
index e6edb41..2059011 100644
--- a/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
+++ b/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
@@ -122,21 +122,21 @@ void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
imageCopy->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
}
-template <bool premultiplied> PassRefPtr<ImageData>
+template <bool premultiplied> PassRefPtr<ByteArray>
static getImageData(const IntRect& rect, const SharedBitmap* bitmap)
{
- PassRefPtr<ImageData> imageData = ImageData::create(rect.width(), rect.height());
+ RefPtr<ImageData> imageData = ImageData::create(rect.width(), rect.height());
const unsigned char* src = static_cast<const unsigned char*>(bitmap->bytes());
if (!src)
- return imageData;
+ return imageData.release();
IntRect sourceRect(0, 0, bitmap->width(), bitmap->height());
sourceRect.intersect(rect);
if (sourceRect.isEmpty())
- return imageData;
+ return imageData.release();
- unsigned char* dst = imageData->data()->data()->data();
+ unsigned char* dst = imageData->data();
memset(dst, 0, imageData->data()->data()->length());
src += (sourceRect.y() * bitmap->width() + sourceRect.x()) * 4;
dst += ((sourceRect.y() - rect.y()) * imageData->width() + sourceRect.x() - rect.x()) * 4;
@@ -169,21 +169,21 @@ static getImageData(const IntRect& rect, const SharedBitmap* bitmap)
dst += dstSkip;
}
- return imageData;
+ return imageData.release();
}
-PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
{
return getImageData<false>(rect, m_data.m_bitmap.get());
}
-PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
{
return getImageData<true>(rect, m_data.m_bitmap.get());
}
template <bool premultiplied>
-static void putImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint, SharedBitmap* bitmap)
+static void putImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, SharedBitmap* bitmap)
{
unsigned char* dst = (unsigned char*)bitmap->bytes();
if (!dst)
@@ -195,12 +195,12 @@ static void putImageData(ImageData* source, const IntRect& sourceRect, const Int
if (destRect.isEmpty())
return;
- const unsigned char* src = source->data()->data()->data();
+ const unsigned char* src = source->data();
dst += (destRect.y() * bitmap->width() + destRect.x()) * 4;
- src += (sourceRect.y() * source->width() + sourceRect.x()) * 4;
+ src += (sourceRect.y() * sourceSize.width() + sourceRect.x()) * 4;
int bytesToCopy = destRect.width() * 4;
int dstSkip = (bitmap->width() - destRect.width()) * 4;
- int srcSkip = (source->width() - destRect.width()) * 4;
+ int srcSkip = (sourceSize.width() - destRect.width()) * 4;
const unsigned char* dstEnd = dst + destRect.height() * bitmap->width() * 4;
while (dst < dstEnd) {
const unsigned char* dstRowEnd = dst + bytesToCopy;
@@ -227,14 +227,14 @@ static void putImageData(ImageData* source, const IntRect& sourceRect, const Int
}
}
-void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
- putImageData<false>(source, sourceRect, destPoint, m_data.m_bitmap.get());
+ putImageData<false>(source, sourceSize, sourceRect, destPoint, m_data.m_bitmap.get());
}
-void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
- putImageData<true>(source, sourceRect, destPoint, m_data.m_bitmap.get());
+ putImageData<true>(source, sourceSize, sourceRect, destPoint, m_data.m_bitmap.get());
}
void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
diff --git a/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/WebCore/platform/graphics/wx/ImageBufferWx.cpp
index 74c9c39..ba33287 100644
--- a/WebCore/platform/graphics/wx/ImageBufferWx.cpp
+++ b/WebCore/platform/graphics/wx/ImageBufferWx.cpp
@@ -54,24 +54,24 @@ GraphicsContext* ImageBuffer::context() const
return 0;
}
-PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
{
notImplemented();
return 0;
}
-PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
+PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
{
notImplemented();
return 0;
}
-void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
notImplemented();
}
-void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
+void ImageBuffer::putPremultipliedImageData(ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint)
{
notImplemented();
}
diff --git a/WebCore/rendering/RenderSVGResourceMasker.cpp b/WebCore/rendering/RenderSVGResourceMasker.cpp
index ed27899..ebbbe93 100644
--- a/WebCore/rendering/RenderSVGResourceMasker.cpp
+++ b/WebCore/rendering/RenderSVGResourceMasker.cpp
@@ -24,14 +24,12 @@
#include "RenderSVGResourceMasker.h"
#include "AffineTransform.h"
-#include "CanvasPixelArray.h"
#include "Element.h"
#include "FloatPoint.h"
#include "FloatRect.h"
#include "GraphicsContext.h"
#include "Image.h"
#include "ImageBuffer.h"
-#include "ImageData.h"
#include "IntRect.h"
#include "RenderSVGResource.h"
#include "SVGElement.h"
@@ -39,6 +37,8 @@
#include "SVGMaskElement.h"
#include "SVGStyledElement.h"
#include "SVGUnitTypes.h"
+
+#include <wtf/ByteArray.h>
#include <wtf/Vector.h>
#include <wtf/UnusedParam.h>
@@ -161,8 +161,7 @@ void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, c
// Create the luminance mask.
IntRect maskImageRect(IntPoint(), maskerData->maskImage->size());
- RefPtr<ImageData> imageData = maskerData->maskImage->getUnmultipliedImageData(maskImageRect);
- ByteArray* srcPixelArray = imageData->data()->data();
+ RefPtr<ByteArray> srcPixelArray = maskerData->maskImage->getUnmultipliedImageData(maskImageRect);
unsigned pixelArrayLength = srcPixelArray->length();
for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) {
@@ -177,7 +176,7 @@ void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, c
srcPixelArray->set(pixelOffset + 3, luma);
}
- maskerData->maskImage->putUnmultipliedImageData(imageData.get(), maskImageRect, IntPoint());
+ maskerData->maskImage->putUnmultipliedImageData(srcPixelArray.get(), maskImageRect.size(), maskImageRect, IntPoint());
}
void RenderSVGResourceMasker::calculateMaskContentRepaintRect()
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index a38dc7e..26439d2 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,15 @@
+2011-01-02 Dirk Schulze <krit at webkit.org>
+
+ Reviewed by Simon Fraser.
+
+ Clarify ImageBuffer and ImageData relationship
+ https://bugs.webkit.org/show_bug.cgi?id=51297
+
+ Use ByteArray instead of ImageData.
+
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::doPixelReadbackToCanvas):
+
2011-01-01 Adam Barth <abarth at webkit.org>
Reviewed by Eric Seidel.
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index a7c4aa1..d77a5b3 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -69,7 +69,6 @@
#include "HTMLNames.h"
#include "Image.h"
#include "ImageBuffer.h"
-#include "ImageData.h"
#include "InspectorController.h"
#include "KeyboardCodes.h"
#include "KeyboardEvent.h"
@@ -120,6 +119,7 @@
#include "WebString.h"
#include "WebVector.h"
#include "WebViewClient.h"
+#include <wtf/ByteArray.h>
#include <wtf/RefPtr.h>
#if PLATFORM(CG)
@@ -1020,10 +1020,10 @@ void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect
IntRect invertRect(rect.x(), bitmapHeight - rect.bottom(), rect.width(), rect.height());
OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(rect.size()));
- RefPtr<ImageData> imageData(ImageData::create(rect.width(), rect.height()));
- if (imageBuffer.get() && imageData.get()) {
- m_layerRenderer->getFramebufferPixels(imageData->data()->data()->data(), invertRect);
- imageBuffer->putPremultipliedImageData(imageData.get(), IntRect(IntPoint(), rect.size()), IntPoint());
+ RefPtr<ByteArray> pixelArray(ByteArray::create(rect.width() * rect.height() * 4));
+ if (imageBuffer.get() && pixelArray.get()) {
+ m_layerRenderer->getFramebufferPixels(pixelArray->data(), invertRect);
+ imageBuffer->putPremultipliedImageData(pixelArray.get(), rect.size(), IntRect(IntPoint(), rect.size()), IntPoint());
gc.save();
gc.translate(FloatSize(0.0f, bitmapHeight));
gc.scale(FloatSize(1.0f, -1.0f));
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list