Revision: 4763
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4763&view=rev
Author:   mdboom
Date:     2007-12-18 05:08:04 -0800 (Tue, 18 Dec 2007)

Log Message:
-----------
Don't allocate the clipping path buffers unless we need them.

Modified Paths:
--------------
    branches/transforms/src/_backend_agg.cpp
    branches/transforms/src/_backend_agg.h

Modified: branches/transforms/src/_backend_agg.cpp
===================================================================
--- branches/transforms/src/_backend_agg.cpp    2007-12-18 13:02:33 UTC (rev 
4762)
+++ branches/transforms/src/_backend_agg.cpp    2007-12-18 13:08:04 UTC (rev 
4763)
@@ -239,27 +239,22 @@
   height(height),
   dpi(dpi),
   NUMBYTES(width*height*4),
+  alphaBuffer(NULL),
+  alphaMaskRenderingBuffer(NULL),
+  alphaMask(NULL),
+  pixfmtAlphaMask(NULL),
+  rendererBaseAlphaMask(NULL),
+  rendererAlphaMask(NULL),
+  scanlineAlphaMask(NULL),
   debug(debug)
 {
   _VERBOSE("RendererAgg::RendererAgg");
   unsigned stride(width*4);
 
-
   pixBuffer      = new agg::int8u[NUMBYTES];
   renderingBuffer = new agg::rendering_buffer;
   renderingBuffer->attach(pixBuffer, width, height, stride);
 
-  alphaBuffer             = new agg::int8u[NUMBYTES];
-  alphaMaskRenderingBuffer = new agg::rendering_buffer;
-  alphaMaskRenderingBuffer->attach(alphaBuffer, width, height, stride);
-  alphaMask               = new alpha_mask_type(*alphaMaskRenderingBuffer);
-
-  pixfmtAlphaMask         = new agg::pixfmt_gray8(*alphaMaskRenderingBuffer);
-  rendererBaseAlphaMask           = new 
renderer_base_alpha_mask_type(*pixfmtAlphaMask);
-  rendererAlphaMask       = new 
renderer_alpha_mask_type(*rendererBaseAlphaMask);
-  scanlineAlphaMask       = new agg::scanline_p8();
-
-
   slineP8  = new scanline_p8;
   slineBin = new scanline_bin;
 
@@ -275,6 +270,21 @@
 
 };
 
+void RendererAgg::create_alpha_buffers() {
+  if (!alphaBuffer) {
+    unsigned stride(width*4);
+    alphaBuffer                   = new agg::int8u[NUMBYTES];
+    alphaMaskRenderingBuffer = new agg::rendering_buffer;
+    alphaMaskRenderingBuffer->attach(alphaBuffer, width, height, stride);
+    alphaMask             = new alpha_mask_type(*alphaMaskRenderingBuffer);
+
+    pixfmtAlphaMask       = new agg::pixfmt_gray8(*alphaMaskRenderingBuffer);
+    rendererBaseAlphaMask         = new 
renderer_base_alpha_mask_type(*pixfmtAlphaMask);
+    rendererAlphaMask     = new 
renderer_alpha_mask_type(*rendererBaseAlphaMask);
+    scanlineAlphaMask     = new agg::scanline_p8();
+  }
+}
+
 template<class R>
 void
 RendererAgg::set_clipbox(const Py::Object& cliprect, R rasterizer) {
@@ -442,6 +452,7 @@
   if (has_clippath &&
       (clippath.ptr() != lastclippath.ptr() ||
        clippath_trans != lastclippath_transform)) {
+    create_alpha_buffers();
     agg::trans_affine trans(clippath_trans);
     trans *= agg::trans_affine_scaling(1.0, -1.0);
     trans *= agg::trans_affine_translation(0.0, (double)height);
@@ -617,7 +628,7 @@
     _color(color) {
   }
 
-  void generate(color_type* output_span, int x, int y, unsigned len)
+  inline void generate(color_type* output_span, int x, int y, unsigned len)
   {
     _allocator.allocate(len);
     child_color_type* input_span = _allocator.span();

Modified: branches/transforms/src/_backend_agg.h
===================================================================
--- branches/transforms/src/_backend_agg.h      2007-12-18 13:02:33 UTC (rev 
4762)
+++ branches/transforms/src/_backend_agg.h      2007-12-18 13:08:04 UTC (rev 
4763)
@@ -77,7 +77,7 @@
   SafeSnap() : first(true), xsnap(0.0), lastx(0.0), lastxsnap(0.0),
               ysnap(0.0), lasty(0.0), lastysnap(0.0)  {}
   SnapData snap (const float& x, const float& y);
-      
+
 private:
   bool first;
   float xsnap, lastx, lastxsnap, ysnap, lasty, lastysnap;
@@ -87,7 +87,7 @@
 // a class in the swig wrapper
 class BufferRegion : public Py::PythonExtension<BufferRegion> {
 public:
-  BufferRegion(const agg::rect_i &r, bool freemem=true) : 
+  BufferRegion(const agg::rect_i &r, bool freemem=true) :
   rect(r), freemem(freemem) {
     width = r.x2 - r.x1;
     height = r.y2 - r.y1;
@@ -99,7 +99,7 @@
   int width;
   int height;
   int stride;
-  
+
   bool freemem;
 
   Py::Object to_string(const Py::Tuple &args);
@@ -151,7 +151,7 @@
 
 
 //struct AMRenderer {
-//  
+//
 //}
 
 // the renderer
@@ -246,6 +246,7 @@
      const Py::SeqBase<Py::Int>&    antialiaseds);
 
 private:
+  void create_alpha_buffers();
   Py::Object lastclippath;
   agg::trans_affine lastclippath_transform;
 };


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to