summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/image-decoders
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/platform/image-decoders
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/platform/image-decoders')
-rw-r--r--WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp18
-rw-r--r--WebCore/platform/image-decoders/gif/GIFImageDecoder.h1
-rw-r--r--WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp23
-rw-r--r--WebCore/platform/image-decoders/png/PNGImageDecoder.cpp6
4 files changed, 42 insertions, 6 deletions
diff --git a/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp b/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
index 1b70cd4..22a6f09 100644
--- a/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
@@ -23,6 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "config.h"
#include "GIFImageDecoder.h"
#include "GIFImageReader.h"
@@ -85,7 +86,7 @@ private:
};
GIFImageDecoder::GIFImageDecoder()
-: m_frameCountValid(true), m_reader(0)
+: m_frameCountValid(true), m_repetitionCount(cAnimationLoopOnce), m_reader(0)
{}
GIFImageDecoder::~GIFImageDecoder()
@@ -149,11 +150,16 @@ int GIFImageDecoder::frameCount()
// The number of repetitions to perform for an animation loop.
int GIFImageDecoder::repetitionCount() const
{
- // We don't have to do any decoding to determine this, since the loop count was determined after
- // the initial query for size.
+ // This value can arrive at any point in the image data stream. Most GIFs
+ // in the wild declare it near the beginning of the file, so it usually is
+ // set by the time we've decoded the size, but (depending on the GIF and the
+ // packets sent back by the webserver) not always. Our caller is
+ // responsible for waiting until image decoding has finished to ask this if
+ // it needs an authoritative answer. In the meantime, we should default to
+ // "loop once", both in the reader and here.
if (m_reader)
- return m_reader->repetitionCount();
- return cAnimationNone;
+ m_repetitionCount = m_reader->repetitionCount();
+ return m_repetitionCount;
}
RGBA32Buffer* GIFImageDecoder::frameBufferAtIndex(size_t index)
@@ -399,6 +405,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;
}
diff --git a/WebCore/platform/image-decoders/gif/GIFImageDecoder.h b/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
index 7d22325..b407b8d 100644
--- a/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
+++ b/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
@@ -79,6 +79,7 @@ private:
bool m_frameCountValid;
bool m_currentBufferSawAlpha;
+ mutable int m_repetitionCount;
mutable GIFImageDecoderPrivate* m_reader;
};
diff --git a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
index cc246e2..44e0e4c 100644
--- a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
@@ -38,13 +38,34 @@
#include "config.h"
#include "JPEGImageDecoder.h"
#include <assert.h>
+#include <stdio.h>
#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
+#if COMPILER(MSVC)
+// Remove warnings from warning level 4.
+#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
+
+// if ADDRESS_TAG_BIT is dfined, INT32 has been declared as a typedef in the PlatformSDK (BaseTsd.h),
+// so we need to stop jpeglib.h from trying to #define it
+// see here for more info: http://www.cygwin.com/ml/cygwin/2004-07/msg01051.html
+# if defined(ADDRESS_TAG_BIT) && !defined(XMD_H)
+# define XMD_H
+# define VTK_JPEG_XMD_H
+# endif
+#endif // COMPILER(MSVC)
+
extern "C" {
#include "jpeglib.h"
}
+#if COMPILER(MSVC)
+# if defined(VTK_JPEG_XMD_H)
+# undef VTK_JPEG_XMD_H
+# undef XMD_H
+# endif
+#endif // COMPILER(MSVC)
+
#include <setjmp.h>
namespace WebCore {
@@ -100,7 +121,7 @@ public:
/* Allocate and initialize JPEG decompression object */
jpeg_create_decompress(&m_info);
- decoder_source_mgr* src;
+ decoder_source_mgr* src = 0;
if (!m_info.src) {
src = (decoder_source_mgr*)fastCalloc(sizeof(decoder_source_mgr), 1);
if (!src) {
diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
index 99da437..17143b1 100644
--- a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
+++ b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -35,12 +35,18 @@
* version of this file under any of the LGPL, the MPL or the GPL.
*/
+#include "config.h"
#include "PNGImageDecoder.h"
#include "png.h"
#include "assert.h"
#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
+#if COMPILER(MSVC)
+// Remove warnings from warning level 4.
+#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
+#endif
+
namespace WebCore {
// Gamma constants.