diff options
author | Steve Block <steveblock@google.com> | 2011-05-09 19:00:11 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-13 11:33:42 +0100 |
commit | 4ed508b9dbd29b5ad961f6677bd00d644955b110 (patch) | |
tree | 00ced8ae41453d4d27c5fd8bdf5ddd9707298b14 | |
parent | 48ec507a560e614dff3de2e4b6148e7b7a6f495f (diff) | |
download | external_webkit-4ed508b9dbd29b5ad961f6677bd00d644955b110.zip external_webkit-4ed508b9dbd29b5ad961f6677bd00d644955b110.tar.gz external_webkit-4ed508b9dbd29b5ad961f6677bd00d644955b110.tar.bz2 |
Merge WebKit at r75315: Fix ImageBuffer
See http://trac.webkit.org/changeset/74868
Change-Id: Iacb6ca5dd044a7bf08eb43012457b92f3a6beccd
-rw-r--r-- | Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp index c7adb25..3ac0cba 100644 --- a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp @@ -29,7 +29,6 @@ #include "Base64.h" #include "BitmapImage.h" #include "ColorSpace.h" -#include "ImageData.h" #include "GraphicsContext.h" #include "NotImplemented.h" #include "PlatformGraphicsContext.h" @@ -105,7 +104,7 @@ void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect imageCopy->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect); } -PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const +PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const { GraphicsContext* gc = this->context(); if (!gc) { @@ -118,12 +117,11 @@ PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) return 0; } - // ! Can't use PassRefPtr<>, otherwise the second access will cause crash. - RefPtr<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()) > m_size.width() || (rect.y() + rect.height()) > m_size.height()) - memset(data, 0, result->data()->length()); + if (rect.x() < 0 || rect.y() < 0 || rect.right() > m_size.width() || rect.bottom() > m_size.height()) + memset(data, 0, result->length()); int originx = rect.x(); int destx = 0; @@ -165,10 +163,10 @@ PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) srcRows += srcPixelsPerRow; destRows += destBytesPerRow; } - return result; + return result.release(); } -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) { GraphicsContext* gc = this->context(); if (!gc) { @@ -207,10 +205,10 @@ void ImageBuffer::putUnmultipliedImageData(ImageData* source, const IntRect& sou ASSERT(endy <= m_size.height()); int numRows = endy - desty; - unsigned srcBytesPerRow = 4 * source->width(); + unsigned srcBytesPerRow = 4 * sourceSize.width(); unsigned dstPixelsPerRow = dst.rowBytesAsPixels(); - unsigned char* srcRows = source->data()->data()->data() + originy * srcBytesPerRow + originx * 4; + unsigned char* srcRows = source->data() + originy * srcBytesPerRow + originx * 4; SkPMColor* dstRows = dst.getAddr32(destx, desty); for (int y = 0; y < numRows; ++y) { for (int x = 0; x < numColumns; x++) { |