[Pixman] [PATCH 3/3] Changed PIXMAN_KERNEL enums
Bill Spitzak
spitzak at gmail.com
Fri Jul 11 19:53:45 PDT 2014
Added TENT filter.
Renamed other values to match what they are now producing.
Add back-compatibility #define for old names.
---
demos/scale.c | 7 ++++---
pixman/pixman-filter.c | 41 +++++++++++++++++++++++++++++++++--------
pixman/pixman.h | 14 ++++++++++----
3 files changed, 47 insertions(+), 15 deletions(-)
diff --git a/demos/scale.c b/demos/scale.c
index 0b6c715..deba8f1 100644
--- a/demos/scale.c
+++ b/demos/scale.c
@@ -73,11 +73,12 @@ static const named_int_t filters[] =
{ "Box", PIXMAN_KERNEL_BOX },
{ "Impulse", PIXMAN_KERNEL_IMPULSE },
{ "Linear", PIXMAN_KERNEL_LINEAR },
- { "Cubic", PIXMAN_KERNEL_CUBIC },
- { "Lanczos2", PIXMAN_KERNEL_LANCZOS2 },
+ { "Tent", PIXMAN_KERNEL_TENT },
+ { "Mitchell", PIXMAN_KERNEL_MITCHELL },
+ { "Catmull-Rom", PIXMAN_KERNEL_CATMULL_ROM },
{ "Lanczos3", PIXMAN_KERNEL_LANCZOS3 },
{ "Lanczos3 Stretched", PIXMAN_KERNEL_LANCZOS3_STRETCHED },
- { "Gaussian", PIXMAN_KERNEL_GAUSSIAN },
+ { "Notch", PIXMAN_KERNEL_NOTCH },
};
static const named_int_t repeats[] =
diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index 5a031ed..b55606a 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -250,17 +250,42 @@ nice_width (double r)
return MAX (2.0, ceil (r * 8));
}
+/* PIXMAN_KERNEL_TENT: Triangle of width 2r. Lots of software uses
+ this as a "better" filter, twice the size of a box but smaller than
+ a cubic.
+
+ When r == 1.0, PIXMAN_KERNEL_BOX, PIXMAN_KERNEL_LINEAR, and
+ PIXMAN_KERNEL_TENT all produce the same filter, allowing
+ them to be exchanged at this point.
+*/
+
+static double
+tent_kernel (double x, double r)
+{
+ if (r < 1.0)
+ return box_kernel(x, r);
+ else
+ return MAX (1.0 - fabs(x / r), 0.0);
+}
+
+static int
+tent_width (double r)
+{
+ return r < 1.0 ? 2 : ceil(2 * r);
+}
+
static const filter_info_t filters[] =
{
- { PIXMAN_KERNEL_IMPULSE, impulse_kernel, impulse_width },
- { PIXMAN_KERNEL_BOX, box_kernel, box_width },
- { PIXMAN_KERNEL_LINEAR, linear_kernel, linear_width },
- { PIXMAN_KERNEL_CUBIC, mitchell_kernel, cubic_width },
- { PIXMAN_KERNEL_GAUSSIAN, notch_kernel, cubic_width },
- { PIXMAN_KERNEL_LANCZOS2, cubic_kernel, cubic_width },
- { PIXMAN_KERNEL_LANCZOS3, lanczos3_kernel, lanczos3_width },
- { PIXMAN_KERNEL_LANCZOS3_STRETCHED, nice_kernel, nice_width },
+ { PIXMAN_KERNEL_IMPULSE, impulse_kernel, impulse_width },
+ { PIXMAN_KERNEL_BOX, box_kernel, box_width },
+ { PIXMAN_KERNEL_LINEAR, linear_kernel, linear_width },
+ { PIXMAN_KERNEL_MITCHELL, mitchell_kernel, cubic_width },
+ { PIXMAN_KERNEL_NOTCH, notch_kernel, cubic_width },
+ { PIXMAN_KERNEL_CATMULL_ROM, cubic_kernel, cubic_width },
+ { PIXMAN_KERNEL_LANCZOS3, lanczos3_kernel, lanczos3_width },
+ { PIXMAN_KERNEL_LANCZOS3_STRETCHED, nice_kernel, nice_width },
+ { PIXMAN_KERNEL_TENT, tent_kernel, tent_width }
};
diff --git a/pixman/pixman.h b/pixman/pixman.h
index 509ba5e..7af49d4 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -837,13 +837,19 @@ typedef enum
PIXMAN_KERNEL_IMPULSE,
PIXMAN_KERNEL_BOX,
PIXMAN_KERNEL_LINEAR,
- PIXMAN_KERNEL_CUBIC,
- PIXMAN_KERNEL_GAUSSIAN,
- PIXMAN_KERNEL_LANCZOS2,
+ PIXMAN_KERNEL_MITCHELL,
+ PIXMAN_KERNEL_NOTCH,
+ PIXMAN_KERNEL_CATMULL_ROM,
PIXMAN_KERNEL_LANCZOS3,
- PIXMAN_KERNEL_LANCZOS3_STRETCHED /* Jim Blinn's 'nice' filter */
+ PIXMAN_KERNEL_LANCZOS3_STRETCHED, /* Jim Blinn's 'nice' filter */
+ PIXMAN_KERNEL_TENT
} pixman_kernel_t;
+/* Back-compatibility enums, do not use: */
+#define PIXMAN_KERNEL_CUBIC PIXMAN_KERNEL_MITCHELL
+#define PIXMAN_KERNEL_LANCZOS2 PIXMAN_KERNEL_CATMULL_ROM
+#define PIXMAN_KERNEL_GAUSSIAN PIXMAN_KERNEL_NOTCH
+
/* Create the parameter list for a SEPARABLE_CONVOLUTION filter
* with the given kernels and scale parameters.
*/
--
1.7.9.5
More information about the Pixman
mailing list