~ubuntu-branches/ubuntu/trusty/compiz/trusty

« back to all changes in this revision

Viewing changes to plugins/imgsvg.cpp

  • Committer: Dennis kasprzyk
  • Author(s): Dennis Kasprzyk
  • Date: 2009-03-15 05:09:18 UTC
  • Revision ID: git-v1:163f6b6f3c3b7764987cbdf8e03cc355edeaa499
New generalized build system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2006 Novell, Inc.
3
 
 *
4
 
 * Permission to use, copy, modify, distribute, and sell this software
5
 
 * and its documentation for any purpose is hereby granted without
6
 
 * fee, provided that the above copyright notice appear in all copies
7
 
 * and that both that copyright notice and this permission notice
8
 
 * appear in supporting documentation, and that the name of
9
 
 * Novell, Inc. not be used in advertising or publicity pertaining to
10
 
 * distribution of the software without specific, written prior permission.
11
 
 * Novell, Inc. makes no representations about the suitability of this
12
 
 * software for any purpose. It is provided "as is" without express or
13
 
 * implied warranty.
14
 
 *
15
 
 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
 
 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
 
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
 
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
 
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
 
 *
23
 
 * Author: David Reveman <davidr@novell.com>
24
 
 */
25
 
 
26
 
#include "imgsvg.h"
27
 
 
28
 
COMPIZ_PLUGIN_20081216 (imgsvg, SvgPluginVTable)
29
 
 
30
 
static bool
31
 
svgSet (CompAction         *action,
32
 
        CompAction::State  state,
33
 
        CompOption::Vector &options)
34
 
{
35
 
    CompWindow *w;
36
 
    Window     xid;
37
 
 
38
 
    xid = CompOption::getIntOptionNamed (options, "window");
39
 
    w   = screen->findWindow (xid);
40
 
 
41
 
    if (w)
42
 
    {
43
 
        decor_point_t p[2];
44
 
        CompString    data;
45
 
 
46
 
        SVG_WINDOW (w);
47
 
 
48
 
        memset (p, 0, sizeof (p));
49
 
 
50
 
        p[0].gravity = CompOption::getIntOptionNamed (options, "gravity0",
51
 
                                                      GRAVITY_NORTH | GRAVITY_WEST);
52
 
 
53
 
        p[0].x = CompOption::getIntOptionNamed (options, "x0");
54
 
        p[0].y = CompOption::getIntOptionNamed (options, "y0");
55
 
 
56
 
        p[1].gravity = CompOption::getIntOptionNamed (options, "gravity1",
57
 
                                                      GRAVITY_SOUTH | GRAVITY_EAST);
58
 
 
59
 
        p[1].x = CompOption::getIntOptionNamed (options, "x1");
60
 
        p[1].y = CompOption::getIntOptionNamed (options, "y1");
61
 
 
62
 
        data = CompOption::getStringOptionNamed (options, "data");
63
 
        sw->setSvg (data, p);
64
 
    }
65
 
 
66
 
    return false;
67
 
}
68
 
 
69
 
static const CompMetadata::OptionInfo svgOptionInfo[] = {
70
 
    { "set", "action", 0, svgSet, NULL }
71
 
};
72
 
 
73
 
SvgScreen::SvgScreen (CompScreen *screen) :
74
 
    PrivateHandler<SvgScreen, CompScreen> (screen),
75
 
    opt (SVG_OPTION_NUM)
76
 
{
77
 
    if (!imgsvgVTable->getMetadata ()->initOptions (svgOptionInfo,
78
 
                                                    SVG_OPTION_NUM, opt))
79
 
    {
80
 
        setFailed ();
81
 
        return;
82
 
    }
83
 
 
84
 
    ScreenInterface::setHandler (screen, true);
85
 
}
86
 
 
87
 
SvgScreen::~SvgScreen ()
88
 
{
89
 
}
90
 
 
91
 
CompOption::Vector &
92
 
SvgScreen::getOptions ()
93
 
{
94
 
    return opt;
95
 
}
96
 
 
97
 
bool
98
 
SvgScreen::setOption (const char        *name,
99
 
                      CompOption::Value &value)
100
 
{
101
 
    CompOption *o;
102
 
 
103
 
    o = CompOption::findOption (opt, name);
104
 
    if (!o)
105
 
        return false;
106
 
 
107
 
    return CompOption::setOption (*o, value);
108
 
}
109
 
 
110
 
bool
111
 
SvgScreen::fileToImage (CompString &path,
112
 
                        CompSize   &size,
113
 
                        int        &stride,
114
 
                        void       *&data)
115
 
{
116
 
    CompString fileName = path;
117
 
    bool       status = false;
118
 
    int        len = fileName.length ();
119
 
 
120
 
    if (len < 4 || fileName.substr (len - 4, 4) != ".svg")
121
 
        fileName += ".svg";
122
 
 
123
 
    status = readSvgToImage (fileName.c_str (), size, data);
124
 
 
125
 
    if (status)
126
 
    {
127
 
        stride = size.width () * 4;
128
 
        return true;
129
 
    }
130
 
 
131
 
    status = screen->fileToImage (path, size, stride, data);
132
 
 
133
 
    return status;
134
 
}
135
 
 
136
 
void
137
 
SvgScreen::handleCompizEvent (const char         *plugin,
138
 
                              const char         *event,
139
 
                              CompOption::Vector &options)
140
 
{
141
 
    screen->handleCompizEvent (plugin, event, options);
142
 
 
143
 
    if (strcmp (plugin, "zoom") == 0)
144
 
    {
145
 
        int output = CompOption::getIntOptionNamed (options, "output");
146
 
        if (output == 0)
147
 
        {
148
 
            if (strcmp (event, "in") == 0)
149
 
            {
150
 
                zoom.setGeometry (CompOption::getIntOptionNamed (options, "x1"),
151
 
                                  CompOption::getIntOptionNamed (options, "y1"),
152
 
                                  CompOption::getIntOptionNamed (options, "x2"),
153
 
                                  CompOption::getIntOptionNamed (options, "y2"));
154
 
            }
155
 
            else if (strcmp (event, "out") == 0)
156
 
            {
157
 
                zoom.setGeometry (0, 0, 0, 0);
158
 
            }
159
 
        }
160
 
    }
161
 
}
162
 
 
163
 
bool
164
 
SvgScreen::readSvgToImage (const char *file,
165
 
                           CompSize   &size,
166
 
                           void       *&data)
167
 
{
168
 
    cairo_surface_t   *surface;
169
 
    std::ifstream     svgFile;
170
 
    GError            *error = NULL;
171
 
    RsvgHandle        *svgHandle;
172
 
    RsvgDimensionData svgDimension;
173
 
 
174
 
    svgFile.open (file);
175
 
    if (!svgFile.is_open ())
176
 
        return false;
177
 
 
178
 
    svgFile.close ();
179
 
    svgHandle = rsvg_handle_new_from_file (file, &error);
180
 
    if (!svgHandle)
181
 
        return FALSE;
182
 
 
183
 
    rsvg_handle_get_dimensions (svgHandle, &svgDimension);
184
 
 
185
 
    size.setWidth (svgDimension.width);
186
 
    size.setHeight (svgDimension.height);
187
 
 
188
 
    data = malloc (svgDimension.width * svgDimension.height * 4);
189
 
    if (!data)
190
 
    {
191
 
        rsvg_handle_free (svgHandle);
192
 
        return false;
193
 
    }
194
 
 
195
 
    surface = cairo_image_surface_create_for_data ((unsigned char *) data,
196
 
                                                   CAIRO_FORMAT_ARGB32,
197
 
                                                   svgDimension.width,
198
 
                                                   svgDimension.height,
199
 
                                                   svgDimension.width * 4);
200
 
    if (surface)
201
 
    {
202
 
        cairo_t *cr;
203
 
 
204
 
        cr = cairo_create (surface);
205
 
 
206
 
        cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
207
 
        cairo_paint (cr);
208
 
        cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
209
 
 
210
 
        rsvg_handle_render_cairo (svgHandle, cr);
211
 
 
212
 
        cairo_destroy (cr);
213
 
        cairo_surface_destroy (surface);
214
 
    }
215
 
 
216
 
    rsvg_handle_free (svgHandle);
217
 
 
218
 
    return true;
219
 
}
220
 
 
221
 
SvgWindow::SvgWindow (CompWindow *window) :
222
 
    PrivateHandler<SvgWindow, CompWindow> (window),
223
 
    sScreen (SvgScreen::get (screen)),
224
 
    gScreen (GLScreen::get (screen)),
225
 
    window (window),
226
 
    gWindow (GLWindow::get (window)),
227
 
    source (NULL),
228
 
    context (NULL)
229
 
{
230
 
    if (gWindow)
231
 
        GLWindowInterface::setHandler (gWindow, false);
232
 
}
233
 
 
234
 
SvgWindow::~SvgWindow ()
235
 
{
236
 
    if (source)
237
 
    {
238
 
        rsvg_handle_free (source->svg);
239
 
        delete source;
240
 
    }
241
 
 
242
 
    if (context)
243
 
    {
244
 
        finiTexture (context->texture[0]);
245
 
        delete context; 
246
 
    }
247
 
}
248
 
 
249
 
bool
250
 
SvgWindow::glDraw (const GLMatrix     &transform,
251
 
                   GLFragment::Attrib &fragment,
252
 
                   const CompRegion   &region,
253
 
                   unsigned int       mask)
254
 
{
255
 
    bool status = gWindow->glDraw (transform, fragment, region, mask);
256
 
 
257
 
    if (!status)
258
 
        return status;
259
 
 
260
 
    const CompRegion &reg = (mask & PAINT_WINDOW_TRANSFORMED_MASK) ?
261
 
                            infiniteRegion : region;
262
 
 
263
 
    if (context && reg.numRects ())
264
 
    {
265
 
        GLTexture::MatrixList matrix (1);
266
 
        REGION                r;
267
 
        int                   i, j;
268
 
        int                   x1, y1, x2, y2;
269
 
        CompRect              rect = context->box.boundingRect ();
270
 
 
271
 
        x1 = MIN (rect.x1 (), sScreen->zoom.x1 ());
272
 
        y1 = MIN (rect.y1 (), sScreen->zoom.y1 ());
273
 
        x2 = MAX (rect.x2 (), sScreen->zoom.x2 ());
274
 
        y2 = MAX (rect.y2 (), sScreen->zoom.y2 ());
275
 
 
276
 
        rect.setGeometry (x1, y1, x2 - x1, y2 - y1);
277
 
 
278
 
        for (i = 0; i < context->texture[0].textures.size (); i++)
279
 
        {
280
 
            matrix[0] = context->texture[0].matrices[i];
281
 
 
282
 
            gWindow->geometry ().reset ();
283
 
            gWindow->glAddGeometry (matrix, context->box, reg);
284
 
 
285
 
            if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
286
 
                mask |= PAINT_WINDOW_BLEND_MASK;
287
 
 
288
 
            gWindow->glDrawTexture (context->texture[0].textures[i], fragment, mask);
289
 
 
290
 
            if (rect.width () > 0 && rect.height () > 0)
291
 
            {
292
 
                float    xScale, yScale;
293
 
                float    dx, dy;
294
 
                int      width, height;
295
 
                int      saveFilter;
296
 
 
297
 
                rect.setGeometry (rect.x1 () - 1,
298
 
                                  rect.y1 () - 1,
299
 
                                  rect.width () + 1,
300
 
                                  rect.height () + 1);
301
 
 
302
 
                xScale = screen->width  () /
303
 
                         (float) (sScreen->zoom.width ());
304
 
                yScale = screen->height () /
305
 
                         (float) (sScreen->zoom.height ());
306
 
 
307
 
                dx = rect.width ();
308
 
                dy = rect.height ();
309
 
 
310
 
                width  = dx * xScale + 0.5f;
311
 
                height = dy * yScale + 0.5f;
312
 
 
313
 
                if (rect   != context->rect          ||
314
 
                    width  != context->size.width () ||
315
 
                    height != context->size.height ())
316
 
                {
317
 
                    float x1, y1, x2, y2;
318
 
 
319
 
                    context->rect = rect;
320
 
                    context->size.setWidth (width);
321
 
                    context->size.setHeight (height);
322
 
 
323
 
                    dx = context->box.boundingRect ().width ();
324
 
                    dy = context->box.boundingRect ().height ();
325
 
 
326
 
                    x1 = (rect.x1 () - context->box.boundingRect ().x ()) / dx;
327
 
                    y1 = (rect.y1 () - context->box.boundingRect ().y ()) / dy;
328
 
                    x2 = (rect.x2 () - context->box.boundingRect ().x ()) / dx;
329
 
                    y2 = (rect.y2 () - context->box.boundingRect ().y ()) / dy;
330
 
 
331
 
                    finiTexture (context->texture[1]);
332
 
 
333
 
                    if (initTexture (context->source, context->texture[1],
334
 
                                     context->size))
335
 
                    {
336
 
                        renderSvg (context->source, context->texture[1],
337
 
                                   context->size, x1, y1, x2, y2);
338
 
 
339
 
                        updateSvgMatrix ();
340
 
                    }
341
 
                }
342
 
 
343
 
                for (j = 0; j < context->texture[1].textures.size (); j++)
344
 
                {
345
 
                    GLTexture::Filter saveFilter;
346
 
                    CompRegion        r (rect);
347
 
 
348
 
                    matrix[0] = context->texture[1].matrices[j];
349
 
 
350
 
                    saveFilter = gScreen->filter (SCREEN_TRANS_FILTER);
351
 
                    gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);
352
 
 
353
 
                    gWindow->geometry ().reset ();
354
 
                    gWindow->glAddGeometry (matrix, r, reg);
355
 
 
356
 
                    gWindow->glDrawTexture (context->texture[1].textures[j],
357
 
                                            fragment, mask);
358
 
 
359
 
                    gScreen->setFilter (SCREEN_TRANS_FILTER, saveFilter);
360
 
                }
361
 
            }
362
 
            else if (context->texture[1].size.width ())
363
 
            {
364
 
                finiTexture (context->texture[1]);
365
 
                initTexture (source, context->texture[1], CompSize ());
366
 
 
367
 
                memset (&context->rect, 0, sizeof (BoxRec));
368
 
                context->size.setWidth (0);
369
 
                context->size.setHeight (0);
370
 
            }
371
 
        }
372
 
    }
373
 
 
374
 
    return status;
375
 
}
376
 
 
377
 
void
378
 
SvgWindow::moveNotify (int  dx,
379
 
                       int  dy,
380
 
                       bool immediate)
381
 
{
382
 
    if (context)
383
 
    {
384
 
        context->box.translate (dx, dy);
385
 
        updateSvgMatrix ();
386
 
    }
387
 
 
388
 
    window->moveNotify (dx, dy, immediate);
389
 
}
390
 
 
391
 
void
392
 
SvgWindow::resizeNotify (int dx,
393
 
                         int dy,
394
 
                         int dwidth,
395
 
                         int dheight)
396
 
{
397
 
    if (source)
398
 
        updateSvgContext ();
399
 
 
400
 
    window->resizeNotify (dx, dy, dwidth, dheight);
401
 
}
402
 
 
403
 
void
404
 
SvgWindow::updateSvgMatrix ()
405
 
{
406
 
    SvgTexture        *texture;
407
 
    GLTexture::Matrix *m;
408
 
    int               i;
409
 
    CompRect          rect;
410
 
 
411
 
    rect = context->box.boundingRect ();
412
 
    texture = &context->texture[0];
413
 
 
414
 
    if (texture->matrices.size () != texture->textures.size ())
415
 
        texture->matrices.resize (texture->textures.size ());
416
 
 
417
 
    for (i = 0; i < texture->textures.size (); i++)
418
 
    {
419
 
        m = &texture->matrices[i];
420
 
        *m = texture->textures[i]->matrix ();
421
 
 
422
 
        m->xx *= (float) texture->size.width ()  / rect.width ();
423
 
        m->yy *= (float) texture->size.height () / rect.height ();
424
 
 
425
 
        m->x0 -= (rect.x () * m->xx);
426
 
        m->y0 -= (rect.y () * m->yy);
427
 
    }
428
 
 
429
 
    texture = &context->texture[1];
430
 
 
431
 
    if (texture->matrices.size () != texture->textures.size ())
432
 
        texture->matrices.resize (texture->textures.size ());
433
 
 
434
 
    for (i = 0; i < texture->textures.size (); i++)
435
 
    {
436
 
        m = &texture->matrices[i];
437
 
        *m = texture->textures[i]->matrix ();
438
 
 
439
 
        m->xx *= (float) texture->size.width ()  / context->rect.width ();
440
 
        m->yy *= (float) texture->size.height () / context->rect.height ();
441
 
 
442
 
        m->x0 -= (context->rect.x () * m->xx);
443
 
        m->y0 -= (context->rect.y () * m->yy);
444
 
    }
445
 
}
446
 
 
447
 
void
448
 
SvgWindow::updateSvgContext ()
449
 
{
450
 
    int      x1, y1, x2, y2;
451
 
    CompSize wSize;
452
 
 
453
 
    if (context)
454
 
    {
455
 
        finiTexture (context->texture[0]);
456
 
        finiTexture (context->texture[1]);
457
 
    }
458
 
    else
459
 
    {
460
 
        context = new SvgContext;
461
 
        if (!context)
462
 
            return;
463
 
    }
464
 
 
465
 
    initTexture (source, context->texture[1], context->size);
466
 
 
467
 
    context->source = source;
468
 
 
469
 
    wSize.setWidth (window->geometry ().width ());
470
 
    wSize.setHeight (window->geometry ().height ());
471
 
 
472
 
    decor_apply_gravity (source->p1.gravity,
473
 
                         source->p1.x, source->p1.y,
474
 
                         wSize.width (), wSize.height (),
475
 
                         &x1, &y1);
476
 
 
477
 
    decor_apply_gravity (source->p2.gravity,
478
 
                         source->p2.x, source->p2.y,
479
 
                         wSize.width (), wSize.height (),
480
 
                         &x2, &y2);
481
 
 
482
 
    x1 = MAX (x1, 0);
483
 
    y1 = MAX (y1, 0);
484
 
    x2 = MIN (x2, wSize.width ());
485
 
    y2 = MIN (y2, wSize.height ());
486
 
 
487
 
    if (!initTexture (source, context->texture[0], wSize))
488
 
    {
489
 
        delete context;
490
 
        context = NULL;
491
 
    }
492
 
    else
493
 
    {
494
 
        renderSvg (source, context->texture[0], wSize, 0.0f, 0.0f, 1.0f, 1.0f);
495
 
 
496
 
        initTexture (source, context->texture[1], CompSize ());
497
 
 
498
 
        context->box += CompRect (x1, y1, x2 - x1, y2 - y1);
499
 
        context->box.translate (window->geometry ().x (), window->geometry ().y ());
500
 
 
501
 
        updateSvgMatrix ();
502
 
    }
503
 
}
504
 
 
505
 
void
506
 
SvgWindow::renderSvg (SvgSource  *source,
507
 
                      SvgTexture &texture,
508
 
                      CompSize   size,
509
 
                      float      x1,
510
 
                      float      y1,
511
 
                      float      x2,
512
 
                      float      y2)
513
 
{
514
 
    float w = x2 - x1;
515
 
    float h = y2 - y1;
516
 
 
517
 
    cairo_save (texture.cr);
518
 
 
519
 
    cairo_set_operator (texture.cr, CAIRO_OPERATOR_SOURCE);
520
 
    cairo_set_source_rgba (texture.cr, 1.0, 1.0, 1.0, 0.0);
521
 
    cairo_paint (texture.cr);
522
 
    cairo_set_operator (texture.cr, CAIRO_OPERATOR_OVER);
523
 
 
524
 
    cairo_scale (texture.cr, 1.0 / w, 1.0 / h);
525
 
 
526
 
    cairo_scale (texture.cr,
527
 
                 (double) size.width () / source->dimension.width,
528
 
                 (double) size.height () / source->dimension.height);
529
 
 
530
 
    cairo_translate (texture.cr,
531
 
                     -x1 * source->dimension.width,
532
 
                     -y1 * source->dimension.height);
533
 
 
534
 
    rsvg_handle_render_cairo (source->svg, texture.cr);
535
 
 
536
 
    cairo_restore (texture.cr);
537
 
}
538
 
 
539
 
bool
540
 
SvgWindow::initTexture (SvgSource  *source,
541
 
                        SvgTexture &texture,
542
 
                        CompSize   size)
543
 
{
544
 
    cairo_surface_t *surface;
545
 
    Display         *dpy = screen->dpy ();
546
 
 
547
 
    texture.size    = size;
548
 
    texture.pixmap  = None;
549
 
    texture.cr      = NULL;
550
 
 
551
 
    if (size.width () && size.height ())
552
 
    {
553
 
        XWindowAttributes attr;
554
 
        XGetWindowAttributes (dpy, window->id (), &attr);
555
 
 
556
 
        texture.pixmap = XCreatePixmap (dpy, screen->root (),
557
 
                                        size.width (), size.height (),
558
 
                                        attr.depth);
559
 
 
560
 
        texture.textures =
561
 
            GLTexture::bindPixmapToTexture (texture.pixmap,
562
 
                                            size.width (), size.height (), attr.depth);
563
 
        if (texture.textures.empty ())
564
 
        {
565
 
            compLogMessage ("svg", CompLogLevelInfo,
566
 
                            "Couldn't bind pixmap 0x%x to texture",
567
 
                            (int) texture.pixmap);
568
 
 
569
 
            XFreePixmap (dpy, texture.pixmap);
570
 
 
571
 
            return false;
572
 
        }
573
 
 
574
 
        surface = cairo_xlib_surface_create (dpy, texture.pixmap, attr.visual,
575
 
                                             size.width (), size.height ());
576
 
        texture.cr = cairo_create (surface);
577
 
        cairo_surface_destroy (surface);
578
 
    }
579
 
 
580
 
    return true;
581
 
}
582
 
 
583
 
void
584
 
SvgWindow::finiTexture (SvgTexture &texture)
585
 
{
586
 
    if (texture.cr)
587
 
        cairo_destroy (texture.cr);
588
 
 
589
 
    if (texture.pixmap)
590
 
        XFreePixmap (screen->dpy (), texture.pixmap);
591
 
}
592
 
 
593
 
void
594
 
SvgWindow::setSvg (CompString    &data,
595
 
                   decor_point_t p[2])
596
 
{
597
 
    RsvgHandle *svg = NULL;
598
 
    GError     *error = NULL;
599
 
 
600
 
    if (!gWindow)
601
 
        return;
602
 
 
603
 
    svg = rsvg_handle_new_from_data ((guint8 *) data.c_str (),
604
 
                                     data.length (), &error);
605
 
 
606
 
    if (source)
607
 
    {
608
 
        rsvg_handle_free (source->svg);
609
 
        source->svg = svg;
610
 
    }
611
 
    else
612
 
    {
613
 
        source = new SvgSource;
614
 
        if (source)
615
 
            source->svg = svg;
616
 
    }
617
 
 
618
 
    if (source && source->svg)
619
 
    {
620
 
        source->p1 = p[0];
621
 
        source->p2 = p[1];
622
 
 
623
 
        source->svg = svg;
624
 
 
625
 
        gWindow->glDrawSetEnabled (this, true);
626
 
        rsvg_handle_get_dimensions (svg, &source->dimension);
627
 
 
628
 
        updateSvgContext ();
629
 
    }
630
 
    else
631
 
    {
632
 
        if (svg)
633
 
            rsvg_handle_free (svg);
634
 
 
635
 
        if (source)
636
 
        {
637
 
            delete source;
638
 
            source = NULL;
639
 
        }
640
 
 
641
 
        if (context)
642
 
        {
643
 
            finiTexture (context->texture[0]);
644
 
            delete context;
645
 
            context = NULL;
646
 
        }
647
 
 
648
 
        gWindow->glDrawSetEnabled (this, false);
649
 
    }
650
 
}
651
 
 
652
 
bool
653
 
SvgPluginVTable::init ()
654
 
{
655
 
    if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
656
 
        return false;
657
 
 
658
 
    getMetadata ()->addFromOptionInfo (svgOptionInfo, SVG_OPTION_NUM);
659
 
    getMetadata ()->addFromFile (name ());
660
 
 
661
 
    rsvg_init ();
662
 
 
663
 
    return true;
664
 
}
665
 
 
666
 
void
667
 
SvgPluginVTable::fini ()
668
 
{
669
 
    rsvg_term ();
670
 
}
671