89
90
rsvg_filter_primitive_get_bounds (RsvgFilterPrimitive * self, RsvgFilterContext * ctx)
91
92
RsvgBbox box, otherbox;
93
cairo_matrix_t affine;
94
_rsvg_affine_identity (affine);
95
rsvg_bbox_init (&box, affine);
96
rsvg_bbox_init (&otherbox, ctx->affine);
95
cairo_matrix_init_identity (&affine);
96
rsvg_bbox_init (&box, &affine);
97
rsvg_bbox_init (&otherbox, &ctx->affine);
97
98
otherbox.virgin = 0;
98
99
if (ctx->filter->filterunits == objectBoundingBox)
99
100
_rsvg_push_view_box (ctx->ctx, 1., 1.);
100
otherbox.x = _rsvg_css_normalize_length (&ctx->filter->x, ctx->ctx, 'h');
101
otherbox.y = _rsvg_css_normalize_length (&ctx->filter->y, ctx->ctx, 'v');
102
otherbox.w = _rsvg_css_normalize_length (&ctx->filter->width, ctx->ctx, 'h');
103
otherbox.h = _rsvg_css_normalize_length (&ctx->filter->height, ctx->ctx, 'v');
101
otherbox.rect.x = _rsvg_css_normalize_length (&ctx->filter->x, ctx->ctx, 'h');
102
otherbox.rect.y = _rsvg_css_normalize_length (&ctx->filter->y, ctx->ctx, 'v');
103
otherbox.rect.width = _rsvg_css_normalize_length (&ctx->filter->width, ctx->ctx, 'h');
104
otherbox.rect.height = _rsvg_css_normalize_length (&ctx->filter->height, ctx->ctx, 'v');
104
105
if (ctx->filter->filterunits == objectBoundingBox)
105
106
_rsvg_pop_view_box (ctx->ctx);
110
111
if (self->x.factor != 'n' || self->y.factor != 'n' ||
111
112
self->width.factor != 'n' || self->height.factor != 'n') {
113
rsvg_bbox_init (&otherbox, ctx->paffine);
114
rsvg_bbox_init (&otherbox, &ctx->paffine);
114
115
otherbox.virgin = 0;
115
116
if (ctx->filter->primitiveunits == objectBoundingBox)
116
117
_rsvg_push_view_box (ctx->ctx, 1., 1.);
117
118
if (self->x.factor != 'n')
118
otherbox.x = _rsvg_css_normalize_length (&self->x, ctx->ctx, 'h');
119
otherbox.rect.x = _rsvg_css_normalize_length (&self->x, ctx->ctx, 'h');
121
122
if (self->y.factor != 'n')
122
otherbox.y = _rsvg_css_normalize_length (&self->y, ctx->ctx, 'v');
123
otherbox.rect.y = _rsvg_css_normalize_length (&self->y, ctx->ctx, 'v');
125
126
if (self->width.factor != 'n')
126
otherbox.w = _rsvg_css_normalize_length (&self->width, ctx->ctx, 'h');
127
otherbox.rect.width = _rsvg_css_normalize_length (&self->width, ctx->ctx, 'h');
128
otherbox.w = ctx->ctx->vb.w;
129
otherbox.rect.width = ctx->ctx->vb.rect.width;
129
130
if (self->height.factor != 'n')
130
otherbox.h = _rsvg_css_normalize_length (&self->height, ctx->ctx, 'v');
131
otherbox.rect.height = _rsvg_css_normalize_length (&self->height, ctx->ctx, 'v');
132
otherbox.h = ctx->ctx->vb.h;
133
otherbox.rect.height = ctx->ctx->vb.rect.height;
133
134
if (ctx->filter->primitiveunits == objectBoundingBox)
134
135
_rsvg_pop_view_box (ctx->ctx);
135
136
rsvg_bbox_clip (&box, &otherbox);
138
rsvg_bbox_init (&otherbox, affine);
139
rsvg_bbox_init (&otherbox, &affine);
139
140
otherbox.virgin = 0;
142
otherbox.w = ctx->width;
143
otherbox.h = ctx->height;
143
otherbox.rect.width = ctx->width;
144
otherbox.rect.height = ctx->height;
144
145
rsvg_bbox_clip (&box, &otherbox);
146
RsvgIRect output = { box.x, box.y,
147
RsvgIRect output = { box.rect.x, box.rect.y,
148
box.rect.x + box.rect.width,
149
box.rect.y + box.rect.height
155
_rsvg_pixbuf_new_cleared (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
156
int width, int height)
155
static cairo_surface_t *
156
_rsvg_image_surface_new (int width, int height)
161
pb = gdk_pixbuf_new (colorspace, has_alpha, bits_per_sample, width, height);
162
data = gdk_pixbuf_get_pixels (pb);
163
memset (data, 0, width * height * 4);
158
cairo_surface_t *surface;
160
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
161
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
162
cairo_surface_destroy (surface);
169
gdk_pixbuf_get_interp_pixel (guchar * src, gdouble ox, gdouble oy, guchar ch, RsvgIRect boundarys,
170
get_interp_pixel (guchar * src, gdouble ox, gdouble oy, guchar ch, RsvgIRect boundarys,
172
173
double xmod, ymod;
173
174
double dist1, dist2, dist3, dist4;
174
175
double c, c1, c2, c3, c4;
176
double fox, foy, cox, coy;
176
178
xmod = fmod (ox, 1.0);
177
179
ymod = fmod (oy, 1.0);
181
183
dist3 = (xmod) * (ymod);
182
184
dist4 = (1 - xmod) * (ymod);
184
if (floor (ox) <= boundarys.x0 || floor (ox) >= boundarys.x1 ||
185
floor (oy) <= boundarys.y0 || floor (oy) >= boundarys.y1)
191
if (fox <= boundarys.x0 || fox >= boundarys.x1 ||
192
foy <= boundarys.y0 || foy >= boundarys.y1)
188
c1 = src[(guint) floor (oy) * rowstride + (guint) floor (ox) * 4 + ch];
195
c1 = src[(guint) foy * rowstride + (guint) fox * 4 + ch];
190
if (ceil (ox) <= boundarys.x0 || ceil (ox) >= boundarys.x1 ||
191
floor (oy) <= boundarys.y0 || floor (oy) >= boundarys.y1)
197
if (cox <= boundarys.x0 || cox >= boundarys.x1 ||
198
foy <= boundarys.y0 || foy >= boundarys.y1)
194
c2 = src[(guint) floor (oy) * rowstride + (guint) ceil (ox) * 4 + ch];
201
c2 = src[(guint) foy * rowstride + (guint) cox * 4 + ch];
196
if (ceil (ox) <= boundarys.x0 || ceil (ox) >= boundarys.x1 ||
197
ceil (oy) <= boundarys.y0 || ceil (oy) >= boundarys.y1)
203
if (cox <= boundarys.x0 || cox >= boundarys.x1 ||
204
coy <= boundarys.y0 || coy >= boundarys.y1)
200
c3 = src[(guint) ceil (oy) * rowstride + (guint) ceil (ox) * 4 + ch];
207
c3 = src[(guint) coy * rowstride + (guint) cox * 4 + ch];
202
if (floor (ox) <= boundarys.x0 || floor (ox) >= boundarys.x1 ||
203
ceil (oy) <= boundarys.y0 || ceil (oy) >= boundarys.y1)
209
if (fox <= boundarys.x0 || fox >= boundarys.x1 ||
210
coy <= boundarys.y0 || coy >= boundarys.y1)
206
c4 = src[(guint) ceil (oy) * rowstride + (guint) floor (ox) * 4 + ch];
213
c4 = src[(guint) coy * rowstride + (guint) fox * 4 + ch];
208
215
c = (c1 * dist1 + c2 * dist2 + c3 * dist3 + c4 * dist4) / (dist1 + dist2 + dist3 + dist4);
214
rsvg_filter_fix_coordinate_system (RsvgFilterContext * ctx, RsvgState * state, RsvgBbox bbox)
221
rsvg_filter_fix_coordinate_system (RsvgFilterContext * ctx, RsvgState * state, RsvgBbox *bbox)
216
223
int x, y, height, width;
224
ctx->width = gdk_pixbuf_get_width (ctx->source);
225
ctx->height = gdk_pixbuf_get_height (ctx->source);
227
for (i = 0; i < 6; i++)
228
ctx->affine[i] = state->affine[i];
227
width = bbox->rect.width;
228
height = bbox->rect.height;
230
ctx->width = cairo_image_surface_get_width (ctx->source_surface);
231
ctx->height = cairo_image_surface_get_height (ctx->source_surface);
233
ctx->affine = state->affine;
229
234
if (ctx->filter->filterunits == objectBoundingBox) {
230
double affine[6] = { width, 0, 0, height, x, y };
231
_rsvg_affine_multiply (ctx->affine, affine, ctx->affine);
235
cairo_matrix_t affine;
236
cairo_matrix_init (&affine, width, 0, 0, height, x, y);
237
cairo_matrix_multiply (&ctx->affine, &affine, &ctx->affine);
233
for (i = 0; i < 6; i++)
234
ctx->paffine[i] = state->affine[i];
239
ctx->paffine = state->affine;
235
240
if (ctx->filter->primitiveunits == objectBoundingBox) {
236
double affine[6] = { width, 0, 0, height, x, y };
237
_rsvg_affine_multiply (ctx->paffine, affine, ctx->paffine);
241
cairo_matrix_t affine;
242
cairo_matrix_init (&affine, width, 0, 0, height, x, y);
243
cairo_matrix_multiply (&ctx->paffine, &affine, &ctx->paffine);
242
rsvg_alpha_blt (GdkPixbuf * src, gint srcx, gint srcy, gint srcwidth,
243
gint srcheight, GdkPixbuf * dst, gint dstx, gint dsty)
248
rsvg_alpha_blt (cairo_surface_t *src,
253
cairo_surface_t *dst,
255
267
gint x, y, srcrowstride, dstrowstride, sx, sy, dx, dy;
256
268
guchar *src_pixels, *dst_pixels;
270
cairo_surface_flush (src);
258
272
dstheight = srcheight;
259
273
dstwidth = srcwidth;
261
275
rightx = srcx + srcwidth;
262
276
bottomy = srcy + srcheight;
264
if (rightx > gdk_pixbuf_get_width (src))
265
rightx = gdk_pixbuf_get_width (src);
266
if (bottomy > gdk_pixbuf_get_height (src))
267
bottomy = gdk_pixbuf_get_height (src);
278
if (rightx > cairo_image_surface_get_width (src))
279
rightx = cairo_image_surface_get_width (src);
280
if (bottomy > cairo_image_surface_get_height (src))
281
bottomy = cairo_image_surface_get_height (src);
268
282
srcwidth = rightx - srcx;
269
283
srcheight = bottomy - srcy;
271
285
rightx = dstx + dstwidth;
272
286
bottomy = dsty + dstheight;
273
if (rightx > gdk_pixbuf_get_width (dst))
274
rightx = gdk_pixbuf_get_width (dst);
275
if (bottomy > gdk_pixbuf_get_height (dst))
276
bottomy = gdk_pixbuf_get_height (dst);
287
if (rightx > cairo_image_surface_get_width (dst))
288
rightx = cairo_image_surface_get_width (dst);
289
if (bottomy > cairo_image_surface_get_height (dst))
290
bottomy = cairo_image_surface_get_height (dst);
277
291
dstwidth = rightx - dstx;
278
292
dstheight = bottomy - dsty;
358
375
gint iwidth, iheight;
359
376
gint width, height;
361
width = gdk_pixbuf_get_width (img);
362
height = gdk_pixbuf_get_height (img);
363
iwidth = gdk_pixbuf_get_width (intermediate);
364
iheight = gdk_pixbuf_get_height (intermediate);
366
has_alpha = gdk_pixbuf_get_has_alpha (img);
368
basestride = gdk_pixbuf_get_rowstride (img);
369
intstride = gdk_pixbuf_get_rowstride (intermediate);
370
basepix = gdk_pixbuf_get_pixels (img);
371
intpix = gdk_pixbuf_get_pixels (intermediate);
378
g_assert (cairo_image_surface_get_format (intermediate) == CAIRO_FORMAT_ARGB32);
380
cairo_surface_flush (img);
382
width = cairo_image_surface_get_width (img);
383
height = cairo_image_surface_get_height (img);
384
iwidth = cairo_image_surface_get_width (intermediate);
385
iheight = cairo_image_surface_get_height (intermediate);
387
has_alpha = cairo_image_surface_get_format (img) == CAIRO_FORMAT_ARGB32;
389
basestride = cairo_image_surface_get_stride (img);
390
intstride = cairo_image_surface_get_stride (intermediate);
391
basepix = cairo_image_surface_get_data (img);
392
intpix = cairo_image_surface_get_data (intermediate);
372
393
basebpp = has_alpha ? 4 : 3;
374
_rsvg_affine_invert (raw_inv_affine, affine);
376
/*scale to w and h */
377
tmp_affine[0] = (double) w;
378
tmp_affine[3] = (double) h;
379
tmp_affine[1] = tmp_affine[2] = tmp_affine[4] = tmp_affine[5] = 0;
380
_rsvg_affine_multiply (tmp_affine, tmp_affine, affine);
382
_rsvg_affine_invert (inv_affine, tmp_affine);
395
raw_inv_affine = *affine;
396
if (cairo_matrix_invert (&raw_inv_affine) != CAIRO_STATUS_SUCCESS)
399
cairo_matrix_init_scale (&inv_affine, w, h);
400
cairo_matrix_multiply (&inv_affine, &inv_affine, affine);
401
if (cairo_matrix_invert (&inv_affine) != CAIRO_STATUS_SUCCESS)
385
404
/*apply the transformation */
386
405
for (i = 0; i < iwidth; i++)
387
406
for (j = 0; j < iheight; j++) {
388
fbasex = (inv_affine[0] * (double) i + inv_affine[2] * (double) j +
389
inv_affine[4]) * (double) width;
390
fbasey = (inv_affine[1] * (double) i + inv_affine[3] * (double) j +
391
inv_affine[5]) * (double) height;
407
fbasex = (inv_affine.xx * (double) i + inv_affine.xy * (double) j +
408
inv_affine.x0) * (double) width;
409
fbasey = (inv_affine.yx * (double) i + inv_affine.yy * (double) j +
410
inv_affine.y0) * (double) height;
392
411
basex = floor (fbasex);
393
412
basey = floor (fbasey);
394
rawx = raw_inv_affine[0] * i + raw_inv_affine[2] * j + raw_inv_affine[4];
395
rawy = raw_inv_affine[1] * i + raw_inv_affine[3] * j + raw_inv_affine[5];
413
rawx = raw_inv_affine.xx * i + raw_inv_affine.xy * j + raw_inv_affine.x0;
414
rawy = raw_inv_affine.yx * i + raw_inv_affine.yy * j + raw_inv_affine.y0;
396
415
if (rawx < 0 || rawy < 0 || rawx >= w ||
397
416
rawy >= h || basex < 0 || basey < 0 || basex >= width || basey >= height) {
398
417
for (k = 0; k < 4; k++)
451
g_object_unref (ctx->bg);
476
cairo_surface_destroy (ctx->bg_surface);
457
* rsvg_filter_render: Create a new pixbuf applied the filter.
482
* rsvg_filter_render: Create a new surface applied the filter.
458
483
* @self: a pointer to the filter to use
459
* @source: a pointer to the source pixbuf
484
* @source: the a #cairo_surface_t of type %CAIRO_SURFACE_TYPE_IMAGE
460
485
* @context: the context
462
487
* This function will create a context for itself, set up the coordinate systems
463
488
* execute all its little primatives and then clean up its own mess
490
* Returns: (transfer full): a new #cairo_surface_t
466
rsvg_filter_render (RsvgFilter * self, GdkPixbuf * source,
467
RsvgDrawingCtx * context, RsvgBbox * bounds, char *channelmap)
493
rsvg_filter_render (RsvgFilter *self,
494
cairo_surface_t *source,
495
RsvgDrawingCtx *context,
469
499
RsvgFilterContext *ctx;
470
500
RsvgFilterPrimitive *current;
502
cairo_surface_t *output;
504
g_return_val_if_fail (source != NULL, NULL);
505
g_return_val_if_fail (cairo_surface_get_type (source) == CAIRO_SURFACE_TYPE_IMAGE, NULL);
475
507
ctx = g_new (RsvgFilterContext, 1);
476
508
ctx->filter = self;
477
ctx->source = source;
509
ctx->source_surface = source;
510
ctx->bg_surface = NULL;
479
511
ctx->results = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, rsvg_filter_free_pair);
480
512
ctx->ctx = context;
482
g_object_ref (source);
484
rsvg_filter_fix_coordinate_system (ctx, rsvg_current_state (context), *bounds);
486
ctx->lastresult.result = source;
514
rsvg_filter_fix_coordinate_system (ctx, rsvg_current_state (context), bounds);
516
ctx->lastresult.surface = cairo_surface_reference (source);
487
517
ctx->lastresult.Rused = 1;
488
518
ctx->lastresult.Gused = 1;
489
519
ctx->lastresult.Bused = 1;
523
553
RsvgFilterPrimitiveOutput *store;
525
g_object_unref (ctx->lastresult.result);
555
cairo_surface_destroy (ctx->lastresult.surface);
527
557
store = g_new (RsvgFilterPrimitiveOutput, 1);
530
if (strcmp (name->str, "")) {
531
g_object_ref (result.result); /* increments the references for the table */
560
if (name->str[0] != '\0') {
561
cairo_surface_reference (result.surface); /* increments the references for the table */
532
562
g_hash_table_insert (ctx->results, g_strdup (name->str), store);
535
g_object_ref (result.result); /* increments the references for the last result */
565
cairo_surface_reference (result.surface); /* increments the references for the last result */
536
566
ctx->lastresult = result;
540
rsvg_filter_store_result (GString * name, GdkPixbuf * result, RsvgFilterContext * ctx)
570
rsvg_filter_store_result (GString * name,
571
cairo_surface_t *surface,
572
RsvgFilterContext * ctx)
542
574
RsvgFilterPrimitiveOutput output;
543
575
output.Rused = 1;
548
580
output.bounds.y0 = 0;
549
581
output.bounds.x1 = ctx->width;
550
582
output.bounds.y1 = ctx->height;
551
output.result = result;
583
output.surface = surface;
553
585
rsvg_filter_store_output (name, output, ctx);
557
pixbuf_get_alpha (GdkPixbuf * pb, RsvgFilterContext * ctx)
588
static cairo_surface_t *
589
surface_get_alpha (cairo_surface_t *source,
590
RsvgFilterContext * ctx)
565
pbsize = gdk_pixbuf_get_width (pb) * gdk_pixbuf_get_height (pb);
567
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8,
568
gdk_pixbuf_get_width (pb), gdk_pixbuf_get_height (pb));
570
data = gdk_pixbuf_get_pixels (output);
571
pbdata = gdk_pixbuf_get_pixels (pb);
595
cairo_surface_t *surface;
600
cairo_surface_flush (source);
602
pbsize = cairo_image_surface_get_width (source) *
603
cairo_image_surface_get_height (source);
605
surface = _rsvg_image_surface_new (cairo_image_surface_get_width (source),
606
cairo_image_surface_get_height (source));
610
data = cairo_image_surface_get_data (surface);
611
pbdata = cairo_image_surface_get_data (source);
613
/* FIXMEchpe: rewrite this into nested width, height loops */
573
614
for (i = 0; i < pbsize; i++)
574
615
data[i * 4 + ctx->channelmap[3]] = pbdata[i * 4 + ctx->channelmap[3]];
617
cairo_surface_mark_dirty (surface);
621
static cairo_surface_t *
580
622
rsvg_compile_bg (RsvgDrawingCtx * ctx)
582
RsvgCairoRender *render = (RsvgCairoRender *) ctx->render;
624
RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
625
cairo_surface_t *surface;
584
cairo_surface_t *surface;
586
unsigned char *pixels = g_new0 (guint8, render->width * render->height * 4);
587
int rowstride = render->width * 4;
589
GdkPixbuf *output = gdk_pixbuf_new_from_data (pixels,
590
GDK_COLORSPACE_RGB, TRUE, 8,
591
render->width, render->height,
593
(GdkPixbufDestroyNotify) g_free,
596
surface = cairo_image_surface_create_for_data (pixels,
598
render->width, render->height, rowstride);
629
surface = _rsvg_image_surface_new (render->width, render->height);
600
633
cr = cairo_create (surface);
601
cairo_surface_destroy (surface);
603
635
for (i = g_list_last (render->cr_stack); i != NULL; i = g_list_previous (i)) {
604
636
cairo_t *draw = i->data;
638
677
output.bounds.x0 = output.bounds.x1 = output.bounds.y0 = output.bounds.y1 = 0;
640
679
if (!strcmp (name->str, "SourceGraphic")) {
641
g_object_ref (ctx->source);
642
output.result = ctx->source;
680
output.surface = cairo_surface_reference (ctx->source_surface);
643
681
output.Rused = output.Gused = output.Bused = output.Aused = 1;
645
683
} else if (!strcmp (name->str, "BackgroundImage")) {
646
output.result = g_object_ref (rsvg_filter_get_bg (ctx));
684
output.surface = rsvg_filter_get_bg (ctx);
686
cairo_surface_reference (output.surface);
647
687
output.Rused = output.Gused = output.Bused = output.Aused = 1;
649
} else if (!strcmp (name->str, "") || !strcmp (name->str, "none") || !name) {
650
g_object_ref (ctx->lastresult.result);
689
} else if (!name || !strcmp (name->str, "") || !strcmp (name->str, "none")) {
651
690
output = ctx->lastresult;
691
cairo_surface_reference (output.surface);
653
693
} else if (!strcmp (name->str, "SourceAlpha")) {
654
694
output.Rused = output.Gused = output.Bused = 0;
655
695
output.Aused = 1;
656
output.result = pixbuf_get_alpha (ctx->source, ctx);
696
output.surface = surface_get_alpha (ctx->source_surface, ctx);
658
698
} else if (!strcmp (name->str, "BackgroundAlpha")) {
659
699
output.Rused = output.Gused = output.Bused = 0;
660
700
output.Aused = 1;
661
output.result = pixbuf_get_alpha (rsvg_filter_get_bg (ctx), ctx);
701
output.surface = surface_get_alpha (rsvg_filter_get_bg (ctx), ctx);
791
841
guchar *in_pixels;
792
842
guchar *in2_pixels;
793
843
guchar *output_pixels;
794
height = gdk_pixbuf_get_height (in);
795
width = gdk_pixbuf_get_width (in);
796
rowstride = gdk_pixbuf_get_rowstride (in);
797
rowstride2 = gdk_pixbuf_get_rowstride (in2);
798
rowstrideo = gdk_pixbuf_get_rowstride (output);
800
output_pixels = gdk_pixbuf_get_pixels (output);
801
in_pixels = gdk_pixbuf_get_pixels (in);
802
in2_pixels = gdk_pixbuf_get_pixels (in2);
845
cairo_surface_flush (in);
846
cairo_surface_flush (in2);
848
height = cairo_image_surface_get_height (in);
849
width = cairo_image_surface_get_width (in);
850
rowstride = cairo_image_surface_get_stride (in);
851
rowstride2 = cairo_image_surface_get_stride (in2);
852
rowstrideo = cairo_image_surface_get_stride (output);
854
output_pixels = cairo_image_surface_get_data (output);
855
in_pixels = cairo_image_surface_get_data (in);
856
in2_pixels = cairo_image_surface_get_data (in2);
804
858
if (boundarys.x0 < 0)
805
859
boundarys.x0 = 0;
900
955
RsvgFilterPrimitiveBlend *upself;
957
cairo_surface_t *output, *in, *in2;
906
959
upself = (RsvgFilterPrimitiveBlend *) self;
907
960
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
909
962
in = rsvg_filter_get_in (self->in, ctx);
910
966
in2 = rsvg_filter_get_in (upself->in2, ctx);
968
cairo_surface_destroy (in);
913
_rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, gdk_pixbuf_get_width (in),
914
gdk_pixbuf_get_height (in));
972
output = _rsvg_image_surface_new (cairo_image_surface_get_width (in),
973
cairo_image_surface_get_height (in));
974
if (output == NULL) {
975
cairo_surface_destroy (in);
976
cairo_surface_destroy (in2);
916
980
rsvg_filter_blend (upself->mode, in, in2, output, boundarys, ctx->channelmap);
918
982
rsvg_filter_store_result (self->result, output, ctx);
921
g_object_unref (in2);
922
g_object_unref (output);
984
cairo_surface_destroy (in);
985
cairo_surface_destroy (in2);
986
cairo_surface_destroy (output);
1036
1099
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
1038
1101
in = rsvg_filter_get_in (self->in, ctx);
1039
in_pixels = gdk_pixbuf_get_pixels (in);
1041
height = gdk_pixbuf_get_height (in);
1042
width = gdk_pixbuf_get_width (in);
1044
targetx = upself->targetx * ctx->paffine[0];
1045
targety = upself->targety * ctx->paffine[3];
1105
cairo_surface_flush (in);
1107
in_pixels = cairo_image_surface_get_data (in);
1109
height = cairo_image_surface_get_height (in);
1110
width = cairo_image_surface_get_width (in);
1112
targetx = upself->targetx * ctx->paffine.xx;
1113
targety = upself->targety * ctx->paffine.yy;
1047
1115
if (upself->dx != 0 || upself->dy != 0) {
1048
dx = upself->dx * ctx->paffine[0];
1049
dy = upself->dy * ctx->paffine[3];
1116
dx = upself->dx * ctx->paffine.xx;
1117
dy = upself->dy * ctx->paffine.yy;
1053
rowstride = gdk_pixbuf_get_rowstride (in);
1055
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
1056
output_pixels = gdk_pixbuf_get_pixels (output);
1121
rowstride = cairo_image_surface_get_stride (in);
1123
output = _rsvg_image_surface_new (width, height);
1124
if (output == NULL) {
1125
cairo_surface_destroy (in);
1129
output_pixels = cairo_image_surface_get_data (output);
1058
1131
for (y = boundarys.y0; y < boundarys.y1; y++)
1059
1132
for (x = boundarys.x0; x < boundarys.x1; x++) {
1263
box_blur (GdkPixbuf * in, GdkPixbuf * output, guchar * intermediate, gint kw,
1264
gint kh, RsvgIRect boundarys, RsvgFilterPrimitiveOutput op)
1339
box_blur (cairo_surface_t *in,
1340
cairo_surface_t *output,
1341
guchar *intermediate,
1344
RsvgIRect boundarys,
1345
RsvgFilterPrimitiveOutput op)
1268
gint rowstride, height, width;
1270
1350
guchar *in_pixels;
1271
1351
guchar *output_pixels;
1276
height = gdk_pixbuf_get_height (in);
1277
width = gdk_pixbuf_get_width (in);
1279
in_pixels = gdk_pixbuf_get_pixels (in);
1280
output_pixels = gdk_pixbuf_get_pixels (output);
1282
rowstride = gdk_pixbuf_get_rowstride (in);
1354
in_pixels = cairo_image_surface_get_data (in);
1355
output_pixels = cairo_image_surface_get_data (output);
1357
rowstride = cairo_image_surface_get_stride (in);
1284
1359
if (kw > boundarys.x1 - boundarys.x0)
1285
1360
kw = boundarys.x1 - boundarys.x0;
1408
1489
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
1410
1491
op = rsvg_filter_get_result (self->in, ctx);
1413
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8,
1414
gdk_pixbuf_get_width (in), gdk_pixbuf_get_height (in));
1494
output = _rsvg_image_surface_new (cairo_image_surface_get_width (in),
1495
cairo_image_surface_get_height (in));
1496
if (output == NULL) {
1497
cairo_surface_destroy (in);
1416
1501
/* scale the SD values */
1417
sdx = upself->sdx * ctx->paffine[0];
1418
sdy = upself->sdy * ctx->paffine[3];
1502
sdx = upself->sdx * ctx->paffine.xx;
1503
sdy = upself->sdy * ctx->paffine.yy;
1420
1505
fast_blur (in, output, sdx, sdy, boundarys, op);
1507
op.surface = output;
1423
1508
op.bounds = boundarys;
1424
1509
rsvg_filter_store_output (self->result, op, ctx);
1426
g_object_unref (in);
1427
g_object_unref (output);
1511
cairo_surface_destroy (in);
1512
cairo_surface_destroy (output);
1519
1603
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
1521
1605
in = rsvg_filter_get_in (self->in, ctx);
1522
in_pixels = gdk_pixbuf_get_pixels (in);
1524
height = gdk_pixbuf_get_height (in);
1525
width = gdk_pixbuf_get_width (in);
1527
rowstride = gdk_pixbuf_get_rowstride (in);
1529
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
1531
output_pixels = gdk_pixbuf_get_pixels (output);
1609
cairo_surface_flush (in);
1611
in_pixels = cairo_image_surface_get_data (in);
1613
height = cairo_image_surface_get_height (in);
1614
width = cairo_image_surface_get_width (in);
1616
rowstride = cairo_image_surface_get_stride (in);
1618
output = _rsvg_image_surface_new (width, height);
1619
if (output == NULL) {
1620
cairo_surface_destroy (in);
1624
output_pixels = cairo_image_surface_get_data (output);
1533
1626
dx = _rsvg_css_normalize_length (&upself->dx, ctx->ctx, 'w');
1534
1627
dy = _rsvg_css_normalize_length (&upself->dy, ctx->ctx, 'v');
1536
ox = ctx->paffine[0] * dx + ctx->paffine[2] * dy;
1537
oy = ctx->paffine[1] * dx + ctx->paffine[3] * dy;
1629
ox = ctx->paffine.xx * dx + ctx->paffine.xy * dy;
1630
oy = ctx->paffine.yx * dx + ctx->paffine.yy * dy;
1539
1632
for (y = boundarys.y0; y < boundarys.y1; y++)
1540
1633
for (x = boundarys.x0; x < boundarys.x1; x++) {
1787
1886
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
1789
1888
in = rsvg_filter_get_in (self->in, ctx);
1790
in_pixels = gdk_pixbuf_get_pixels (in);
1792
height = gdk_pixbuf_get_height (in);
1793
width = gdk_pixbuf_get_width (in);
1795
rowstride = gdk_pixbuf_get_rowstride (in);
1797
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
1798
output_pixels = gdk_pixbuf_get_pixels (output);
1892
cairo_surface_flush (in);
1894
in_pixels = cairo_image_surface_get_data (in);
1896
height = cairo_image_surface_get_height (in);
1897
width = cairo_image_surface_get_width (in);
1899
rowstride = cairo_image_surface_get_stride (in);
1901
output = _rsvg_image_surface_new (width, height);
1902
if (output == NULL) {
1903
cairo_surface_destroy (in);
1907
output_pixels = cairo_image_surface_get_data (output);
1800
1909
for (y = boundarys.y0; y < boundarys.y1; y++)
1801
1910
for (x = boundarys.x0; x < boundarys.x1; x++) {
2130
2237
in = rsvg_filter_get_in (self->in, ctx);
2131
in_pixels = gdk_pixbuf_get_pixels (in);
2133
height = gdk_pixbuf_get_height (in);
2134
width = gdk_pixbuf_get_width (in);
2136
rowstride = gdk_pixbuf_get_rowstride (in);
2138
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
2140
output_pixels = gdk_pixbuf_get_pixels (output);
2241
cairo_surface_flush (in);
2243
in_pixels = cairo_image_surface_get_data (in);
2245
height = cairo_image_surface_get_height (in);
2246
width = cairo_image_surface_get_width (in);
2248
rowstride = cairo_image_surface_get_stride (in);
2250
output = _rsvg_image_surface_new (width, height);
2251
if (output == NULL) {
2252
cairo_surface_destroy (in);
2256
output_pixels = cairo_image_surface_get_data (output);
2142
2258
for (y = boundarys.y0; y < boundarys.y1; y++)
2143
2259
for (x = boundarys.x0; x < boundarys.x1; x++) {
2321
2439
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
2323
2441
in = rsvg_filter_get_in (self->in, ctx);
2324
in_pixels = gdk_pixbuf_get_pixels (in);
2326
height = gdk_pixbuf_get_height (in);
2327
width = gdk_pixbuf_get_width (in);
2329
rowstride = gdk_pixbuf_get_rowstride (in);
2445
cairo_surface_flush (in);
2447
in_pixels = cairo_image_surface_get_data (in);
2449
height = cairo_image_surface_get_height (in);
2450
width = cairo_image_surface_get_width (in);
2452
rowstride = cairo_image_surface_get_stride (in);
2331
2454
/* scale the radius values */
2332
kx = upself->rx * ctx->paffine[0];
2333
ky = upself->ry * ctx->paffine[3];
2335
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
2337
output_pixels = gdk_pixbuf_get_pixels (output);
2455
kx = upself->rx * ctx->paffine.xx;
2456
ky = upself->ry * ctx->paffine.yy;
2458
output = _rsvg_image_surface_new (width, height);
2459
if (output == NULL) {
2460
cairo_surface_destroy (in);
2464
output_pixels = cairo_image_surface_get_data (output);
2339
2466
for (y = boundarys.y0; y < boundarys.y1; y++)
2340
2467
for (x = boundarys.x0; x < boundarys.x1; x++)
2465
2595
RsvgFilterPrimitiveComposite *upself;
2597
cairo_surface_t *output, *in, *in2;
2471
2599
upself = (RsvgFilterPrimitiveComposite *) self;
2472
2600
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
2474
2602
in = rsvg_filter_get_in (self->in, ctx);
2475
in_pixels = gdk_pixbuf_get_pixels (in);
2606
cairo_surface_flush (in);
2476
2608
in2 = rsvg_filter_get_in (upself->in2, ctx);
2477
in2_pixels = gdk_pixbuf_get_pixels (in2);
2479
height = gdk_pixbuf_get_height (in);
2480
width = gdk_pixbuf_get_width (in);
2482
rowstride = gdk_pixbuf_get_rowstride (in);
2484
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
2485
output_pixels = gdk_pixbuf_get_pixels (output);
2610
cairo_surface_destroy (in);
2614
cairo_surface_flush (in2);
2616
in_pixels = cairo_image_surface_get_data (in);
2617
in2_pixels = cairo_image_surface_get_data (in2);
2619
height = cairo_image_surface_get_height (in);
2620
width = cairo_image_surface_get_width (in);
2622
rowstride = cairo_image_surface_get_stride (in);
2624
output = _rsvg_image_surface_new (width, height);
2625
if (output == NULL) {
2626
cairo_surface_destroy (in);
2627
cairo_surface_destroy (in2);
2631
output_pixels = cairo_image_surface_get_data (output);
2487
2633
if (upself->mode == COMPOSITE_MODE_ARITHMETIC)
2488
2634
for (y = boundarys.y0; y < boundarys.y1; y++)
2796
2947
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
2798
2949
in = rsvg_filter_get_in (self->in, ctx);
2799
in_pixels = gdk_pixbuf_get_pixels (in);
2953
cairo_surface_flush (in);
2801
2955
in2 = rsvg_filter_get_in (upself->in2, ctx);
2802
in2_pixels = gdk_pixbuf_get_pixels (in2);
2804
height = gdk_pixbuf_get_height (in);
2805
width = gdk_pixbuf_get_width (in);
2807
rowstride = gdk_pixbuf_get_rowstride (in);
2809
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
2811
output_pixels = gdk_pixbuf_get_pixels (output);
2957
cairo_surface_destroy (in);
2961
cairo_surface_flush (in2);
2963
in_pixels = cairo_image_surface_get_data (in);
2964
in2_pixels = cairo_image_surface_get_data (in2);
2966
height = cairo_image_surface_get_height (in);
2967
width = cairo_image_surface_get_width (in);
2969
rowstride = cairo_image_surface_get_stride (in);
2971
output = _rsvg_image_surface_new (width, height);
2972
if (output == NULL) {
2973
cairo_surface_destroy (in);
2974
cairo_surface_destroy (in2);
2978
output_pixels = cairo_image_surface_get_data (output);
2813
2980
switch (upself->xChannelSelector) {
2849
3016
for (y = boundarys.y0; y < boundarys.y1; y++)
2850
3017
for (x = boundarys.x0; x < boundarys.x1; x++) {
2852
ox = x + upself->scale * ctx->paffine[0] *
3019
ox = x + upself->scale * ctx->paffine.xx *
2853
3020
((double) in2_pixels[y * rowstride + x * 4 + xch] / 255.0 - 0.5);
2858
oy = y + upself->scale * ctx->paffine[3] *
3025
oy = y + upself->scale * ctx->paffine.yy *
2859
3026
((double) in2_pixels[y * rowstride + x * 4 + ych] / 255.0 - 0.5);
2863
3030
for (ch = 0; ch < 4; ch++) {
2864
3031
output_pixels[y * rowstride + x * 4 + ch] =
2865
gdk_pixbuf_get_interp_pixel (in_pixels, ox, oy, ch, boundarys, rowstride);
3032
get_interp_pixel (in_pixels, ox, oy, ch, boundarys, rowstride);
3036
cairo_surface_mark_dirty (output);
2869
3038
rsvg_filter_store_result (self->result, output, ctx);
2871
g_object_unref (in);
2872
g_object_unref (in2);
2873
g_object_unref (output);
3040
cairo_surface_destroy (in);
3041
cairo_surface_destroy (in2);
3042
cairo_surface_destroy (output);
3200
3377
tileWidth = (boundarys.x1 - boundarys.x0);
3201
3378
tileHeight = (boundarys.y1 - boundarys.y0);
3203
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
3204
output_pixels = gdk_pixbuf_get_pixels (output);
3380
output = _rsvg_image_surface_new (width, height);
3381
if (output == NULL) {
3382
cairo_surface_destroy (in);
3206
_rsvg_affine_invert (affine, ctx->paffine);
3386
output_pixels = cairo_image_surface_get_data (output);
3208
3388
for (y = 0; y < tileHeight; y++) {
3209
3389
for (x = 0; x < tileWidth; x++) {
3211
3391
double point[2];
3213
point[0] = affine[0] * (x + boundarys.x0) + affine[2] * (y + boundarys.y0) + affine[4];
3214
point[1] = affine[1] * (x + boundarys.x0) + affine[3] * (y + boundarys.y0) + affine[5];
3393
point[0] = affine.xx * (x + boundarys.x0) + affine.xy * (y + boundarys.y0) + affine.x0;
3394
point[1] = affine.yx * (x + boundarys.x0) + affine.yy * (y + boundarys.y0) + affine.y0;
3216
3396
pixel = output_pixels + 4 * (x + boundarys.x0) + (y + boundarys.y0) * rowstride;
3376
3555
if (width == 0 || height == 0)
3379
img = rsvg_pixbuf_new_from_href (upself->href->str,
3380
rsvg_handle_get_base_uri (upself->ctx), NULL);
3558
img = rsvg_cairo_surface_new_from_href (upself->ctx,
3385
intermediate = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 1, 8, width, height);
3388
rsvg_art_affine_image (img, intermediate,
3390
(boundarys.x1 - boundarys.x0) / ctx->paffine[0],
3391
(boundarys.y1 - boundarys.y0) / ctx->paffine[3]);
3393
if (!intermediate) {
3394
g_object_unref (img);
3564
intermediate = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
3565
if (cairo_surface_status (intermediate) != CAIRO_STATUS_SUCCESS ||
3566
!rsvg_art_affine_image (img, intermediate,
3568
(gdouble) width / ctx->paffine.xx,
3569
(gdouble) height / ctx->paffine.yy)) {
3570
cairo_surface_destroy (intermediate);
3571
cairo_surface_destroy (img);
3398
g_object_unref (img);
3575
cairo_surface_destroy (img);
3400
length = gdk_pixbuf_get_height (intermediate) * gdk_pixbuf_get_rowstride (intermediate);
3577
length = cairo_image_surface_get_height (intermediate) *
3578
cairo_image_surface_get_stride (intermediate);
3401
3579
for (i = 0; i < 4; i++)
3402
3580
channelmap[i] = ctx->channelmap[i];
3403
pixels = gdk_pixbuf_get_pixels (intermediate);
3581
pixels = cairo_image_surface_get_data (intermediate);
3404
3582
for (i = 0; i < length; i += 4) {
3405
3583
unsigned char alpha;
3406
3584
unsigned char pixel[4];
3439
3618
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
3441
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, ctx->width, ctx->height);
3620
output = _rsvg_image_surface_new (ctx->width, ctx->height);
3443
3624
img = rsvg_filter_primitive_image_render_in (self, ctx);
3444
3625
if (img == NULL) {
3445
3626
img = rsvg_filter_primitive_image_render_ext (self, ctx);
3447
gdk_pixbuf_copy_area (img, 0, 0,
3448
boundarys.x1 - boundarys.x0,
3449
boundarys.y1 - boundarys.y0, output, boundarys.x0, boundarys.y0);
3450
g_object_unref (img);
3453
gdk_pixbuf_copy_area (img, boundarys.x0, boundarys.y0, boundarys.x1 - boundarys.x0,
3454
boundarys.y1 - boundarys.y0, output, boundarys.x0, boundarys.y0);
3455
g_object_unref (img);
3635
cr = cairo_create (output);
3636
cairo_set_source_surface (cr, img, x, y);
3637
cairo_rectangle (cr, 0, 0,
3638
boundarys.x1 - boundarys.x0,
3639
boundarys.y1 - boundarys.y0);
3641
cairo_translate (cr, -boundarys.x0, -boundarys.y0);
3645
cairo_surface_destroy (img);
3648
op.surface = output;
3459
3649
op.bounds = boundarys;
3720
3911
Nx = -surfaceScale * factorx * ((gdouble)
3722
gdk_pixbuf_get_interp_pixel (I, x - dx, y - dy, chan,
3913
get_interp_pixel (I, x - dx, y - dy, chan,
3725
Kx[1] * gdk_pixbuf_get_interp_pixel (I, x, y - dy, chan,
3728
Kx[2] * gdk_pixbuf_get_interp_pixel (I, x + dx, y - dy, chan,
3731
Kx[3] * gdk_pixbuf_get_interp_pixel (I, x - dx, y, chan,
3734
Kx[4] * gdk_pixbuf_get_interp_pixel (I, x, y, chan, boundarys,
3736
Kx[5] * gdk_pixbuf_get_interp_pixel (I, x + dx, y, chan,
3739
Kx[6] * gdk_pixbuf_get_interp_pixel (I, x - dx, y + dy, chan,
3742
Kx[7] * gdk_pixbuf_get_interp_pixel (I, x, y + dy, chan,
3745
Kx[8] * gdk_pixbuf_get_interp_pixel (I, x + dx, y + dy, chan,
3916
Kx[1] * get_interp_pixel (I, x, y - dy, chan,
3919
Kx[2] * get_interp_pixel (I, x + dx, y - dy, chan,
3922
Kx[3] * get_interp_pixel (I, x - dx, y, chan,
3925
Kx[4] * get_interp_pixel (I, x, y, chan, boundarys,
3927
Kx[5] * get_interp_pixel (I, x + dx, y, chan,
3930
Kx[6] * get_interp_pixel (I, x - dx, y + dy, chan,
3933
Kx[7] * get_interp_pixel (I, x, y + dy, chan,
3936
Kx[8] * get_interp_pixel (I, x + dx, y + dy, chan,
3747
3938
rowstride))) / 255.0;
3749
3940
Ny = -surfaceScale * factory * ((gdouble)
3751
gdk_pixbuf_get_interp_pixel (I, x - dx, y - dy, chan,
3942
get_interp_pixel (I, x - dx, y - dy, chan,
3754
Ky[1] * gdk_pixbuf_get_interp_pixel (I, x, y - dy, chan,
3757
Ky[2] * gdk_pixbuf_get_interp_pixel (I, x + dx, y - dy, chan,
3760
Ky[3] * gdk_pixbuf_get_interp_pixel (I, x - dx, y, chan,
3763
Ky[4] * gdk_pixbuf_get_interp_pixel (I, x, y, chan, boundarys,
3765
Ky[5] * gdk_pixbuf_get_interp_pixel (I, x + dx, y, chan,
3768
Ky[6] * gdk_pixbuf_get_interp_pixel (I, x - dx, y + dy, chan,
3771
Ky[7] * gdk_pixbuf_get_interp_pixel (I, x, y + dy, chan,
3774
Ky[8] * gdk_pixbuf_get_interp_pixel (I, x + dx, y + dy, chan,
3945
Ky[1] * get_interp_pixel (I, x, y - dy, chan,
3948
Ky[2] * get_interp_pixel (I, x + dx, y - dy, chan,
3951
Ky[3] * get_interp_pixel (I, x - dx, y, chan,
3954
Ky[4] * get_interp_pixel (I, x, y, chan, boundarys,
3956
Ky[5] * get_interp_pixel (I, x + dx, y, chan,
3959
Ky[6] * get_interp_pixel (I, x - dx, y + dy, chan,
3962
Ky[7] * get_interp_pixel (I, x, y + dy, chan,
3965
Ky[8] * get_interp_pixel (I, x + dx, y + dy, chan,
3776
3967
rowstride))) / 255.0;
3977
4168
if (source == NULL)
4171
iaffine = ctx->paffine;
4172
if (cairo_matrix_invert (&iaffine) != CAIRO_STATUS_SUCCESS)
3980
4175
upself = (RsvgFilterPrimitiveDiffuseLighting *) self;
3981
4176
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
3983
4178
in = rsvg_filter_get_in (self->in, ctx);
3984
in_pixels = gdk_pixbuf_get_pixels (in);
3986
height = gdk_pixbuf_get_height (in);
3987
width = gdk_pixbuf_get_width (in);
3989
rowstride = gdk_pixbuf_get_rowstride (in);
3991
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
3993
output_pixels = gdk_pixbuf_get_pixels (output);
4182
cairo_surface_flush (in);
4184
in_pixels = cairo_image_surface_get_data (in);
4186
height = cairo_image_surface_get_height (in);
4187
width = cairo_image_surface_get_width (in);
4189
rowstride = cairo_image_surface_get_stride (in);
4191
output = _rsvg_image_surface_new (width, height);
4192
if (output == NULL) {
4193
cairo_surface_destroy (in);
4197
output_pixels = cairo_image_surface_get_data (output);
3995
4199
colour.x = ((guchar *) (&upself->lightingcolour))[2] / 255.0;
3996
4200
colour.y = ((guchar *) (&upself->lightingcolour))[1] / 255.0;
4007
dx = upself->dx * ctx->paffine[0];
4008
dy = upself->dy * ctx->paffine[3];
4211
dx = upself->dx * ctx->paffine.xx;
4212
dy = upself->dy * ctx->paffine.yy;
4009
4213
rawdx = upself->dx;
4010
4214
rawdy = upself->dy;
4013
_rsvg_affine_invert (iaffine, ctx->paffine);
4015
4217
for (y = boundarys.y0; y < boundarys.y1; y++)
4016
4218
for (x = boundarys.x0; x < boundarys.x1; x++) {
4017
4219
z = surfaceScale * (double) in_pixels[y * rowstride + x * 4 + ctx->channelmap[3]];
4018
L = get_light_direction (source, x, y, z, iaffine, ctx->ctx);
4220
L = get_light_direction (source, x, y, z, &iaffine, ctx->ctx);
4019
4221
N = get_surface_normal (in_pixels, boundarys, x, y,
4020
4222
dx, dy, rawdx, rawdy, upself->surfaceScale,
4021
4223
rowstride, ctx->channelmap[3]);
4022
lightcolour = get_light_colour (source, colour, x, y, z, iaffine, ctx->ctx);
4224
lightcolour = get_light_colour (source, colour, x, y, z, &iaffine, ctx->ctx);
4023
4225
factor = dotproduct (N, L);
4025
4227
output_pixels[y * rowstride + x * 4 + ctx->channelmap[0]] =
4151
4354
if (source == NULL)
4357
iaffine = ctx->paffine;
4358
if (cairo_matrix_invert (&iaffine) != CAIRO_STATUS_SUCCESS)
4154
4361
upself = (RsvgFilterPrimitiveSpecularLighting *) self;
4155
4362
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
4157
4364
in = rsvg_filter_get_in (self->in, ctx);
4158
in_pixels = gdk_pixbuf_get_pixels (in);
4160
height = gdk_pixbuf_get_height (in);
4161
width = gdk_pixbuf_get_width (in);
4163
rowstride = gdk_pixbuf_get_rowstride (in);
4165
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
4167
output_pixels = gdk_pixbuf_get_pixels (output);
4368
cairo_surface_flush (in);
4370
in_pixels = cairo_image_surface_get_data (in);
4372
height = cairo_image_surface_get_height (in);
4373
width = cairo_image_surface_get_width (in);
4375
rowstride = cairo_image_surface_get_stride (in);
4377
output = _rsvg_image_surface_new (width, height);
4378
if (output == NULL) {
4379
cairo_surface_destroy (in);
4383
output_pixels = cairo_image_surface_get_data (output);
4169
4385
colour.x = ((guchar *) (&upself->lightingcolour))[2] / 255.0;
4170
4386
colour.y = ((guchar *) (&upself->lightingcolour))[1] / 255.0;
4173
4389
surfaceScale = upself->surfaceScale / 255.0;
4175
_rsvg_affine_invert (iaffine, ctx->paffine);
4177
4391
for (y = boundarys.y0; y < boundarys.y1; y++)
4178
4392
for (x = boundarys.x0; x < boundarys.x1; x++) {
4179
4393
z = in_pixels[y * rowstride + x * 4 + 3] * surfaceScale;
4180
L = get_light_direction (source, x, y, z, iaffine, ctx->ctx);
4394
L = get_light_direction (source, x, y, z, &iaffine, ctx->ctx);
4182
4396
L = normalise (L);
4184
lightcolour = get_light_colour (source, colour, x, y, z, iaffine, ctx->ctx);
4398
lightcolour = get_light_colour (source, colour, x, y, z, &iaffine, ctx->ctx);
4185
4399
base = dotproduct (get_surface_normal (in_pixels, boundarys, x, y,
4186
1, 1, 1.0 / ctx->paffine[0],
4187
1.0 / ctx->paffine[3], upself->surfaceScale,
4400
1, 1, 1.0 / ctx->paffine.xx,
4401
1.0 / ctx->paffine.yy, upself->surfaceScale,
4188
4402
rowstride, ctx->channelmap[3]), L);
4190
4404
factor = upself->specularConstant * pow (base, upself->specularExponent) * 255;
4313
4529
guchar *in_pixels;
4314
4530
guchar *output_pixels;
4319
RsvgFilterPrimitiveTile *upself;
4321
upself = (RsvgFilterPrimitiveTile *) self;
4532
cairo_surface_t *output, *in;
4322
4534
oboundarys = rsvg_filter_primitive_get_bounds (self, ctx);
4324
4536
input = rsvg_filter_get_result (self->in, ctx);
4326
4538
boundarys = input.bounds;
4329
in_pixels = gdk_pixbuf_get_pixels (in);
4331
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, ctx->width, ctx->height);
4332
rowstride = gdk_pixbuf_get_rowstride (output);
4334
output_pixels = gdk_pixbuf_get_pixels (output);
4540
cairo_surface_flush (in);
4542
in_pixels = cairo_image_surface_get_data (in);
4544
output = _rsvg_image_surface_new (ctx->width, ctx->height);
4545
if (output == NULL) {
4546
cairo_surface_destroy (in);
4550
rowstride = cairo_image_surface_get_stride (output);
4552
output_pixels = cairo_image_surface_get_data (output);
4336
4554
for (y = oboundarys.y0; y < oboundarys.y1; y++)
4337
4555
for (x = oboundarys.x0; x < oboundarys.x1; x++)