mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-23 14:20:11 +01:00
Rip out all the code for doing anything other than linear interpolation between color stops, instead of doing different funky things based on pattern->filter. (#4184)
This commit is contained in:
parent
48b3a1cacd
commit
00af78735e
2 changed files with 10 additions and 63 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
2005-08-23 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* src/cairo-pattern.c (_cairo_pattern_calc_color_at_pixel):
|
||||||
|
Rip out all the code for doing anything other than linear
|
||||||
|
interpolation between color stops, instead of doing different
|
||||||
|
funky things based on pattern->filter. (#4184)
|
||||||
|
|
||||||
2005-08-23 Carl Worth <cworth@cworth.org>
|
2005-08-23 Carl Worth <cworth@cworth.org>
|
||||||
|
|
||||||
* src/cairo-font.c: (cairo_font_face_reference),
|
* src/cairo-font.c: (cairo_font_face_reference),
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,6 @@
|
||||||
|
|
||||||
#include "cairoint.h"
|
#include "cairoint.h"
|
||||||
|
|
||||||
typedef void (*cairo_shader_function_t) (unsigned char *color0,
|
|
||||||
unsigned char *color1,
|
|
||||||
cairo_fixed_t factor,
|
|
||||||
uint32_t *pixel);
|
|
||||||
|
|
||||||
typedef struct _cairo_shader_color_stop {
|
typedef struct _cairo_shader_color_stop {
|
||||||
cairo_fixed_t offset;
|
cairo_fixed_t offset;
|
||||||
cairo_fixed_48_16_t scale;
|
cairo_fixed_48_16_t scale;
|
||||||
|
|
@ -43,7 +38,6 @@ typedef struct _cairo_shader_op {
|
||||||
cairo_shader_color_stop_t *stops;
|
cairo_shader_color_stop_t *stops;
|
||||||
int n_stops;
|
int n_stops;
|
||||||
cairo_extend_t extend;
|
cairo_extend_t extend;
|
||||||
cairo_shader_function_t shader_function;
|
|
||||||
} cairo_shader_op_t;
|
} cairo_shader_op_t;
|
||||||
|
|
||||||
#define MULTIPLY_COLORCOMP(c1, c2) \
|
#define MULTIPLY_COLORCOMP(c1, c2) \
|
||||||
|
|
@ -803,24 +797,6 @@ _cairo_pattern_transform (cairo_pattern_t *pattern,
|
||||||
cairo_matrix_multiply (&pattern->matrix, ctm_inverse, &pattern->matrix);
|
cairo_matrix_multiply (&pattern->matrix, ctm_inverse, &pattern->matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INTERPOLATE_COLOR_NEAREST(c1, c2, factor) \
|
|
||||||
((factor < 32768)? c1: c2)
|
|
||||||
|
|
||||||
static void
|
|
||||||
_cairo_pattern_shader_nearest (unsigned char *color0,
|
|
||||||
unsigned char *color1,
|
|
||||||
cairo_fixed_t factor,
|
|
||||||
uint32_t *pixel)
|
|
||||||
{
|
|
||||||
*pixel =
|
|
||||||
((INTERPOLATE_COLOR_NEAREST (color0[3], color1[3], factor) << 24) |
|
|
||||||
(INTERPOLATE_COLOR_NEAREST (color0[0], color1[0], factor) << 16) |
|
|
||||||
(INTERPOLATE_COLOR_NEAREST (color0[1], color1[1], factor) << 8) |
|
|
||||||
(INTERPOLATE_COLOR_NEAREST (color0[2], color1[2], factor) << 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef INTERPOLATE_COLOR_NEAREST
|
|
||||||
|
|
||||||
#define INTERPOLATE_COLOR_LINEAR(c1, c2, factor) \
|
#define INTERPOLATE_COLOR_LINEAR(c1, c2, factor) \
|
||||||
(((c2 * factor) + (c1 * (65536 - factor))) / 65536)
|
(((c2 * factor) + (c1 * (65536 - factor))) / 65536)
|
||||||
|
|
||||||
|
|
@ -836,24 +812,6 @@ _cairo_pattern_shader_linear (unsigned char *color0,
|
||||||
(INTERPOLATE_COLOR_LINEAR (color0[2], color1[2], factor) << 0));
|
(INTERPOLATE_COLOR_LINEAR (color0[2], color1[2], factor) << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define E_MINUS_ONE 1.7182818284590452354
|
|
||||||
|
|
||||||
static void
|
|
||||||
_cairo_pattern_shader_gaussian (unsigned char *color0,
|
|
||||||
unsigned char *color1,
|
|
||||||
cairo_fixed_t factor,
|
|
||||||
uint32_t *pixel)
|
|
||||||
{
|
|
||||||
double f = _cairo_fixed_to_double (factor);
|
|
||||||
|
|
||||||
factor = _cairo_fixed_from_double ((exp (f * f) - 1.0) / E_MINUS_ONE);
|
|
||||||
|
|
||||||
*pixel = ((INTERPOLATE_COLOR_LINEAR (color0[3], color1[3], factor) << 24) |
|
|
||||||
(INTERPOLATE_COLOR_LINEAR (color0[0], color1[0], factor) << 16) |
|
|
||||||
(INTERPOLATE_COLOR_LINEAR (color0[1], color1[1], factor) << 8) |
|
|
||||||
(INTERPOLATE_COLOR_LINEAR (color0[2], color1[2], factor) << 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef INTERPOLATE_COLOR_LINEAR
|
#undef INTERPOLATE_COLOR_LINEAR
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -911,24 +869,6 @@ _cairo_pattern_shader_init (cairo_gradient_pattern_t *pattern,
|
||||||
op->n_stops = pattern->n_stops;
|
op->n_stops = pattern->n_stops;
|
||||||
op->extend = pattern->base.extend;
|
op->extend = pattern->base.extend;
|
||||||
|
|
||||||
/* XXX: this is wrong, the filter should not be used for selecting
|
|
||||||
color stop interpolation function. function should always be 'linear'
|
|
||||||
and filter should be used for computing pixels. */
|
|
||||||
switch (pattern->base.filter) {
|
|
||||||
case CAIRO_FILTER_FAST:
|
|
||||||
case CAIRO_FILTER_NEAREST:
|
|
||||||
op->shader_function = _cairo_pattern_shader_nearest;
|
|
||||||
break;
|
|
||||||
case CAIRO_FILTER_GAUSSIAN:
|
|
||||||
op->shader_function = _cairo_pattern_shader_gaussian;
|
|
||||||
break;
|
|
||||||
case CAIRO_FILTER_GOOD:
|
|
||||||
case CAIRO_FILTER_BEST:
|
|
||||||
case CAIRO_FILTER_BILINEAR:
|
|
||||||
op->shader_function = _cairo_pattern_shader_linear;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CAIRO_STATUS_SUCCESS;
|
return CAIRO_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1004,7 +944,7 @@ _cairo_pattern_calc_color_at_pixel (cairo_shader_op_t *op,
|
||||||
factor = ((cairo_fixed_48_16_t) factor << 16) /
|
factor = ((cairo_fixed_48_16_t) factor << 16) /
|
||||||
stops[1]->scale;
|
stops[1]->scale;
|
||||||
|
|
||||||
op->shader_function (stops[0]->color_char,
|
_cairo_pattern_shader_linear (stops[0]->color_char,
|
||||||
stops[1]->color_char,
|
stops[1]->color_char,
|
||||||
factor, pixel);
|
factor, pixel);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue