summaryrefslogtreecommitdiff
path: root/rsvg-mask.c
diff options
context:
space:
mode:
authorCaleb Michael Moore <cmoore@src.gnome.org>2005-02-23 16:04:50 +0000
committerCaleb Michael Moore <cmoore@src.gnome.org>2005-02-23 16:04:50 +0000
commit901e96e1650ddec60849358c153190b702be5eac (patch)
tree84d8523b77e2f13ab93e5d759533670629c94736 /rsvg-mask.c
parentcf83fe9985f8b6d4e9bb79e53be69b08a6ac7b61 (diff)
downloadlibrsvg-901e96e1650ddec60849358c153190b702be5eac.tar.gz
seperation and fixes
Diffstat (limited to 'rsvg-mask.c')
-rw-r--r--rsvg-mask.c218
1 files changed, 2 insertions, 216 deletions
diff --git a/rsvg-mask.c b/rsvg-mask.c
index 57912741..7f0346b3 100644
--- a/rsvg-mask.c
+++ b/rsvg-mask.c
@@ -25,12 +25,7 @@
#include "rsvg-private.h"
#include "rsvg-mask.h"
#include "rsvg-styles.h"
-#include "rsvg-art-draw.h"
-#include "rsvg-art-composite.h"
-#include "rsvg-art-render.h"
#include "rsvg-css.h"
-#include <libart_lgpl/art_rgba.h>
-#include <libart_lgpl/art_svp_ops.h>
#include <string.h>
static void
@@ -42,98 +37,16 @@ rsvg_mask_free (RsvgDefVal * self)
g_free (z);
}
-void
-rsvg_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, RsvgDrawingCtx *ctx)
-{
- art_u8 *tos_pixels, *nos_pixels, *mask_pixels;
- int width;
- int height;
- int rowstride;
- int x, y;
-
- GdkPixbuf *save, *mask;
- RsvgDefsDrawable *drawable;
-
- drawable = (RsvgDefsDrawable*)self;
-
- mask = _rsvg_pixbuf_new_cleared(GDK_COLORSPACE_RGB, 1, 8,
- gdk_pixbuf_get_width(tos),
- gdk_pixbuf_get_height(tos));
-
- save = ((RsvgArtRender *)ctx->render)->pixbuf;
- ((RsvgArtRender *)ctx->render)->pixbuf = mask;
-
- rsvg_state_push(ctx);
- rsvg_defs_drawable_draw (drawable, ctx, 0);
- rsvg_state_pop(ctx);
-
- ((RsvgArtRender *)ctx->render)->pixbuf = save;
-
- if (tos == NULL || nos == NULL)
- {
- /* FIXME: What warning/GError here? */
- return;
- }
-
- if (!gdk_pixbuf_get_has_alpha (nos))
- {
- g_warning (_("push/pop transparency group on non-alpha buffer nyi"));
- return;
- }
-
- width = gdk_pixbuf_get_width (tos);
- height = gdk_pixbuf_get_height (tos);
- rowstride = gdk_pixbuf_get_rowstride (tos);
-
- tos_pixels = gdk_pixbuf_get_pixels (tos);
- nos_pixels = gdk_pixbuf_get_pixels (nos);
- mask_pixels = gdk_pixbuf_get_pixels (mask);
-
- for (y = 0; y < height; y++)
- {
- for (x = 0; x < width; x++)
- {
- guchar r, g, b, rm, gm, bm, am;
- guint a;
- guint luminance;
- a = tos_pixels[4 * x + 3];
- if (a)
- {
- r = tos_pixels[4 * x];
- g = tos_pixels[4 * x + 1];
- b = tos_pixels[4 * x + 2];
-
- rm = mask_pixels[4 * x];
- gm = mask_pixels[4 * x + 1];
- bm = mask_pixels[4 * x + 2];
- am = mask_pixels[4 * x + 3];
-
- luminance = (rm * 2125 + gm * 7154 + bm * 0721) / 10000;
-
- a = a * luminance / 255 * am / 255;
-
- art_rgba_run_alpha (nos_pixels + 4 * x, r, g, b, a, 1);
- }
- }
- tos_pixels += rowstride;
- nos_pixels += rowstride;
- mask_pixels += rowstride;
- }
- g_object_unref (G_OBJECT (mask));
-}
-
static void
rsvg_defs_drawable_mask_draw (RsvgDefsDrawable * self, RsvgDrawingCtx *ctx,
int dominate)
{
- RsvgState *state = rsvg_state_current (ctx);
RsvgDefsDrawableGroup *group = (RsvgDefsDrawableGroup*)self;
guint i;
rsvg_state_reinherit_top(ctx, &self->state, 0);
- if (state->opacity != 0xff || state->filter)
- rsvg_push_discrete_layer (ctx);
+ rsvg_push_discrete_layer (ctx);
for (i = 0; i < group->children->len; i++)
{
@@ -145,8 +58,7 @@ rsvg_defs_drawable_mask_draw (RsvgDefsDrawable * self, RsvgDrawingCtx *ctx,
rsvg_state_pop(ctx);
}
- if (state->opacity != 0xff || state->filter)
- rsvg_pop_discrete_layer (ctx);
+ rsvg_pop_discrete_layer (ctx);
}
@@ -284,68 +196,6 @@ rsvg_clip_path_free (RsvgDefVal * self)
g_free (z);
}
-ArtSVP *
-rsvg_clip_path_render (RsvgClipPath * self, RsvgDrawingCtx *ctx)
-{
- RsvgState *state = rsvg_state_current (ctx);
- RsvgDefsDrawableGroup *group = (RsvgDefsDrawableGroup*)self;
- guint i;
-
- ArtSVP *svp, *svpx;
- svpx = NULL;
-
- rsvg_state_reinherit_top(ctx, &self->super.super.state, 0);
-
- if (self->units == objectBoundingBox)
- {
- state->affine[0] = ((RsvgArtRender *)ctx->render)->bbox.x1
- - ((RsvgArtRender *)ctx->render)->bbox.x0;
- state->affine[1] = 0;
- state->affine[2] = 0;
- state->affine[3] = ((RsvgArtRender *)ctx->render)->bbox.y1 -
- ((RsvgArtRender *)ctx->render)->bbox.y0;
- state->affine[4] = ((RsvgArtRender *)ctx->render)->bbox.x0;
- state->affine[5] = ((RsvgArtRender *)ctx->render)->bbox.y0;
- }
-
- for (i = 0; i < group->children->len; i++)
- {
- RsvgArtSVPRender * asvpr;
- RsvgRender * save;
- rsvg_state_push(ctx);
-
- asvpr = rsvg_art_svp_render_new();
- save = ctx->render;
- ctx->render = (RsvgRender *)asvpr;
-
- rsvg_defs_drawable_draw (g_ptr_array_index(group->children, i),
- ctx, 0);
-
- svp = asvpr->outline;
- /*todo, free the render*/
- ctx->render = save;
-
- if (svp != NULL)
- {
- if (svpx != NULL)
- {
- ArtSVP * svpn;
- svpn = art_svp_union(svpx, svp);
- art_free(svpx);
- art_free(svp);
- svpx = svpn;
- }
- else
- svpx = svp;
- }
-
- rsvg_state_pop(ctx);
- }
-
- return svpx;
-}
-
-
static RsvgClipPath *
rsvg_new_clip_path (void)
{
@@ -431,67 +281,3 @@ rsvg_clip_path_parse (const RsvgDefs * defs, const char *str)
}
return NULL;
}
-
-ArtSVP *
-rsvg_rect_clip_path(double x, double y, double w, double h, RsvgDrawingCtx * ctx)
-{
- RsvgArtSVPRender * asvpr;
- RsvgRender * save;
- GString * d = NULL;
- ArtSVP * output = NULL;
- char buf [G_ASCII_DTOSTR_BUF_SIZE];
-
- /* emulate a rect using a path */
- d = g_string_new ("M ");
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x));
- g_string_append_c (d, ' ');
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y));
-
- g_string_append (d, " H ");
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x + w));
-
- g_string_append (d, " V ");
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y+h));
-
- g_string_append (d, " H ");
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x));
-
- g_string_append (d, " V ");
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y));
-
- g_string_append (d, " Z");
-
- asvpr = rsvg_art_svp_render_new();
-
- save = ctx->render;
- ctx->render = (RsvgRender *)asvpr;
-
- asvpr->super.render_path(ctx, d->str);
-
- ctx->render = save;
-
- output = asvpr->outline;
- /* todo, free the render */
-
- g_string_free (d, TRUE);
- return output;
-}
-
-ArtSVP *
-rsvg_clip_path_merge(ArtSVP * first, ArtSVP * second, char operation)
-{
- ArtSVP * tmppath;
- if (first != NULL && second != NULL)
- {
- if (operation == 'i')
- tmppath = art_svp_intersect(first, second);
- else
- tmppath = art_svp_union(first, second);
- art_free(second);
- return tmppath;
- }
- else if (first != NULL)
- return first;
- else
- return second;
-}