[lasem] svg_filter: rename LsmFilterSurface to LsmSvgFilterSurface.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] svg_filter: rename LsmFilterSurface to LsmSvgFilterSurface.
- Date: Mon, 22 Oct 2012 13:50:39 +0000 (UTC)
commit 59f16e99c28c97700b13136a9434645d19333205
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Mon Oct 22 15:49:36 2012 +0200
svg_filter: rename LsmFilterSurface to LsmSvgFilterSurface.
Move code into its own source files.
docs/reference/lasem/Makefile.am | 3 +-
src/Makefile.am | 6 +-
src/lsmcairo.c | 430 -----------------------------------
src/lsmcairo.h | 32 ---
src/lsmsvgfiltersurface.c | 459 ++++++++++++++++++++++++++++++++++++++
src/lsmsvgfiltersurface.h | 66 ++++++
src/lsmsvgview.c | 87 ++++----
7 files changed, 575 insertions(+), 508 deletions(-)
---
diff --git a/docs/reference/lasem/Makefile.am b/docs/reference/lasem/Makefile.am
index f998752..2b750ea 100644
--- a/docs/reference/lasem/Makefile.am
+++ b/docs/reference/lasem/Makefile.am
@@ -155,7 +155,8 @@ IGNORE_HFILES=\
lsmsvgfiltermerge.h \
lsmsvgfiltermergenode.h \
lsmsvgfilterspecularlighting.h \
- lsmsvgfiltertile.h
+ lsmsvgfiltertile.h \
+ lsmsvgfiltersurface.h
# Images to copy into HTML directory.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
diff --git a/src/Makefile.am b/src/Makefile.am
index 198af3e..c27254e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -134,7 +134,8 @@ LASEM_SVG_SRCS = \
lsmsvgfiltermerge.c \
lsmsvgfiltermergenode.c \
lsmsvgfilterspecularlighting.c \
- lsmsvgfiltertile.c
+ lsmsvgfiltertile.c \
+ lsmsvgfiltersurface.c
LASEM_DOM_HDRS = \
lsm.h \
@@ -247,7 +248,8 @@ LASEM_SVG_HDRS = \
lsmsvgfiltermerge.h \
lsmsvgfiltermergenode.h \
lsmsvgfilterspecularlighting.h \
- lsmsvgfiltertile.h
+ lsmsvgfiltertile.h \
+ lsmsvgfiltersurface.h
liblasem_ LASEM_API_VERSION@_ladir = $(includedir)/lasem- LASEM_API_VERSION@
diff --git a/src/lsmcairo.c b/src/lsmcairo.c
index e39b880..15d2f37 100644
--- a/src/lsmcairo.c
+++ b/src/lsmcairo.c
@@ -29,435 +29,6 @@
#include <math.h>
#include <string.h>
-struct _LsmFilterSurface {
- char *name;
- cairo_surface_t *surface;
- LsmBox subregion;
-
- gint ref_count;
-};
-
-LsmFilterSurface *
-lsm_filter_surface_new (const char *name, unsigned int width, unsigned int height, const LsmBox *subregion)
-{
- LsmFilterSurface *filter_surface;
- cairo_surface_t *surface;
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
-
- filter_surface = lsm_filter_surface_new_with_content (name, surface, subregion);
-
- cairo_surface_destroy (surface);
-
- return filter_surface;
-}
-
-LsmFilterSurface *
-lsm_filter_surface_new_with_content (const char *name, cairo_surface_t *surface, const LsmBox *subregion)
-{
- LsmFilterSurface *filter_surface;
- LsmBox null_subregion = {0, 0, 0, 0};
-
- if (surface == NULL ||
- cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_IMAGE ||
- cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0);
- subregion = &null_subregion;
- } else if (subregion == NULL)
- subregion = &null_subregion;
-
- cairo_surface_reference (surface);
-
- filter_surface = g_new (LsmFilterSurface, 1);
- filter_surface->name = g_strdup (name);
- filter_surface->subregion = *subregion;
- filter_surface->surface = surface;
- filter_surface->ref_count = 1;
-
- return filter_surface;
-}
-
-LsmFilterSurface *
-lsm_filter_surface_new_similar (const char *name, LsmFilterSurface *model, const LsmBox *subregion)
-{
- if (model == NULL)
- return lsm_filter_surface_new (name, 0, 0, subregion);
-
- return lsm_filter_surface_new (name,
- cairo_image_surface_get_width (model->surface),
- cairo_image_surface_get_height (model->surface),
- subregion != NULL ? subregion : &model->subregion);
-}
-
-const char *
-lsm_filter_surface_get_name (LsmFilterSurface *surface)
-{
- g_return_val_if_fail (surface != NULL, NULL);
-
- return surface->name;
-}
-
-cairo_surface_t *
-lsm_filter_surface_get_cairo_surface (LsmFilterSurface *surface)
-{
- g_return_val_if_fail (surface != NULL, NULL);
-
- return surface->surface;
-}
-
-const LsmBox *
-lsm_filter_surface_get_subregion (LsmFilterSurface *surface)
-{
- static const LsmBox null_subregion = {0, 0, 0, 0};
-
- if (surface == NULL)
- return &null_subregion;
-
- return &surface->subregion;
-}
-
-LsmFilterSurface *
-lsm_filter_surface_ref (LsmFilterSurface *filter_surface)
-{
- g_return_val_if_fail (filter_surface != NULL, NULL);
-
- g_atomic_int_inc (&filter_surface->ref_count);
-
- return filter_surface;
-}
-
-void
-lsm_filter_surface_unref (LsmFilterSurface *filter_surface)
-{
- g_return_if_fail (filter_surface != NULL);
- g_return_if_fail (filter_surface->ref_count > 0);
-
- if (g_atomic_int_dec_and_test (&filter_surface->ref_count)) {
- cairo_surface_destroy (filter_surface->surface);
- g_free (filter_surface->name);
- g_free (filter_surface);
- }
-}
-
-G_DEFINE_BOXED_TYPE (LsmFilterSurface, lsm_filter_surface, lsm_filter_surface_ref, lsm_filter_surface_unref)
-
-static void
-box_blur (unsigned char *input_pixels,
- unsigned char *output_pixels,
- guchar * intermediate,
- gint kw, gint kh,
- int x1,
- int y1,
- int x2,
- int y2,
- int rowstride)
-{
- gint ch;
- gint x, y;
- gint sum;
-
- if (kw > x2 - x1)
- kw = x2 - x1;
-
- if (kh > y2 - y1)
- kh = y2 - y1;
-
-
- if (kw >= 1) {
- for (ch = 0; ch < 4; ch++) {
- for (y = y1; y < y2; y++) {
- sum = 0;
- for (x = x1; x < x1 + kw; x++) {
- sum += (intermediate[x % kw] = input_pixels[4 * x + y * rowstride + ch]);
-
- if (x - kw / 2 >= 0 && x - kw / 2 < x2)
- output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
- }
- for (x = x1 + kw; x < x2; x++) {
- sum -= intermediate[x % kw];
- sum += (intermediate[x % kw] = input_pixels[4 * x + y * rowstride + ch]);
- output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
- }
- for (x = x2; x < x2 + kw; x++) {
- sum -= intermediate[x % kw];
-
- if (x - kw / 2 >= 0 && x - kw / 2 < x2)
- output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
- }
- }
- }
- input_pixels = output_pixels;
- }
-
- if (kh >= 1) {
- for (ch = 0; ch < 4; ch++) {
- for (x = x1; x < x2; x++) {
- sum = 0;
-
- for (y = y1; y < y1 + kh; y++) {
- sum += (intermediate[y % kh] = input_pixels[4 * x + y * rowstride + ch]);
-
- if (y - kh / 2 >= 0 && y - kh / 2 < y2)
- output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
- }
- for (; y < y2; y++) {
- sum -= intermediate[y % kh];
- sum += (intermediate[y % kh] = input_pixels[4 * x + y * rowstride + ch]);
- output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
- }
- for (; y < y2 + kh; y++) {
- sum -= intermediate[y % kh];
-
- if (y - kh / 2 >= 0 && y - kh / 2 < y2)
- output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
- }
- }
- }
- }
-}
-
-void
-lsm_filter_surface_fast_blur (LsmFilterSurface *input,
- LsmFilterSurface *output,
- double sx, double sy)
-{
- int kx, ky;
- unsigned char *intermediate;
- int rowstride;
- int x1, y1, x2, y2;
- unsigned char *input_pixels;
- unsigned char *output_pixels;
- int width, height;
- cairo_surface_t *blur_surface;
- gboolean do_clip = FALSE;
-
- g_return_if_fail (input != NULL);
- g_return_if_fail (output != NULL);
-
- cairo_surface_flush (input->surface);
-
- /* Original intermediate surface size calculation was:
- *
- * kx = floor (sx * 3 * sqrt (2 * M_PI) / 4 + 0.5);
- * ky = floor (sy * 3 * sqrt (2 * M_PI) / 4 + 0.5);
- *
- * Which has the drawback to give a surface with even dimensions, leading
- * to a blur with a one pixel offset.
- * The new dimensions are now always odd.
- *
- * 0.94 = 3.0 * sqrt(2*M_PI) / 8.0
- */
-
- kx = round (sx * 0.94 - 0.5) * 2.0 + 1.5;
- ky = round (sy * 0.94 - 0.5) * 2.0 + 1.5;
-
- if (kx < 1 && ky < 1)
- return;
-
- rowstride = cairo_image_surface_get_stride (input->surface);
-
- width = cairo_image_surface_get_width (input->surface);
- height = cairo_image_surface_get_height (input->surface);
-
- if (input->subregion.x < output->subregion.x ||
- input->subregion.y < output->subregion.y ||
- input->subregion.width > output->subregion.width ||
- input->subregion.height > output->subregion.height) {
- do_clip = TRUE;
- blur_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
- } else
- blur_surface = output->surface;
-
- if (width != cairo_image_surface_get_width (output->surface) ||
- height != cairo_image_surface_get_height (output->surface))
- return;
-
- x1 = output->subregion.x - kx;
- y1 = output->subregion.y - ky;
- x2 = output->subregion.width + output->subregion.x + kx;
- y2 = output->subregion.height + output->subregion.y + ky;
- x1 = CLAMP (x1, 0, width);
- y1 = CLAMP (y1, 0, height);
- x2 = CLAMP (x2, x1, width);
- y2 = CLAMP (y2, y1, height);
-
- intermediate = g_new (guchar, MAX (kx, ky));
-
- input_pixels = cairo_image_surface_get_data (input->surface);
- output_pixels = cairo_image_surface_get_data (blur_surface);
-
- box_blur (input_pixels, output_pixels, intermediate, kx, ky, x1, y1, x2, y2, rowstride);
- box_blur (output_pixels, output_pixels, intermediate, kx, ky, x1, y1, x2, y2, rowstride);
- box_blur (output_pixels, output_pixels, intermediate, kx, ky, x1, y1, x2, y2, rowstride);
-
- g_free (intermediate);
-
- cairo_surface_mark_dirty (blur_surface);
-
- if (do_clip) {
- cairo_t *cairo;
-
- cairo = cairo_create (output->surface);
- cairo_rectangle (cairo,
- output->subregion.x, output->subregion.y,
- output->subregion.width, output->subregion.height);
- cairo_clip (cairo);
- cairo_set_source_surface (cairo, blur_surface, 0, 0);
- cairo_paint (cairo);
- cairo_surface_destroy (blur_surface);
- cairo_destroy (cairo);
- }
-}
-
-void
-lsm_filter_surface_flood (LsmFilterSurface *surface,
- double red,
- double green,
- double blue,
- double opacity)
-{
- cairo_t *cairo;
-
- g_return_if_fail (surface != NULL);
-
- cairo = cairo_create (surface->surface);
- cairo_rectangle (cairo, surface->subregion.x, surface->subregion.y, surface->subregion.width, surface->subregion.height);
- cairo_clip (cairo);
- cairo_set_source_rgba (cairo, red, green, blue, opacity);
- cairo_paint (cairo);
-}
-
-void
-lsm_filter_surface_blend (LsmFilterSurface *input_1,
- LsmFilterSurface *input_2,
- LsmFilterSurface *output,
- int blending_mode)
-{
- cairo_t *cairo;
- cairo_operator_t op;
-
- g_return_if_fail (input_1 != NULL);
- g_return_if_fail (input_2 != NULL);
- g_return_if_fail (output != NULL);
-
- switch (blending_mode) {
- case LSM_SVG_BLENDING_MODE_MULTIPLY:
- op = CAIRO_OPERATOR_MULTIPLY;
- break;
- case LSM_SVG_BLENDING_MODE_SCREEN:
- op = CAIRO_OPERATOR_SCREEN;
- break;
- case LSM_SVG_BLENDING_MODE_DARKEN:
- op = CAIRO_OPERATOR_DARKEN;
- break;
- case LSM_SVG_BLENDING_MODE_LIGHTEN:
- op = CAIRO_OPERATOR_LIGHTEN;
- break;
- case LSM_SVG_BLENDING_MODE_IN:
- op = CAIRO_OPERATOR_IN;
- break;
- case LSM_SVG_BLENDING_MODE_OUT:
- op = CAIRO_OPERATOR_OUT;
- break;
- case LSM_SVG_BLENDING_MODE_ATOP:
- op = CAIRO_OPERATOR_ATOP;
- break;
- case LSM_SVG_BLENDING_MODE_XOR:
- op = CAIRO_OPERATOR_XOR;
- break;
- default:
- op = CAIRO_OPERATOR_OVER;
- break;
- }
-
- cairo = cairo_create (output->surface);
- cairo_rectangle (cairo, output->subregion.x, output->subregion.y, output->subregion.width, output->subregion.height);
- cairo_clip (cairo);
- cairo_set_source_surface (cairo, input_2->surface, 0, 0);
- cairo_paint (cairo);
- cairo_set_source_surface (cairo, input_1->surface, 0, 0);
- cairo_set_operator (cairo, op);
- cairo_paint (cairo);
- cairo_destroy (cairo);
-}
-
-void
-lsm_filter_surface_offset (LsmFilterSurface *input,
- LsmFilterSurface *output,
- int dx, int dy)
-{
- cairo_t *cairo;
-
- g_return_if_fail (input != NULL);
- g_return_if_fail (output != NULL);
-
- cairo = cairo_create (output->surface);
- cairo_rectangle (cairo, output->subregion.x, output->subregion.y, output->subregion.width, output->subregion.height);
- cairo_clip (cairo);
- cairo_set_source_surface (cairo, input->surface, dx, dy);
- cairo_paint (cairo);
- cairo_destroy (cairo);
-}
-
-void
-lsm_filter_surface_merge (LsmFilterSurface *input,
- LsmFilterSurface *output)
-{
- cairo_t *cairo;
-
- g_return_if_fail (input != NULL);
- g_return_if_fail (output != NULL);
-
- cairo = cairo_create (output->surface);
- cairo_rectangle (cairo, output->subregion.x, output->subregion.y, output->subregion.width, output->subregion.height);
- cairo_clip (cairo);
- cairo_set_source_surface (cairo, input->surface, 0, 0);
- cairo_paint (cairo);
- cairo_destroy (cairo);
-}
-
-void
-lsm_filter_surface_tile (LsmFilterSurface *input, LsmFilterSurface *output)
-{
- cairo_t *cairo;
- cairo_surface_t *surface;
- cairo_pattern_t *pattern;
-
- g_return_if_fail (input != NULL);
- g_return_if_fail (output != NULL);
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, input->subregion.width, input->subregion.height);
- cairo = cairo_create (surface);
- cairo_set_source_surface (cairo, input->surface, input->subregion.x, input->subregion.y);
- cairo_paint (cairo);
- cairo_destroy (cairo);
-
- cairo = cairo_create (output->surface);
- cairo_rectangle (cairo, output->subregion.x, output->subregion.y, output->subregion.width, output->subregion.height);
- cairo_clip (cairo);
- cairo_set_source_surface (cairo, surface, 0, 0);
- pattern = cairo_get_source (cairo);
- cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
- cairo_paint (cairo);
- cairo_destroy (cairo);
- cairo_surface_destroy (surface);
-}
-
-void
-lsm_filter_surface_alpha (LsmFilterSurface *input, LsmFilterSurface *output)
-{
- cairo_t *cairo;
-
- g_return_if_fail (input != NULL);
- g_return_if_fail (output != NULL);
-
- cairo = cairo_create (output->surface);
- cairo_set_source_rgb (cairo, 0, 0, 0);
- cairo_mask_surface (cairo, input->surface, 0, 0);
-
- cairo_destroy (cairo);
-}
-
void
lsm_cairo_box_user_to_device (cairo_t *cairo, LsmBox *to, const LsmBox *from)
{
@@ -602,4 +173,3 @@ lsm_cairo_set_source_pixbuf (cairo_t *cairo,
cairo_set_source_surface (cairo, surface, pixbuf_x, pixbuf_y);
cairo_surface_destroy (surface);
}
-
diff --git a/src/lsmcairo.h b/src/lsmcairo.h
index 44f5332..6df3363 100644
--- a/src/lsmcairo.h
+++ b/src/lsmcairo.h
@@ -30,42 +30,10 @@
G_BEGIN_DECLS
-typedef struct _LsmFilterSurface LsmFilterSurface;
-
-#define LSM_TYPE_FILTER_SURFACE (lsm_filter_surface_get_type())
-
-GType lsm_filter_surface_get_type (void);
-
-LsmFilterSurface * lsm_filter_surface_new (const char *name, unsigned int width, unsigned int height,
- const LsmBox *subregion);
-LsmFilterSurface * lsm_filter_surface_new_with_content (const char *name, cairo_surface_t *surface, const LsmBox *subregion);
-LsmFilterSurface * lsm_filter_surface_new_similar (const char *name, LsmFilterSurface *model, const LsmBox *subregion);
-
-void lsm_filter_surface_copy_data (LsmFilterSurface *to, LsmFilterSurface *from);
-const char * lsm_filter_surface_get_name (LsmFilterSurface *surface);
-cairo_surface_t * lsm_filter_surface_get_cairo_surface (LsmFilterSurface *surface);
-const LsmBox * lsm_filter_surface_get_subregion (LsmFilterSurface *surface);
-void lsm_filter_surface_unref (LsmFilterSurface *filter_surface);
-LsmFilterSurface * lsm_filter_surface_ref (LsmFilterSurface *filter_surface);
-
-void lsm_filter_surface_alpha (LsmFilterSurface *input, LsmFilterSurface *output);
-void lsm_filter_surface_blend (LsmFilterSurface *input_1,
- LsmFilterSurface *input_2,
- LsmFilterSurface *output,
- int blending_mode);
-void lsm_filter_surface_fast_blur (LsmFilterSurface *input, LsmFilterSurface *output, double sx, double sy);
-void lsm_filter_surface_flood (LsmFilterSurface *surface,
- double red, double green, double blue, double opacity);
-void lsm_filter_surface_offset (LsmFilterSurface *input, LsmFilterSurface *output,
- int dx, int dy);
-void lsm_filter_surface_merge (LsmFilterSurface *input, LsmFilterSurface *output);
-void lsm_filter_surface_tile (LsmFilterSurface *input, LsmFilterSurface *output);
-
void lsm_cairo_box_user_to_device (cairo_t *cairo, LsmBox *to, const LsmBox *from);
void lsm_cairo_box_device_to_user (cairo_t *cairo, LsmBox *to, const LsmBox *from);
void lsm_cairo_set_source_pixbuf (cairo_t *cairo, const GdkPixbuf *pixbuf,
double pixbuf_x, double pixbuf_y);
-
G_END_DECLS
#endif
diff --git a/src/lsmsvgfiltersurface.c b/src/lsmsvgfiltersurface.c
new file mode 100644
index 0000000..5570b2d
--- /dev/null
+++ b/src/lsmsvgfiltersurface.c
@@ -0,0 +1,459 @@
+/* Lasem
+ *
+ * Copyright  2004 Caleb Moore
+ * Copyright  2012 Emmanuel Pacaud
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Caleb Moore <c moore student unsw edu au>
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <lsmsvgfiltersurface.h>
+#include <lsmsvgenums.h>
+#include <lsmutils.h>
+#include <math.h>
+#include <string.h>
+
+struct _LsmSvgFilterSurface {
+ char *name;
+ cairo_surface_t *surface;
+ LsmBox subregion;
+
+ gint ref_count;
+};
+
+LsmSvgFilterSurface *
+lsm_svg_filter_surface_new (const char *name, unsigned int width, unsigned int height, const LsmBox *subregion)
+{
+ LsmSvgFilterSurface *filter_surface;
+ cairo_surface_t *surface;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+
+ filter_surface = lsm_svg_filter_surface_new_with_content (name, surface, subregion);
+
+ cairo_surface_destroy (surface);
+
+ return filter_surface;
+}
+
+LsmSvgFilterSurface *
+lsm_svg_filter_surface_new_with_content (const char *name, cairo_surface_t *surface, const LsmBox *subregion)
+{
+ LsmSvgFilterSurface *filter_surface;
+ LsmBox null_subregion = {0, 0, 0, 0};
+
+ if (surface == NULL ||
+ cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_IMAGE ||
+ cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0);
+ subregion = &null_subregion;
+ } else if (subregion == NULL)
+ subregion = &null_subregion;
+
+ cairo_surface_reference (surface);
+
+ filter_surface = g_new (LsmSvgFilterSurface, 1);
+ filter_surface->name = g_strdup (name);
+ filter_surface->subregion = *subregion;
+ filter_surface->surface = surface;
+ filter_surface->ref_count = 1;
+
+ return filter_surface;
+}
+
+LsmSvgFilterSurface *
+lsm_svg_filter_surface_new_similar (const char *name, LsmSvgFilterSurface *model, const LsmBox *subregion)
+{
+ if (model == NULL)
+ return lsm_svg_filter_surface_new (name, 0, 0, subregion);
+
+ return lsm_svg_filter_surface_new (name,
+ cairo_image_surface_get_width (model->surface),
+ cairo_image_surface_get_height (model->surface),
+ subregion != NULL ? subregion : &model->subregion);
+}
+
+const char *
+lsm_svg_filter_surface_get_name (LsmSvgFilterSurface *surface)
+{
+ g_return_val_if_fail (surface != NULL, NULL);
+
+ return surface->name;
+}
+
+cairo_surface_t *
+lsm_svg_filter_surface_get_cairo_surface (LsmSvgFilterSurface *surface)
+{
+ g_return_val_if_fail (surface != NULL, NULL);
+
+ return surface->surface;
+}
+
+const LsmBox *
+lsm_svg_filter_surface_get_subregion (LsmSvgFilterSurface *surface)
+{
+ static const LsmBox null_subregion = {0, 0, 0, 0};
+
+ if (surface == NULL)
+ return &null_subregion;
+
+ return &surface->subregion;
+}
+
+LsmSvgFilterSurface *
+lsm_svg_filter_surface_ref (LsmSvgFilterSurface *filter_surface)
+{
+ g_return_val_if_fail (filter_surface != NULL, NULL);
+
+ g_atomic_int_inc (&filter_surface->ref_count);
+
+ return filter_surface;
+}
+
+void
+lsm_svg_filter_surface_unref (LsmSvgFilterSurface *filter_surface)
+{
+ g_return_if_fail (filter_surface != NULL);
+ g_return_if_fail (filter_surface->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&filter_surface->ref_count)) {
+ cairo_surface_destroy (filter_surface->surface);
+ g_free (filter_surface->name);
+ g_free (filter_surface);
+ }
+}
+
+G_DEFINE_BOXED_TYPE (LsmSvgFilterSurface, lsm_svg_filter_surface, lsm_svg_filter_surface_ref, lsm_svg_filter_surface_unref)
+
+static void
+box_blur (unsigned char *input_pixels,
+ unsigned char *output_pixels,
+ guchar * intermediate,
+ gint kw, gint kh,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ int rowstride)
+{
+ gint ch;
+ gint x, y;
+ gint sum;
+
+ if (kw > x2 - x1)
+ kw = x2 - x1;
+
+ if (kh > y2 - y1)
+ kh = y2 - y1;
+
+
+ if (kw >= 1) {
+ for (ch = 0; ch < 4; ch++) {
+ for (y = y1; y < y2; y++) {
+ sum = 0;
+ for (x = x1; x < x1 + kw; x++) {
+ sum += (intermediate[x % kw] = input_pixels[4 * x + y * rowstride + ch]);
+
+ if (x - kw / 2 >= 0 && x - kw / 2 < x2)
+ output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
+ }
+ for (x = x1 + kw; x < x2; x++) {
+ sum -= intermediate[x % kw];
+ sum += (intermediate[x % kw] = input_pixels[4 * x + y * rowstride + ch]);
+ output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
+ }
+ for (x = x2; x < x2 + kw; x++) {
+ sum -= intermediate[x % kw];
+
+ if (x - kw / 2 >= 0 && x - kw / 2 < x2)
+ output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
+ }
+ }
+ }
+ input_pixels = output_pixels;
+ }
+
+ if (kh >= 1) {
+ for (ch = 0; ch < 4; ch++) {
+ for (x = x1; x < x2; x++) {
+ sum = 0;
+
+ for (y = y1; y < y1 + kh; y++) {
+ sum += (intermediate[y % kh] = input_pixels[4 * x + y * rowstride + ch]);
+
+ if (y - kh / 2 >= 0 && y - kh / 2 < y2)
+ output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
+ }
+ for (; y < y2; y++) {
+ sum -= intermediate[y % kh];
+ sum += (intermediate[y % kh] = input_pixels[4 * x + y * rowstride + ch]);
+ output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
+ }
+ for (; y < y2 + kh; y++) {
+ sum -= intermediate[y % kh];
+
+ if (y - kh / 2 >= 0 && y - kh / 2 < y2)
+ output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
+ }
+ }
+ }
+ }
+}
+
+void
+lsm_svg_filter_surface_fast_blur (LsmSvgFilterSurface *input,
+ LsmSvgFilterSurface *output,
+ double sx, double sy)
+{
+ int kx, ky;
+ unsigned char *intermediate;
+ int rowstride;
+ int x1, y1, x2, y2;
+ unsigned char *input_pixels;
+ unsigned char *output_pixels;
+ int width, height;
+ cairo_surface_t *blur_surface;
+ gboolean do_clip = FALSE;
+
+ g_return_if_fail (input != NULL);
+ g_return_if_fail (output != NULL);
+
+ cairo_surface_flush (input->surface);
+
+ /* Original intermediate surface size calculation was:
+ *
+ * kx = floor (sx * 3 * sqrt (2 * M_PI) / 4 + 0.5);
+ * ky = floor (sy * 3 * sqrt (2 * M_PI) / 4 + 0.5);
+ *
+ * Which has the drawback to give a surface with even dimensions, leading
+ * to a blur with a one pixel offset.
+ * The new dimensions are now always odd.
+ *
+ * 0.94 = 3.0 * sqrt(2*M_PI) / 8.0
+ */
+
+ kx = round (sx * 0.94 - 0.5) * 2.0 + 1.5;
+ ky = round (sy * 0.94 - 0.5) * 2.0 + 1.5;
+
+ if (kx < 1 && ky < 1)
+ return;
+
+ rowstride = cairo_image_surface_get_stride (input->surface);
+
+ width = cairo_image_surface_get_width (input->surface);
+ height = cairo_image_surface_get_height (input->surface);
+
+ if (input->subregion.x < output->subregion.x ||
+ input->subregion.y < output->subregion.y ||
+ input->subregion.width > output->subregion.width ||
+ input->subregion.height > output->subregion.height) {
+ do_clip = TRUE;
+ blur_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ } else
+ blur_surface = output->surface;
+
+ if (width != cairo_image_surface_get_width (output->surface) ||
+ height != cairo_image_surface_get_height (output->surface))
+ return;
+
+ x1 = output->subregion.x - kx;
+ y1 = output->subregion.y - ky;
+ x2 = output->subregion.width + output->subregion.x + kx;
+ y2 = output->subregion.height + output->subregion.y + ky;
+ x1 = CLAMP (x1, 0, width);
+ y1 = CLAMP (y1, 0, height);
+ x2 = CLAMP (x2, x1, width);
+ y2 = CLAMP (y2, y1, height);
+
+ intermediate = g_new (guchar, MAX (kx, ky));
+
+ input_pixels = cairo_image_surface_get_data (input->surface);
+ output_pixels = cairo_image_surface_get_data (blur_surface);
+
+ box_blur (input_pixels, output_pixels, intermediate, kx, ky, x1, y1, x2, y2, rowstride);
+ box_blur (output_pixels, output_pixels, intermediate, kx, ky, x1, y1, x2, y2, rowstride);
+ box_blur (output_pixels, output_pixels, intermediate, kx, ky, x1, y1, x2, y2, rowstride);
+
+ g_free (intermediate);
+
+ cairo_surface_mark_dirty (blur_surface);
+
+ if (do_clip) {
+ cairo_t *cairo;
+
+ cairo = cairo_create (output->surface);
+ cairo_rectangle (cairo,
+ output->subregion.x, output->subregion.y,
+ output->subregion.width, output->subregion.height);
+ cairo_clip (cairo);
+ cairo_set_source_surface (cairo, blur_surface, 0, 0);
+ cairo_paint (cairo);
+ cairo_surface_destroy (blur_surface);
+ cairo_destroy (cairo);
+ }
+}
+
+void
+lsm_svg_filter_surface_flood (LsmSvgFilterSurface *surface,
+ double red,
+ double green,
+ double blue,
+ double opacity)
+{
+ cairo_t *cairo;
+
+ g_return_if_fail (surface != NULL);
+
+ cairo = cairo_create (surface->surface);
+ cairo_rectangle (cairo, surface->subregion.x, surface->subregion.y, surface->subregion.width, surface->subregion.height);
+ cairo_clip (cairo);
+ cairo_set_source_rgba (cairo, red, green, blue, opacity);
+ cairo_paint (cairo);
+}
+
+void
+lsm_svg_filter_surface_blend (LsmSvgFilterSurface *input_1,
+ LsmSvgFilterSurface *input_2,
+ LsmSvgFilterSurface *output,
+ int blending_mode)
+{
+ cairo_t *cairo;
+ cairo_operator_t op;
+
+ g_return_if_fail (input_1 != NULL);
+ g_return_if_fail (input_2 != NULL);
+ g_return_if_fail (output != NULL);
+
+ switch (blending_mode) {
+ case LSM_SVG_BLENDING_MODE_MULTIPLY:
+ op = CAIRO_OPERATOR_MULTIPLY;
+ break;
+ case LSM_SVG_BLENDING_MODE_SCREEN:
+ op = CAIRO_OPERATOR_SCREEN;
+ break;
+ case LSM_SVG_BLENDING_MODE_DARKEN:
+ op = CAIRO_OPERATOR_DARKEN;
+ break;
+ case LSM_SVG_BLENDING_MODE_LIGHTEN:
+ op = CAIRO_OPERATOR_LIGHTEN;
+ break;
+ case LSM_SVG_BLENDING_MODE_IN:
+ op = CAIRO_OPERATOR_IN;
+ break;
+ case LSM_SVG_BLENDING_MODE_OUT:
+ op = CAIRO_OPERATOR_OUT;
+ break;
+ case LSM_SVG_BLENDING_MODE_ATOP:
+ op = CAIRO_OPERATOR_ATOP;
+ break;
+ case LSM_SVG_BLENDING_MODE_XOR:
+ op = CAIRO_OPERATOR_XOR;
+ break;
+ default:
+ op = CAIRO_OPERATOR_OVER;
+ break;
+ }
+
+ cairo = cairo_create (output->surface);
+ cairo_rectangle (cairo, output->subregion.x, output->subregion.y, output->subregion.width, output->subregion.height);
+ cairo_clip (cairo);
+ cairo_set_source_surface (cairo, input_2->surface, 0, 0);
+ cairo_paint (cairo);
+ cairo_set_source_surface (cairo, input_1->surface, 0, 0);
+ cairo_set_operator (cairo, op);
+ cairo_paint (cairo);
+ cairo_destroy (cairo);
+}
+
+void
+lsm_svg_filter_surface_offset (LsmSvgFilterSurface *input,
+ LsmSvgFilterSurface *output,
+ int dx, int dy)
+{
+ cairo_t *cairo;
+
+ g_return_if_fail (input != NULL);
+ g_return_if_fail (output != NULL);
+
+ cairo = cairo_create (output->surface);
+ cairo_rectangle (cairo, output->subregion.x, output->subregion.y, output->subregion.width, output->subregion.height);
+ cairo_clip (cairo);
+ cairo_set_source_surface (cairo, input->surface, dx, dy);
+ cairo_paint (cairo);
+ cairo_destroy (cairo);
+}
+
+void
+lsm_svg_filter_surface_merge (LsmSvgFilterSurface *input,
+ LsmSvgFilterSurface *output)
+{
+ cairo_t *cairo;
+
+ g_return_if_fail (input != NULL);
+ g_return_if_fail (output != NULL);
+
+ cairo = cairo_create (output->surface);
+ cairo_rectangle (cairo, output->subregion.x, output->subregion.y, output->subregion.width, output->subregion.height);
+ cairo_clip (cairo);
+ cairo_set_source_surface (cairo, input->surface, 0, 0);
+ cairo_paint (cairo);
+ cairo_destroy (cairo);
+}
+
+void
+lsm_svg_filter_surface_tile (LsmSvgFilterSurface *input, LsmSvgFilterSurface *output)
+{
+ cairo_t *cairo;
+ cairo_surface_t *surface;
+ cairo_pattern_t *pattern;
+
+ g_return_if_fail (input != NULL);
+ g_return_if_fail (output != NULL);
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, input->subregion.width, input->subregion.height);
+ cairo = cairo_create (surface);
+ cairo_set_source_surface (cairo, input->surface, input->subregion.x, input->subregion.y);
+ cairo_paint (cairo);
+ cairo_destroy (cairo);
+
+ cairo = cairo_create (output->surface);
+ cairo_rectangle (cairo, output->subregion.x, output->subregion.y, output->subregion.width, output->subregion.height);
+ cairo_clip (cairo);
+ cairo_set_source_surface (cairo, surface, 0, 0);
+ pattern = cairo_get_source (cairo);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+ cairo_paint (cairo);
+ cairo_destroy (cairo);
+ cairo_surface_destroy (surface);
+}
+
+void
+lsm_svg_filter_surface_alpha (LsmSvgFilterSurface *input, LsmSvgFilterSurface *output)
+{
+ cairo_t *cairo;
+
+ g_return_if_fail (input != NULL);
+ g_return_if_fail (output != NULL);
+
+ cairo = cairo_create (output->surface);
+ cairo_set_source_rgb (cairo, 0, 0, 0);
+ cairo_mask_surface (cairo, input->surface, 0, 0);
+
+ cairo_destroy (cairo);
+}
diff --git a/src/lsmsvgfiltersurface.h b/src/lsmsvgfiltersurface.h
new file mode 100644
index 0000000..6323944
--- /dev/null
+++ b/src/lsmsvgfiltersurface.h
@@ -0,0 +1,66 @@
+/* Lasem
+ *
+ * Copyright  2012 Emmanuel Pacaud
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef LSM_SVG_FILTER_SURFACE_H
+#define LSM_SVG_FILTER_SURFACE_H
+
+#include <lsmtypes.h>
+#include <cairo.h>
+
+G_BEGIN_DECLS
+
+typedef struct _LsmSvgFilterSurface LsmSvgFilterSurface;
+
+#define LSM_TYPE_FILTER_SURFACE (lsm_svg_filter_surface_get_type())
+
+GType lsm_svg_filter_surface_get_type (void);
+
+LsmSvgFilterSurface * lsm_svg_filter_surface_new (const char *name, unsigned int width, unsigned int height,
+ const LsmBox *subregion);
+LsmSvgFilterSurface * lsm_svg_filter_surface_new_with_content (const char *name, cairo_surface_t *surface, const LsmBox *subregion);
+LsmSvgFilterSurface * lsm_svg_filter_surface_new_similar (const char *name, LsmSvgFilterSurface *model, const LsmBox *subregion);
+
+void lsm_svg_filter_surface_copy_data (LsmSvgFilterSurface *to, LsmSvgFilterSurface *from);
+const char * lsm_svg_filter_surface_get_name (LsmSvgFilterSurface *surface);
+cairo_surface_t * lsm_svg_filter_surface_get_cairo_surface(LsmSvgFilterSurface *surface);
+const LsmBox * lsm_svg_filter_surface_get_subregion (LsmSvgFilterSurface *surface);
+void lsm_svg_filter_surface_unref (LsmSvgFilterSurface *filter_surface);
+LsmSvgFilterSurface * lsm_svg_filter_surface_ref (LsmSvgFilterSurface *filter_surface);
+
+void lsm_svg_filter_surface_alpha (LsmSvgFilterSurface *input, LsmSvgFilterSurface *output);
+void lsm_svg_filter_surface_blend (LsmSvgFilterSurface *input_1,
+ LsmSvgFilterSurface *input_2,
+ LsmSvgFilterSurface *output,
+ int blending_mode);
+void lsm_svg_filter_surface_fast_blur (LsmSvgFilterSurface *input, LsmSvgFilterSurface *output,
+ double sx, double sy);
+void lsm_svg_filter_surface_flood (LsmSvgFilterSurface *surface,
+ double red, double green, double blue, double opacity);
+void lsm_svg_filter_surface_offset (LsmSvgFilterSurface *input, LsmSvgFilterSurface *output,
+ int dx, int dy);
+void lsm_svg_filter_surface_merge (LsmSvgFilterSurface *input, LsmSvgFilterSurface *output);
+void lsm_svg_filter_surface_tile (LsmSvgFilterSurface *input, LsmSvgFilterSurface *output);
+
+G_END_DECLS
+
+#endif
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index f06ca16..8b22f2b 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -33,6 +33,7 @@
#include <lsmsvgmarkerelement.h>
#include <lsmsvgclippathelement.h>
#include <lsmsvgmaskelement.h>
+#include <lsmsvgfiltersurface.h>
#include <lsmcairo.h>
#include <lsmstr.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -1962,7 +1963,7 @@ void
lsm_svg_view_pop_filter (LsmSvgView *view)
{
LsmSvgElement *filter_element;
- LsmFilterSurface *filter_surface;
+ LsmSvgFilterSurface *filter_surface;
cairo_surface_t *surface;
GSList *iter;
@@ -1985,7 +1986,7 @@ lsm_svg_view_pop_filter (LsmSvgView *view)
subregion.width = cairo_image_surface_get_width (surface);
subregion.height = cairo_image_surface_get_height (surface);
- filter_surface = lsm_filter_surface_new_with_content ("SourceGraphic", surface, &subregion);
+ filter_surface = lsm_svg_filter_surface_new_with_content ("SourceGraphic", surface, &subregion);
cairo_pattern_get_matrix (view->pattern_data->pattern, &matrix);
view->filter_surfaces = g_slist_prepend (view->filter_surfaces, filter_surface);
@@ -1998,12 +1999,12 @@ lsm_svg_view_pop_filter (LsmSvgView *view)
static int count = 0;
for (iter = view->filter_surfaces; iter != NULL; iter = iter->next) {
- LsmFilterSurface *surface = iter->data;
+ LsmSvgFilterSurface *surface = iter->data;
filename = g_strdup_printf ("filter-%04d-%s-%s.png", count++,
view->style->filter->value,
- lsm_filter_surface_get_name (surface));
- cairo_surface_write_to_png (lsm_filter_surface_get_cairo_surface (surface), filename);
+ lsm_svg_filter_surface_get_name (surface));
+ cairo_surface_write_to_png (lsm_svg_filter_surface_get_cairo_surface (surface), filename);
g_free (filename);
}
}
@@ -2012,7 +2013,7 @@ lsm_svg_view_pop_filter (LsmSvgView *view)
cairo_pattern_t *pattern;
cairo_surface_t *surface;
- surface = lsm_filter_surface_get_cairo_surface (view->filter_surfaces->data);
+ surface = lsm_svg_filter_surface_get_cairo_surface (view->filter_surfaces->data);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE);
cairo_pattern_set_matrix (pattern, &matrix);
@@ -2021,7 +2022,7 @@ lsm_svg_view_pop_filter (LsmSvgView *view)
}
for (iter = view->filter_surfaces; iter != NULL; iter = iter->next)
- lsm_filter_surface_unref (iter->data);
+ lsm_svg_filter_surface_unref (iter->data);
g_slist_free (view->filter_surfaces);
view->filter_surfaces = NULL;
}
@@ -2029,59 +2030,59 @@ lsm_svg_view_pop_filter (LsmSvgView *view)
_end_pattern (view);
}
-static LsmFilterSurface *
+static LsmSvgFilterSurface *
_get_filter_surface (LsmSvgView *view, const char *input)
{
GSList *iter;
- LsmFilterSurface *source_surface = NULL;
+ LsmSvgFilterSurface *source_surface = NULL;
if (input == NULL)
return view->filter_surfaces->data;
for (iter = view->filter_surfaces; iter != NULL; iter = iter->next) {
- LsmFilterSurface *surface = iter->data;
+ LsmSvgFilterSurface *surface = iter->data;
- if (g_strcmp0 (input, lsm_filter_surface_get_name (surface)) == 0)
+ if (g_strcmp0 (input, lsm_svg_filter_surface_get_name (surface)) == 0)
return surface;
source_surface = surface;
}
if (g_strcmp0 (input, "SourceAlpha") == 0 && source_surface != NULL) {
- LsmFilterSurface *surface;
+ LsmSvgFilterSurface *surface;
- surface = lsm_filter_surface_new_similar ("SourceAlpha", source_surface, NULL);
- lsm_filter_surface_alpha (source_surface, surface);
+ surface = lsm_svg_filter_surface_new_similar ("SourceAlpha", source_surface, NULL);
+ lsm_svg_filter_surface_alpha (source_surface, surface);
view->filter_surfaces = g_slist_prepend (view->filter_surfaces, surface);
return surface;
} else if (g_strcmp0 (input, "BackgroundImage") == 0) {
/* TODO */
- LsmFilterSurface *surface;
+ LsmSvgFilterSurface *surface;
lsm_warning_render ("LsmSvgView::get_filter_surface] BackgroundImage is not yet implemented");
- surface = lsm_filter_surface_new_similar ("BackgroundImage", source_surface, NULL);
+ surface = lsm_svg_filter_surface_new_similar ("BackgroundImage", source_surface, NULL);
view->filter_surfaces = g_slist_prepend (view->filter_surfaces, surface);
} else if (g_strcmp0 (input, "BackgroundAlpha") == 0) {
/* TODO */
- LsmFilterSurface *surface;
+ LsmSvgFilterSurface *surface;
lsm_warning_render ("LsmSvgView::get_filter_surface] BackgroundAlpha is not yet implemented");
- surface = lsm_filter_surface_new_similar ("BackgroundAlpha", source_surface, NULL);
+ surface = lsm_svg_filter_surface_new_similar ("BackgroundAlpha", source_surface, NULL);
view->filter_surfaces = g_slist_prepend (view->filter_surfaces, surface);
}
return NULL;
}
-static LsmFilterSurface *
-_create_filter_surface (LsmSvgView *view, const char *output, LsmFilterSurface *input_surface, const LsmBox *subregion)
+static LsmSvgFilterSurface *
+_create_filter_surface (LsmSvgView *view, const char *output, LsmSvgFilterSurface *input_surface, const LsmBox *subregion)
{
- LsmFilterSurface *surface;
+ LsmSvgFilterSurface *surface;
- surface = lsm_filter_surface_new_similar (output, input_surface, subregion);
+ surface = lsm_svg_filter_surface_new_similar (output, input_surface, subregion);
view->filter_surfaces = g_slist_prepend (view->filter_surfaces, surface);
@@ -2092,7 +2093,7 @@ LsmBox
lsm_svg_view_get_filter_surface_extents (LsmSvgView *view, const char *name)
{
static LsmBox null_extents = {.x = 0.0, .y = 0.0, .width = 0.0, .height = 0.0};
- LsmFilterSurface *surface;
+ LsmSvgFilterSurface *surface;
LsmBox extents;
g_return_val_if_fail (LSM_IS_SVG_VIEW (view), null_extents);
@@ -2101,7 +2102,7 @@ lsm_svg_view_get_filter_surface_extents (LsmSvgView *view, const char *name)
if (surface == NULL)
return null_extents;
- lsm_cairo_box_device_to_user (view->dom_view.cairo, &extents, lsm_filter_surface_get_subregion (surface));
+ lsm_cairo_box_device_to_user (view->dom_view.cairo, &extents, lsm_svg_filter_surface_get_subregion (surface));
return extents;
}
@@ -2110,9 +2111,9 @@ void
lsm_svg_view_apply_blend (LsmSvgView *view, const char *input_1, const char*input_2, const char *output,
const LsmBox *subregion, LsmSvgBlendingMode mode)
{
- LsmFilterSurface *output_surface;
- LsmFilterSurface *input_1_surface;
- LsmFilterSurface *input_2_surface;
+ LsmSvgFilterSurface *output_surface;
+ LsmSvgFilterSurface *input_1_surface;
+ LsmSvgFilterSurface *input_2_surface;
LsmBox subregion_px;
g_return_if_fail (LSM_IS_SVG_VIEW (view));
@@ -2130,14 +2131,14 @@ lsm_svg_view_apply_blend (LsmSvgView *view, const char *input_1, const char*inpu
lsm_log_render ("[SvgView::blend] mode = %s", lsm_svg_blending_mode_to_string (mode));
- lsm_filter_surface_blend (input_1_surface, input_2_surface, output_surface, mode);
+ lsm_svg_filter_surface_blend (input_1_surface, input_2_surface, output_surface, mode);
}
void
lsm_svg_view_apply_flood (LsmSvgView *view, const char *output, const LsmBox *subregion)
{
- LsmFilterSurface *output_surface;
- LsmFilterSurface *input_surface;
+ LsmSvgFilterSurface *output_surface;
+ LsmSvgFilterSurface *input_surface;
LsmBox subregion_px;
g_return_if_fail (LSM_IS_SVG_VIEW (view));
@@ -2151,7 +2152,7 @@ lsm_svg_view_apply_flood (LsmSvgView *view, const char *output, const LsmBox *su
subregion_px.width, subregion_px.height,
subregion_px.x, subregion_px.y);
- lsm_filter_surface_flood (output_surface,
+ lsm_svg_filter_surface_flood (output_surface,
view->style->flood_color->value.red,
view->style->flood_color->value.green,
view->style->flood_color->value.blue,
@@ -2162,8 +2163,8 @@ void
lsm_svg_view_apply_gaussian_blur (LsmSvgView *view, const char *input, const char *output,
const LsmBox *subregion, double std_x, double std_y)
{
- LsmFilterSurface *input_surface;
- LsmFilterSurface *output_surface;
+ LsmSvgFilterSurface *input_surface;
+ LsmSvgFilterSurface *output_surface;
LsmBox subregion_px;
g_return_if_fail (LSM_IS_SVG_VIEW (view));
@@ -2188,15 +2189,15 @@ lsm_svg_view_apply_gaussian_blur (LsmSvgView *view, const char *input, const cha
lsm_log_render ("[SvgView::apply_gaussian_blur] %g px,%g px",
std_x, std_y);
- lsm_filter_surface_fast_blur (input_surface, output_surface, std_x, std_y);
+ lsm_svg_filter_surface_fast_blur (input_surface, output_surface, std_x, std_y);
}
void
lsm_svg_view_apply_offset (LsmSvgView *view, const char *input, const char *output,
const LsmBox *subregion, double dx, double dy)
{
- LsmFilterSurface *input_surface;
- LsmFilterSurface *output_surface;
+ LsmSvgFilterSurface *input_surface;
+ LsmSvgFilterSurface *output_surface;
LsmBox subregion_px;
g_return_if_fail (LSM_IS_SVG_VIEW (view));
@@ -2217,14 +2218,14 @@ lsm_svg_view_apply_offset (LsmSvgView *view, const char *input, const char *outp
lsm_log_render ("[SvgView::apply_offset] %g px,%g px", dx, dy);
- lsm_filter_surface_offset (input_surface, output_surface, dx, dy);
+ lsm_svg_filter_surface_offset (input_surface, output_surface, dx, dy);
}
void
lsm_svg_view_apply_merge (LsmSvgView *view, const char *input, const char *output, const LsmBox *subregion)
{
- LsmFilterSurface *input_surface;
- LsmFilterSurface *output_surface;
+ LsmSvgFilterSurface *input_surface;
+ LsmSvgFilterSurface *output_surface;
LsmBox subregion_px;
g_return_if_fail (LSM_IS_SVG_VIEW (view));
@@ -2242,14 +2243,14 @@ lsm_svg_view_apply_merge (LsmSvgView *view, const char *input, const char *outpu
output_surface = _create_filter_surface (view, output, input_surface, &subregion_px);
if (output_surface != NULL)
- lsm_filter_surface_merge (input_surface, output_surface);
+ lsm_svg_filter_surface_merge (input_surface, output_surface);
}
void
lsm_svg_view_apply_tile (LsmSvgView *view, const char *input, const char *output, const LsmBox *subregion)
{
- LsmFilterSurface *input_surface;
- LsmFilterSurface *output_surface;
+ LsmSvgFilterSurface *input_surface;
+ LsmSvgFilterSurface *output_surface;
LsmBox subregion_px;
input_surface = _get_filter_surface (view, input);
@@ -2262,7 +2263,7 @@ lsm_svg_view_apply_tile (LsmSvgView *view, const char *input, const char *output
lsm_cairo_box_user_to_device (view->dom_view.cairo, &subregion_px, subregion);
output_surface = _create_filter_surface (view, output, input_surface, &subregion_px);
- lsm_filter_surface_tile (input_surface, output_surface);
+ lsm_svg_filter_surface_tile (input_surface, output_surface);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]