7 /* doesn't set win or parent */
8 static struct RrSurface *surface_new(enum RrSurfaceType type,
11 struct RrSurface *sur;
13 sur = malloc(sizeof(struct RrSurface));
15 sur->ntextures = numtex;
17 sur->texture = malloc(sizeof(struct RrTexture) * numtex);
18 memset(sur->texture, 0, sizeof(struct RrTexture) * numtex);
24 struct RrSurface *RrSurfaceNewProto(enum RrSurfaceType type,
27 struct RrSurface *sur;
29 sur = surface_new(type, numtex);
36 struct RrSurface *RrSurfaceNew(struct RrInstance *inst,
37 enum RrSurfaceType type,
41 struct RrSurface *sur;
43 sur = surface_new(type, numtex);
50 struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type,
51 struct RrSurface *parent,
54 struct RrSurface *sur;
56 sur = surface_new(type, numtex);
57 sur->inst = parent->inst;
58 sur->win = None; /* XXX XCreateWindow? */
65 /* doesn't set win or parent */
66 static struct RrSurface *surface_copy(struct RrSurface *orig)
68 struct RrSurface *sur;
70 sur = malloc(sizeof(struct RrSurface));
71 sur->type = orig->type;
73 case RR_SURFACE_PLANAR:
74 sur->data = orig->data;
76 case RR_SURFACE_NONPLANAR:
80 sur->ntextures = orig->ntextures;
81 sur->texture = malloc(sizeof(struct RrTexture) * sur->ntextures);
82 memcpy(sur->texture, orig->texture,
83 sizeof(struct RrTexture) * sur->ntextures);
87 struct RrSurface *RrSurfaceCopy(struct RrInstance *inst,
88 struct RrSurface *orig,
91 struct RrSurface *sur;
93 sur = surface_copy(orig);
100 struct RrSurface *RrSurfaceCopyChild(struct RrSurface *orig,
101 struct RrSurface *parent)
103 struct RrSurface *sur;
105 sur = surface_copy(orig);
106 sur->inst = parent->inst;
107 sur->win = None; /* XXX XCreateWindow? */
108 sur->parent = parent;
112 void RrSurfaceFree(struct RrSurface *sur)
117 if (sur->parent && sur->win)
118 XDestroyWindow(RrDisplay(sur->inst), sur->win);
123 struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum)
125 assert(texnum < sur->ntextures);
126 return &(sur->texture[texnum]);