[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] [SCM] Gnash branch, master, updated. d996bc6ce3dcf0393248
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] [SCM] Gnash branch, master, updated. d996bc6ce3dcf03932483bf5bcb15150b031b2ce |
Date: |
Wed, 01 Sep 2010 09:25:07 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".
The branch, master has been updated
via d996bc6ce3dcf03932483bf5bcb15150b031b2ce (commit)
via cced55be7ef655df91e80afa395bdb948d891e9c (commit)
via cbf3d9a0051206f9953f481941140dcb3ce9017e (commit)
via 03ccfa21b91ca84235b3ea5b9458198d1c415aa3 (commit)
via 924e59c3ce94d95c47ab4546a652d7f05cbad31e (commit)
via 4bfd4fb1b894953263a114de1eb81d7e1b70a8bd (commit)
via c968b0838493c36a387098135128d0b6b8039c11 (commit)
from 1d35dcd5e8481f6c39f4155b800b7f1de930d57f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=d996bc6ce3dcf03932483bf5bcb15150b031b2ce
commit d996bc6ce3dcf03932483bf5bcb15150b031b2ce
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 1 11:22:48 2010 +0200
Fix unused variable warnings.
diff --git a/gui/sdl/sdl_cairo_glue.cpp b/gui/sdl/sdl_cairo_glue.cpp
index 2499ea0..f7bd231 100644
--- a/gui/sdl/sdl_cairo_glue.cpp
+++ b/gui/sdl/sdl_cairo_glue.cpp
@@ -41,7 +41,7 @@ SdlCairoGlue::~SdlCairoGlue()
}
bool
-SdlCairoGlue::init(int argc, char** argv[])
+SdlCairoGlue::init(int /*argc*/, char** /*argv*/[])
{
// GNASH_REPORT_FUNCTION;
return true;
@@ -61,7 +61,7 @@ SdlCairoGlue::createRenderHandler(int depth)
/// Not implemented, Fixme
void
-SdlCairoGlue::setInvalidatedRegions(const InvalidatedRanges& ranges)
+SdlCairoGlue::setInvalidatedRegions(const InvalidatedRanges& /*ranges*/)
{
}
diff --git a/gui/sdl/sdl_ogl_glue.cpp b/gui/sdl/sdl_ogl_glue.cpp
index c8a0f50..2045ae6 100644
--- a/gui/sdl/sdl_ogl_glue.cpp
+++ b/gui/sdl/sdl_ogl_glue.cpp
@@ -45,7 +45,7 @@ SdlOglGlue::~SdlOglGlue()
}
-bool SdlOglGlue::init(int argc, char **argv[])
+bool SdlOglGlue::init(int /*argc*/, char ** /*argv*/ [])
{
// GNASH_REPORT_FUNCTION;
#ifdef FIX_I810_LOD_BIAS
@@ -77,7 +77,7 @@ SdlOglGlue::createRenderHandler(int depth)
/// Not implemented, Fixme
void
-SdlOglGlue::setInvalidatedRegions(const InvalidatedRanges& ranges)
+SdlOglGlue::setInvalidatedRegions(const InvalidatedRanges& /*ranges*/)
{
}
http://git.savannah.gnu.org/cgit//commit/?id=cced55be7ef655df91e80afa395bdb948d891e9c
commit cced55be7ef655df91e80afa395bdb948d891e9c
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 1 11:12:17 2010 +0200
Fix for bug #25758
diff --git a/macros/qt4.m4 b/macros/qt4.m4
index a074a91..416c74f 100644
--- a/macros/qt4.m4
+++ b/macros/qt4.m4
@@ -176,8 +176,8 @@ dnl fi
has_qt4="no"
fi
- AC_PATH_PROGS(MOC4, [moc-qt4 moc], ,[${QTDIR}/bin /usr/lib/qt4/bin
/usr/share/qt4/bin/ ${pathlist}])
- AC_PATH_PROGS(UIC4, [uic-qt4 uic], ,[${QTDIR}/bin /usr/lib/qt4/bin
/usr/share/qt4/bin/ ${pathlist}])
+ AC_PATH_PROGS(MOC4, [moc-qt4 moc], ,[/usr/bin ${QTDIR}/bin
/usr/lib/qt4/bin /usr/share/qt4/bin/ ${pathlist}])
+ AC_PATH_PROGS(UIC4, [uic-qt4 uic], ,[/usr/bin ${QTDIR}/bin
/usr/lib/qt4/bin /usr/share/qt4/bin/ ${pathlist}])
AC_SUBST([QT4_CFLAGS])
http://git.savannah.gnu.org/cgit//commit/?id=cbf3d9a0051206f9953f481941140dcb3ce9017e
commit cbf3d9a0051206f9953f481941140dcb3ce9017e
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 1 11:00:10 2010 +0200
Log discarded actions only in action logging.
diff --git a/libcore/vm/ActionExec.cpp b/libcore/vm/ActionExec.cpp
index 977f022..d385662 100644
--- a/libcore/vm/ActionExec.cpp
+++ b/libcore/vm/ActionExec.cpp
@@ -269,18 +269,22 @@ ActionExec::operator()()
DisplayObject* guardedChar = env.get_target();
if (_abortOnUnload && guardedChar && guardedChar->unloaded()) {
- // action_execution_order_test8.c shows that the opcode
- // guard is not SWF version based (TODO: automate it!)
- std::stringstream ss;
- ss << "Target of action_buffer (" << guardedChar->getTarget()
- << " of type " << typeName(*guardedChar) << ") unloaded "
- "by execution of opcode: " << std::endl;
-
- dumpActions(pc, next_pc, ss);
- ss << "Discarding " << stop_pc-next_pc
- << " bytes of remaining opcodes: " << std::endl;
- dumpActions(next_pc, stop_pc, ss);
- log_debug("%s", ss.str());
+
+ IF_VERBOSE_ACTION(
+ // action_execution_order_test8.c shows that the opcode
+ // guard is not SWF version based
+ std::stringstream ss;
+ ss << "Target of action_buffer (" <<
+ guardedChar->getTarget() << " of type " <<
+ typeName(*guardedChar) << ") unloaded "
+ "by execution of opcode: " << std::endl;
+
+ dumpActions(pc, next_pc, ss);
+ ss << "Discarding " << stop_pc-next_pc
+ << " bytes of remaining opcodes: " << std::endl;
+ dumpActions(next_pc, stop_pc, ss);
+ log_action("%s", ss.str());
+ );
break;
}
http://git.savannah.gnu.org/cgit//commit/?id=03ccfa21b91ca84235b3ea5b9458198d1c415aa3
commit 03ccfa21b91ca84235b3ea5b9458198d1c415aa3
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 1 10:56:29 2010 +0200
Remove jpeg namespace, use <algorithm> functions.
diff --git a/libbase/GnashImageJpeg.cpp b/libbase/GnashImageJpeg.cpp
index ff4cc89..dc059f6 100644
--- a/libbase/GnashImageJpeg.cpp
+++ b/libbase/GnashImageJpeg.cpp
@@ -26,72 +26,61 @@
#include "gnashconfig.h"
#endif
+#include "GnashImageJpeg.h"
+
+#include <sstream>
+#include <csetjmp>
+#include <boost/noncopyable.hpp>
+#include <algorithm>
+
#include "utility.h"
#include "GnashImage.h"
#include "IOChannel.h"
#include "log.h"
#include "GnashException.h"
-#include "GnashImageJpeg.h"
-
-#include <sstream>
-#include <csetjmp>
-/// \brief A namespace solely for avoiding name
-/// conflicts with other external headers.
-namespace jpeg {
-// jpeglib.h redefines HAVE_STDLIB_H. This silences
-// the warnings, but it's not good.
+// jpeglib.h redefines HAVE_STDLIB_H.
#undef HAVE_STDLIB_H
extern "C" {
# include <jpeglib.h>
}
#undef HAVE_STDLIB_H
-}
-
-// jpeglib.h is included in the namespace jpeg because otherwise it
-// causes horrible conflicts with qt includes. How do C coders sustain
-// the will to live?
-using namespace jpeg;
-
#ifdef _WIN32
typedef jpeg_boolean jpeg_bool_t;
#else
-typedef jpeg::boolean jpeg_bool_t;
+typedef boolean jpeg_bool_t;
#endif
namespace gnash {
namespace image {
-static void
+namespace {
+
+void
jpeg_error_exit(j_common_ptr cinfo)
{
-
// Set a flag to stop parsing
JpegInput* in = static_cast<JpegInput*>(cinfo->client_data);
-
in->errorOccurred(cinfo->err->jpeg_message_table[cinfo->err->msg_code]);
-
}
// Set up some error handlers for the jpeg lib.
-static void
+void
setup_jpeg_err(jpeg_error_mgr* jerr)
{
// Set up defaults.
jpeg_std_error(jerr);
-
jerr->error_exit = jpeg_error_exit;
}
-// Helper object for reading jpeg image data. Basically a thin
static const int IO_BUF_SIZE = 4096;
// A jpeglib source manager that reads from a IOChannel. Paraphrased
// from IJG jpeglib jdatasrc.c.
-class rw_source_IOChannel
+class rw_source_IOChannel : boost::noncopyable
{
public:
jpeg_source_mgr m_pub; /* public fields */
@@ -112,7 +101,7 @@ public:
static void init_source(j_decompress_ptr cinfo)
{
- rw_source_IOChannel* src = (rw_source_IOChannel*) cinfo->src;
+ rw_source_IOChannel* src = (rw_source_IOChannel*) cinfo->src;
src->m_start_of_file = true;
}
@@ -120,10 +109,10 @@ public:
// when it needs more data from the file.
static jpeg_bool_t fill_input_buffer(j_decompress_ptr cinfo)
{
- rw_source_IOChannel* src = (rw_source_IOChannel*) cinfo->src;
+ rw_source_IOChannel* src = (rw_source_IOChannel*) cinfo->src;
// TODO: limit read as requested by caller
- size_t bytes_read = src->m_in_stream->read(src->m_buffer,
IO_BUF_SIZE);
+ size_t bytes_read = src->m_in_stream->read(src->m_buffer, IO_BUF_SIZE);
if (bytes_read <= 0) {
// Is the file completely empty?
@@ -132,26 +121,23 @@ public:
log_error(_("JPEG: Empty jpeg source stream."));
return false;
}
- // warn("jpeg end-of-stream");
// Insert a fake EOI marker.
- src->m_buffer[0] = (JOCTET) 0xFF;
- src->m_buffer[1] = (JOCTET) JPEG_EOI;
+ src->m_buffer[0] = 0xFF;
+ src->m_buffer[1] = JPEG_EOI;
bytes_read = 2;
}
// Hack to work around SWF bug: sometimes data
// starts with FFD9FFD8, when it should be
// FFD8FFD9!
- if (src->m_start_of_file && bytes_read >= 4)
- {
- if (src->m_buffer[0] == 0xFF
- && src->m_buffer[1] == 0xD9
- && src->m_buffer[2] == 0xFF
- && src->m_buffer[3] == 0xD8)
- {
- src->m_buffer[1] = 0xD8;
- src->m_buffer[3] = 0xD9;
+ if (src->m_start_of_file && bytes_read >= 4) {
+
+ const JOCTET wrong[] = { 0xff, 0xd9, 0xff, 0xd8 };
+
+ if (std::equal(src->m_buffer, src->m_buffer + 4, wrong)) {
+ log_debug("Wrong bytes");
+ std::swap(src->m_buffer[1], src->m_buffer[3]);
}
}
@@ -165,7 +151,7 @@ public:
// Called by client when it wants to advance past some
// uninteresting data.
- static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
+ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
{
rw_source_IOChannel* src = (rw_source_IOChannel*) cinfo->src;
@@ -188,7 +174,7 @@ public:
}
- void discardPartialBuffer()
+ void discardPartialBuffer()
{
// Discard existing bytes in our buffer.
m_pub.bytes_in_buffer = 0;
@@ -201,9 +187,9 @@ public:
/// @param instream
/// Stream to read from. Ownership always shared with caller.
///
- static void setup(jpeg_decompress_struct* cinfo,
boost::shared_ptr<IOChannel> instream)
+ static void setup(jpeg_decompress_struct* cinfo,
+ boost::shared_ptr<IOChannel> instream)
{
- // assert(cinfo->src == NULL);
rw_source_IOChannel* source = new rw_source_IOChannel(instream);
cinfo->src = (jpeg_source_mgr*)source;
}
@@ -216,22 +202,23 @@ private:
m_pub.init_source = init_source;
m_pub.fill_input_buffer = fill_input_buffer;
m_pub.skip_input_data = skip_input_data;
- m_pub.resync_to_restart = jpeg_resync_to_restart; // use default
method
+ // use default method
+ m_pub.resync_to_restart = jpeg_resync_to_restart;
m_pub.term_source = term_source;
m_pub.bytes_in_buffer = 0;
m_pub.next_input_byte = NULL;
}
- bool _ownSourceStream;
+ const bool _ownSourceStream;
// Source stream
boost::shared_ptr<IOChannel> m_in_stream;
- bool m_start_of_file; /* have we gotten any data yet? */
- JOCTET m_buffer[IO_BUF_SIZE]; /* start of buffer */
-
+ bool m_start_of_file;
+ JOCTET m_buffer[IO_BUF_SIZE];
};
+} // unnamed namespace
JpegInput::JpegInput(boost::shared_ptr<IOChannel> in)
:
@@ -270,8 +257,7 @@ JpegInput::discardPartialBuffer()
rw_source_IOChannel* src = (rw_source_IOChannel*) m_cinfo.src;
// We only have to discard the input buffer after reading the tables.
- if (src)
- {
+ if (src) {
src->discardPartialBuffer();
}
}
@@ -289,7 +275,7 @@ JpegInput::readHeader(unsigned int maxHeaderBytes)
if (maxHeaderBytes) {
// Read the encoding tables.
// TODO: how to limit reads ?
- int ret = jpeg_read_header(&m_cinfo, FALSE);
+ const int ret = jpeg_read_header(&m_cinfo, FALSE);
switch (ret) {
case JPEG_SUSPENDED:
// suspended due to lack of data
@@ -303,8 +289,7 @@ JpegInput::readHeader(unsigned int maxHeaderBytes)
// Found valid table-specs-only datastream
break;
default:
- log_debug(_("unexpected: jpeg_read_header returned %d
[%s:%d]"),
- ret, __FILE__, __LINE__);
+ log_debug(_("unexpected: jpeg_read_header returned %d"), ret);
break;
}
@@ -333,9 +318,10 @@ JpegInput::read()
}
// hack, FIXME
- static const int stateReady = 202; /* found SOS, ready for
start_decompress */
+ // found SOS, ready for start_decompress
+ static const int stateReady = 202;
while (m_cinfo.global_state != stateReady) {
- int ret = jpeg_read_header(&m_cinfo, FALSE);
+ const int ret = jpeg_read_header(&m_cinfo, FALSE);
switch (ret) {
case JPEG_SUSPENDED:
// suspended due to lack of data
@@ -484,7 +470,8 @@ JpegInput::readSWFJpeg2WithTables(JpegInput& loader)
class rw_dest_IOChannel
{
public:
- struct jpeg_destination_mgr m_pub; /* public fields */
+
+ struct jpeg_destination_mgr m_pub;
/// Constructor.
//
@@ -509,7 +496,7 @@ public:
static void init_destination(j_compress_ptr cinfo)
{
- rw_dest_IOChannel* dest = (rw_dest_IOChannel*) cinfo->dest;
+ rw_dest_IOChannel* dest = (rw_dest_IOChannel*) cinfo->dest;
assert(dest);
dest->m_pub.next_output_byte = dest->m_buffer;
@@ -526,13 +513,13 @@ public:
/// Write the output buffer into the stream.
static jpeg_bool_t empty_output_buffer(j_compress_ptr cinfo)
{
- rw_dest_IOChannel* dest = (rw_dest_IOChannel*) cinfo->dest;
+ rw_dest_IOChannel* dest = (rw_dest_IOChannel*) cinfo->dest;
assert(dest);
- if (dest->m_out_stream.write(dest->m_buffer, IO_BUF_SIZE) !=
IO_BUF_SIZE)
- {
+ if (dest->m_out_stream.write(dest->m_buffer, IO_BUF_SIZE)
+ != IO_BUF_SIZE) {
// Error.
- log_error(_("jpeg::rw_dest_IOChannel couldn't write data."));
+ log_error(_("rw_dest_IOChannel couldn't write data."));
return false;
}
@@ -557,7 +544,7 @@ public:
if (dest->m_out_stream.write(dest->m_buffer, datacount) !=
datacount)
{
// Error.
- log_error(_("jpeg::rw_dest_IOChannel::term_destination "
+ log_error(_("rw_dest_IOChannel::term_destination "
"couldn't write data."));
}
}
@@ -577,7 +564,8 @@ private:
};
-JpegOutput::JpegOutput(boost::shared_ptr<IOChannel> out, size_t width, size_t
height, int quality)
+JpegOutput::JpegOutput(boost::shared_ptr<IOChannel> out, size_t width,
+ size_t height, int quality)
:
Output(out, width, height)
{
@@ -611,10 +599,8 @@ JpegOutput::writeImageRGB(const unsigned char* rgbData)
// RGB...
const size_t components = 3;
- for (size_t y = 0; y < _height; ++y)
- {
+ for (size_t y = 0; y < _height; ++y) {
const unsigned char* ypos = &rgbData[y * _width * components];
-
// JPEG needs non-const data.
jpeg_write_scanlines(&m_cinfo, const_cast<unsigned char**>(&ypos), 1);
}
@@ -622,11 +608,10 @@ JpegOutput::writeImageRGB(const unsigned char* rgbData)
std::auto_ptr<Output>
-JpegOutput::create(boost::shared_ptr<IOChannel> out, size_t width,
- size_t height, int quality)
+JpegOutput::create(boost::shared_ptr<IOChannel> o, size_t width, size_t height,
+ int quality)
{
- std::auto_ptr<Output> outChannel(
- new JpegOutput(out, width, height, quality));
+ std::auto_ptr<Output> outChannel(new JpegOutput(o, width, height,
quality));
return outChannel;
}
diff --git a/libbase/GnashImageJpeg.h b/libbase/GnashImageJpeg.h
index dc49df5..e5e3e8a 100644
--- a/libbase/GnashImageJpeg.h
+++ b/libbase/GnashImageJpeg.h
@@ -23,15 +23,11 @@
#ifndef GNASH_IMAGE_JPEG_H
#define GNASH_IMAGE_JPEG_H
+#include <csetjmp>
+
#include "dsodefs.h"
-#include <csetjmp> // for jmp_buf
#include "GnashImage.h"
-
-/// \brief A namespace solely for avoiding name
-/// conflicts with other external headers.
-namespace jpeg {
-
// jpeglib.h redefines HAVE_STDLIB_H. This silences
// the warnings, but it's not good.
#undef HAVE_STDLIB_H
@@ -40,8 +36,6 @@ extern "C" {
}
#undef HAVE_STDLIB_H
-}
-
// Forward declarations
namespace gnash { class IOChannel; }
@@ -61,8 +55,8 @@ private:
std::jmp_buf _jmpBuf;
// State needed for input.
- jpeg::jpeg_decompress_struct m_cinfo;
- jpeg::jpeg_error_mgr m_jerr;
+ jpeg_decompress_struct m_cinfo;
+ jpeg_error_mgr m_jerr;
bool _compressorOpened;
@@ -133,7 +127,7 @@ public:
/// \brief
/// For reading SWF JPEG2-style image data, using pre-loaded
- /// headers stored in the given jpeg::input object.
+ /// headers stored in the given JpegInput object.
//
/// @param loader The JpegInput object to use for reading the
/// data. This should have been constructed with
@@ -200,8 +194,8 @@ public:
private:
- jpeg::jpeg_compress_struct m_cinfo;
- jpeg::jpeg_error_mgr m_jerr;
+ jpeg_compress_struct m_cinfo;
+ jpeg_error_mgr m_jerr;
};
http://git.savannah.gnu.org/cgit//commit/?id=924e59c3ce94d95c47ab4546a652d7f05cbad31e
commit 924e59c3ce94d95c47ab4546a652d7f05cbad31e
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 1 10:51:31 2010 +0200
Minor cleanup to gif code.
diff --git a/libbase/GnashImageGif.cpp b/libbase/GnashImageGif.cpp
index 7469598..f6d1b0a 100644
--- a/libbase/GnashImageGif.cpp
+++ b/libbase/GnashImageGif.cpp
@@ -18,24 +18,28 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-#include "utility.h"
#include "GnashImageGif.h"
-#include "log.h"
-#include "GnashException.h"
-#include "IOChannel.h"
#include <sstream>
-#include <cstring> // std::memcpy
+#include <algorithm>
#include <boost/scoped_array.hpp>
extern "C" {
#include <gif_lib.h>
}
+#include "utility.h"
+#include "log.h"
+#include "GnashException.h"
+#include "IOChannel.h"
+
+
namespace gnash {
namespace image {
-static int
+namespace {
+
+int
readData(GifFileType* ft, GifByteType* data, int length)
{
// Do not read until opened.
@@ -44,10 +48,12 @@ readData(GifFileType* ft, GifByteType* data, int length)
return in->read(reinterpret_cast<char*>(data), length);
}
+}
-GifInput::GifInput(boost::shared_ptr<IOChannel> in) :
+GifInput::GifInput(boost::shared_ptr<IOChannel> in)
+ :
Input(in),
- _gif(NULL),
+ _gif(0),
_currentRow(0)
{
}
@@ -76,17 +82,18 @@ void
GifInput::readScanline(unsigned char* rgbData)
{
- ColorMapObject* colormap = (_gif->Image.ColorMap) ?
- _gif->Image.ColorMap :
- _gif->SColorMap;
+ const ColorMapObject* const colormap = (_gif->Image.ColorMap) ?
+ _gif->Image.ColorMap : _gif->SColorMap;
assert(colormap);
unsigned char* ptr = rgbData;
- for (size_t i = 0, e = getWidth(); i < e; ++i)
- {
- GifColorType* mapentry = &colormap->Colors[_gifData[_currentRow][i]];
+ for (size_t i = 0, e = getWidth(); i < e; ++i) {
+
+ const GifColorType* const mapentry =
+ &colormap->Colors[_gifData[_currentRow][i]];
+
*ptr++ = mapentry->Red;
*ptr++ = mapentry->Green;
*ptr++ = mapentry->Blue;
@@ -136,8 +143,8 @@ GifInput::read()
// Set the width dimension of the array
_gifData[i].reset(new GifPixelType[screenWidth]);
// Fill all the pixels with the background color.
- std::memset(_gifData[i].get(), backgroundColor,
- screenWidth);
+ std::fill_n(_gifData[i].get(), screenWidth,
+ backgroundColor);
}
// The position of the image on the GIF 'screen'
@@ -158,10 +165,8 @@ GifInput::read()
screenWidth, screenHeight);
// The order of interlaced GIFs.
- static const int interlacedOffsets[] =
- { 0, 4, 2, 1 };
- static const int interlacedJumps[] =
- { 8, 8, 4, 2 };
+ const int interlacedOffsets[] = { 0, 4, 2, 1 };
+ const int interlacedJumps[] = { 8, 8, 4, 2 };
for (size_t i = 0; i < 4; ++i) {
http://git.savannah.gnu.org/cgit//commit/?id=4bfd4fb1b894953263a114de1eb81d7e1b70a8bd
commit 4bfd4fb1b894953263a114de1eb81d7e1b70a8bd
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 1 10:50:44 2010 +0200
Use <algorithm> functions, clean up.
diff --git a/libbase/GnashImage.cpp b/libbase/GnashImage.cpp
index d24071e..2d33fec 100644
--- a/libbase/GnashImage.cpp
+++ b/libbase/GnashImage.cpp
@@ -20,19 +20,20 @@
// Based on the public domain work of Thatcher Ulrich <address@hidden> 2002
-#include <cstring>
-#include <memory> // for auto_ptr
+#include "GnashImage.h"
+
+#include <memory>
#include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp>
+#include <algorithm>
-#include "FileTypes.h"
-#include "GnashImage.h"
#ifdef USE_PNG
# include "GnashImagePng.h"
#endif
#ifdef USE_GIF
# include "GnashImageGif.h"
#endif
+#include "FileTypes.h"
#include "GnashImageJpeg.h"
#include "IOChannel.h"
#include "log.h"
@@ -84,7 +85,7 @@ GnashImage::update(const GnashImage& from)
assert(width() == from.width());
assert(_type == from._type);
assert(_location == from._location);
- std::memcpy(begin(), from.begin(), size());
+ std::copy(from.begin(), from.begin() + size(), begin());
}
ImageRGB::ImageRGB(size_t width, size_t height)
http://git.savannah.gnu.org/cgit//commit/?id=c968b0838493c36a387098135128d0b6b8039c11
commit c968b0838493c36a387098135128d0b6b8039c11
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 1 10:07:23 2010 +0200
Const correctness and style.
diff --git a/libbase/GnashImagePng.cpp b/libbase/GnashImagePng.cpp
index 3acad77..98352b0 100644
--- a/libbase/GnashImagePng.cpp
+++ b/libbase/GnashImagePng.cpp
@@ -72,7 +72,8 @@ flushData(png_structp /*pngptr*/)
} // unnamed namespace
-PngInput::PngInput(boost::shared_ptr<IOChannel> in) :
+PngInput::PngInput(boost::shared_ptr<IOChannel> in)
+ :
Input(in),
_pngPtr(0),
_infoPtr(0),
@@ -85,21 +86,20 @@ PngInput::PngInput(boost::shared_ptr<IOChannel> in) :
PngInput::~PngInput()
{
- png_destroy_read_struct(&_pngPtr, &_infoPtr,
- static_cast<png_infopp>(NULL));
+ png_destroy_read_struct(&_pngPtr, &_infoPtr, 0);
}
size_t
PngInput::getHeight() const
{
- assert (_pngPtr && _infoPtr);
+ assert(_pngPtr && _infoPtr);
return png_get_image_height(_pngPtr, _infoPtr);
}
size_t
PngInput::getWidth() const
{
- assert (_pngPtr && _infoPtr);
+ assert(_pngPtr && _infoPtr);
return png_get_image_width(_pngPtr, _infoPtr);
}
@@ -112,8 +112,8 @@ PngInput::getComponents() const
void
PngInput::readScanline(unsigned char* imageData)
{
- assert (_currentRow < getHeight());
- assert (_rowPtrs);
+ assert(_currentRow < getHeight());
+ assert(_rowPtrs);
// Data packed as RGB / RGBA
const size_t size = getWidth() * getComponents();
@@ -128,17 +128,15 @@ void
PngInput::init()
{
// Initialize png library.
- _pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
- NULL, &error, &warning);
+ _pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, &error,
+ &warning);
+
if (!_pngPtr) return;
_infoPtr = png_create_info_struct(_pngPtr);
- if (!_infoPtr)
- {
- png_destroy_read_struct(&_pngPtr,
- static_cast<png_infopp>(NULL),
- static_cast<png_infopp>(NULL));
+ if (!_infoPtr) {
+ png_destroy_read_struct(&_pngPtr, 0, 0);
return;
}
}
@@ -151,8 +149,8 @@ PngInput::read()
png_read_info(_pngPtr, _infoPtr);
- png_byte type = png_get_color_type(_pngPtr, _infoPtr);
- png_byte bitDepth = png_get_bit_depth(_pngPtr, _infoPtr);
+ const png_byte type = png_get_color_type(_pngPtr, _infoPtr);
+ const png_byte bitDepth = png_get_bit_depth(_pngPtr, _infoPtr);
// Convert indexed images to RGB
if (type == PNG_COLOR_TYPE_PALETTE) {
@@ -177,23 +175,19 @@ PngInput::read()
if (bitDepth == 16) png_set_strip_16(_pngPtr);
// Set the type of the image if it hasn't been set already.
- if (_type == GNASH_IMAGE_INVALID)
- {
- if (type & PNG_COLOR_MASK_ALPHA)
- {
+ if (_type == GNASH_IMAGE_INVALID) {
+ if (type & PNG_COLOR_MASK_ALPHA) {
log_debug("Loading PNG image with alpha");
_type = TYPE_RGBA;
}
- else
- {
+ else {
log_debug("Loading PNG image without alpha");
_type = TYPE_RGB;
}
}
// Convert 1-channel grey images to 3-channel RGB.
- if (type == PNG_COLOR_TYPE_GRAY || type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
+ if (type == PNG_COLOR_TYPE_GRAY || type == PNG_COLOR_TYPE_GRAY_ALPHA) {
log_debug("Converting greyscale PNG to RGB(A)");
png_set_gray_to_rgb(_pngPtr);
}
@@ -202,7 +196,6 @@ PngInput::read()
const size_t height = getHeight();
const size_t width = getWidth();
-
const size_t components = getComponents();
// We must have 3 or 4-channel data by this point.
@@ -217,8 +210,7 @@ PngInput::read()
_rowPtrs.reset(new png_bytep[height]);
// Fill in the row pointers.
- for (size_t y = 0; y < height; ++y)
- {
+ for (size_t y = 0; y < height; ++y) {
_rowPtrs[y] = _pixelData.get() + y * width * components;
}
@@ -231,7 +223,8 @@ PngInput::read()
/// PNG output
///
-PngOutput::PngOutput(boost::shared_ptr<IOChannel> out, size_t width, size_t
height, int /* quality */)
+PngOutput::PngOutput(boost::shared_ptr<IOChannel> out, size_t width,
+ size_t height, int /*quality*/)
:
Output(out, width, height),
_pngPtr(0),
@@ -257,8 +250,7 @@ PngOutput::init()
_infoPtr = png_create_info_struct(_pngPtr);
- if (!_infoPtr)
- {
+ if (!_infoPtr) {
png_destroy_write_struct(&_pngPtr, static_cast<png_infopp>(NULL));
return;
}
@@ -274,8 +266,7 @@ PngOutput::writeImageRGBA(const unsigned char* rgbaData)
// RGBA
const size_t components = 4;
- for (size_t y = 0; y < _height; ++y)
- {
+ for (size_t y = 0; y < _height; ++y) {
rows[y] = rgbaData + _width * y * components;
}
@@ -300,8 +291,7 @@ PngOutput::writeImageRGB(const unsigned char* rgbData)
// RGB
const size_t components = 3;
- for (size_t y = 0; y < _height; ++y)
- {
+ for (size_t y = 0; y < _height; ++y) {
rows[y] = rgbData + _width * y * components;
}
@@ -317,11 +307,10 @@ PngOutput::writeImageRGB(const unsigned char* rgbData)
std::auto_ptr<Output>
-PngOutput::create(boost::shared_ptr<IOChannel> out, size_t width,
+PngOutput::create(boost::shared_ptr<IOChannel> o, size_t width,
size_t height, int quality)
{
- std::auto_ptr<Output> outChannel(
- new PngOutput(out, width, height, quality));
+ std::auto_ptr<Output> outChannel(new PngOutput(o, width, height, quality));
return outChannel;
}
-----------------------------------------------------------------------
Summary of changes:
gui/sdl/sdl_cairo_glue.cpp | 4 +-
gui/sdl/sdl_ogl_glue.cpp | 4 +-
libbase/GnashImage.cpp | 11 ++--
libbase/GnashImageGif.cpp | 45 +++++++++-------
libbase/GnashImageJpeg.cpp | 127 +++++++++++++++++++------------------------
libbase/GnashImageJpeg.h | 20 +++-----
libbase/GnashImagePng.cpp | 63 +++++++++-------------
libcore/vm/ActionExec.cpp | 28 ++++++----
macros/qt4.m4 | 4 +-
9 files changed, 142 insertions(+), 164 deletions(-)
hooks/post-receive
--
Gnash
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] [SCM] Gnash branch, master, updated. d996bc6ce3dcf03932483bf5bcb15150b031b2ce,
Benjamin Wolsey <=