Added the new method makeWeightTabs to the ScaleFilters
class. It's used to calculate weight coeffs on the scale 
filter interval.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2114 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/ScaleFilters.cxx b/common/rfb/ScaleFilters.cxx
index d5530b7..28fa24f 100644
--- a/common/rfb/ScaleFilters.cxx
+++ b/common/rfb/ScaleFilters.cxx
@@ -20,6 +20,7 @@
 #include <assert.h>

 #include <math.h>

 

+#include <rfb/Rect.h>

 #include <rfb/ScaleFilters.h>

 

 using namespace rfb;

@@ -84,4 +85,28 @@
   filter.radius = radius_;

   filter.func = func_;

   return filter;

-}
\ No newline at end of file
+}

+

+void ScaleFilters::makeWeightTabs(int filter_id, int src_x, int dst_x, SFilterWeightTab *weightTabs) {

+  double sx;

+  double ratio = dst_x / src_x;

+  SFilter sFilter = filters[filter_id];

+

+  weightTabs = new SFilterWeightTab[dst_x];

+

+  // Make the weight tab for the each dest x position

+  for (int x = 0; x < dst_x; x++) {

+    sx = double(x) / ratio;

+

+    // Calculate the scale filter interval, [i0, i1)

+    int i0 = int(__rfbmin(ceil(sx-sFilter.radius), 0));

+    int i1 = int(__rfbmax(ceil(sx+sFilter.radius), src_x));

+    weightTabs[x].i0 = i0; weightTabs[x].i1 = i1;

+    weightTabs[x].weight = new float[i1-i0];

+

+    // Calculate the weight coeffs on the scale filter interval

+    for (int ci = 0, i = i0; i < i1; i++) {

+      weightTabs[x].weight[ci++] = (float)sFilter.func(float(i)-sx);

+    }

+  }

+}

diff --git a/common/rfb/ScaleFilters.h b/common/rfb/ScaleFilters.h
index 0ec0730..317d0b4 100644
--- a/common/rfb/ScaleFilters.h
+++ b/common/rfb/ScaleFilters.h
@@ -60,6 +60,8 @@
 

     SFilter &operator[](unsigned int filter_id);

 

+    void makeWeightTabs(int filter, int src_x, int dst_x, SFilterWeightTab *weightTabs);

+

   protected:

     void initFilters();