gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog backend/render_handler_cairo.cp...


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler_cairo.cp...
Date: Sun, 15 Jun 2008 07:47:18 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     08/06/15 07:47:17

Modified files:
        .              : ChangeLog 
        backend        : render_handler_cairo.cpp 
        gui            : gtk.cpp gtk_glue.h gtk_glue_agg.cpp 
                         gtk_glue_cairo.h gtksup.h gui.cpp 

Log message:
                * backend/render_handler_cairo.cpp: Remove init_cairo_matrix, 
which is
                unused and broken.
                * gui/gtk.cpp: Use GTK's internal region invalidation instead 
of our
                own bounds invalidation, because the former seems to be more 
portable.
                This change makes the GTK GUI fully functional when compiled 
against
                GTK's native Mac port.
                * gui/{gtk.cpp, gtk_glue.h, gtk_glue_cairo.h, gtksup.h}: Don't 
include
                gdkx.h, since we don't use it.
                * gui/gtk_glue_agg.cpp: Disable double buffering in all cases, 
because
                we always render into our own offscreen buffer (rather than 
GTK's).
                Make sure we pass the right row stride when blitting.
                * gui/gui.cpp: tiny cleanup.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6933&r2=1.6934
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_cairo.cpp?cvsroot=gnash&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.179&r2=1.180
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk_glue.h?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk_glue_agg.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk_glue_cairo.h?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtksup.h?cvsroot=gnash&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.170&r2=1.171

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6933
retrieving revision 1.6934
diff -u -b -r1.6933 -r1.6934
--- ChangeLog   14 Jun 2008 22:23:54 -0000      1.6933
+++ ChangeLog   15 Jun 2008 07:47:15 -0000      1.6934
@@ -1,3 +1,18 @@
+2008-06-14 Bastiaan Jacques <address@hidden>
+
+       * backend/render_handler_cairo.cpp: Remove init_cairo_matrix, which is
+       unused and broken.
+       * gui/gtk.cpp: Use GTK's internal region invalidation instead of our
+       own bounds invalidation, because the former seems to be more portable.
+       This change makes the GTK GUI fully functional when compiled against
+       GTK's native Mac port.
+       * gui/{gtk.cpp, gtk_glue.h, gtk_glue_cairo.h, gtksup.h}: Don't include
+       gdkx.h, since we don't use it.
+       * gui/gtk_glue_agg.cpp: Disable double buffering in all cases, because
+       we always render into our own offscreen buffer (rather than GTK's).
+       Make sure we pass the right row stride when blitting.
+       * gui/gui.cpp: tiny cleanup.
+
 2008-06-14  Rob Savoye  <address@hidden>
 
        * libnet/network.{h,cpp}: Read and write Buffers too. Set _port for

Index: backend/render_handler_cairo.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_cairo.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- backend/render_handler_cairo.cpp    5 Jun 2008 03:26:31 -0000       1.46
+++ backend/render_handler_cairo.cpp    15 Jun 2008 07:47:16 -0000      1.47
@@ -968,15 +968,6 @@
     _cr = context;
   }
   
-  void
-  init_cairo_matrix(cairo_matrix_t* cairo_matrix, const matrix& gnash_matrix)
-  {
-    cairo_matrix_init(cairo_matrix,
-           gnash_matrix.m_[0][0], gnash_matrix.m_[1][0],
-           gnash_matrix.m_[0][1], gnash_matrix.m_[1][1],
-           gnash_matrix.m_[0][2], gnash_matrix.m_[1][2]);
-  }
-  
   bool initTestBuffer(unsigned width, unsigned height)
   {
     cairo_surface_t* test_surface =

Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -b -r1.179 -r1.180
--- gui/gtk.cpp 23 May 2008 05:58:08 -0000      1.179
+++ gui/gtk.cpp 15 Jun 2008 07:47:17 -0000      1.180
@@ -39,11 +39,7 @@
 #endif
 
 #include <gtk/gtk.h>
-#ifndef _WIN32
-#include <gdk/gdkx.h>
-#else
 #include <gdk/gdk.h>
-#endif
 #include <gdk/gdkkeysyms.h>
 #include <string>
 
@@ -109,7 +105,6 @@
        ,_popup_menu(0)
        ,_menubar(0)
        ,_vbox(0)
-       ,_drawbounds()
        ,_glue()
 {
 }
@@ -827,42 +822,28 @@
 void
 GtkGui::renderBuffer()
 {
-    if ( _drawbounds.size() == 0 ) return; // nothing to do..
-    
-    for (unsigned bno=0; bno < _drawbounds.size(); bno++) {
-       
-        geometry::Range2d<int>& bounds = _drawbounds[bno];
-        
-        assert ( bounds.isFinite() );
-        
-        _glue->render(bounds.getMinX(), bounds.getMinY(),
-                      bounds.getMaxX(), bounds.getMaxY());
-       
-    }
+    gdk_window_process_updates(_drawingArea->window, false);
 }
 
 void
-GtkGui::rerenderPixels(int xmin, int ymin, int xmax, int ymax) 
+GtkGui::expose(const GdkRegion *region) 
 {
+    gint num_rects;
+    GdkRectangle* rects;
 
-    // This function is called in expose events to force partly re-rendering
-    // of the window. The coordinates are PIXELS.
-    
-    // The macro PIXELS_TO_TWIPS can't be used since the renderer might do 
-    // scaling.
+    // In some versions of GTK this can't be const...
+    GdkRegion* nonconst_region = const_cast<GdkRegion*>(region);
     
-    InvalidatedRanges ranges;
+    gdk_region_get_rectangles (nonconst_region, &rects, &num_rects);
+    assert(num_rects);
     
-    geometry::Range2d<int> exposed_pixels(xmin, ymin, xmax, ymax);
-    
-    geometry::Range2d<float> exposed_twips = 
-        _renderer->pixel_to_world(exposed_pixels);     
-    
-    ranges.add(exposed_twips);
-    setInvalidatedRegions(ranges);
-    
-    renderBuffer();   
+    for (int i=0; i<num_rects; ++i) {
+      const GdkRectangle& cur_rect = rects[i];
+      _glue->render(cur_rect.x, cur_rect.y, cur_rect.x + cur_rect.width,
+                    cur_rect.y + cur_rect.height);
+    }
     
+    g_free(rects);
 }
 
 void
@@ -871,18 +852,20 @@
     // forward to renderer
     //
     // Why? Why have the region been invalidated ??
+    //   A: I don't understand this question.
     // Was the renderer offscreen buffer also invalidated
     // (need to rerender)?
+    //   A: Yes.
     // Was only the 'onscreen' buffer be invalidated (no need to rerender,
     // just to blit) ??
+    //   A: I don't understand this question.
     //
-    // To be safe just assume this 'invalidated' region is actually
-    // the offscreen buffer, for safety, but we need to clarify this.
-    //
+    // Clarification: the render (optionally) only draws to the invalidated
+    // (i.e., changed) part of the buffer. So we need to tell the renderer
+    // where that is. The renderer draws to the offscreen buffer. (Although
+    // that should be obvious!)
     _renderer->set_invalidated_regions(ranges);
     
-    _drawbounds.clear();
-    
     for (unsigned rno=0; rno<ranges.size(); rno++) {
         geometry::Range2d<int> bounds = Intersection(
             _renderer->world_to_pixel(ranges.getRange(rno)),
@@ -894,8 +877,16 @@
         
         assert(bounds.isFinite()); 
         
-        _drawbounds.push_back(bounds);
-        
+        GdkRectangle rect;
+        rect.x = bounds.getMinX();
+        rect.y = bounds.getMinY();
+        rect.width = bounds.width();
+        rect.height = bounds.height();
+
+        // We add the rectangle to the part of the window to be redrawn
+        // (also known as the "clipping" or "damaged" area). in renderBuffer(),
+        // we force a redraw.
+        gdk_window_invalidate_rect(_drawingArea->window, &rect, false);
     }
     
 }
@@ -1739,12 +1730,7 @@
 
     GtkGui* gui = static_cast<GtkGui*>(data);
 
-    const int xmin = event->area.x;
-    const int xmax = event->area.x + event->area.width;
-    const int ymin = event->area.y;
-    const int ymax = event->area.y + event->area.height;
-
-    gui->rerenderPixels(xmin, ymin, xmax, ymax);
+    gui->expose(event->region);
 
     return TRUE;
 }

Index: gui/gtk_glue.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk_glue.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- gui/gtk_glue.h      22 Mar 2008 02:27:56 -0000      1.15
+++ gui/gtk_glue.h      15 Jun 2008 07:47:17 -0000      1.16
@@ -21,11 +21,7 @@
 #include "gnash.h"
 
 #include <gtk/gtk.h>
-#ifndef _WIN32
-#include <gdk/gdkx.h>
-#else
 #include <gdk/gdk.h>
-#endif
 
 namespace gnash
 {

Index: gui/gtk_glue_agg.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk_glue_agg.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- gui/gtk_glue_agg.cpp        22 Mar 2008 02:28:18 -0000      1.34
+++ gui/gtk_glue_agg.cpp        15 Jun 2008 07:47:17 -0000      1.35
@@ -210,9 +210,6 @@
     return;
   }
   
-  // Disable double buffering, otherwise gtk tries to update widget
-  // contents from offscreen buffer at the end of expose event
-  gtk_widget_set_double_buffered(_drawing_area, FALSE);
   //log_debug("create_shm_image() OK"); // <-- remove this
 #endif // ENABLE_MIT_SHM
    
@@ -239,6 +236,10 @@
 GtkAggGlue::prepDrawingArea(GtkWidget *drawing_area)
 {
     _drawing_area = drawing_area;
+
+    // Disable double buffering, otherwise gtk tries to update widget
+    // contents from its internal offscreen buffer at the end of expose event
+    gtk_widget_set_double_buffered(_drawing_area, FALSE);
 }
 
 bool 
@@ -498,7 +499,7 @@
                _height,
                GDK_RGB_DITHER_NONE,
                _offscreenbuf,
-               (int)(_width*_bpp/8)
+               _width*((_bpp+7)/8)
        );      
 
 #ifdef ENABLE_MIT_SHM
@@ -510,7 +511,6 @@
 void
 GtkAggGlue::render(int minx, int miny, int maxx, int maxy)
 {
-
 #ifdef ENABLE_MIT_SHM
   if (_shm_image) {
   
@@ -528,7 +528,6 @@
   
   } else {
 #endif       
-
        // Update only the invalidated rectangle
        gdk_draw_rgb_image (
                _drawing_area->window,

Index: gui/gtk_glue_cairo.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk_glue_cairo.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- gui/gtk_glue_cairo.h        22 Mar 2008 02:27:56 -0000      1.16
+++ gui/gtk_glue_cairo.h        15 Jun 2008 07:47:17 -0000      1.17
@@ -18,11 +18,7 @@
 #include "gtk_glue.h"
 
 #include <gtk/gtk.h>
-#ifndef _WIN32
-#include <gdk/gdkx.h>
-#else
 #include <gdk/gdk.h>
-#endif
 
 # include <cairo.h>
 

Index: gui/gtksup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gtksup.h,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- gui/gtksup.h        27 Apr 2008 09:46:39 -0000      1.75
+++ gui/gtksup.h        15 Jun 2008 07:47:17 -0000      1.76
@@ -25,11 +25,7 @@
 #include "gnash.h"
 #include "gtk_glue.h"
 
-#ifndef _WIN32
-#include <gdk/gdkx.h>
-#else
 #include <gdk/gdk.h>
-#endif
 #include <gtk/gtk.h>
 
 #ifdef GUI_HILDON
@@ -183,7 +179,7 @@
 
     gchar* find_pixmap_file(const gchar *filename);
     
-    void rerenderPixels(int xmin, int ymin, int xmax, int ymax);
+    void expose(const GdkRegion* region);
     
     void setInvalidatedRegions(const InvalidatedRanges& ranges);
 
@@ -212,8 +208,6 @@
     GtkWidget   *_menubar;
     GtkWidget   *_vbox;
 
-    std::vector< geometry::Range2d<int> > _drawbounds;
-
     // Adds the gnash icon to a window.
     void addGnashIcon(GtkWindow* window);
 

Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -b -r1.170 -r1.171
--- gui/gui.cpp 5 Jun 2008 03:26:32 -0000       1.170
+++ gui/gui.cpp 15 Jun 2008 07:47:17 -0000      1.171
@@ -793,7 +793,7 @@
                                corners[3].x = xmin;
                                corners[3].y = ymax;
                 matrix no_transform;
-                               gnash::render::draw_poly(&corners[0], 4,
+                               gnash::render::draw_poly(corners, 4,
                                        rgba(0,0,0,0), rgba(255,0,0,255), 
no_transform, false);
                                        
                        }




reply via email to

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