gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r9593: Let BitmapMovieDefinition tak


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9593: Let BitmapMovieDefinition take RGBA as well as RGB images, which allows
Date: Thu, 14 Aug 2008 12:12:22 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9593
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-08-14 12:12:22 +0200
message:
  Let BitmapMovieDefinition take RGBA as well as RGB images, which allows
  creating transparent bitmap characters from PNG, potentially from GIF
  (not yet implemented) and should make implementing MovieClip.attachBitmap()
  possible.
  
  Restore the clone() method of ImageBase, as I'm not sure it was a good idea
  to drop it.
modified:
  backend/render_handler.h
  backend/render_handler_agg.cpp
  backend/render_handler_cairo.cpp
  backend/render_handler_ogl.cpp
  backend/render_handler_ogl.h
  libbase/GnashImage.h
  libbase/GnashImageGif.cpp
  libbase/GnashImageJpeg.cpp
  libbase/GnashImagePng.cpp
  libbase/GnashImagePng.h
  libbase/image.cpp
  libbase/image.h
  libcore/asobj/NetStream.cpp
  libcore/asobj/NetStream.h
  libcore/bitmap_info.h
  libcore/impl.cpp
  libcore/parser/BitmapMovieDefinition.cpp
  libcore/parser/BitmapMovieDefinition.h
  libcore/render.cpp
  libcore/render.h
  libcore/swf/tag_loaders.cpp
  libcore/video_stream_instance.cpp
  libcore/video_stream_instance.h
  libmedia/MediaBuffer.h
  libmedia/gst/VideoDecoderGst.h
    ------------------------------------------------------------
    revno: 9590.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2008-08-14 11:03:58 +0200
    message:
      Rename image_base to ImageBase.
      
      Pass pointers to ImageBase class around as much as possible to make
      handling different kinds of images (specifically RGB and RGBA) possible.
      
      bitmap_character_def can take either rgb or rgba images.
      
      BitmapMovieDefinition takes an ImageBase and decides which
      bitmap_character_def to create.
      
      The DefineBitsJpeg2 tag loader always casts to RGB, as this is the
      only kind of image it can handle (checked with an assertion).
    modified:
      backend/render_handler.h
      backend/render_handler_agg.cpp
      backend/render_handler_cairo.cpp
      backend/render_handler_ogl.cpp
      backend/render_handler_ogl.h
      libbase/image.cpp
      libbase/image.h
      libcore/asobj/NetStream.cpp
      libcore/asobj/NetStream.h
      libcore/bitmap_info.h
      libcore/impl.cpp
      libcore/parser/BitmapMovieDefinition.cpp
      libcore/parser/BitmapMovieDefinition.h
      libcore/render.cpp
      libcore/render.h
      libcore/swf/tag_loaders.cpp
      libcore/video_stream_instance.cpp
      libcore/video_stream_instance.h
      libmedia/MediaBuffer.h
      libmedia/gst/VideoDecoderGst.h
    ------------------------------------------------------------
    revno: 9590.1.5
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2008-08-14 11:52:07 +0200
    message:
      Add image type information to GnashImageInput - imageType() - to allow
      distinguishing between RGB and RGBA images. The type begins as
      GNASH_IMAGE_INVALID, which also provides an additional way of checking
      whether the read has succeeded (or the read() function has been called).
      
      Only PngImageInput can return RGBA images so far. GifImageInput should be
      able to in the future.
      
      Return RGBA from readImageData when appropriate. This automatically 
creates
      a transparent BitmapMovieDefinition.
      
      Restore clone() method. It seems worth preserving typeinfo.
    modified:
      libbase/GnashImage.h
      libbase/GnashImageGif.cpp
      libbase/GnashImageJpeg.cpp
      libbase/GnashImagePng.cpp
      libbase/GnashImagePng.h
      libbase/image.cpp
      libbase/image.h
      libcore/parser/BitmapMovieDefinition.cpp
    ------------------------------------------------------------
    revno: 9590.1.6
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2008-08-14 12:11:16 +0200
    message:
      Use clone() again.
    modified:
      backend/render_handler_ogl.cpp
=== modified file 'backend/render_handler.h'
--- a/backend/render_handler.h  2008-07-16 10:00:22 +0000
+++ b/backend/render_handler.h  2008-08-14 09:03:58 +0000
@@ -163,7 +163,7 @@
 
     // @@ forward decl to avoid including base/image.h; TODO change the
     // render_handler interface to not depend on these classes at all.
-    namespace image { class image_base; class rgb; class rgba; }
+    namespace image { class ImageBase; class rgb; class rgba; }
 }
 
 namespace gnash {
@@ -268,7 +268,7 @@
   ///   The width and height determine the size of the Flash video instance
   ///   on the stage (in TWIPS) prior to matrix transformations.         
   ///
-  virtual void drawVideoFrame(image::image_base* frame, const matrix* mat, 
const rect* bounds) = 0;
+  virtual void drawVideoFrame(image::ImageBase* frame, const matrix* mat, 
const rect* bounds) = 0;
 
   /// Sets the update region (called prior to begin_display).
   //

=== modified file 'backend/render_handler_agg.cpp'
--- a/backend/render_handler_agg.cpp    2008-07-23 13:35:48 +0000
+++ b/backend/render_handler_agg.cpp    2008-08-14 09:03:58 +0000
@@ -439,7 +439,7 @@
   }
   
 
-  void drawVideoFrame(image::image_base* baseframe, const matrix* source_mat, 
+  void drawVideoFrame(image::ImageBase* baseframe, const matrix* source_mat, 
     const rect* bounds) {
   
     // NOTE: Assuming that the source image is RGB 8:8:8

=== modified file 'backend/render_handler_cairo.cpp'
--- a/backend/render_handler_cairo.cpp  2008-08-14 07:47:51 +0000
+++ b/backend/render_handler_cairo.cpp  2008-08-14 09:03:58 +0000
@@ -454,7 +454,7 @@
     return render_handler::RGB;
   }
   
-  virtual void drawVideoFrame(image::image_base* baseframe, const matrix* m, 
const rect* bounds)
+  virtual void drawVideoFrame(image::ImageBase* baseframe, const matrix* m, 
const rect* bounds)
   {
     // Extract frame attributes
     image::rgb* frame = static_cast<image::rgb*>(baseframe);

=== modified file 'backend/render_handler_ogl.cpp'
--- a/backend/render_handler_ogl.cpp    2008-08-14 07:47:51 +0000
+++ b/backend/render_handler_ogl.cpp    2008-08-14 10:11:16 +0000
@@ -413,10 +413,10 @@
 
 // Use the image class copy constructor; it's not important any more
 // what kind of image it is.
-bitmap_info_ogl::bitmap_info_ogl(image::image_base* image, GLenum pixelformat,
+bitmap_info_ogl::bitmap_info_ogl(image::ImageBase* image, GLenum pixelformat,
                                  bool ogl_accessible)
 :
-  _img(new image::image_base(*image)),
+  _img(image->clone()),
   _pixel_format(pixelformat),
   _ogl_img_type(_img->height() == 1 ? GL_TEXTURE_1D : GL_TEXTURE_2D),
   _ogl_accessible(ogl_accessible),
@@ -674,7 +674,7 @@
   // anti-aliased with the rest of the drawing. Since display lists cannot be
   // concatenated this means we'll add up with several display lists for normal
   // drawing operations.
-  virtual void drawVideoFrame(image::image_base* baseframe, const matrix* m, 
const rect* bounds)
+  virtual void drawVideoFrame(image::ImageBase* baseframe, const matrix* m, 
const rect* bounds)
   {
     GLint index;
 
@@ -705,7 +705,7 @@
     _render_indices.push_back(index);
   }
   
-  virtual void reallyDrawVideoFrame(image::image_base* baseframe, const 
matrix* m, const rect* bounds)
+  virtual void reallyDrawVideoFrame(image::ImageBase* baseframe, const matrix* 
m, const rect* bounds)
   {
     image::rgb* frame = static_cast<image::rgb*>(baseframe);
 

=== modified file 'backend/render_handler_ogl.h'
--- a/backend/render_handler_ogl.h      2008-06-13 23:40:24 +0000
+++ b/backend/render_handler_ogl.h      2008-08-14 09:03:58 +0000
@@ -148,7 +148,7 @@
 class bitmap_info_ogl : public bitmap_info
 {
   public:
-    bitmap_info_ogl(image::image_base* image, GLenum pixelformat,
+    bitmap_info_ogl(image::ImageBase* image, GLenum pixelformat,
                     bool ogl_accessible);
     ~bitmap_info_ogl();
 
@@ -159,7 +159,7 @@
     void setup();    
     void upload(boost::uint8_t* data, size_t width, size_t height);
     
-    std::auto_ptr<image::image_base> _img;
+    std::auto_ptr<image::ImageBase> _img;
     GLenum _pixel_format;
     GLenum _ogl_img_type;
     bool _ogl_accessible;  

=== modified file 'libbase/GnashImage.h'
--- a/libbase/GnashImage.h      2008-08-12 10:58:20 +0000
+++ b/libbase/GnashImage.h      2008-08-14 09:52:07 +0000
@@ -22,6 +22,7 @@
 
 #include <boost/shared_ptr.hpp> 
 #include "log.h"
+#include "image.h"
 
 // Forward declarations
 namespace gnash { class IOChannel; }
@@ -33,7 +34,8 @@
 public:
 
        ImageInput(boost::shared_ptr<IOChannel> in) :
-           _inStream(in)
+           _inStream(in),
+           _type(GNASH_IMAGE_INVALID)
        {}
 
        virtual ~ImageInput() {}
@@ -64,10 +66,14 @@
        virtual size_t getWidth() const = 0;
        virtual void readScanline(unsigned char* rgb_data) = 0;
 
+    ImageType imageType() { return _type; }
+
 protected:
 
     boost::shared_ptr<IOChannel> _inStream;
 
+    ImageType _type;
+
 };
 
 class ImageOutput

=== modified file 'libbase/GnashImageGif.cpp'
--- a/libbase/GnashImageGif.cpp 2008-08-06 16:24:10 +0000
+++ b/libbase/GnashImageGif.cpp 2008-08-14 09:52:07 +0000
@@ -207,6 +207,10 @@
         }
     } while (record != TERMINATE_RECORD_TYPE);
 
+    // Set the type to RGB
+    // TODO: implement RGBA!
+    _type = GNASH_IMAGE_RGB;
+
 }
 
 } // namespace gnash

=== modified file 'libbase/GnashImageJpeg.cpp'
--- a/libbase/GnashImageJpeg.cpp        2008-08-11 19:05:37 +0000
+++ b/libbase/GnashImageJpeg.cpp        2008-08-14 09:52:07 +0000
@@ -368,6 +368,11 @@
        }
 
        _compressorOpened = true;
+       
+       // Until this point the type should be GNASH_IMAGE_INVALID.
+       // It's possible to create transparent JPEG data by merging an
+       // alpha channel, but that is handled explicitly elsewhere.
+       _type = GNASH_IMAGE_RGB;
 }
 
 

=== modified file 'libbase/GnashImagePng.cpp'
--- a/libbase/GnashImagePng.cpp 2008-08-13 11:52:44 +0000
+++ b/libbase/GnashImagePng.cpp 2008-08-14 09:52:07 +0000
@@ -97,14 +97,20 @@
     return png_get_image_width(_pngPtr, _infoPtr);
 }
 
+size_t
+PngImageInput::getComponents() const
+{
+    return png_get_channels(_pngPtr, _infoPtr);
+}
+
 void
-PngImageInput::readScanline(unsigned char* rgbData)
+PngImageInput::readScanline(unsigned char* imageData)
 {
     assert (_currentRow < getHeight());
     assert (_rowPtrs);
 
-    // Data packed as RGB
-    std::memcpy(rgbData, _rowPtrs[_currentRow], getWidth() * 3);
+    // Data packed as RGB / RGBA
+    std::memcpy(imageData, _rowPtrs[_currentRow], getWidth() * 
getComponents());
     
     ++_currentRow;
 }
@@ -142,7 +148,7 @@
     // Convert indexed images to RGB
     if (type == PNG_COLOR_TYPE_PALETTE)
     {
-        log_debug("Palette->RGB");
+        log_debug("Convertin palette PNG to RGB(A)");
         png_set_palette_to_rgb(_pngPtr);
     }
     
@@ -156,13 +162,22 @@
     // Make 16-bit data into 8-bit data
     if (bitDepth == 16) png_set_strip_16(_pngPtr);
 
-    // Remove alpha channel because Gnash can't deal with it yet.
-    if (type & PNG_COLOR_MASK_ALPHA) png_set_strip_alpha(_pngPtr);
+    // Set the type of the image.
+    if (type & PNG_COLOR_MASK_ALPHA)
+    {
+        log_debug("Loading PNG image with alpha");
+        _type = GNASH_IMAGE_RGBA;
+    }
+    else
+    {
+        log_debug("Loading PNG image without alpha");
+        _type = GNASH_IMAGE_RGB;
+    }
 
     // Convert 1-channel grey images to 3-channel RGB.
     if (type == PNG_COLOR_TYPE_GRAY || type == PNG_COLOR_TYPE_GRAY_ALPHA)
     {
-        log_debug("Grey->RGB");
+        log_debug("Converting greyscale PNG to RGB(A)");
         png_set_gray_to_rgb(_pngPtr);
     }
 
@@ -171,12 +186,13 @@
     const size_t height = getHeight();
     const size_t width = getWidth();
 
-    const size_t components = 3;
-
-    // We must have 3-channel data by this point.
-    assert (png_get_channels(_pngPtr, _infoPtr) == components);
-
-    // Allocate space for the data (3 bytes per pixel)
+    const size_t components = getComponents();
+
+    // We must have 3 or 4-channel data by this point.
+    assert (_type == GNASH_IMAGE_RGB && components == 3 ||
+            _type == GNASH_IMAGE_RGBA && components == 4);
+
+    // Allocate space for the data
     _pixelData.reset(new png_byte[width * height * components]);
 
     // Allocate an array of pointers to the beginning of

=== modified file 'libbase/GnashImagePng.h'
--- a/libbase/GnashImagePng.h   2008-08-13 11:52:44 +0000
+++ b/libbase/GnashImagePng.h   2008-08-14 09:52:07 +0000
@@ -51,6 +51,10 @@
 
     void init();
 
+       // Return number of components (i.e. == 3 for RGB
+       // data).
+    size_t getComponents() const;
+
 public:
 
        /// Constructor.  
@@ -70,17 +74,11 @@
        // Return the width of the image.
        size_t getWidth() const;
 
-       // Return number of components (i.e. == 3 for RGB
-       // data).  The size of the data for a scanline is
-       // get_width() * get_components().
-       //
-       size_t getComponents() const;
-
        // Read a scanline's worth of image data into the
        // given buffer.  The amount of data read is
-       // get_width() * get_components().
+       // getWidth() * getComponents().
        //
-       void readScanline(unsigned char* rgb_data);
+       void readScanline(unsigned char* imageData);
 
 
     DSOEXPORT static std::auto_ptr<ImageInput> 
create(boost::shared_ptr<IOChannel> in)

=== modified file 'libbase/image.cpp'
--- a/libbase/image.cpp 2008-08-14 07:47:51 +0000
+++ b/libbase/image.cpp 2008-08-14 09:52:07 +0000
@@ -38,11 +38,11 @@
 namespace image
 {
        //
-       // image_base
+       // ImageBase
        //
 
        /// Create an image taking ownership of the given buffer, supposedly of 
height*pitch bytes
-       image_base::image_base(boost::uint8_t* data, int width, int height, int 
pitch, ImageType type)
+       ImageBase::ImageBase(boost::uint8_t* data, int width, int height, int 
pitch, ImageType type)
                :
                _type(type),
                m_size(height*pitch),
@@ -54,7 +54,7 @@
        }
 
        /// Create an image allocating a buffer of height*pitch bytes
-       image_base::image_base(int width, int height, int pitch, ImageType type)
+       ImageBase::ImageBase(int width, int height, int pitch, ImageType type)
                :
                _type(type),
                m_size(height*pitch),
@@ -66,31 +66,31 @@
                assert(pitch >= width);
        }
 
-       void image_base::update(boost::uint8_t* data)
+       void ImageBase::update(boost::uint8_t* data)
        {
                std::memcpy(m_data.get(), data, m_size);
        }
 
-       void image_base::update(const image_base& from)
+       void ImageBase::update(const ImageBase& from)
        {
                assert(from.m_pitch == m_pitch);
                assert(m_size <= from.m_size);
                assert(_type == from._type);
-               std::memcpy(m_data.get(), const_cast<image_base&>(from).data(), 
m_size);
+               std::memcpy(m_data.get(), const_cast<ImageBase&>(from).data(), 
m_size);
        }
 
-    void image_base::clear(const boost::uint8_t byteValue)
+    void ImageBase::clear(const boost::uint8_t byteValue)
     {
         std::memset(m_data.get(), byteValue, m_size);
     }
 
-       boost::uint8_t* image_base::scanline(size_t y)
+       boost::uint8_t* ImageBase::scanline(size_t y)
        {
                assert(y < m_height);
                return m_data.get() + m_pitch * y;
        }
 
-       boost::uint8_t* const image_base::scanlinePointer(size_t y) const
+       boost::uint8_t* const ImageBase::scanlinePointer(size_t y) const
        {
                assert(y < m_height);
                return m_data.get() + m_pitch * y;
@@ -103,7 +103,7 @@
 
        rgb::rgb(int width, int height)
                :
-               image_base( width, height,
+               ImageBase( width, height,
                        (width * 3 + 3) & ~3, // round pitch up to nearest 
4-byte boundary
                        GNASH_IMAGE_RGB)
        {
@@ -125,7 +125,7 @@
 
        rgba::rgba(int width, int height)
                :
-               image_base(width, height, width * 4, GNASH_IMAGE_RGBA)
+               ImageBase(width, height, width * 4, GNASH_IMAGE_RGBA)
        {
                assert(width > 0);
                assert(height > 0);
@@ -169,7 +169,7 @@
 
        alpha::alpha(int width, int height)
                :
-               image_base(width, height, width, GNASH_IMAGE_ALPHA)
+               ImageBase(width, height, width, GNASH_IMAGE_ALPHA)
        {
                assert(width > 0);
                assert(height > 0);
@@ -185,7 +185,7 @@
        //
 
        // Write the given image to the given out stream, in jpeg format.
-       void writeImageData(FileType type, boost::shared_ptr<IOChannel> out, 
image::image_base* image, int quality)
+       void writeImageData(FileType type, boost::shared_ptr<IOChannel> out, 
image::ImageBase* image, int quality)
        {
                
                const size_t width = image->width();
@@ -221,9 +221,9 @@
        }
 
     // See gnash.h for file types.
-    std::auto_ptr<rgb> readImageData(boost::shared_ptr<IOChannel> in, FileType 
type)
+    std::auto_ptr<ImageBase> readImageData(boost::shared_ptr<IOChannel> in, 
FileType type)
     {
-        std::auto_ptr<rgb> im (NULL);
+        std::auto_ptr<ImageBase> im (NULL);
         std::auto_ptr<ImageInput> inChannel;
 
         switch (type)
@@ -246,7 +246,19 @@
         const size_t height = inChannel->getHeight();
         const size_t width = inChannel->getWidth();
         
-        im.reset(new image::rgb(width, height));
+        switch (inChannel->imageType())
+        {
+            case GNASH_IMAGE_RGB:
+                im.reset(new image::rgb(width, height));
+                break;
+            case GNASH_IMAGE_RGBA:
+                im.reset(new image::rgba(width, height));
+                break;
+            default:
+                log_error("Invalid image returned");
+                im.reset(NULL);
+                return im;
+        }
         
         for (size_t i = 0; i < height; ++i)
         {

=== modified file 'libbase/image.h'
--- a/libbase/image.h   2008-08-14 07:47:51 +0000
+++ b/libbase/image.h   2008-08-14 09:52:07 +0000
@@ -1,3 +1,4 @@
+
 // Image.h: image data class for Gnash.
 // 
 //   Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
@@ -39,8 +40,6 @@
 /// Handy image utilities for RGB surfaces.
 namespace gnash
 {
-namespace image
-{
 
 enum ImageType
 {
@@ -50,12 +49,17 @@
        GNASH_IMAGE_ALPHA
 };
 
+namespace image
+{
+
+
+
        /// Base class for different types of images
-       class DSOEXPORT image_base
+       class DSOEXPORT ImageBase
        {
        public:
 
-               image_base(const image_base& o)
+               ImageBase(const ImageBase& o)
                        :
                        _type(o._type),
                        m_size(o.size()),
@@ -67,10 +71,10 @@
                        update(o);
                }
                        
-               image_base(boost::uint8_t *data, int width, int height, int 
pitch, ImageType type);
+               ImageBase(boost::uint8_t *data, int width, int height, int 
pitch, ImageType type);
 
-               /// Construct an image_base allocating data for height*pitch 
bytes
-               image_base(int width, int height, int pitch, ImageType type);
+               /// Construct an ImageBase allocating data for height*pitch 
bytes
+               ImageBase(int width, int height, int pitch, ImageType type);
 
         ImageType type() const { return _type; }
 
@@ -95,7 +99,7 @@
                /// Copy image data from a buffer.
                //
                /// Note that this buffer MUST have the same m_pitch, or 
unexpected things
-               /// will happen. In general, it is only safe to copy from 
another image_base
+               /// will happen. In general, it is only safe to copy from 
another ImageBase
                /// (or derivative thereof) or unexpected things will happen. 
                ///
                /// @param data buffer to copy data from.
@@ -109,20 +113,21 @@
                ///
                /// @param from image to copy data from.
                ///
-               void update(const image_base& from);
+               void update(const ImageBase& from);
                
                void clear(const boost::uint8_t byteValue = 0);
 
                /// Return a pointer to the underlying data
-               virtual boost::uint8_t* data() { return m_data.get(); }
+               boost::uint8_t* data() { return m_data.get(); }
 
                /// Return a pointer to first byte of given line
                DSOEXPORT boost::uint8_t* scanline(size_t y);
 
         DSOEXPORT boost::uint8_t* const scanlinePointer(size_t y) const;
 
-               virtual ~image_base() {}
+               virtual ~ImageBase() {}
 
+        virtual std::auto_ptr<ImageBase> clone() = 0;
 
        protected:
 
@@ -148,12 +153,10 @@
                /// Data bytes, geometry defined by members below
                boost::scoped_array<boost::uint8_t> m_data;
 
-       private:
-
        };
 
        /// 24-bit RGB image.  Packed data, red byte first (RGBRGB...)
-       class DSOEXPORT rgb : public image_base
+       class DSOEXPORT rgb : public ImageBase
        {
 
        public:
@@ -162,19 +165,24 @@
 
                rgb(const rgb& o)
                        :
-                       image_base(o)
+                       ImageBase(o)
                {}
 
                rgb(boost::uint8_t* data, int width, int height, int stride)
-                       : image_base(data, width, height, stride, 
GNASH_IMAGE_RGB)
+                       : ImageBase(data, width, height, stride, 
GNASH_IMAGE_RGB)
                {}
 
                ~rgb();
 
+        virtual std::auto_ptr<ImageBase> clone()
+        {
+            return std::auto_ptr<ImageBase>(new rgb(*this));
+        };
+
        };
 
        /// 32-bit RGBA image.  Packed data, red byte first (RGBARGBA...)
-       class DSOEXPORT rgba : public image_base
+       class DSOEXPORT rgba : public ImageBase
        {
 
        public:
@@ -183,7 +191,7 @@
 
                rgba(const rgba& o)
                        :
-                       image_base(o)
+                       ImageBase(o)
                {}
 
                ~rgba();
@@ -196,17 +204,22 @@
 
         void mergeAlpha(const boost::uint8_t* alphaData, const size_t 
bufferLength);
 
+        virtual std::auto_ptr<ImageBase> clone()
+        {
+            return std::auto_ptr<ImageBase>(new rgba(*this));
+        };
+
        };
 
        /// 8-bit alpha image.
-       class DSOEXPORT alpha : public image_base
+       class DSOEXPORT alpha : public ImageBase
        {
        public:
                alpha(int width, int height);
 
                alpha(const alpha& o)
                        :
-                       image_base(o)
+                       ImageBase(o)
                {}
 
                ~alpha();
@@ -217,6 +230,11 @@
                ///
                void    set_pixel(size_t x, size_t y, boost::uint8_t a);
 
+        virtual std::auto_ptr<ImageBase> clone()
+        {
+            return std::auto_ptr<ImageBase>(new alpha(*this));
+        };
+
        };
 
        /// Write the given image to the given out channel in a specified 
format.
@@ -226,7 +244,7 @@
        /// @param image    The image to write.
        /// @param quality  The quality of the image output (not used for all 
formats)
        DSOEXPORT void writeImageData(FileType type, 
boost::shared_ptr<gnash::IOChannel> out,
-                                     image_base* image, int quality);
+                                     ImageBase* image, int quality);
 
        /// \brief
        /// For reading SWF JPEG2-style image data, using pre-loaded
@@ -238,7 +256,7 @@
        /// but stores the data in rgba format.
        DSOEXPORT std::auto_ptr<rgba> 
readSWFJpeg3(boost::shared_ptr<gnash::IOChannel> in);
        
-       DSOEXPORT std::auto_ptr<rgb> 
readImageData(boost::shared_ptr<gnash::IOChannel> in, FileType type);
+       DSOEXPORT std::auto_ptr<ImageBase> 
readImageData(boost::shared_ptr<gnash::IOChannel> in, FileType type);
 
 } // namespace image
 } // namespace gnash

=== modified file 'libcore/asobj/NetStream.cpp'
--- a/libcore/asobj/NetStream.cpp       2008-08-13 07:32:20 +0000
+++ b/libcore/asobj/NetStream.cpp       2008-08-14 09:03:58 +0000
@@ -552,12 +552,12 @@
        }
 }
 
-std::auto_ptr<image::image_base>
+std::auto_ptr<image::ImageBase>
 NetStream::get_video()
 {
        boost::mutex::scoped_lock lock(image_mutex);
 
-       if (!m_imageframe.get()) return std::auto_ptr<image::image_base>(0);
+       if (!m_imageframe.get()) return std::auto_ptr<image::ImageBase>(0);
 
        // TODO: inspect if we could return m_imageframe directly...
        return m_imageframe;    

=== modified file 'libcore/asobj/NetStream.h'
--- a/libcore/asobj/NetStream.h 2008-08-13 07:32:20 +0000
+++ b/libcore/asobj/NetStream.h 2008-08-14 09:03:58 +0000
@@ -276,7 +276,7 @@
        boost::mutex image_mutex;
 
        // The image/videoframe which is given to the renderer
-       std::auto_ptr<image::image_base> m_imageframe;
+       std::auto_ptr<image::ImageBase> m_imageframe;
 
        // The video URL
        std::string url;
@@ -420,7 +420,7 @@
        //
        /// @return a image containing the video frame, a NULL auto_ptr if none 
were ready
        ///
-       std::auto_ptr<image::image_base> get_video();
+       std::auto_ptr<image::ImageBase> get_video();
        
        /// Register the character to invalidate on video updates
        void setInvalidatedVideo(character* ch)

=== modified file 'libcore/bitmap_info.h'
--- a/libcore/bitmap_info.h     2008-03-27 10:50:12 +0000
+++ b/libcore/bitmap_info.h     2008-08-14 09:03:58 +0000
@@ -24,7 +24,7 @@
 
 // Forward declarations
 namespace image {
-       class image_base;
+       class ImageBase;
 }
 
 
@@ -37,8 +37,8 @@
 class DSOEXPORT bitmap_info : public ref_counted
 {
 public:
-//     virtual void layout_image(image::image_base* /*im*/) { };
-//     image::image_base*  m_suspended_image;
+//     virtual void layout_image(image::ImageBase* /*im*/) { };
+//     image::ImageBase*  m_suspended_image;
 
        unsigned int    m_texture_id;           // nuke?
        int             m_original_width;       // nuke?

=== modified file 'libcore/impl.cpp'
--- a/libcore/impl.cpp  2008-08-08 13:46:37 +0000
+++ b/libcore/impl.cpp  2008-08-14 09:03:58 +0000
@@ -258,7 +258,7 @@
 
     try
     {
-        std::auto_ptr<image::rgb> im(image::readImageData(imageData, type));
+        std::auto_ptr<image::ImageBase> im(image::readImageData(imageData, 
type));
         if (!im.get())
         {
             log_error(_("Can't read image file from %s"), url);

=== modified file 'libcore/parser/BitmapMovieDefinition.cpp'
--- a/libcore/parser/BitmapMovieDefinition.cpp  2008-07-09 07:33:34 +0000
+++ b/libcore/parser/BitmapMovieDefinition.cpp  2008-08-14 09:52:07 +0000
@@ -23,7 +23,8 @@
 #include "fill_style.h"
 #include "shape.h" // for class path and class edge
 #include "render.h" // for ::display
-
+#include "image.h"
+#include "log.h"
 
 namespace gnash {
 
@@ -33,7 +34,28 @@
 {
        if ( _shapedef ) return _shapedef.get();
 
-       _bitmap = new bitmap_character_def(_image);
+    // Checking the type allows a neat switch statement.
+    switch (_image->type())
+    {
+        case GNASH_IMAGE_RGB:
+        {
+            std::auto_ptr<image::rgb> 
imageRGB(dynamic_cast<image::rgb*>(_image.release()));
+            assert(imageRGB.get());
+            _bitmap = new bitmap_character_def(imageRGB);
+            break;
+        }
+        case GNASH_IMAGE_RGBA:
+        {
+            std::auto_ptr<image::rgba> 
imageRGBA(dynamic_cast<image::rgba*>(_image.release()));
+            assert(imageRGBA.get());
+            _bitmap = new bitmap_character_def(imageRGBA);
+            break;        
+        }
+        default:
+            log_error ("Attempt to create a bitmap character "
+                       "from unsupported image type");
+            return NULL;
+    }
 
        // Create the shape definition
        _shapedef = new DynamicShape();
@@ -74,7 +96,7 @@
 }
 
 BitmapMovieDefinition::BitmapMovieDefinition(
-               std::auto_ptr<image::rgb> image,
+               std::auto_ptr<image::ImageBase> image,
                const std::string& url)
        :
        _version(6),

=== modified file 'libcore/parser/BitmapMovieDefinition.h'
--- a/libcore/parser/BitmapMovieDefinition.h    2008-05-20 10:40:39 +0000
+++ b/libcore/parser/BitmapMovieDefinition.h    2008-08-14 09:03:58 +0000
@@ -24,6 +24,7 @@
 #include "BitmapMovieInstance.h" // for create_movie_instance
 #include "bitmap_character_def.h" // for destructor visibility by intrusive_ptr
 #include "DynamicShape.h" // for destructor visibility by intrusive_ptr
+#include "image.h"
 
 #include <string>
 #include <memory> // for auto_ptr
@@ -48,7 +49,7 @@
        float _framerate;
        std::string _url;
 
-       std::auto_ptr<image::rgb> _image;
+       std::auto_ptr<image::ImageBase> _image;
 
        boost::intrusive_ptr<bitmap_character_def> _bitmap;
 
@@ -88,7 +89,7 @@
        ///  - image->size() bytes (for get_bytes_loaded()/get_bytes_total())
        ///  - provided url
        ///
-       BitmapMovieDefinition(std::auto_ptr<image::rgb> image, const 
std::string& url);
+       BitmapMovieDefinition(std::auto_ptr<image::ImageBase> image, const 
std::string& url);
 
        // Discard id, always return the only shape character we have 
        virtual character_def* get_character_def(int /*id*/)

=== modified file 'libcore/render.cpp'
--- a/libcore/render.cpp        2008-06-30 09:16:45 +0000
+++ b/libcore/render.cpp        2008-08-14 09:03:58 +0000
@@ -84,7 +84,7 @@
                }
                
                // Draws the video frames
-               void drawVideoFrame(image::image_base* frame, const matrix* 
mat, const rect* bounds){
+               void drawVideoFrame(image::ImageBase* frame, const matrix* mat, 
const rect* bounds){
                        if (s_render_handler) return 
s_render_handler->drawVideoFrame(frame, mat, bounds);
                }
 

=== modified file 'libcore/render.h'
--- a/libcore/render.h  2008-06-30 09:16:45 +0000
+++ b/libcore/render.h  2008-08-14 09:03:58 +0000
@@ -62,7 +62,7 @@
                int videoFrameFormat();
 
                /// See render_handler::drawVideoFrame (in 
backend/render_handler.h)
-               void drawVideoFrame(image::image_base* frame, const matrix* 
mat, const rect* bounds);
+               void drawVideoFrame(image::ImageBase* frame, const matrix* mat, 
const rect* bounds);
 
                /// See render_handler::begin_display (in 
backend/render_handler.h)
                void    begin_display(

=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp       2008-08-13 21:30:32 +0000
+++ b/libcore/swf/tag_loaders.cpp       2008-08-14 09:03:58 +0000
@@ -338,8 +338,6 @@
     // Read the image data.
     //
 
-    boost::shared_ptr<tu_file> ad( StreamAdapter::getFile(in, 
in.get_tag_end_position()).release() );
-    std::auto_ptr<image::rgb> im (image::readImageData(ad, 
GNASH_FILETYPE_JPEG));
 
     if ( m->get_bitmap_character_def(character_id) )
     {
@@ -349,7 +347,15 @@
     }
     else
     {
-        boost::intrusive_ptr<bitmap_character_def> ch = new 
bitmap_character_def(im);
+        boost::shared_ptr<tu_file> ad( StreamAdapter::getFile(in, 
in.get_tag_end_position()).release() );
+
+        std::auto_ptr<image::ImageBase> im (image::readImageData(ad, 
GNASH_FILETYPE_JPEG));
+
+        // It must be an RGB image, as normal JPEG images don't support RGBA.
+        std::auto_ptr<image::rgb> 
imageRGB(dynamic_cast<image::rgb*>(im.release()));
+        assert(imageRGB.get());            
+
+        boost::intrusive_ptr<bitmap_character_def> ch = new 
bitmap_character_def(imageRGB);
         m->add_bitmap_character_def(character_id, ch.get());
     }
 }

=== modified file 'libcore/video_stream_instance.cpp'
--- a/libcore/video_stream_instance.cpp 2008-07-11 15:24:24 +0000
+++ b/libcore/video_stream_instance.cpp 2008-08-14 09:03:58 +0000
@@ -223,7 +223,7 @@
        matrix m = get_world_matrix();
        const rect& bounds = m_def->get_bound();
 
-       image::image_base* img = getVideoFrame();
+       image::ImageBase* img = getVideoFrame();
        if (img)
        {
                gnash::render::drawVideoFrame(img, &m, &bounds);
@@ -232,7 +232,7 @@
        clear_invalidated();
 }
 
-image::image_base*
+image::ImageBase*
 video_stream_instance::getVideoFrame()
 {
 
@@ -240,7 +240,7 @@
        // If this is a video from a NetStream object, retrieve a video frame 
from there.
        if (_ns)
        {
-               std::auto_ptr<image::image_base> tmp = _ns->get_video();
+               std::auto_ptr<image::ImageBase> tmp = _ns->get_video();
                if ( tmp.get() ) _lastDecodedVideoFrame = tmp;
        }
 

=== modified file 'libcore/video_stream_instance.h'
--- a/libcore/video_stream_instance.h   2008-07-11 14:07:27 +0000
+++ b/libcore/video_stream_instance.h   2008-08-14 09:03:58 +0000
@@ -97,7 +97,7 @@
        void initializeDecoder();
 
        /// Get video frame to be displayed
-       image::image_base* getVideoFrame();
+       image::ImageBase* getVideoFrame();
 
        // m_video_source - A Camera object that is capturing video data or a 
NetStream object.
        // To drop the connection to the Video object, pass null for source.
@@ -114,7 +114,7 @@
        boost::int32_t _lastDecodedVideoFrameNum;
 
        /// Last decoded frame 
-       std::auto_ptr<image::image_base> _lastDecodedVideoFrame;
+       std::auto_ptr<image::ImageBase> _lastDecodedVideoFrame;
 
        /// The decoder used to decode the video frames
        std::auto_ptr<media::VideoDecoder> _decoder;

=== modified file 'libmedia/MediaBuffer.h'
--- a/libmedia/MediaBuffer.h    2008-03-05 03:55:48 +0000
+++ b/libmedia/MediaBuffer.h    2008-08-14 09:03:58 +0000
@@ -80,7 +80,7 @@
        }
 
        /// Pointer to the data. The data is owned by this class.
-       std::auto_ptr<image::image_base> image;
+       std::auto_ptr<image::ImageBase> image;
 
        /// Timestamp in millisec
        boost::uint32_t timestamp;

=== modified file 'libmedia/gst/VideoDecoderGst.h'
--- a/libmedia/gst/VideoDecoderGst.h    2008-06-03 11:39:51 +0000
+++ b/libmedia/gst/VideoDecoderGst.h    2008-08-14 09:03:58 +0000
@@ -56,9 +56,9 @@
     return GST_BUFFER_DATA(_buffer);
   }
 
-  std::auto_ptr<image::image_base> clone() const
+  std::auto_ptr<image::ImageBase> clone() const
   {
-    return std::auto_ptr<image_base>(new rgb(*this));
+    return std::auto_ptr<ImageBase>(new rgb(*this));
   }
 
 private:


reply via email to

[Prev in Thread] Current Thread [Next in Thread]