~ubuntu-branches/ubuntu/trusty/librsvg/trusty-proposed

« back to all changes in this revision

Viewing changes to rsvg-structure.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2012-03-27 01:47:52 UTC
  • mfrom: (1.1.32) (34.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20120327014752-c9vmipiww40cnip7
Tags: 2.36.0-1
* New upstream release.
* Update debian/copyright using the machine-readable copyright format 1.0.
* Bump Standards-Version to 3.9.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
    RsvgNodeUse *use = (RsvgNodeUse *) self;
200
200
    RsvgNode *child;
201
201
    RsvgState *state;
202
 
    double affine[6];
 
202
    cairo_matrix_t affine;
203
203
    double x, y, w, h;
204
204
    x = _rsvg_css_normalize_length (&use->x, ctx, 'h');
205
205
    y = _rsvg_css_normalize_length (&use->y, ctx, 'v');
218
218
 
219
219
    state = rsvg_current_state (ctx);
220
220
    if (RSVG_NODE_TYPE (child) != RSVG_NODE_TYPE_SYMBOL) {
221
 
        _rsvg_affine_translate (affine, x, y);
222
 
        _rsvg_affine_multiply (state->affine, affine, state->affine);
 
221
        cairo_matrix_init_translate (&affine, x, y);
 
222
        cairo_matrix_multiply (&state->affine, &affine, &state->affine);
223
223
 
224
224
        rsvg_push_discrete_layer (ctx);
225
225
        rsvg_state_push (ctx);
231
231
 
232
232
        if (symbol->vbox.active) {
233
233
            rsvg_preserve_aspect_ratio
234
 
                (symbol->preserve_aspect_ratio, symbol->vbox.w, symbol->vbox.h, &w, &h, &x, &y);
235
 
 
236
 
            _rsvg_affine_translate (affine, x, y);
237
 
            _rsvg_affine_multiply (state->affine, affine, state->affine);
238
 
            _rsvg_affine_scale (affine, w / symbol->vbox.w, h / symbol->vbox.h);
239
 
            _rsvg_affine_multiply (state->affine, affine, state->affine);
240
 
            _rsvg_affine_translate (affine, -symbol->vbox.x, -symbol->vbox.y);
241
 
            _rsvg_affine_multiply (state->affine, affine, state->affine);
242
 
 
243
 
            _rsvg_push_view_box (ctx, symbol->vbox.w, symbol->vbox.h);
 
234
                (symbol->preserve_aspect_ratio,
 
235
                 symbol->vbox.rect.width, symbol->vbox.rect.height,
 
236
                 &w, &h, &x, &y);
 
237
 
 
238
            cairo_matrix_init_translate (&affine, x, y);
 
239
            cairo_matrix_multiply (&state->affine, &affine, &state->affine);
 
240
 
 
241
            cairo_matrix_init_scale (&affine, w / symbol->vbox.rect.width, h / symbol->vbox.rect.height);
 
242
            cairo_matrix_multiply (&state->affine, &affine, &state->affine);
 
243
 
 
244
            cairo_matrix_init_translate (&affine, -symbol->vbox.rect.x, -symbol->vbox.rect.y);
 
245
            cairo_matrix_multiply (&state->affine, &affine, &state->affine);
 
246
 
 
247
            _rsvg_push_view_box (ctx, symbol->vbox.rect.width, symbol->vbox.rect.height);
244
248
            rsvg_push_discrete_layer (ctx);
245
249
            if (!state->overflow || (!state->has_overflow && child->state->overflow))
246
 
                rsvg_add_clipping_rect (ctx, symbol->vbox.x, symbol->vbox.y,
247
 
                                        symbol->vbox.w, symbol->vbox.h);
 
250
                rsvg_add_clipping_rect (ctx, symbol->vbox.rect.x, symbol->vbox.rect.y,
 
251
                                        symbol->vbox.rect.width, symbol->vbox.rect.height);
248
252
        } else {
249
 
            _rsvg_affine_translate (affine, x, y);
250
 
            _rsvg_affine_multiply (state->affine, affine, state->affine);
 
253
            cairo_matrix_init_translate (&affine, x, y);
 
254
            cairo_matrix_multiply (&state->affine, &affine, &state->affine);
251
255
            rsvg_push_discrete_layer (ctx);
252
256
        }
253
257
 
266
270
{
267
271
    RsvgNodeSvg *sself;
268
272
    RsvgState *state;
269
 
    gdouble affine[6], affine_old[6], affine_new[6];
 
273
    cairo_matrix_t affine, affine_old, affine_new;
270
274
    guint i;
271
275
    double nx, ny, nw, nh;
272
276
    sself = (RsvgNodeSvg *) self;
280
284
 
281
285
    state = rsvg_current_state (ctx);
282
286
 
283
 
    for (i = 0; i < 6; i++)
284
 
        affine_old[i] = state->affine[i];
 
287
    affine_old = state->affine;
285
288
 
286
289
    if (sself->vbox.active) {
287
290
        double x = nx, y = ny, w = nw, h = nh;
288
291
        rsvg_preserve_aspect_ratio (sself->preserve_aspect_ratio,
289
 
                                    sself->vbox.w, sself->vbox.h, &w, &h, &x, &y);
290
 
        affine[0] = w / sself->vbox.w;
291
 
        affine[1] = 0;
292
 
        affine[2] = 0;
293
 
        affine[3] = h / sself->vbox.h;
294
 
        affine[4] = x - sself->vbox.x * w / sself->vbox.w;
295
 
        affine[5] = y - sself->vbox.y * h / sself->vbox.h;
296
 
        _rsvg_affine_multiply (state->affine, affine, state->affine);
297
 
        _rsvg_push_view_box (ctx, sself->vbox.w, sself->vbox.h);
 
292
                                    sself->vbox.rect.width, sself->vbox.rect.height,
 
293
                                    &w, &h, &x, &y);
 
294
        cairo_matrix_init (&affine,
 
295
                           w / sself->vbox.rect.width,
 
296
                           0,
 
297
                           0,
 
298
                           h / sself->vbox.rect.height,
 
299
                           x - sself->vbox.rect.x * w / sself->vbox.rect.width,
 
300
                           y - sself->vbox.rect.y * h / sself->vbox.rect.height);
 
301
        cairo_matrix_multiply (&state->affine, &affine, &state->affine);
 
302
        _rsvg_push_view_box (ctx, sself->vbox.rect.width, sself->vbox.rect.height);
298
303
    } else {
299
 
        affine[0] = 1;
300
 
        affine[1] = 0;
301
 
        affine[2] = 0;
302
 
        affine[3] = 1;
303
 
        affine[4] = nx;
304
 
        affine[5] = ny;
305
 
        _rsvg_affine_multiply (state->affine, affine, state->affine);
 
304
        cairo_matrix_init_translate (&affine, nx, ny);
 
305
        cairo_matrix_multiply (&state->affine, &affine, &state->affine);
306
306
        _rsvg_push_view_box (ctx, nw, nh);
307
307
    }
308
 
    for (i = 0; i < 6; i++)
309
 
        affine_new[i] = state->affine[i];
 
308
 
 
309
    affine_new = state->affine;
310
310
 
311
311
    rsvg_push_discrete_layer (ctx);
312
312
 
313
313
    /* Bounding box addition must be AFTER the discrete layer push, 
314
314
       which must be AFTER the transformation happens. */
315
315
    if (!state->overflow && self->parent) {
316
 
        for (i = 0; i < 6; i++)
317
 
            state->affine[i] = affine_old[i];
 
316
        state->affine = affine_old;
318
317
        rsvg_add_clipping_rect (ctx, nx, ny, nw, nh);
319
 
        for (i = 0; i < 6; i++)
320
 
            state->affine[i] = affine_new[i];
 
318
        state->affine = affine_new;
321
319
    }
322
320
 
323
321
    for (i = 0; i < self->children->len; i++) {
361
359
         * style element is not loaded yet here, so we need to store those attribues
362
360
         * to be applied later.
363
361
         */
364
 
        svg->atts = rsvg_property_bag_ref(atts);
 
362
        svg->atts = rsvg_property_bag_dup(atts);
365
363
    }
366
364
}
367
365