[cairo-commit] rendertest/src rendertest.c,1.10,1.11

David Reveman commit at pdx.freedesktop.org
Fri Jul 1 03:37:37 PDT 2005


Committed by: davidr

Update of /cvs/cairo/rendertest/src
In directory gabe:/tmp/cvs-serv30118/src

Modified Files:
	rendertest.c 
Log Message:
Add normalization of convolution filters

Index: rendertest.c
===================================================================
RCS file: /cvs/cairo/rendertest/src/rendertest.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- rendertest.c	31 Jan 2005 08:13:12 -0000	1.10
+++ rendertest.c	1 Jul 2005 10:37:35 -0000	1.11
@@ -483,12 +483,44 @@
                     render_fixed16_16_t *params,
                     int n_params)
 {
+  render_fixed16_16_t *normalized = 0;
+  render_status_t     status;
+    
   if (filter != RENDER_FILTER_NEAREST && filter != RENDER_FILTER_BILINEAR)
     surface->flags |= RENDER_SURFACE_FLAG_FILTER_MASK;
   else
     surface->flags &= ~RENDER_SURFACE_FLAG_FILTER_MASK;
 
-  return surface->backend->set_filter (surface, filter, params, n_params);
+  if (filter == RENDER_FILTER_CONVOLUTION)
+  {
+      render_fixed16_16_t sum = 0;
+      int                 i;
+
+      for (i = 2; i < n_params; i++)
+          sum += params[i];
+
+      if (sum != FIXED1)
+      {
+          normalized = malloc (sizeof (render_fixed16_16_t) * n_params);
+          if (!normalized)
+              return RENDER_STATUS_NO_MEMORY;
+
+          normalized[0] = params[0];
+          normalized[1] = params[1];
+
+          for (i = 2; i < n_params; i++)
+              normalized[i] = params[i] / (sum >> 16);
+
+          params = normalized;
+      }
+  }
+
+  status = surface->backend->set_filter (surface, filter, params, n_params);
+
+  if (normalized)
+      free (normalized);
+
+  return status;
 }
 
 #define TEST_CHECK \




More information about the cairo-commit mailing list