gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash server/render.cpp server/render.h ChangeL...


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash server/render.cpp server/render.h ChangeL...
Date: Wed, 17 Jan 2007 16:31:30 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     07/01/17 16:31:30

Modified files:
        server         : render.cpp render.h 
        .              : ChangeLog 
        backend        : render_handler.h render_handler_agg.cpp 

Log message:
        Video for AGG, part one:
                * backend/render_handler.h: Add get_scale() method, to retrieve 
the
                renderer's current scaling.
                * backend/render_handler_agg.cpp: Add a better trunc() 
implementation
                from Sandro. Implement drawVideoFrame(); scaling is not yet 
supported.
                Implement get_scale().
                * server/render{.h,.cpp}: initialise s_render_handler to NULL 
so as to
                avoid reading uninitialised memory. Add and implement
                render::get_scale().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/render.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/render.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2127&r2=1.2128
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler.h?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.53&r2=1.54

Patches:
Index: server/render.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/render.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/render.cpp   6 Dec 2006 10:58:34 -0000       1.13
+++ server/render.cpp   17 Jan 2007 16:31:30 -0000      1.14
@@ -18,7 +18,7 @@
 #include <cassert>
 
 namespace gnash {
-       static render_handler* s_render_handler;
+       static render_handler* s_render_handler = NULL;
 
        void set_render_handler(render_handler* r)
        {
@@ -86,6 +86,15 @@
                        if (s_render_handler) 
s_render_handler->delete_bitmap_info(bi);
                }
 
+               void get_scale(point& scale) {
+                       if (s_render_handler) {
+                               s_render_handler->get_scale(scale);
+                       } else {
+                               scale.m_x = 1.0;
+                               scale.m_y = 1.0;
+                       }
+               }
+
                // Returns the format the current renderer wants videoframes in.
                int videoFrameFormat() {
                        if (s_render_handler) return 
s_render_handler->videoFrameFormat();

Index: server/render.h
===================================================================
RCS file: /sources/gnash/gnash/server/render.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/render.h     5 Dec 2006 14:26:09 -0000       1.12
+++ server/render.h     17 Jan 2007 16:31:30 -0000      1.13
@@ -52,6 +52,8 @@
                ///
                bitmap_info*    create_bitmap_info_rgba(image::rgba* im);
 
+               void get_scale(point& scale);
+
                /// Delete the given bitmap info struct.
                void    delete_bitmap_info(bitmap_info* bi);
 

Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2127
retrieving revision 1.2128
diff -u -b -r1.2127 -r1.2128
--- ChangeLog   17 Jan 2007 15:55:53 -0000      1.2127
+++ ChangeLog   17 Jan 2007 16:31:30 -0000      1.2128
@@ -19,6 +19,14 @@
        * plugin/klash/Makefile.am: Stop building the klash binary. The klash
        code is obsolete and hasn't compiled for a while.
        * plugin/klash/klash_part.cpp: Use the gnash binary instead of klash.
+       * backend/render_handler.h: Add get_scale() method, to retrieve the
+       renderer's current scaling.
+       * backend/render_handler_agg.cpp: Add a better trunc() implementation
+       from Sandro. Implement drawVideoFrame(); scaling is not yet supported.
+       Implement get_scale().
+       * server/render{.h,.cpp}: initialise s_render_handler to NULL so as to
+       avoid reading uninitialised memory. Add and implement 
+       render::get_scale().
 
 2007-01-17 Sandro Santilli <address@hidden>
 

Index: backend/render_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- backend/render_handler.h    6 Dec 2006 11:10:05 -0000       1.26
+++ backend/render_handler.h    17 Jan 2007 16:31:30 -0000      1.27
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: render_handler.h,v 1.26 2006/12/06 11:10:05 strk Exp $ */
+/* $Id: render_handler.h,v 1.27 2007/01/17 16:31:30 bjacques Exp $ */
 
 #ifndef RENDER_HANDLER_H
 #define RENDER_HANDLER_H
@@ -454,6 +454,9 @@
     // nop
   }    
     
+  virtual void get_scale(point& /*scale*/) {
+  }
+    
 protected:
 
   // Cached fill style list with just one entry used for font rendering

Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- backend/render_handler_agg.cpp      5 Dec 2006 15:56:40 -0000       1.53
+++ backend/render_handler_agg.cpp      17 Jan 2007 16:31:30 -0000      1.54
@@ -16,7 +16,7 @@
 
  
 
-/* $Id: render_handler_agg.cpp,v 1.53 2006/12/05 15:56:40 strk Exp $ */
+/* $Id: render_handler_agg.cpp,v 1.54 2007/01/17 16:31:30 bjacques Exp $ */
 
 // Original version by Udo Giacomozzi and Hannes Mayr, 
 // INDUNET GmbH (www.indunet.it)
@@ -169,7 +169,7 @@
 #include "render_handler_agg_style.h"
 
 #ifndef trunc
-#define trunc(a) static_cast<long>(a)
+#define trunc(x) ( x < 0 ?  -floor(-x) : floor(x) )
 #endif
 
 using namespace gnash;
@@ -411,10 +411,60 @@
                return RGB;
        }
        
-       /// Draws the video frames
-       void drawVideoFrame(image::image_base* baseframe, const matrix* mat, 
const rect* bounds){
-               image::rgb* frame = static_cast<image::rgb*>(frame);
-               //TODO: implement!
+       /** \brief Draws the video frames
+         * This implementation blits (copies) the RGB buffer provided by the 
caller
+         * directly into the Agg render buffer.
+         *
+         * @param baseframe The RGB video buffer frame.
+         *
+         * @param mat The matrix with world coordinates used to retrieve the x
+         * and y coordinate of the video object.
+         *
+         * @param bounds the width and height fields of this rect are used to
+         * determine the width and height of the RGB image to be drawn. The x 
and y
+         * members of this field are ignored.
+         */
+   void drawVideoFrame(image::image_base* baseframe, const matrix* mat, const 
rect* bounds)
+       {
+         point a;
+         mat->transform(&a, point(bounds->get_x_min(), bounds->get_y_min()));
+
+          int xpos = round( TWIPS_TO_PIXELS(a.m_x) );
+         int ypos = round( TWIPS_TO_PIXELS(a.m_y) );
+
+         // TODO: handle this by only blitting part of the source RGB image.
+         if (xpos < 0) {
+           xpos = 0;
+         }
+         if (ypos < 0) {
+           ypos = 0;
+         }
+       
+         int bytes_per_pixel = 3;              
+         image::rgb* frame = static_cast<image::rgb*>(baseframe);
+
+         // Note that image::rgb* allocates a buffer with extra padding
+         // for performance purposes. Therefore, we need to use the
+         // actual image size so we don't copy padding bytes to the Agg
+         // buffer.
+         int frame_width = TWIPS_TO_PIXELS(bounds->width()) * bytes_per_pixel;
+         unsigned char* rgbbuf_ptr = frame->m_data;
+         unsigned char* rgbbuf_end = rgbbuf_ptr + frame_width *
+                                     frame->m_height;
+       
+         unsigned char* aggbuf_ptr = memaddr;
+         unsigned char* aggbuf_end = memaddr + memsize;  
+       
+         // Skip the first ypos rows.
+         aggbuf_ptr += ypos * m_rbuf.stride();
+         // Move xpos pixels to the right.
+         aggbuf_ptr += xpos * bytes_per_pixel;         
+
+         while(rgbbuf_ptr <= rgbbuf_end && aggbuf_ptr <= aggbuf_end) {
+           memcpy(aggbuf_ptr, rgbbuf_ptr, frame_width);
+           aggbuf_ptr += m_rbuf.stride();
+           rgbbuf_ptr += frame->m_pitch; 
+         }
        }
 
 
@@ -1424,6 +1474,11 @@
     yscale = new_yscale/20.0f;
   }
   
+  virtual void get_scale(point& scale) {
+    scale.m_x = PIXELS_TO_TWIPS(xscale);
+    scale.m_y = PIXELS_TO_TWIPS(yscale);
+  }
+  
 private:  // private methods  
 
   /// Returns the cache manager instance of the given character definition.




reply via email to

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