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 /* cant be a child of a prototype! */
58 if (!parent->inst) return NULL;
60 sur = surface_new(type, numtex);
61 sur->inst = parent->inst;
62 sur->win = None; /* XXX XCreateWindow? */
69 /* doesn't set win or parent */
70 static struct RrSurface *surface_copy(struct RrSurface *orig)
72 struct RrSurface *sur;
74 sur = malloc(sizeof(struct RrSurface));
75 sur->type = orig->type;
77 case RR_SURFACE_PLANAR:
78 sur->data = orig->data;
80 case RR_SURFACE_NONPLANAR:
84 sur->ntextures = orig->ntextures;
85 sur->texture = malloc(sizeof(struct RrTexture) * sur->ntextures);
86 memcpy(sur->texture, orig->texture,
87 sizeof(struct RrTexture) * sur->ntextures);
91 struct RrSurface *RrSurfaceCopy(struct RrInstance *inst,
92 struct RrSurface *orig,
95 struct RrSurface *sur;
97 sur = surface_copy(orig);
104 struct RrSurface *RrSurfaceCopyChild(struct RrSurface *orig,
105 struct RrSurface *parent)
107 struct RrSurface *sur;
109 /* cant be a child of a prototype! */
110 assert(parent->inst);
111 if (!parent->inst) return NULL;
113 sur = surface_copy(orig);
114 sur->inst = parent->inst;
115 sur->win = None; /* XXX XCreateWindow? */
116 sur->parent = parent;
120 void RrSurfaceFree(struct RrSurface *sur)
125 if (sur->parent && sur->win)
126 XDestroyWindow(RrDisplay(sur->inst), sur->win);
131 struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum)
133 assert(texnum < sur->ntextures);
134 return &(sur->texture[texnum]);