[lasem] svg_spec_lighting: more boilerplate



commit 7eba7da0d891b4cd0f708b3689cd1c52fc00329c
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Mon Aug 3 22:09:57 2015 +0200

    svg_spec_lighting: more boilerplate

 src/lsmsvgfilterspecularlighting.c |   11 ++++++++-
 src/lsmsvgfiltersurface.c          |   38 ++++++++++++++++++++++++++++++++++++
 src/lsmsvgfiltersurface.h          |    3 ++
 src/lsmsvgview.c                   |   25 +++++++++++++++++++++++
 src/lsmsvgview.h                   |    3 ++
 5 files changed, 78 insertions(+), 2 deletions(-)
---
diff --git a/src/lsmsvgfilterspecularlighting.c b/src/lsmsvgfilterspecularlighting.c
index 77b50d3..d258723 100644
--- a/src/lsmsvgfilterspecularlighting.c
+++ b/src/lsmsvgfilterspecularlighting.c
@@ -38,9 +38,16 @@ lsm_svg_filter_specular_lighting_get_node_name (LsmDomNode *node)
 
 static void
 lsm_svg_filter_specular_lighting_apply  (LsmSvgFilterPrimitive *self, LsmSvgView *view,
-                                    const char *input, const char *output, const LsmBox *subregion)
+                                        const char *input, const char *output, const LsmBox *subregion)
 {
-/*        lsm_svg_view_apply_specular_lighting (view, output, subregion);*/
+       LsmSvgFilterSpecularLighting *specular_lighting = LSM_SVG_FILTER_SPECULAR_LIGHTING (self);
+
+       lsm_svg_view_apply_specular_lighting (view, output, subregion,
+                                             specular_lighting->surface_scale.value,
+                                             specular_lighting->specular_constant.value,
+                                             specular_lighting->specular_exponent.value,
+                                             specular_lighting->kernel_unit_length.value.a,
+                                             specular_lighting->kernel_unit_length.value.b);
 }
 
 /* LsmSvgFilterSpecularLighting implementation */
diff --git a/src/lsmsvgfiltersurface.c b/src/lsmsvgfiltersurface.c
index 8e278c9..57e1adc 100644
--- a/src/lsmsvgfiltersurface.c
+++ b/src/lsmsvgfiltersurface.c
@@ -736,6 +736,44 @@ lsm_svg_filter_surface_convolve_matrix (LsmSvgFilterSurface *input, LsmSvgFilter
 }
 
 void
+lsm_svg_filter_surface_specular_lighting (LsmSvgFilterSurface *output,
+                                         double surface_scale, double specular_constant, double 
specular_exponent,
+                                         double dx, double dy)
+{
+       cairo_t *cairo;
+       int width, height;
+#if 0
+       guchar *output_pixels;
+       gint rowstride;
+       gint x1, x2, y1, y2;
+#endif
+
+       g_return_if_fail (output != NULL);
+
+       width = cairo_image_surface_get_width (output->surface);
+       height = cairo_image_surface_get_height (output->surface);
+
+       if (height < 1 || width < 1)
+               return;
+
+       cairo = cairo_create (output->surface);
+
+#if 0
+       output_pixels = cairo_image_surface_get_data (output->surface);
+       rowstride = cairo_image_surface_get_stride (output->surface);
+
+       x1 = CLAMP (output->subregion.x, 0, width);
+       x2 = CLAMP (output->subregion.x + output->subregion.width, 0, width);
+       y1 = CLAMP (output->subregion.y, 0, height);
+       y2 = CLAMP (output->subregion.y + output->subregion.height, 0, height);
+#endif
+
+       cairo_surface_mark_dirty (output->surface);
+
+       cairo_destroy (cairo);
+}
+
+void
 lsm_svg_filter_surface_image (LsmSvgFilterSurface *output, GdkPixbuf *pixbuf,
                              LsmSvgPreserveAspectRatio preserve_aspect_ratio)
 {
diff --git a/src/lsmsvgfiltersurface.h b/src/lsmsvgfiltersurface.h
index c820a51..731e348 100644
--- a/src/lsmsvgfiltersurface.h
+++ b/src/lsmsvgfiltersurface.h
@@ -72,6 +72,9 @@ void                  lsm_svg_filter_surface_image            (LsmSvgFilterSurface *output, 
GdkPixbuf *p
                                                                 LsmSvgPreserveAspectRatio 
preserve_aspect_ratio);
 void                   lsm_svg_filter_surface_morphology       (LsmSvgFilterSurface *input_surface, 
LsmSvgFilterSurface *output_surface,
                                                                 LsmSvgMorphologyOperator op, double rx, 
double ry);
+void                   lsm_svg_filter_surface_specular_lighting(LsmSvgFilterSurface *output_surface,
+                                                                double surface_scale, double 
specular_constant, double specular_exponent,
+                                                                double dx, double dy);
 
 G_END_DECLS
 
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index ae6a9f1..348ff40 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -2273,6 +2273,31 @@ lsm_svg_view_apply_convolve_matrix (LsmSvgView *view, const char *input, const c
        lsm_svg_filter_surface_convolve_matrix (input_surface, output_surface, x_order, y_order, n_values, 
values, edge_mode);
 }
 
+void 
+lsm_svg_view_apply_specular_lighting (LsmSvgView *view, const char *output, const LsmBox *subregion,
+                                     double surface_scale, double specular_constant, double 
specular_exponent,
+                                     double dx, double dy)
+{
+       LsmSvgFilterSurface *output_surface;
+       LsmSvgFilterSurface *input_surface;
+       LsmBox subregion_px;
+
+       g_return_if_fail (LSM_IS_SVG_VIEW (view));
+
+       input_surface = _get_filter_surface (view, NULL);
+
+       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_log_render ("[SvgView::apply_specular_lighting] subregion %gx%g px at %g,%g px",
+                       subregion_px.width, subregion_px.height,
+                       subregion_px.x, subregion_px.y);
+
+       cairo_user_to_device_distance (view->dom_view.cairo, &dx, &dy);
+
+       lsm_svg_filter_surface_specular_lighting (output_surface, surface_scale, specular_constant, 
specular_exponent, dx, dy);
+}
+
 void
 lsm_svg_view_apply_merge (LsmSvgView *view, const char *input, const char *output, const LsmBox *subregion)
 {
diff --git a/src/lsmsvgview.h b/src/lsmsvgview.h
index b586964..487e5b0 100644
--- a/src/lsmsvgview.h
+++ b/src/lsmsvgview.h
@@ -184,6 +184,9 @@ void                lsm_svg_view_apply_morphology           (LsmSvgView *view, const char 
*input, con
 void           lsm_svg_view_apply_convolve_matrix      (LsmSvgView *view, const char *input, const char 
*output, const LsmBox *subregion,
                                                         unsigned a, unsigned b, unsigned n_values, double 
*values,
                                                         LsmSvgEdgeMode edge_mode);
+void           lsm_svg_view_apply_specular_lighting    (LsmSvgView *view, const char *output, const LsmBox 
*subregion,
+                                                        double surface_scale, double specular_constant, 
double specular_exponent,
+                                                        double dx, double dy);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]