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.cpp


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler_cairo.cpp
Date: Fri, 14 Mar 2008 06:16:40 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     08/03/14 06:16:40

Modified files:
        .              : ChangeLog 
        backend        : render_handler_cairo.cpp 

Log message:
        Partially implement invalidated bounds, improving performance by 
approximately 10%.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5906&r2=1.5907
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_cairo.cpp?cvsroot=gnash&r1=1.39&r2=1.40

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5906
retrieving revision 1.5907
diff -u -b -r1.5906 -r1.5907
--- ChangeLog   13 Mar 2008 17:25:38 -0000      1.5906
+++ ChangeLog   14 Mar 2008 06:16:38 -0000      1.5907
@@ -1,3 +1,8 @@
+2008-03-13 Bastiaan Jacques <address@hidden>
+
+       * backend/render_handler_cairo.cpp: Partially implement invalidated
+       bounds, improving performance by approximately 10%.
+
 2008-03-13 Benjamin Wolsey <address@hidden>
 
        * testsuite/actionscript.all/Microphone.as: more comprehensive tests

Index: backend/render_handler_cairo.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_cairo.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- backend/render_handler_cairo.cpp    13 Mar 2008 06:43:55 -0000      1.39
+++ backend/render_handler_cairo.cpp    14 Mar 2008 06:16:40 -0000      1.40
@@ -43,6 +43,7 @@
 #include <boost/scoped_array.hpp>
 #include "render_handler.h"
 #include "image.h"
+#include <cmath>
 
 namespace gnash {
 
@@ -320,33 +321,79 @@
                                 c.m_b / 255.0, c.m_a / 255.0);
   }
 
+  void set_invalidated_regions(const InvalidatedRanges& ranges)
+  {
+    _invalidated_ranges = ranges;
+  }
+
+  static void
+  snap_to_pixel(cairo_t* cr, double& x, double& y, bool up)
+  {
+    cairo_user_to_device(cr, &x, &y);
+   
+    if (up) {
+      x = std::ceil(x);
+      y = std::ceil(y);
+    } else {
+      x = std::floor(x);
+      y = std::floor(y);
+    }
+
+    cairo_device_to_user(cr, &x, &y);
+  }
+
   virtual void  begin_display(
     const rgba& bg_color,
     int viewport_x0, int viewport_y0,
     int viewport_width, int viewport_height,
     float x0, float x1, float y0, float y1)
   {
-
-  
     float display_width  = fabsf(x1 - x0);
     float display_height = fabsf(y1 - y0);
 
     cairo_identity_matrix(_cr);
-    cairo_rectangle(_cr, x0, y0, display_width, display_height);
-    cairo_clip(_cr);
+
+    cairo_save(_cr);
+
+    if (bg_color.m_a) {
+      set_color(bg_color);
+    }
+
     cairo_scale(_cr, viewport_width / display_width,
                      viewport_height / display_height);
     cairo_translate(_cr, x0, y0);
   
-         // Clear the background, if background color has alpha > 0.
-         if (bg_color.m_a) {
-      set_color(bg_color);
-      cairo_paint(_cr);
+    for (size_t rno=0; rno < _invalidated_ranges.size(); rno++) {
+    
+      const Range2d<float>& range = _invalidated_ranges.getRange(rno);
+      if (range.isNull()) {
+        continue;
     }
+      if (range.isWorld()) {
+        cairo_rectangle(_cr, x0, y0, display_width, display_height);
+        break;
+      }
+
+      double x = range.getMinX(),
+             y = range.getMinY(),
+             maxx = range.getMaxX(),
+             maxy = range.getMaxY();
+
+      snap_to_pixel(_cr, x, y, false);
+      snap_to_pixel(_cr, maxx, maxy, true);
+
+      cairo_rectangle(_cr, x, y, maxx - x, maxy - y);
+    }
+
+    cairo_clip(_cr);
+
+    // Paint the background color over the clipped region(s).
+    cairo_paint(_cr);
   }
 
   virtual void  end_display()
   {
+    cairo_restore(_cr);
   }
     
   virtual void  draw_line_strip(const void* coords, int vertex_count,
@@ -965,6 +1012,7 @@
   std::vector<PathVec> _masks;
   size_t _video_bufsize;
   bool _drawing_mask;
+  InvalidatedRanges _invalidated_ranges;
     
 }; // class render_handler_cairo
 




reply via email to

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