[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
pkasting at chromium.org
pkasting at chromium.org
Wed Jan 20 22:27:55 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 9ae74794e154743201414e4f2561a9e6c3d75391
Author: pkasting at chromium.org <pkasting at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jan 18 17:46:39 2010 +0000
Simplify image decoders slightly by using OwnPtr instead of raw pointers
and eliminating a basically-useless wrapper class in the GIF decoder.
https://bugs.webkit.org/show_bug.cgi?id=28751
Reviewed by Adam Barth.
* platform/graphics/qt/ImageDecoderQt.cpp:
(WebCore::ImageDecoderQt::ImageDecoderQt):
(WebCore::ImageDecoderQt::~ImageDecoderQt):
(WebCore::ImageDecoderQt::setData):
(WebCore::ImageDecoderQt::internalReadImage):
(WebCore::ImageDecoderQt::failRead):
* platform/graphics/qt/ImageDecoderQt.h:
* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::GIFImageDecoder):
(WebCore::GIFImageDecoder::~GIFImageDecoder):
(WebCore::GIFImageDecoder::setData):
(WebCore::GIFImageDecoder::frameCount):
(WebCore::GIFImageDecoder::repetitionCount):
(WebCore::GIFImageDecoder::decode):
(WebCore::GIFImageDecoder::decodingHalted):
(WebCore::GIFImageDecoder::initFrameBuffer):
(WebCore::GIFImageDecoder::haveDecodedRow):
(WebCore::GIFImageDecoder::gifComplete):
* platform/image-decoders/gif/GIFImageDecoder.h:
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageDecoder::JPEGImageDecoder):
(WebCore::JPEGImageDecoder::~JPEGImageDecoder):
(WebCore::JPEGImageDecoder::setData):
(WebCore::JPEGImageDecoder::decode):
* platform/image-decoders/jpeg/JPEGImageDecoder.h:
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::PNGImageDecoder):
(WebCore::PNGImageDecoder::~PNGImageDecoder):
(WebCore::PNGImageDecoder::setData):
(WebCore::PNGImageDecoder::decode):
(WebCore::PNGImageDecoder::headerAvailable):
(WebCore::PNGImageDecoder::rowAvailable):
* platform/image-decoders/png/PNGImageDecoder.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53411 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5e735cf..6737348 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2010-01-18 Peter Kasting <pkasting at google.com>
+
+ Reviewed by Adam Barth.
+
+ Simplify image decoders slightly by using OwnPtr instead of raw pointers
+ and eliminating a basically-useless wrapper class in the GIF decoder.
+ https://bugs.webkit.org/show_bug.cgi?id=28751
+
+ * platform/graphics/qt/ImageDecoderQt.cpp:
+ (WebCore::ImageDecoderQt::ImageDecoderQt):
+ (WebCore::ImageDecoderQt::~ImageDecoderQt):
+ (WebCore::ImageDecoderQt::setData):
+ (WebCore::ImageDecoderQt::internalReadImage):
+ (WebCore::ImageDecoderQt::failRead):
+ * platform/graphics/qt/ImageDecoderQt.h:
+ * platform/image-decoders/gif/GIFImageDecoder.cpp:
+ (WebCore::GIFImageDecoder::GIFImageDecoder):
+ (WebCore::GIFImageDecoder::~GIFImageDecoder):
+ (WebCore::GIFImageDecoder::setData):
+ (WebCore::GIFImageDecoder::frameCount):
+ (WebCore::GIFImageDecoder::repetitionCount):
+ (WebCore::GIFImageDecoder::decode):
+ (WebCore::GIFImageDecoder::decodingHalted):
+ (WebCore::GIFImageDecoder::initFrameBuffer):
+ (WebCore::GIFImageDecoder::haveDecodedRow):
+ (WebCore::GIFImageDecoder::gifComplete):
+ * platform/image-decoders/gif/GIFImageDecoder.h:
+ * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+ (WebCore::JPEGImageDecoder::JPEGImageDecoder):
+ (WebCore::JPEGImageDecoder::~JPEGImageDecoder):
+ (WebCore::JPEGImageDecoder::setData):
+ (WebCore::JPEGImageDecoder::decode):
+ * platform/image-decoders/jpeg/JPEGImageDecoder.h:
+ * platform/image-decoders/png/PNGImageDecoder.cpp:
+ (WebCore::PNGImageDecoder::PNGImageDecoder):
+ (WebCore::PNGImageDecoder::~PNGImageDecoder):
+ (WebCore::PNGImageDecoder::setData):
+ (WebCore::PNGImageDecoder::decode):
+ (WebCore::PNGImageDecoder::headerAvailable):
+ (WebCore::PNGImageDecoder::rowAvailable):
+ * platform/image-decoders/png/PNGImageDecoder.h:
+
2010-01-18 Daniel Cheng <dcheng at google.com>
Reviewed by Adam Roben.
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index 5fa76ca..234f78b 100644
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -47,16 +47,12 @@ ImageDecoder* ImageDecoder::create(const SharedBuffer& data)
}
ImageDecoderQt::ImageDecoderQt()
- : m_buffer(0)
- , m_reader(0)
- , m_repetitionCount(cAnimationNone)
+ : m_repetitionCount(cAnimationNone)
{
}
ImageDecoderQt::~ImageDecoderQt()
{
- delete m_reader;
- delete m_buffer;
}
void ImageDecoderQt::setData(SharedBuffer* data, bool allDataReceived)
@@ -77,10 +73,10 @@ void ImageDecoderQt::setData(SharedBuffer* data, bool allDataReceived)
// Attempt to load the data
QByteArray imageData = QByteArray::fromRawData(m_data->data(), m_data->size());
- m_buffer = new QBuffer;
+ m_buffer.set(new QBuffer);
m_buffer->setData(imageData);
m_buffer->open(QBuffer::ReadOnly);
- m_reader = new QImageReader(m_buffer, m_format);
+ m_reader.set(new QImageReader(m_buffer.get(), m_format));
// This will force the JPEG decoder to use JDCT_IFAST
m_reader->setQuality(49);
@@ -183,10 +179,8 @@ void ImageDecoderQt::internalReadImage(size_t frameIndex)
if (m_frameBufferCache[i].status() != RGBA32Buffer::FrameComplete)
return;
- delete m_reader;
- delete m_buffer;
- m_buffer = 0;
- m_reader = 0;
+ m_reader.clear();
+ m_buffer.clear();
}
void ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex)
@@ -234,10 +228,8 @@ void ImageDecoderQt::forceLoadEverything()
void ImageDecoderQt::failRead()
{
setFailed();
- delete m_reader;
- delete m_buffer;
- m_reader = 0;
- m_buffer = 0;
+ m_reader.clear();
+ m_buffer.clear();
}
}
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.h b/WebCore/platform/graphics/qt/ImageDecoderQt.h
index d11b938..be9a9b0 100644
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.h
+++ b/WebCore/platform/graphics/qt/ImageDecoderQt.h
@@ -33,6 +33,7 @@
#include <QtCore/QList>
#include <QtCore/QHash>
#include <QtCore/QBuffer>
+#include <wtf/OwnPtr.h>
namespace WebCore {
@@ -66,8 +67,8 @@ private:
private:
QByteArray m_format;
- QBuffer* m_buffer;
- QImageReader* m_reader;
+ OwnPtr<QBuffer> m_buffer;
+ OwnPtr<QImageReader> m_reader;
mutable int m_repetitionCount;
};
diff --git a/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp b/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
index a0e5be9..fd33cc0 100644
--- a/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
@@ -29,70 +29,15 @@
namespace WebCore {
-class GIFImageDecoderPrivate {
-public:
- GIFImageDecoderPrivate(GIFImageDecoder* decoder = 0)
- : m_reader(decoder)
- , m_readOffset(0)
- {
- }
-
- ~GIFImageDecoderPrivate()
- {
- m_reader.close();
- }
-
- bool decode(SharedBuffer* data,
- GIFImageDecoder::GIFQuery query = GIFImageDecoder::GIFFullQuery,
- unsigned int haltFrame = -1)
- {
- return m_reader.read((const unsigned char*)data->data() + m_readOffset, data->size() - m_readOffset,
- query,
- haltFrame);
- }
-
- unsigned frameCount() const { return m_reader.images_count; }
- int repetitionCount() const { return m_reader.loop_count; }
-
- void setReadOffset(unsigned o) { m_readOffset = o; }
-
- bool isTransparent() const { return m_reader.frame_reader->is_transparent; }
-
- void getColorMap(unsigned char*& map, unsigned& size) const
- {
- if (m_reader.frame_reader->is_local_colormap_defined) {
- map = m_reader.frame_reader->local_colormap;
- size = (unsigned)m_reader.frame_reader->local_colormap_size;
- } else {
- map = m_reader.global_colormap;
- size = m_reader.global_colormap_size;
- }
- }
-
- unsigned frameXOffset() const { return m_reader.frame_reader->x_offset; }
- unsigned frameYOffset() const { return m_reader.frame_reader->y_offset; }
- unsigned frameWidth() const { return m_reader.frame_reader->width; }
- unsigned frameHeight() const { return m_reader.frame_reader->height; }
-
- int transparentPixel() const { return m_reader.frame_reader->tpixel; }
-
- unsigned duration() const { return m_reader.frame_reader->delay_time; }
-
-private:
- GIFImageReader m_reader;
- unsigned m_readOffset;
-};
-
GIFImageDecoder::GIFImageDecoder()
: m_frameCountValid(true)
, m_repetitionCount(cAnimationLoopOnce)
- , m_reader(0)
+ , m_readOffset(0)
{
}
GIFImageDecoder::~GIFImageDecoder()
{
- delete m_reader;
}
// Take the data and store it.
@@ -109,7 +54,7 @@ void GIFImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
// Create the GIF reader.
if (!m_reader && !m_failed)
- m_reader = new GIFImageDecoderPrivate(this);
+ m_reader.set(new GIFImageReader(this));
}
// Whether or not the size information has been decoded yet.
@@ -132,13 +77,13 @@ size_t GIFImageDecoder::frameCount()
// slowly. Might be interesting to try to clone our existing read session to preserve
// state, but for now we just crawl all the data. Note that this is no worse than what
// ImageIO does on Mac right now (it also crawls all the data again).
- GIFImageDecoderPrivate reader;
+ GIFImageReader reader(0);
// This function may fail, but we want to keep any partial data it may
// have decoded, so don't mark it is invalid. If there is an overflow
// or some serious error, m_failed will have gotten set for us.
- reader.decode(m_data.get(), GIFFrameCountQuery);
+ reader.read((const unsigned char*)m_data->data(), m_data->size(), GIFFrameCountQuery, -1);
m_frameCountValid = true;
- m_frameBufferCache.resize(reader.frameCount());
+ m_frameBufferCache.resize(reader.images_count);
}
return m_frameBufferCache.size();
@@ -161,7 +106,7 @@ int GIFImageDecoder::repetitionCount() const
// cAnimationLoopOnce (-1) when its current incarnation hasn't actually
// seen a loop count yet; in this case we return our previously-cached
// value.
- const int repetitionCount = m_reader->repetitionCount();
+ const int repetitionCount = m_reader->loop_count;
if (repetitionCount != cLoopCountNotSeen)
m_repetitionCount = repetitionCount;
}
@@ -235,12 +180,10 @@ void GIFImageDecoder::decode(GIFQuery query, unsigned haltAtFrame)
if (m_failed)
return;
- m_failed = !m_reader->decode(m_data.get(), query, haltAtFrame);
+ m_failed = !m_reader->read((const unsigned char*)m_data->data() + m_readOffset, m_data->size() - m_readOffset, query, haltAtFrame);
- if (m_failed) {
- delete m_reader;
- m_reader = 0;
- }
+ if (m_failed)
+ m_reader.clear();
}
// Callbacks from the GIF reader.
@@ -254,20 +197,20 @@ bool GIFImageDecoder::sizeNowAvailable(unsigned width, unsigned height)
void GIFImageDecoder::decodingHalted(unsigned bytesLeft)
{
- m_reader->setReadOffset(m_data->size() - bytesLeft);
+ m_readOffset = m_data->size() - bytesLeft;
}
bool GIFImageDecoder::initFrameBuffer(unsigned frameIndex)
{
// Initialize the frame rect in our buffer.
- IntRect frameRect(m_reader->frameXOffset(), m_reader->frameYOffset(),
- m_reader->frameWidth(), m_reader->frameHeight());
+ const GIFFrameReader* frameReader = m_reader->frame_reader;
+ IntRect frameRect(frameReader->x_offset, frameReader->y_offset, frameReader->width, frameReader->height);
// Make sure the frameRect doesn't extend past the bottom-right of the buffer.
if (frameRect.right() > size().width())
- frameRect.setWidth(size().width() - m_reader->frameXOffset());
+ frameRect.setWidth(size().width() - frameReader->x_offset);
if (frameRect.bottom() > size().height())
- frameRect.setHeight(size().height() - m_reader->frameYOffset());
+ frameRect.setHeight(size().height() - frameReader->y_offset);
RGBA32Buffer* const buffer = &m_frameBufferCache[frameIndex];
int left = upperBoundScaledX(frameRect.x());
@@ -346,24 +289,30 @@ bool GIFImageDecoder::haveDecodedRow(unsigned frameIndex,
unsigned repeatCount,
bool writeTransparentPixels)
{
+ const GIFFrameReader* frameReader = m_reader->frame_reader;
// The pixel data and coordinates supplied to us are relative to the frame's
// origin within the entire image size, i.e.
- // (m_reader->frameXOffset(), m_reader->frameYOffset()). There is no
- // guarantee that
- // (rowEnd - rowBuffer) == (size().width() - m_reader->frameXOffset()), so
+ // (frameReader->x_offset, frameReader->y_offset). There is no guarantee
+ // that (rowEnd - rowBuffer) == (size().width() - frameReader->x_offset), so
// we must ensure we don't run off the end of either the source data or the
// row's X-coordinates.
- int xBegin = upperBoundScaledX(m_reader->frameXOffset());
- int yBegin = upperBoundScaledY(m_reader->frameYOffset() + rowNumber);
+ int xBegin = upperBoundScaledX(frameReader->x_offset);
+ int yBegin = upperBoundScaledY(frameReader->y_offset + rowNumber);
int xEnd = lowerBoundScaledX(std::min(xBegin + static_cast<int>(rowEnd - rowBuffer), size().width()) - 1, xBegin + 1) + 1;
int yEnd = lowerBoundScaledY(std::min(yBegin + static_cast<int>(repeatCount), size().height()) - 1, yBegin + 1) + 1;
if (!rowBuffer || (xBegin < 0) || (yBegin < 0) || (xEnd <= xBegin) || (yEnd <= yBegin))
return true;
// Get the colormap.
+ const unsigned char* colorMap;
unsigned colorMapSize;
- unsigned char* colorMap;
- m_reader->getColorMap(colorMap, colorMapSize);
+ if (frameReader->is_local_colormap_defined) {
+ colorMap = frameReader->local_colormap;
+ colorMapSize = (unsigned)frameReader->local_colormap_size;
+ } else {
+ colorMap = m_reader->global_colormap;
+ colorMapSize = m_reader->global_colormap_size;
+ }
if (!colorMap)
return true;
@@ -374,8 +323,8 @@ bool GIFImageDecoder::haveDecodedRow(unsigned frameIndex,
// Write one row's worth of data into the frame.
for (int x = xBegin; x < xEnd; ++x) {
- const unsigned char sourceValue = *(rowBuffer + (m_scaled ? m_scaledColumns[x] : x) - m_reader->frameXOffset());
- if ((!m_reader->isTransparent() || (sourceValue != m_reader->transparentPixel())) && (sourceValue < colorMapSize)) {
+ const unsigned char sourceValue = *(rowBuffer + (m_scaled ? m_scaledColumns[x] : x) - frameReader->x_offset);
+ if ((!frameReader->is_transparent || (sourceValue != frameReader->tpixel)) && (sourceValue < colorMapSize)) {
const size_t colorIndex = static_cast<size_t>(sourceValue) * 3;
buffer.setRGBA(x, yBegin, colorMap[colorIndex], colorMap[colorIndex + 1], colorMap[colorIndex + 2], 255);
} else {
@@ -448,9 +397,8 @@ void GIFImageDecoder::frameComplete(unsigned frameIndex, unsigned frameDuration,
void GIFImageDecoder::gifComplete()
{
if (m_reader)
- m_repetitionCount = m_reader->repetitionCount();
- delete m_reader;
- m_reader = 0;
+ m_repetitionCount = m_reader->loop_count;
+ m_reader.clear();
}
} // namespace WebCore
diff --git a/WebCore/platform/image-decoders/gif/GIFImageDecoder.h b/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
index 59328c0..011ca96 100644
--- a/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
+++ b/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
@@ -27,10 +27,11 @@
#define GIFImageDecoder_h
#include "ImageDecoder.h"
+#include <wtf/OwnPtr.h>
-namespace WebCore {
+class GIFImageReader;
- class GIFImageDecoderPrivate;
+namespace WebCore {
// This class decodes the GIF image format.
class GIFImageDecoder : public ImageDecoder {
@@ -80,7 +81,8 @@ namespace WebCore {
bool m_frameCountValid;
bool m_currentBufferSawAlpha;
mutable int m_repetitionCount;
- GIFImageDecoderPrivate* m_reader;
+ OwnPtr<GIFImageReader> m_reader;
+ unsigned m_readOffset;
};
} // namespace WebCore
diff --git a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
index 577cbcc..2a2636a 100644
--- a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
@@ -400,12 +400,11 @@ void term_source (j_decompress_ptr jd)
}
JPEGImageDecoder::JPEGImageDecoder()
-: m_reader(0)
-{}
+{
+}
JPEGImageDecoder::~JPEGImageDecoder()
{
- delete m_reader;
}
// Take the data and store it.
@@ -419,7 +418,7 @@ void JPEGImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
// Create the JPEG reader.
if (!m_reader && !m_failed)
- m_reader = new JPEGImageReader(this);
+ m_reader.set(new JPEGImageReader(this));
}
// Whether or not the size information has been decoded yet.
@@ -462,10 +461,8 @@ void JPEGImageDecoder::decode(bool sizeOnly)
m_failed = !m_reader->decode(m_data->buffer(), sizeOnly);
- if (m_failed || (!m_frameBufferCache.isEmpty() && m_frameBufferCache[0].status() == RGBA32Buffer::FrameComplete)) {
- delete m_reader;
- m_reader = 0;
- }
+ if (m_failed || (!m_frameBufferCache.isEmpty() && m_frameBufferCache[0].status() == RGBA32Buffer::FrameComplete))
+ m_reader.clear();
}
bool JPEGImageDecoder::outputScanlines()
diff --git a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
index 8a4b50f..d8bfd70 100644
--- a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
+++ b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
@@ -28,6 +28,7 @@
#define JPEGImageDecoder_h
#include "ImageDecoder.h"
+#include <wtf/OwnPtr.h>
namespace WebCore {
@@ -55,13 +56,11 @@ namespace WebCore {
void decode(bool sizeOnly = false);
- JPEGImageReader* reader() { return m_reader; }
-
bool outputScanlines();
void jpegComplete();
private:
- JPEGImageReader* m_reader;
+ OwnPtr<JPEGImageReader> m_reader;
};
} // namespace WebCore
diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
index 8a6e914..35c8af0 100644
--- a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -150,13 +150,11 @@ private:
};
PNGImageDecoder::PNGImageDecoder()
- : m_reader(0)
{
}
PNGImageDecoder::~PNGImageDecoder()
{
- delete m_reader;
}
// Take the data and store it.
@@ -170,7 +168,7 @@ void PNGImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
// Create the PNG reader.
if (!m_reader && !m_failed)
- m_reader = new PNGImageReader(this);
+ m_reader.set(new PNGImageReader(this));
}
// Whether or not the size information has been decoded yet.
@@ -205,10 +203,8 @@ void PNGImageDecoder::decode(bool sizeOnly)
m_reader->decode(*m_data, sizeOnly);
- if (m_failed || (!m_frameBufferCache.isEmpty() && m_frameBufferCache[0].status() == RGBA32Buffer::FrameComplete)) {
- delete m_reader;
- m_reader = 0;
- }
+ if (m_failed || (!m_frameBufferCache.isEmpty() && m_frameBufferCache[0].status() == RGBA32Buffer::FrameComplete))
+ m_reader.clear();
}
void decodingFailed(png_structp png, png_const_charp errorMsg)
@@ -237,8 +233,8 @@ void PNGImageDecoder::decodingFailed()
void PNGImageDecoder::headerAvailable()
{
- png_structp png = reader()->pngPtr();
- png_infop info = reader()->infoPtr();
+ png_structp png = m_reader->pngPtr();
+ png_infop info = m_reader->infoPtr();
png_uint_32 width = png->width;
png_uint_32 height = png->height;
@@ -305,11 +301,11 @@ void PNGImageDecoder::headerAvailable()
channels = png_get_channels(png, info);
ASSERT(channels == 3 || channels == 4);
- reader()->setHasAlpha(channels == 4);
+ m_reader->setHasAlpha(channels == 4);
- if (reader()->decodingSizeOnly()) {
+ if (m_reader->decodingSizeOnly()) {
// If we only needed the size, halt the reader.
- reader()->setReadOffset(reader()->currentBufferSize() - png->buffer_size);
+ m_reader->setReadOffset(m_reader->currentBufferSize() - png->buffer_size);
png->buffer_size = 0;
}
}
@@ -329,8 +325,8 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
RGBA32Buffer& buffer = m_frameBufferCache[0];
if (buffer.status() == RGBA32Buffer::FrameEmpty) {
if (!buffer.setSize(scaledSize().width(), scaledSize().height())) {
- static_cast<PNGImageDecoder*>(png_get_progressive_ptr(reader()->pngPtr()))->decodingFailed();
- longjmp(reader()->pngPtr()->jmpbuf, 1);
+ static_cast<PNGImageDecoder*>(png_get_progressive_ptr(m_reader->pngPtr()))->decodingFailed();
+ longjmp(m_reader->pngPtr()->jmpbuf, 1);
return;
}
buffer.setStatus(RGBA32Buffer::FramePartial);
@@ -339,8 +335,8 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
// For PNGs, the frame always fills the entire image.
buffer.setRect(IntRect(IntPoint(), size()));
- if (reader()->pngPtr()->interlaced)
- reader()->createInterlaceBuffer((reader()->hasAlpha() ? 4 : 3) * size().width() * size().height());
+ if (m_reader->pngPtr()->interlaced)
+ m_reader->createInterlaceBuffer((m_reader->hasAlpha() ? 4 : 3) * size().width() * size().height());
}
if (rowBuffer == 0)
@@ -374,11 +370,11 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
* old row and the new row.
*/
- png_structp png = reader()->pngPtr();
- bool hasAlpha = reader()->hasAlpha();
+ png_structp png = m_reader->pngPtr();
+ bool hasAlpha = m_reader->hasAlpha();
unsigned colorChannels = hasAlpha ? 4 : 3;
png_bytep row;
- png_bytep interlaceBuffer = reader()->interlaceBuffer();
+ png_bytep interlaceBuffer = m_reader->interlaceBuffer();
if (interlaceBuffer) {
row = interlaceBuffer + (rowIndex * colorChannels * size().width());
png_progressive_combine_row(png, row, rowBuffer);
diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.h b/WebCore/platform/image-decoders/png/PNGImageDecoder.h
index 3c0535b..07a0b3a 100644
--- a/WebCore/platform/image-decoders/png/PNGImageDecoder.h
+++ b/WebCore/platform/image-decoders/png/PNGImageDecoder.h
@@ -27,6 +27,7 @@
#define PNGImageDecoder_h
#include "ImageDecoder.h"
+#include <wtf/OwnPtr.h>
namespace WebCore {
@@ -50,8 +51,6 @@ namespace WebCore {
void decode(bool sizeOnly = false);
- PNGImageReader* reader() { return m_reader; }
-
// Callbacks from libpng
void decodingFailed();
void headerAvailable();
@@ -59,7 +58,7 @@ namespace WebCore {
void pngComplete();
private:
- PNGImageReader* m_reader;
+ OwnPtr<PNGImageReader> m_reader;
};
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list