gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9592: Fix cairo and ogl builds (oop


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9592: Fix cairo and ogl builds (oops).
Date: Thu, 14 Aug 2008 09:56:13 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9592
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-08-14 09:56:13 +0200
message:
  Fix cairo and ogl builds (oops).
modified:
  backend/render_handler_cairo.cpp
  backend/render_handler_ogl.cpp
  libbase/image.cpp
  libbase/image.h
  libcore/swf/tag_loaders.cpp
    ------------------------------------------------------------
    revno: 9590.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2008-08-13 17:01:08 +0200
    message:
      Add FSF copyright to image.{h,cpp}, as they aren't much like the original 
any
      more.
    modified:
      libbase/image.cpp
      libbase/image.h
    ------------------------------------------------------------
    revno: 9590.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2008-08-13 23:30:32 +0200
    message:
      Take JpegImageInput by ref. Check only once that the pointer is valid; if 
      the first check fails, there's no point in a second one.
    modified:
      libbase/image.cpp
      libbase/image.h
      libcore/swf/tag_loaders.cpp
    ------------------------------------------------------------
    revno: 9590.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2008-08-14 09:47:51 +0200
    message:
      Fix builds for ogl and cairo.
      
      The ogl render handler is the only place where cloning an image is
      necessary, and it doesn't care what type of image it is, so it
      can use image_base copy constructor rather than providing a general
      virtual image_base::clone() method. (Cloning should be discouraged...)
      
      Provide a proper const (read-only) scanlinePointer method for cairo,
      which means slightly more code but no const_casting.
      
      This is all aimed at making a more useful and less hackish image class,
      as well as reducing memcopying and direct access to image class data.
    modified:
      backend/render_handler_cairo.cpp
      backend/render_handler_ogl.cpp
      libbase/image.cpp
      libbase/image.h
=== modified file 'backend/render_handler_cairo.cpp'
--- a/backend/render_handler_cairo.cpp  2008-07-20 06:24:37 +0000
+++ b/backend/render_handler_cairo.cpp  2008-08-14 07:47:51 +0000
@@ -55,7 +55,7 @@
   boost::uint32_t* dst32 = reinterpret_cast<boost::uint32_t*>(dst);
   for (size_t y = 0;  y < im->height();  y++)
   {
-         const boost::uint8_t* src = im->scanline(y);
+         const boost::uint8_t* src = im->scanlinePointer(y);
          for (size_t x = 0;  x < im->width();  x++, src += 3)
          {
              *dst32++ = (src[0] << 16) | (src[1] << 8) | src[2];
@@ -70,7 +70,7 @@
   boost::uint32_t* dst32 = reinterpret_cast<boost::uint32_t*>(dst);
   for (size_t y = 0;  y < im->height();  y++)
   {
-    const boost::uint8_t* src = im->scanline(y);
+    const boost::uint8_t* src = im->scanlinePointer(y);
     for (size_t x = 0;  x < im->width();  x++, src += 4)
     {
       const boost::uint8_t& r = src[0],

=== modified file 'backend/render_handler_ogl.cpp'
--- a/backend/render_handler_ogl.cpp    2008-08-07 10:02:35 +0000
+++ b/backend/render_handler_ogl.cpp    2008-08-14 07:47:51 +0000
@@ -411,11 +411,12 @@
   return n % 2 == 0;
 }
 
-
+// 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,
                                  bool ogl_accessible)
 :
-  _img(image->clone()),
+  _img(new image::image_base(*image)),
   _pixel_format(pixelformat),
   _ogl_img_type(_img->height() == 1 ? GL_TEXTURE_1D : GL_TEXTURE_2D),
   _ogl_accessible(ogl_accessible),

=== modified file 'libbase/image.cpp'
--- a/libbase/image.cpp 2008-08-13 09:48:52 +0000
+++ b/libbase/image.cpp 2008-08-14 07:47:51 +0000
@@ -1,9 +1,23 @@
-// image.cpp   -- Thatcher Ulrich <address@hidden> 2002
-
-// This source code has been donated to the Public Domain.  Do
-// whatever you want with it.
-
-// Handy image utilities for RGB surfaces.
+// Image.cpp: image data class for Gnash.
+// 
+//   Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+// Based on the public domain work of Thatcher Ulrich <address@hidden> 2002
 
 #include <cstring>
 #include <memory>              // for auto_ptr
@@ -76,6 +90,12 @@
                return m_data.get() + m_pitch * y;
        }
 
+       boost::uint8_t* const image_base::scanlinePointer(size_t y) const
+       {
+               assert(y < m_height);
+               return m_data.get() + m_pitch * y;
+       }
+
 
        //
        // rgb
@@ -235,22 +255,22 @@
         return im;
     }
 
-       std::auto_ptr<rgb> readSWFJpeg2WithTables(JpegImageInput* j_in)
+       std::auto_ptr<rgb> readSWFJpeg2WithTables(JpegImageInput& loader)
        // Create and read a new image, using a input object that
        // already has tables loaded.  The IJG documentation describes
        // this as "abbreviated" format.
        {
-               assert(j_in);
-
-               j_in->startImage();
-
-               std::auto_ptr<rgb> im(new image::rgb(j_in->getWidth(), 
j_in->getHeight()));
-
-               for (size_t y = 0; y < j_in->getHeight(); y++) {
-                       j_in->readScanline(im->scanline(y));
+
+               loader.startImage();
+
+               std::auto_ptr<rgb> im(new image::rgb(loader.getWidth(), 
loader.getHeight()));
+
+
+               for (size_t y = 0, height = loader.getHeight(); y < height; 
y++) {
+                       loader.readScanline(im->scanline(y));
                }
 
-               j_in->finishImage();
+               loader.finishImage();
 
                return im;
        }

=== modified file 'libbase/image.h'
--- a/libbase/image.h   2008-08-13 09:48:52 +0000
+++ b/libbase/image.h   2008-08-14 07:47:51 +0000
@@ -1,9 +1,23 @@
-// image.h     -- Thatcher Ulrich <address@hidden> 2002
-
-// This source code has been donated to the Public Domain.  Do
-// whatever you want with it.
-
-// Handy image utilities for RGB surfaces.
+// Image.h: image data class for Gnash.
+// 
+//   Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+// Based on the public domain work of Thatcher Ulrich <address@hidden> 2002
 
 #ifndef GNASH_IMAGE_H
 #define GNASH_IMAGE_H
@@ -105,6 +119,8 @@
                /// 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() {}
 
 
@@ -215,7 +231,7 @@
        /// \brief
        /// For reading SWF JPEG2-style image data, using pre-loaded
        /// headers stored in the given jpeg::input object.
-       DSOEXPORT std::auto_ptr<rgb> readSWFJpeg2WithTables(JpegImageInput* 
loader);
+       DSOEXPORT std::auto_ptr<rgb> readSWFJpeg2WithTables(JpegImageInput& 
loader);
 
        /// \brief
        /// For reading SWF JPEG3-style image data, like ordinary JPEG, 

=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp       2008-08-12 08:28:22 +0000
+++ b/libcore/swf/tag_loaders.cpp       2008-08-13 21:30:32 +0000
@@ -289,13 +289,12 @@
         return;
     }
 
-    assert(j_in);
     j_in->discardPartialBuffer();
     
     std::auto_ptr<image::rgb> im;
     try
     {
-        im = image::readSWFJpeg2WithTables(j_in);
+        im = image::readSWFJpeg2WithTables(*j_in);
     }
     catch (std::exception& e)
     {


reply via email to

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