[ps] Use a color_t rather than open-code.

Simplify the code by tracking the current solid color with a
cairo_color_t.
This commit is contained in:
Chris Wilson 2008-09-05 06:58:56 +01:00
parent 85ed37da33
commit d45b3168db
4 changed files with 21 additions and 30 deletions

View file

@ -72,10 +72,7 @@ typedef struct cairo_ps_surface {
cairo_bool_t use_string_datasource;
cairo_bool_t current_pattern_is_solid_color;
double current_color_red;
double current_color_green;
double current_color_blue;
double current_color_alpha;
cairo_color_t current_color;
int num_pages;

View file

@ -2818,10 +2818,7 @@ _cairo_ps_surface_emit_pattern (cairo_ps_surface_t *surface,
cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) pattern;
if (surface->current_pattern_is_solid_color == FALSE ||
surface->current_color_red != solid->color.red ||
surface->current_color_green != solid->color.green ||
surface->current_color_blue != solid->color.blue ||
surface->current_color_alpha != solid->color.alpha)
! _cairo_color_equal (&surface->current_color, &solid->color))
{
status = _cairo_pdf_operators_flush (&surface->pdf_operators);
if (status)
@ -2830,10 +2827,7 @@ _cairo_ps_surface_emit_pattern (cairo_ps_surface_t *surface,
_cairo_ps_surface_emit_solid_pattern (surface, (cairo_solid_pattern_t *) pattern);
surface->current_pattern_is_solid_color = TRUE;
surface->current_color_red = solid->color.red;
surface->current_color_green = solid->color.green;
surface->current_color_blue = solid->color.blue;
surface->current_color_alpha = solid->color.alpha;
surface->current_color = solid->color;
}
return CAIRO_STATUS_SUCCESS;

View file

@ -134,6 +134,24 @@ struct _cairo_cache {
int freeze_count;
};
/* XXX: Right now, the _cairo_color structure puts unpremultiplied
color in the doubles and premultiplied color in the shorts. Yes,
this is crazy insane, (but at least we don't export this
madness). I'm still working on a cleaner API, but in the meantime,
at least this does prevent precision loss in color when changing
alpha. */
struct _cairo_color {
double red;
double green;
double blue;
double alpha;
unsigned short red_short;
unsigned short green_short;
unsigned short blue_short;
unsigned short alpha_short;
};
typedef enum _cairo_paginated_mode {
CAIRO_PAGINATED_MODE_ANALYZE, /* analyze page regions */
CAIRO_PAGINATED_MODE_RENDER, /* render page contents */

View file

@ -818,24 +818,6 @@ struct _cairo_image_surface {
extern const cairo_private cairo_surface_backend_t _cairo_image_surface_backend;
/* XXX: Right now, the _cairo_color structure puts unpremultiplied
color in the doubles and premultiplied color in the shorts. Yes,
this is crazy insane, (but at least we don't export this
madness). I'm still working on a cleaner API, but in the meantime,
at least this does prevent precision loss in color when changing
alpha. */
struct _cairo_color {
double red;
double green;
double blue;
double alpha;
unsigned short red_short;
unsigned short green_short;
unsigned short blue_short;
unsigned short alpha_short;
};
#define CAIRO_EXTEND_SURFACE_DEFAULT CAIRO_EXTEND_NONE
#define CAIRO_EXTEND_GRADIENT_DEFAULT CAIRO_EXTEND_PAD
#define CAIRO_FILTER_DEFAULT CAIRO_FILTER_GOOD