summaryrefslogtreecommitdiff
path: root/cd/src/gdk/cdgdkimg.c
blob: 4b4475b83f8b59d27a3b7512796ed0a97c0197e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/** \file
 * \brief Gdk Image Driver
 *
 * See Copyright Notice in cd.h
 */

#include <stdlib.h>

#include "cdgdk.h"
#include "cdimage.h"


static void cdkillcanvas(cdCtxCanvas* ctxcanvas)
{
  cdgdkKillCanvas(ctxcanvas);
}

static void cdcreatecanvas(cdCanvas* canvas, void *data)
{
  cdCtxImage *ctximage = ((cdImage*)data)->ctximage;
  cdgdkCreateCanvas(canvas, (GdkDrawable*)ctximage->img, ctximage->scr, ctximage->vis);
}

static void cdinittable(cdCanvas* canvas)
{
  cdgdkInitTable(canvas);

  canvas->cxKillCanvas = cdkillcanvas;
}

static cdContext cdImageContext =
{
  CD_CAP_ALL & ~(CD_CAP_PLAY | CD_CAP_YAXIS | CD_CAP_FPRIMTIVES | CD_CAP_PATH | CD_CAP_BEZIER ),
  0,
  cdcreatecanvas,
  cdinittable,
  NULL,
  NULL
};


cdContext* cdContextImage(void)
{
  if (cdUseContextPlus(CD_QUERY))
  {
    cdContext* ctx = cdGetContextPlus(CD_CTX_IMAGE);
    if (ctx != NULL)
      return ctx;
  }

  return &cdImageContext;
}