Commit cd69dc94 authored by Christian Persch's avatar Christian Persch

Use cairo_operator_t directly

parent e39130e8
......@@ -70,66 +70,6 @@ _rsvg_cairo_set_text_antialias (cairo_t * cr, TextRenderingProperty aa)
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
}
static void
_rsvg_cairo_set_operator (cairo_t * cr, RsvgCompOpType comp_op)
{
cairo_operator_t op;
switch (comp_op) {
case RSVG_COMP_OP_CLEAR:
op = CAIRO_OPERATOR_CLEAR;
break;
case RSVG_COMP_OP_SRC:
op = CAIRO_OPERATOR_SOURCE;
break;
case RSVG_COMP_OP_DST:
op = CAIRO_OPERATOR_DEST;
break;
case RSVG_COMP_OP_DST_OVER:
op = CAIRO_OPERATOR_DEST_OVER;
break;
case RSVG_COMP_OP_SRC_IN:
op = CAIRO_OPERATOR_IN;
break;
case RSVG_COMP_OP_DST_IN:
op = CAIRO_OPERATOR_DEST_IN;
break;
case RSVG_COMP_OP_SRC_OUT:
op = CAIRO_OPERATOR_OUT;
break;
case RSVG_COMP_OP_DST_OUT:
op = CAIRO_OPERATOR_DEST_OUT;
break;
case RSVG_COMP_OP_SRC_ATOP:
op = CAIRO_OPERATOR_ATOP;
break;
case RSVG_COMP_OP_DST_ATOP:
op = CAIRO_OPERATOR_DEST_ATOP;
break;
case RSVG_COMP_OP_XOR:
op = CAIRO_OPERATOR_XOR;
break;
case RSVG_COMP_OP_PLUS:
op = CAIRO_OPERATOR_ADD;
break;
case RSVG_COMP_OP_MULTIPLY:
case RSVG_COMP_OP_SCREEN:
case RSVG_COMP_OP_OVERLAY:
case RSVG_COMP_OP_DARKEN:
case RSVG_COMP_OP_LIGHTEN:
case RSVG_COMP_OP_COLOR_DODGE:
case RSVG_COMP_OP_COLOR_BURN:
case RSVG_COMP_OP_HARD_LIGHT:
case RSVG_COMP_OP_SOFT_LIGHT:
case RSVG_COMP_OP_DIFFERENCE:
case RSVG_COMP_OP_EXCLUSION:
default:
op = CAIRO_OPERATOR_OVER;
break;
}
cairo_set_operator (cr, op);
}
static void
rsvg_pixmap_destroy (gchar * pixels, gpointer data)
{
......@@ -546,7 +486,7 @@ rsvg_cairo_render_path (RsvgDrawingCtx * ctx, const RsvgBpathDef * bpath_def)
need_tmpbuf = ((state->fill != NULL) && (state->stroke != NULL) && state->opacity != 0xff)
|| state->clip_path_ref || state->mask || state->filter
|| (state->comp_op != RSVG_COMP_OP_SRC_OVER);
|| (state->comp_op != CAIRO_OPERATOR_OVER);
if (need_tmpbuf)
rsvg_cairo_push_discrete_layer (ctx);
......@@ -755,7 +695,7 @@ rsvg_cairo_render_image (RsvgDrawingCtx * ctx, const GdkPixbuf * pixbuf,
cairo_pixels += 4 * width;
}
_rsvg_cairo_set_operator (render->cr, state->comp_op);
cairo_set_operator (render->cr, state->comp_op);
#if 1
cairo_set_source_surface (render->cr, surface, pixbuf_x, pixbuf_y);
......@@ -900,7 +840,7 @@ rsvg_cairo_push_render_stack (RsvgDrawingCtx * ctx)
lateclip = TRUE;
if (state->opacity == 0xFF
&& !state->filter && !state->mask && !lateclip && (state->comp_op == RSVG_COMP_OP_SRC_OVER)
&& !state->filter && !state->mask && !lateclip && (state->comp_op == CAIRO_OPERATOR_OVER)
&& (state->enable_background == RSVG_ENABLE_BACKGROUND_ACCUMULATE))
return;
if (!state->filter)
......@@ -970,7 +910,7 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx * ctx)
lateclip = TRUE;
if (state->opacity == 0xFF
&& !state->filter && !state->mask && !lateclip && (state->comp_op == RSVG_COMP_OP_SRC_OVER)
&& !state->filter && !state->mask && !lateclip && (state->comp_op == CAIRO_OPERATOR_OVER)
&& (state->enable_background == RSVG_ENABLE_BACKGROUND_ACCUMULATE))
return;
......@@ -1008,7 +948,7 @@ rsvg_cairo_pop_render_stack (RsvgDrawingCtx * ctx)
if (lateclip)
rsvg_cairo_clip (ctx, rsvg_current_state (ctx)->clip_path_ref, &render->bbox);
_rsvg_cairo_set_operator (render->cr, state->comp_op);
cairo_set_operator (render->cr, state->comp_op);
if (state->mask) {
rsvg_cairo_generate_mask (render->cr, state->mask, ctx, &render->bbox);
......
......@@ -97,7 +97,7 @@ rsvg_state_init (RsvgState * state)
state->fill_rule = FILL_RULE_NONZERO;
state->clip_rule = FILL_RULE_NONZERO;
state->enable_background = RSVG_ENABLE_BACKGROUND_ACCUMULATE;
state->comp_op = RSVG_COMP_OP_SRC_OVER;
state->comp_op = CAIRO_OPERATOR_OVER;
state->overflow = FALSE;
state->flood_color = 0;
state->flood_opacity = 255;
......@@ -492,55 +492,55 @@ rsvg_parse_style_pair (RsvgHandle * ctx,
state->enable_background = RSVG_ENABLE_BACKGROUND_ACCUMULATE;
} else if (g_str_equal (name, "comp-op")) {
if (g_str_equal (value, "clear"))
state->comp_op = RSVG_COMP_OP_CLEAR;
state->comp_op = CAIRO_OPERATOR_CLEAR;
else if (g_str_equal (value, "src"))
state->comp_op = RSVG_COMP_OP_SRC;
state->comp_op = CAIRO_OPERATOR_SOURCE;
else if (g_str_equal (value, "dst"))
state->comp_op = RSVG_COMP_OP_DST;
state->comp_op = CAIRO_OPERATOR_DEST;
else if (g_str_equal (value, "src-over"))
state->comp_op = RSVG_COMP_OP_SRC_OVER;
state->comp_op = CAIRO_OPERATOR_OVER;
else if (g_str_equal (value, "dst-over"))
state->comp_op = RSVG_COMP_OP_DST_OVER;
state->comp_op = CAIRO_OPERATOR_DEST_OVER;
else if (g_str_equal (value, "src-in"))
state->comp_op = RSVG_COMP_OP_SRC_IN;
state->comp_op = CAIRO_OPERATOR_IN;
else if (g_str_equal (value, "dst-in"))
state->comp_op = RSVG_COMP_OP_DST_IN;
state->comp_op = CAIRO_OPERATOR_DEST_IN;
else if (g_str_equal (value, "src-out"))
state->comp_op = RSVG_COMP_OP_SRC_OUT;
state->comp_op = CAIRO_OPERATOR_OUT;
else if (g_str_equal (value, "dst-out"))
state->comp_op = RSVG_COMP_OP_DST_OUT;
state->comp_op = CAIRO_OPERATOR_DEST_OUT;
else if (g_str_equal (value, "src-atop"))
state->comp_op = RSVG_COMP_OP_SRC_ATOP;
state->comp_op = CAIRO_OPERATOR_ATOP;
else if (g_str_equal (value, "dst-atop"))
state->comp_op = RSVG_COMP_OP_DST_ATOP;
state->comp_op = CAIRO_OPERATOR_DEST_ATOP;
else if (g_str_equal (value, "xor"))
state->comp_op = RSVG_COMP_OP_XOR;
state->comp_op = CAIRO_OPERATOR_XOR;
else if (g_str_equal (value, "plus"))
state->comp_op = RSVG_COMP_OP_PLUS;
state->comp_op = CAIRO_OPERATOR_ADD;
else if (g_str_equal (value, "multiply"))
state->comp_op = RSVG_COMP_OP_MULTIPLY;
state->comp_op = CAIRO_OPERATOR_MULTIPLY;
else if (g_str_equal (value, "screen"))
state->comp_op = RSVG_COMP_OP_SCREEN;
state->comp_op = CAIRO_OPERATOR_SCREEN;
else if (g_str_equal (value, "overlay"))
state->comp_op = RSVG_COMP_OP_OVERLAY;
state->comp_op = CAIRO_OPERATOR_OVERLAY;
else if (g_str_equal (value, "darken"))
state->comp_op = RSVG_COMP_OP_DARKEN;
state->comp_op = CAIRO_OPERATOR_DARKEN;
else if (g_str_equal (value, "lighten"))
state->comp_op = RSVG_COMP_OP_LIGHTEN;
state->comp_op = CAIRO_OPERATOR_LIGHTEN;
else if (g_str_equal (value, "color-dodge"))
state->comp_op = RSVG_COMP_OP_COLOR_DODGE;
state->comp_op = CAIRO_OPERATOR_COLOR_DODGE;
else if (g_str_equal (value, "color-burn"))
state->comp_op = RSVG_COMP_OP_COLOR_BURN;
state->comp_op = CAIRO_OPERATOR_COLOR_BURN;
else if (g_str_equal (value, "hard-light"))
state->comp_op = RSVG_COMP_OP_HARD_LIGHT;
state->comp_op = CAIRO_OPERATOR_HARD_LIGHT;
else if (g_str_equal (value, "soft-light"))
state->comp_op = RSVG_COMP_OP_SOFT_LIGHT;
state->comp_op = CAIRO_OPERATOR_SOFT_LIGHT;
else if (g_str_equal (value, "difference"))
state->comp_op = RSVG_COMP_OP_DIFFERENCE;
state->comp_op = CAIRO_OPERATOR_DIFFERENCE;
else if (g_str_equal (value, "exclusion"))
state->comp_op = RSVG_COMP_OP_EXCLUSION;
state->comp_op = CAIRO_OPERATOR_EXCLUSION;
else
state->comp_op = RSVG_COMP_OP_SRC_OVER;
state->comp_op = CAIRO_OPERATOR_OVER;
} else if (g_str_equal (name, "display")) {
state->has_visible = TRUE;
if (g_str_equal (value, "none"))
......
......@@ -27,6 +27,7 @@
#ifndef RSVG_STYLES_H
#define RSVG_STYLES_H
#include <cairo.h>
#include "rsvg.h"
#include "rsvg-paint-server.h"
......@@ -75,33 +76,6 @@ typedef enum {
TEXT_RENDERING_GEOMETRIC_PRECISION
} TextRenderingProperty;
typedef enum {
RSVG_COMP_OP_CLEAR,
RSVG_COMP_OP_SRC,
RSVG_COMP_OP_DST,
RSVG_COMP_OP_SRC_OVER,
RSVG_COMP_OP_DST_OVER,
RSVG_COMP_OP_SRC_IN,
RSVG_COMP_OP_DST_IN,
RSVG_COMP_OP_SRC_OUT,
RSVG_COMP_OP_DST_OUT,
RSVG_COMP_OP_SRC_ATOP,
RSVG_COMP_OP_DST_ATOP,
RSVG_COMP_OP_XOR,
RSVG_COMP_OP_PLUS,
RSVG_COMP_OP_MULTIPLY,
RSVG_COMP_OP_SCREEN,
RSVG_COMP_OP_OVERLAY,
RSVG_COMP_OP_DARKEN,
RSVG_COMP_OP_LIGHTEN,
RSVG_COMP_OP_COLOR_DODGE,
RSVG_COMP_OP_COLOR_BURN,
RSVG_COMP_OP_HARD_LIGHT,
RSVG_COMP_OP_SOFT_LIGHT,
RSVG_COMP_OP_DIFFERENCE,
RSVG_COMP_OP_EXCLUSION
} RsvgCompOpType;
typedef enum {
RSVG_ENABLE_BACKGROUND_ACCUMULATE,
RSVG_ENABLE_BACKGROUND_NEW
......@@ -229,7 +203,7 @@ struct _RsvgState {
gboolean has_middleMarker;
gboolean has_endMarker;
RsvgCompOpType comp_op;
cairo_operator_t comp_op;
RsvgEnableBackgroundType enable_background;
ShapeRenderingProperty shape_rendering_type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment