gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog gui/fb.cpp gui/fbsup.h gui/gui....


From: Udo Giacomozzi
Subject: [Gnash-commit] gnash ChangeLog gui/fb.cpp gui/fbsup.h gui/gui....
Date: Thu, 12 Oct 2006 16:37:26 +0000

CVSROOT:        /cvsroot/gnash
Module name:    gnash
Changes by:     Udo Giacomozzi <udog>   06/10/12 16:37:25

Modified files:
        .              : ChangeLog 
        gui            : fb.cpp fbsup.h gui.cpp gui.h 
        server         : button_character_instance.cpp 
                         button_character_instance.h character.cpp 
                         character.h dlist.cpp dlist.h 
                         edit_text_character.cpp edit_text_character.h 
                         generic_character.h gnash.h movie_interface.h 
                         movie_root.cpp movie_root.h sprite_instance.cpp 
                         sprite_instance.h types.cpp 
        server/parser  : button_character_def.h character_def.h 
                         edit_text_character_def.h movie_def_impl.h 
                         sprite_definition.h text_character_def.h 

Log message:
        Added two new methods to the rect class and implemented a method to 
detect updated regions of the stage

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1170&r2=1.1171
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/fb.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/fbsup.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.cpp?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/generic_character.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_interface.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/types.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/button_character_def.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/character_def.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/edit_text_character_def.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/sprite_definition.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/text_character_def.h?cvsroot=gnash&r1=1.3&r2=1.4

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.1170
retrieving revision 1.1171
diff -u -b -r1.1170 -r1.1171
--- ChangeLog   12 Oct 2006 16:03:12 -0000      1.1170
+++ ChangeLog   12 Oct 2006 16:37:25 -0000      1.1171
@@ -1,3 +1,24 @@
+2006-10-12 Udo Giacomozzi <address@hidden>
+  
+  * gnash/gui/fb.cpp, gnash/gui/fbsup.h, gnash/gui/gui.cpp,
+    gnash/gui/gui.h, gnash/server/button_character_instance.cpp,
+    gnash/server/button_character_instance.h, gnash/server/character.cpp,      
          
+    gnash/server/character.h, gnash/server/dlist.cpp, gnash/server/dlist.h,    
                  
+    gnash/server/edit_text_character.cpp, gnash/server/edit_text_character.h,  
      
+    gnash/server/generic_character.h, gnash/server/gnash.h,                    
  
+    gnash/server/movie_interface.h, gnash/server/movie_root.cpp,               
+    gnash/server/movie_root.h, gnash/server/sprite_instance.cpp,          
+    gnash/server/sprite_instance.h, gnash/server/types.cpp, 
+    gnash/server/parser/button_character_def.h, 
+    gnash/server/parser/character_def.h, 
+    gnash/server/parser/edit_text_character_def.h, 
+    gnash/server/parser/movie_def_impl.h,          
+    gnash/server/parser/sprite_definition.h,       
+    gnash/server/parser/text_character_def.h
+    Enhanced "rect" class and implemented a method to detect updated regions
+    on the stage.
+      
+                     
 2006-10-12 Sandro Santilli <address@hidden>
 
        * configure.ac: don't check for GLEXT unless gtk/opengl combination

Index: gui/fb.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/gui/fb.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gui/fb.cpp  11 Oct 2006 22:18:32 -0000      1.9
+++ gui/fb.cpp  12 Oct 2006 16:37:25 -0000      1.10
@@ -57,6 +57,7 @@
 #include "fbsup.h"
 #include "log.h"
 
+#include "render_handler.h"
 #include "render_handler_agg.h"
 
 //#define DEBUG_SHOW_FPS  // prints number of frames per second to STDOUT
@@ -214,6 +215,9 @@
   int _size = fix_screeninfo.smem_len;   // TODO: should recalculate!  
   unsigned char *_mem;
   
+  m_stage_width = _width;
+  m_stage_height = _height;
+  
   
   #ifdef DOUBLE_BUFFER
   _mem = buffer;
@@ -315,11 +319,35 @@
 
 void FBGui::renderBuffer()
 {
-
 #ifdef DOUBLE_BUFFER
-       // TODO: Copy only updated parts of the screen!
-       memcpy(fbmem, buffer, var_screeninfo.xres*var_screeninfo.yres*
-    (var_screeninfo.bits_per_pixel/8));
+
+  assert(m_draw_minx <= m_draw_maxx);
+  assert(m_draw_miny <= m_draw_maxy);
+  
+  // Size of a pixel in bytes
+  // NOTE: +7 to support 15 bpp
+  const unsigned int pixel_size = (var_screeninfo.bits_per_pixel+7)/8;
+
+  // Size, in bytes, of a framebuffer row
+  const unsigned int scanline_size =
+    var_screeninfo.xres * pixel_size;
+    
+  // Size, in bytes, of a row that has to be copied
+  const unsigned int row_size =
+    (m_draw_maxx-m_draw_minx+1) * pixel_size;
+    
+  // copy each row
+  for (int y=m_draw_miny; y<=m_draw_maxy; y++) {
+  
+    const unsigned int pixel_index = y * scanline_size + 
m_draw_minx*pixel_size;
+    
+    memcpy(&fbmem[pixel_index], &buffer[pixel_index], row_size);
+    
+  }  
+     
+
+       /*memcpy(fbmem, buffer, var_screeninfo.xres*var_screeninfo.yres*
+    (var_screeninfo.bits_per_pixel/8));*/
 #endif
        
 #ifdef DEBUG_SHOW_FPS
@@ -357,5 +385,37 @@
 }
 
 
+int FBGui::valid_x(int x) {
+  if (x<0) x=0;
+  if (x>=m_stage_width) x=m_stage_width-1;
+  return x;
+}
+
+int FBGui::valid_y(int y) {
+  if (y<0) y=0;
+  if (y>=m_stage_height) y=m_stage_height-1;
+  return y;
+}
+
+void FBGui::set_invalidated_region(const rect bounds) {
+
+#ifdef DOUBLE_BUFFER
+  
+  // forward to renderer
+  _renderer->set_invalidated_region(bounds);
+  
+  // remember for renderBuffer()
+  _renderer->world_to_pixel(&m_draw_minx, &m_draw_miny, bounds.m_x_min, 
bounds.m_y_min);
+  _renderer->world_to_pixel(&m_draw_maxx, &m_draw_maxy, bounds.m_x_max, 
bounds.m_y_max);
+  
+  m_draw_minx = valid_x(m_draw_minx);
+  m_draw_miny = valid_y(m_draw_miny);
+  m_draw_maxx = valid_x(m_draw_maxx);
+  m_draw_maxy = valid_y(m_draw_maxy);
+
+#endif
+  
+}
+
 // end of namespace gnash
 }

Index: gui/fbsup.h
===================================================================
RCS file: /cvsroot/gnash/gnash/gui/fbsup.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gui/fbsup.h 11 Oct 2006 22:18:32 -0000      1.6
+++ gui/fbsup.h 12 Oct 2006 16:37:25 -0000      1.7
@@ -84,6 +84,14 @@
 #ifdef DOUBLE_BUFFER
                unsigned char *buffer; // offscreen buffer
 #endif         
+    int m_draw_minx;
+    int m_draw_miny;
+    int m_draw_maxx;
+    int m_draw_maxy;
+    
+    int m_stage_width;
+    int m_stage_height;
+
     struct fb_var_screeninfo var_screeninfo;
        struct fb_fix_screeninfo fix_screeninfo;
 
@@ -95,6 +103,9 @@
        
        bool initialize_renderer();
 
+       int valid_x(int x);
+       int valid_y(int y);
+       
        public:
                FBGui();
                FBGui(unsigned long xid, float scale, bool loop, unsigned int 
depth);
@@ -107,6 +118,8 @@
     virtual void renderBuffer();
     virtual void setInterval(unsigned int interval);
     virtual void setTimeout(unsigned int timeout);
+    
+    virtual void set_invalidated_region(const rect bounds);
 };
 
 // end of namespace gnash

Index: gui/gui.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- gui/gui.cpp 9 Oct 2006 13:47:44 -0000       1.20
+++ gui/gui.cpp 12 Oct 2006 16:37:25 -0000      1.21
@@ -47,6 +47,7 @@
 //#include "movie_definition.h"
 #include "sprite_instance.h"
 #include "gui.h"
+#include "render.h"  // debug
 #include "render_handler.h"
 
 namespace gnash {
@@ -61,6 +62,10 @@
     _depth(16)
 {
 //    GNASH_REPORT_FUNCTION;
+  _last_invalidated_bounds.m_x_min = 0.0f;
+  _last_invalidated_bounds.m_y_min = 0.0f;
+  _last_invalidated_bounds.m_x_max = 0.0f;
+  _last_invalidated_bounds.m_y_max = 0.0f;
 }
 
 Gui::Gui(unsigned long xid, float scale, bool loop, unsigned int depth) :
@@ -72,6 +77,10 @@
     _yscale(scale),
     _depth(depth)
 {
+  _last_invalidated_bounds.m_x_min = 0.0f;
+  _last_invalidated_bounds.m_y_min = 0.0f;
+  _last_invalidated_bounds.m_x_max = 0.0f;
+  _last_invalidated_bounds.m_y_max = 0.0f;
 }
 
 Gui::~Gui()
@@ -193,13 +202,58 @@
 bool
 Gui::advance_movie(Gui* gui)
 {
+
+  rect changed_bounds;  // new bounds for the current frame
+  rect draw_bounds;     // redraw bounds (union of current and previous frame)
+
 //    GNASH_REPORT_FUNCTION;
        gnash::movie_interface* m = gnash::get_current_root();
 
+  // Advance movie by one frame
        m->advance(1.0);
+
+  // Find out the surrounding frame of all characters wich have been updated.
+  m->get_invalidated_bounds(&changed_bounds, false);
+
+  // Union it with the previous frame (when a character moved, we also need to
+  // redraw it's previous position).
+  draw_bounds = changed_bounds;
+  if (_last_invalidated_bounds.m_x_min <= _last_invalidated_bounds.m_x_max)  
+    draw_bounds.expand_to_rect(_last_invalidated_bounds);
+  
+  // Avoid drawing of stopped movies
+  if (draw_bounds.m_x_min <= draw_bounds.m_x_max) {
+  
+    // Tell the GUI that we only need to update this region (it may ignore this
+    // information)
+    gui->set_invalidated_region(draw_bounds);
+
+    // render the frame      
        m->display();
+  
+    // show invalidated region using a red rectangle (Flash debug style)
+    #if 0
+    point corners[4];
+    corners[0].m_x = draw_bounds.m_x_min;      
+    corners[0].m_y = draw_bounds.m_y_min;      
+    corners[1].m_x = draw_bounds.m_x_max;      
+    corners[1].m_y = draw_bounds.m_y_min;      
+    corners[2].m_x = draw_bounds.m_x_max;      
+    corners[2].m_y = draw_bounds.m_y_max;      
+    corners[3].m_x = draw_bounds.m_x_min;      
+    corners[3].m_y = draw_bounds.m_y_max;
+    matrix dummy;      
+    gnash::render::set_matrix(dummy); // reset matrix
+    gnash::render::draw_poly(&corners[0], 4, rgba(0,0,0,0), rgba(255,0,0,255));
+    #endif     
+
+    // show frame on screen
        gui->renderBuffer();
   
+  };
+  
+  _last_invalidated_bounds = changed_bounds;
+  
        if ( ! gui->loops() )
        {
                size_t curframe = m->get_current_frame();

Index: gui/gui.h
===================================================================
RCS file: /cvsroot/gnash/gnash/gui/gui.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- gui/gui.h   9 Oct 2006 16:05:24 -0000       1.19
+++ gui/gui.h   12 Oct 2006 16:37:25 -0000      1.20
@@ -43,6 +43,7 @@
 #endif
 
 #include "tu_config.h"
+#include "gnash.h"  // for rect
 
 #include <string>
 
@@ -113,6 +114,21 @@
     /// Register event handlers.
     virtual bool setupEvents() = 0;
 
+       /// Defines the region on the stage that needs to be redrawn/updated.
+    /// Changes outside that region are unnecessary but not disallowed.
+    /// Coordinates are in TWIPS!
+    /// Note this information is given to the GUI and not directly to the 
+    /// renderer because both of them need to support this feature for 
+    /// correct results. It is up to the GUI to forward this information to
+    /// the renderer.
+    virtual void set_invalidated_region(const rect bounds) {      
+      // does not need to be implemented (optional feature), but still needs to
+      // be available.
+      // Why "rect" (floats)? Because the gui does not really know about the
+      // scale the renderer currently uses... 
+    } 
+    
+
     /// \brief
     /// Render the current buffer. For OpenGL, this means that the buffer is
     /// swapped.
@@ -158,7 +174,7 @@
     /// \brief
     /// Advances the movie to the next frame. This is to take place after the
     /// interval specified in the call to setInterval().
-    static bool advance_movie(Gui* gui);
+    bool advance_movie(Gui* gui);
 
     /// Resize the client area view and the window accordingly.
     /// @param width  The desired width in pixels.
@@ -184,6 +200,8 @@
     unsigned int    _interval;
     /// The handler which is called to update the client area of our window.
     render_handler* _renderer;
+    /// Invalidated bounds of previous frame
+    rect            _last_invalidated_bounds;
 };
 
  

Index: server/button_character_instance.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/button_character_instance.cpp        27 Aug 2006 18:30:38 -0000      
1.3
+++ server/button_character_instance.cpp        12 Oct 2006 16:37:25 -0000      
1.4
@@ -327,6 +327,7 @@
                }
        }
 
+       clear_invalidated();
        do_display_callback();
 }
 
@@ -524,6 +525,7 @@
 button_character_instance::set_member(const tu_stringi& name,
                const as_value& val)
 {
+
        // TODO: pull these up into a base class, to
        // share as much as possible with sprite_instance.
        as_standard_member      std_member = get_standard_member(name);
@@ -703,6 +705,32 @@
        return false;
 }
 
+void 
+button_character_instance::get_invalidated_bounds(rect* bounds, bool force) 
+{
+  if (!m_visible) return; // not visible anyway
+
+  // TODO: Instead of using these for loops again and again, wouldn't it be a
+  // good idea to have a generic "get_record_character()" method?
+       for (unsigned int i = 0; i < m_def->m_button_records.size(); i++)
+       {
+               button_record&  rec = m_def->m_button_records[i];
+               if (m_record_character[i] == NULL)
+               {
+                       continue;
+               }
+               if ((m_mouse_state == UP && rec.m_up)
+                   || (m_mouse_state == DOWN && rec.m_down)
+                   || (m_mouse_state == OVER && rec.m_over))
+               {
+                               
/*bounds->expand_to_transformed_rect(get_world_matrix(), 
+          m_record_character[i]->get_bound());*/
+        m_record_character[i]->get_invalidated_bounds(bounds, 
+          force||m_invalidated);        
+               }
+       }
+}
+
 } // end of namespace gnash
 
 

Index: server/button_character_instance.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/button_character_instance.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/button_character_instance.h  2 Oct 2006 17:12:58 -0000       1.2
+++ server/button_character_instance.h  12 Oct 2006 16:37:25 -0000      1.3
@@ -5,7 +5,7 @@
 
 // SWF buttons.  Mouse-sensitive update/display, actions, etc.
 
-/* $Id: button_character_instance.h,v 1.2 2006/10/02 17:12:58 nihilus Exp $ */
+/* $Id: button_character_instance.h,v 1.3 2006/10/12 16:37:25 udog Exp $ */
 
 #ifndef GNASH_BUTTON_CHARACTER_INSTANCE_H
 #define GNASH_BUTTON_CHARACTER_INSTANCE_H
@@ -111,6 +111,9 @@
 
        virtual bool get_member(const tu_stringi& name, as_value* val);
 
+       void get_invalidated_bounds(rect* bounds, bool force);
+       
+
        // not sure if we need to override this one.
        //virtual const char*   get_text_value() const { return NULL; } // 
edit_text_character overrides this
 };

Index: server/character.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/character.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/character.cpp        22 Sep 2006 19:04:37 -0000      1.6
+++ server/character.cpp        12 Oct 2006 16:37:25 -0000      1.7
@@ -36,7 +36,7 @@
 //
 //
 
-/* $Id: character.cpp,v 1.6 2006/09/22 19:04:37 nihilus Exp $ */
+/* $Id: character.cpp,v 1.7 2006/10/12 16:37:25 udog Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -172,6 +172,7 @@
        return NULL;
 }
 
+
 } // namespace gnash
 
 // Local Variables:

Index: server/character.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/character.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/character.h  11 Oct 2006 11:00:37 -0000      1.19
+++ server/character.h  12 Oct 2006 16:37:25 -0000      1.20
@@ -36,7 +36,7 @@
 //
 //
 
-/* $Id: character.h,v 1.19 2006/10/11 11:00:37 strk Exp $ */
+/* $Id: character.h,v 1.20 2006/10/12 16:37:25 udog Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -132,13 +132,21 @@
        {
            assert(m.is_valid());
            m_matrix = m;
+           set_invalidated();
        }
     const cxform&      get_cxform() const { return m_color_transform; }
-    void       set_cxform(const cxform& cx) { m_color_transform = cx; }
+    void       set_cxform(const cxform& cx) 
+    { 
+      m_color_transform = cx;
+      set_invalidated(); 
+    }
     void       concatenate_cxform(const cxform& cx) { 
m_color_transform.concatenate(cx); }
     void       concatenate_matrix(const matrix& m) { m_matrix.concatenate(m); }
     float      get_ratio() const { return m_ratio; }
-    void       set_ratio(float f) { m_ratio = f; }
+    void       set_ratio(float f) {
+      if (f!=m_ratio) set_invalidated(); 
+      m_ratio = f;       
+    }
     uint16_t   get_clip_depth() const { return m_clip_depth; }
     void       set_clip_depth(uint16_t d) { m_clip_depth = d; }
 
@@ -249,7 +257,10 @@
 
     virtual void       get_drag_state(drag_state* st);
 
-    virtual void       set_visible(bool visible) { m_visible = visible; }
+    virtual void       set_visible(bool visible) {
+      if (m_visible!=visible) set_invalidated();  
+      m_visible = visible;      
+    }
     virtual bool       get_visible() const { return m_visible; }
 
     virtual void       set_display_callback(void (*callback)(void*), void* 
user_ptr)
@@ -270,6 +281,11 @@
 
        virtual void get_mouse_state(int* x, int* y, int* buttons);
 
+       void get_invalidated_bounds(rect*, bool) {
+         log_msg("character::get_invalidated_bounds() called!\n"); // should 
never happen 
+         // nop
+  }
+       
 };
 
 

Index: server/dlist.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/dlist.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- server/dlist.cpp    12 Oct 2006 13:31:12 -0000      1.27
+++ server/dlist.cpp    12 Oct 2006 16:37:25 -0000      1.28
@@ -179,6 +179,7 @@
        ch->set_matrix(mat);
        ch->set_ratio(ratio);
        ch->set_clip_depth(clip_depth);
+       ch->set_invalidated();
 
        container_type::iterator it = find_if(
                        _characters.begin(), _characters.end(),
@@ -219,6 +220,7 @@
        ch->set_matrix(mat);
        ch->set_ratio(ratio);
        ch->set_clip_depth(clip_depth);
+       ch->set_invalidated();
        ch->restart();
 
        container_type::iterator it = find_if(
@@ -576,6 +578,19 @@
        }
 }
 
+void 
+DisplayList::get_invalidated_bounds(rect* bounds, bool force) {
+    
+       for( iterator it = _characters.begin(),
+                       endIt = _characters.end();
+               it != endIt; ++it)
+       {
+    DisplayItem& dobj = *it;
+    dobj->get_invalidated_bounds(bounds, force);
+       }
+       
+}
+
 } // namespace gnash
 
 

Index: server/dlist.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/dlist.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/dlist.h      12 Oct 2006 13:31:12 -0000      1.12
+++ server/dlist.h      12 Oct 2006 16:37:25 -0000      1.13
@@ -209,6 +209,11 @@
        /// dump list to given output stream (debugging)
        void dump(std::ostream& os) const;
 
+  /// Like character_instance::get_invalidated_bounds() this method calls the
+  /// method with the same name of all childs. 
+       void get_invalidated_bounds(rect* bounds, bool force);
+       
+
        /// Return number of elements in the list
        size_t size() const { 
                return _characters.size();

Index: server/edit_text_character.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/edit_text_character.cpp      11 Oct 2006 11:02:39 -0000      1.18
+++ server/edit_text_character.cpp      12 Oct 2006 16:37:25 -0000      1.19
@@ -3,7 +3,7 @@
 // This source code has been donated to the Public Domain.  Do
 // whatever you want with it.
 
-/* $Id: edit_text_character.cpp,v 1.18 2006/10/11 11:02:39 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.19 2006/10/12 16:37:25 udog Exp $ */
 
 #include "utf8.h"
 #include "log.h"
@@ -148,9 +148,21 @@
                show_cursor();
        }
 
+       clear_invalidated();
        do_display_callback();
 }
 
+
+       void edit_text_character::get_invalidated_bounds(rect* bounds, bool 
force) {
+       
+    if (!force && !m_invalidated) return; // no need to redraw 
+       
+    bounds->expand_to_transformed_rect(get_world_matrix(), 
+      m_def->get_bound());            
+         
+  }
+
+
 bool edit_text_character::on_event(event_id id)
 {
        if (m_def->get_readonly() == true)
@@ -291,6 +303,8 @@
        }
 
        format_text();
+       
+       set_invalidated();
 }
 
 void

Index: server/edit_text_character.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/edit_text_character.h        11 Oct 2006 11:02:39 -0000      1.12
+++ server/edit_text_character.h        12 Oct 2006 16:37:25 -0000      1.13
@@ -94,6 +94,8 @@
        /// Draw the dynamic string.
        void    display();
 
+       void get_invalidated_bounds(rect*, bool);
+
        virtual float   get_height() const;
        virtual float   get_width() const;
 

Index: server/generic_character.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/generic_character.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/generic_character.h  10 Oct 2006 17:14:45 -0000      1.9
+++ server/generic_character.h  12 Oct 2006 16:37:25 -0000      1.10
@@ -45,6 +45,8 @@
 
 #include "character.h" // for inheritance
 
+#include "shape_character_def.h" // for get_invalidated_bounds 
+
 #include <cassert>
 
 namespace gnash {
@@ -77,6 +79,7 @@
 //                     GNASH_REPORT_FUNCTION;
                
            m_def->display(this);       // pass in transform info
+           clear_invalidated();
            do_display_callback();
        }
 
@@ -119,6 +122,19 @@
        /// instance derive. 
     character_def* get_character_def() { return m_def; }
 
+  
+  void enclose_own_bounds(rect *) const {
+    assert(0); // TO BE IMPLEMENTED!!!!!
+  }
+    
+       void get_invalidated_bounds(rect* bounds, bool force) {
+    if (m_visible && (m_invalidated||force)) {
+      bounds->expand_to_transformed_rect(get_world_matrix(), 
+        m_def->get_bound());            
+    }    
+  }
+    
+
 };
 
 

Index: server/gnash.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/gnash.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- server/gnash.h      12 Oct 2006 14:32:09 -0000      1.59
+++ server/gnash.h      12 Oct 2006 16:37:25 -0000      1.60
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: gnash.h,v 1.59 2006/10/12 14:32:09 strk Exp $ */
+/* $Id: gnash.h,v 1.60 2006/10/12 16:37:25 udog Exp $ */
 
 /// \mainpage
 ///
@@ -528,6 +528,13 @@
        /// sheared, scaled, etc) box.
        void    enclose_transformed_rect(const matrix& m, const rect& r);
 
+       /// Same as enclose_transformed_rect but expanding the current rect 
instead
+       /// of replacing it.
+       void    expand_to_transformed_rect(const matrix& m, const rect& r);
+       
+       /// Makes union of the given and the current rect
+       void  expand_to_rect(const rect& r);
+
        void    set_lerp(const rect& a, const rect& b, float t);
 };
 

Index: server/movie_interface.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/movie_interface.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/movie_interface.h    2 Oct 2006 19:11:13 -0000       1.9
+++ server/movie_interface.h    12 Oct 2006 16:37:25 -0000      1.10
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: movie_interface.h,v 1.9 2006/10/02 19:11:13 nihilus Exp $ */
+/* $Id: movie_interface.h,v 1.10 2006/10/12 16:37:25 udog Exp $ */
 
 #ifndef GNASH_MOVIE_INTERFACE_H
 #define GNASH_MOVIE_INTERFACE_H
@@ -69,6 +69,12 @@
 class movie_interface : public as_object
 {
 public:
+
+  /// Set when the visual aspect this particular character or movie has been 
+  /// changed and redrawing is necessary.  
+  bool m_invalidated;
+
+
        virtual movie_definition*       get_movie_definition() = 0;
        
        /// Frame counts in this API are 0-based (unlike ActionScript)
@@ -192,6 +198,32 @@
 
        /// for external movies
        virtual sprite_instance* get_root_movie() = 0;
+       
+  /// This method must be called whenever the visual aspect of this 
+  /// character/movie did change. 
+       void set_invalidated() {
+       
+         if (m_invalidated) return; // flag already set, don't do anything
+       
+         m_invalidated = true;
+         /*if (m_parent)
+           m_parent->set_child_invalidated();*/    
+  }
+  
+  // Should be called by display()
+  void clear_invalidated() {
+    m_invalidated = false;
+  }
+  
+  
+  /// Checks if the character instance is still enclosed in the given bounds.
+  /// Otherwise it will expand them to surround the character. It is used to
+  /// determine what area needs to be re-rendered. The coordinates are world
+  /// coordinates. 
+  /// Only instances with m_invalidated flag set are checked unless force
+  /// is set.  
+  virtual void get_invalidated_bounds(rect* bounds, bool force) = 0;
+       
 };
 
 }      // namespace gnash

Index: server/movie_root.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/movie_root.cpp       26 Aug 2006 22:58:12 -0000      1.14
+++ server/movie_root.cpp       12 Oct 2006 16:37:25 -0000      1.15
@@ -81,6 +81,8 @@
        {
        assert(m_def != NULL);
 
+       m_invalidated=true;
+
        set_display_viewport(0, 0,
                (int) m_def->get_width_pixels(),
                (int) m_def->get_height_pixels());
@@ -419,6 +421,9 @@
 void
 movie_root::display()
 {
+
+  clear_invalidated();
+
 //         GNASH_REPORT_FUNCTION;
     if (m_movie->get_visible() == false)
         {

Index: server/movie_root.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/movie_root.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/movie_root.h 29 Sep 2006 04:19:34 -0000      1.13
+++ server/movie_root.h 12 Oct 2006 16:37:25 -0000      1.14
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: movie_root.h,v 1.13 2006/09/29 04:19:34 nihilus Exp $ */
+/* $Id: movie_root.h,v 1.14 2006/10/12 16:37:25 udog Exp $ */
 
 #ifndef GNASH_MOVIE_ROOT_H
 #define GNASH_MOVIE_ROOT_H
@@ -283,6 +283,29 @@
        movie* get_active_entity();
        void set_active_entity(movie* ch);
 
+       void get_invalidated_bounds(rect* bounds, bool force) {
+        
+         if (m_invalidated) {
+           // complete redraw (usually first frame)
+           bounds->m_x_min = -1e10f;
+           bounds->m_y_min = -1e10f;
+           bounds->m_x_max = +1e10f;
+           bounds->m_y_max = +1e10f;
+    } else {
+      // browse characters to compute bounds
+      
+      // TODO: Use better start-values
+           bounds->m_x_min = +1e10f;
+           bounds->m_y_min = +1e10f;
+           bounds->m_x_max = -1e10f;
+           bounds->m_y_max = -1e10f;
+      
+      m_movie->get_invalidated_bounds(bounds, force||m_invalidated);
+    }
+
+          
+  }
+
 private:
         void fire_mouse_event();
 

Index: server/sprite_instance.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- server/sprite_instance.cpp  10 Oct 2006 17:14:45 -0000      1.62
+++ server/sprite_instance.cpp  12 Oct 2006 16:37:25 -0000      1.63
@@ -1175,6 +1175,7 @@
 #ifdef DEBUG_DYNTEXT_VARIABLES
 log_msg("sprite[%p]::set_member(%s, %s)", (void*)this, name.c_str(), 
val.to_string());
 #endif
+
        as_standard_member      std_member = get_standard_member(name);
        switch (std_member)
        {
@@ -1533,6 +1534,8 @@
                                {
                                        m_display_list.clear();
                                }
+                               
+                               set_invalidated();
                        }
                        execute_frame_tags(m_current_frame);
                }
@@ -1763,12 +1766,16 @@
 
        m_display_list.display();
 
+       clear_invalidated();
        do_display_callback();
 }
 
 void sprite_instance::swap_characters(character* ch1, character* ch2)
 {
        m_display_list.swap_characters(ch1, ch2);
+       
+       ch1->set_invalidated();
+       ch2->set_invalidated();
 }
 
 character*
@@ -1922,6 +1929,8 @@
        mat,
        ratio,
        clip_depth);
+       
+        set_invalidated();
 }
 
 int sprite_instance::get_id_at_depth(int depth)
@@ -2206,6 +2215,7 @@
        m_root->set_background_color(color);
 }
 
+
 /* public */
 void
 sprite_instance::set_textfield_variable(const std::string& name,
@@ -2242,4 +2252,12 @@
        }
 } 
 
+void 
+sprite_instance::get_invalidated_bounds(rect* bounds, bool force) {
+  
+  if (!m_visible) return;
+  // TODO: check if alpha=0 (return if so)
+  m_display_list.get_invalidated_bounds(bounds, force||m_invalidated);
+}
+
 } // namespace gnash

Index: server/sprite_instance.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/sprite_instance.h    11 Oct 2006 13:50:23 -0000      1.30
+++ server/sprite_instance.h    12 Oct 2006 16:37:25 -0000      1.31
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.30 2006/10/11 13:50:23 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.31 2006/10/12 16:37:25 udog Exp $ */
 
 // Stateful live Sprite instance
 
@@ -334,6 +334,7 @@
        ///
        void    remove_display_object(uint16_t depth, int /* id */)
        {
+           set_invalidated();
            m_display_list.remove_display_object(depth);
        }
 
@@ -496,6 +497,9 @@
        void set_textfield_variable(const std::string& name,
                        edit_text_character* ch);
 
+       void get_invalidated_bounds(rect* bounds, bool force);
+                       
+
        const DisplayList& getDisplayList() const {
                return m_display_list;
        }

Index: server/types.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/types.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/types.cpp    11 Oct 2006 08:08:36 -0000      1.11
+++ server/types.cpp    12 Oct 2006 16:37:25 -0000      1.12
@@ -304,6 +304,30 @@
                expand_to_point(p3.m_x, p3.m_y);
        }
 
+       void  rect::expand_to_rect(const rect& r) 
+  {
+    point tmp;
+    tmp = r.get_corner(0);  expand_to_point(tmp.m_x, tmp.m_y);    
+    tmp = r.get_corner(1);  expand_to_point(tmp.m_x, tmp.m_y);    
+    tmp = r.get_corner(2);  expand_to_point(tmp.m_x, tmp.m_y);    
+    tmp = r.get_corner(3);  expand_to_point(tmp.m_x, tmp.m_y);    
+  }    
+
+       void    rect::expand_to_transformed_rect(const matrix& m, const rect& r)
+       {
+               // Get the transformed bounding box.
+               point   p0, p1, p2, p3;
+               m.transform(&p0, r.get_corner(0));
+               m.transform(&p1, r.get_corner(1));
+               m.transform(&p2, r.get_corner(2));
+               m.transform(&p3, r.get_corner(3));
+
+               expand_to_point(p0.m_x, p0.m_y);
+               expand_to_point(p1.m_x, p1.m_y);
+               expand_to_point(p2.m_x, p2.m_y);
+               expand_to_point(p3.m_x, p3.m_y);
+       }
+
 
        void    rect::set_lerp(const rect& a, const rect& b, float t)
        // Set this to the lerp of a and b.

Index: server/parser/button_character_def.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/parser/button_character_def.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/parser/button_character_def.h        26 Aug 2006 22:58:12 -0000      
1.1
+++ server/parser/button_character_def.h        12 Oct 2006 16:37:25 -0000      
1.2
@@ -112,6 +112,23 @@
        character* create_character_instance(character* parent, int id);
 
        void    read(stream* in, int tag_type, movie_definition* m);
+       
+       const rect&     get_bound() const {
+    // It is required that get_bound() is implemented in character definition
+    // classes. However, button character definitions do not have shape 
+    // definitions themselves. Instead, they hold a list of 
shape_character_def.
+    // get_bound() is currently only used by generic_character which normally
+    // is used only shape character definitions. See character_def.h to learn
+    // why it is virtual anyway.
+    // get_button_bound() is used for buttons.
+    assert(0); // should not be called  
+  }
+  
+  const rect&  get_button_bound(int id) const {
+    UNUSED(id);
+    assert(0); // not implemented
+  }
+       
 };
 
 }      // end namespace gnash

Index: server/parser/character_def.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/parser/character_def.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/parser/character_def.h       10 Oct 2006 17:14:45 -0000      1.5
+++ server/parser/character_def.h       12 Oct 2006 16:37:25 -0000      1.6
@@ -42,6 +42,7 @@
 #include "config.h"
 #endif
 
+#include "gnash.h" // for rect
 #include "resource.h" // for inheritance from resource class
 
 // Forward declarations
@@ -112,6 +113,9 @@
                return this;
        }
        
+       // Declared as virtual here because generic_character needs access to it
+       virtual const rect&     get_bound() const = 0;
+       
        //
        // Caching.
        //

Index: server/parser/edit_text_character_def.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/parser/edit_text_character_def.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/parser/edit_text_character_def.h     10 Oct 2006 10:39:50 -0000      
1.5
+++ server/parser/edit_text_character_def.h     12 Oct 2006 16:37:25 -0000      
1.6
@@ -215,6 +215,14 @@
                return m_readonly;
        }
 
+       const rect&     get_bound() const {
+         // I know it's stupid to have an alias that's nearly the same name but
+    // get_bound() is required by the base class and get_bounds() was already
+    // there. Should be fixed (remove get_bounds). 
+    return get_bounds(); 
+  }
+       
+
 private:
 
        /// Root movie_definition

Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/parser/movie_def_impl.h      3 Oct 2006 10:10:35 -0000       1.11
+++ server/parser/movie_def_impl.h      12 Oct 2006 16:37:25 -0000      1.12
@@ -526,6 +526,14 @@
 
        virtual const std::string& get_url() const { return _url; }
 
+       const rect&     get_bound() const {
+    // It is required that get_bound() is implemented in character definition
+    // classes. However, it makes no sense to call it for movie interfaces.
+    // get_bound() is currently only used by generic_character which normally
+    // is used only shape character definitions. See character_def.h to learn
+    // why it is virtual anyway.
+    assert(0); // should not be called  
+  }
 
 };
 

Index: server/parser/sprite_definition.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/parser/sprite_definition.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/parser/sprite_definition.h   2 Oct 2006 16:28:11 -0000       1.3
+++ server/parser/sprite_definition.h   12 Oct 2006 16:37:25 -0000      1.4
@@ -360,6 +360,14 @@
                return m_movie_def;
        }
 
+       const rect&     get_bound() const {
+    // It is required that get_bound() is implemented in character definition
+    // classes. However, it makes no sense to call it for sprite definitions.
+    // get_bound() is currently only used by generic_character which normally
+    // is used only shape character definitions. See character_def.h to learn
+    // why it is virtual anyway.
+    assert(0); // should not be called  
+  }
 
 };
 

Index: server/parser/text_character_def.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/parser/text_character_def.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/parser/text_character_def.h  25 Aug 2006 17:57:46 -0000      1.3
+++ server/parser/text_character_def.h  12 Oct 2006 16:37:25 -0000      1.4
@@ -76,6 +76,12 @@
        /// Draw the string.
        void display(character* inst);
 
+       const rect&     get_bound() const {
+    // TODO: There is a m_matrix field in the definition(!) that's currently 
+    // ignored. Don't know if it needs to be transformed... 
+    return m_rect; 
+  }
+       
 };
 
 




reply via email to

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