10 struct RrSurface *sur;
17 #define MERGE_AREA(a, x, y, w, h) \
18 a->w = MAX(a->x + a->w - 1, x + w - 1) - MIN(a->x, x), \
19 a->h = MAX(a->y + a->h - 1, y + h - 1) - MIN(a->y, y), \
20 a->x = MIN(a->x, x), \
24 void RrExpose(struct RrInstance *inst, XExposeEvent *e)
27 struct RrSurface *sur;
32 if ((sur = RrInstaceLookupSurface(inst, win))) {
34 struct RrSurface *p = NULL;
36 while (XCheckTypedWindowEvent(RrDisplay(inst), Expose,
39 switch (RrSurfaceType(sur)) {
42 case RR_SURFACE_PLANAR:
43 if (RrPlanarHasAlpha(sur))
44 p = RrSurfaceParent(sur);
46 case RR_SURFACE_NONPLANAR:
55 RrDebug("Unable to find surface for window 0x%lx\n", win);
58 /*! Paints the surface, and all its children */
59 void RrPaint(struct RrSurface *sur, int recurse_always)
61 struct RrInstance *inst;
67 inst = RrSurfaceInstance(sur);
69 /* can't paint a prototype! */
73 if (!RrSurfaceVisible(sur)) return;
75 ok = glXMakeCurrent(RrDisplay(inst), RrSurfaceWindow(sur),RrContext(inst));
78 glViewport(0, 0, RrScreenWidth(inst), RrScreenHeight(inst));
80 glMatrixMode(GL_PROJECTION);
82 glOrtho(RrSurfaceX(sur), RrSurfaceX(sur) + RrSurfaceWidth(sur),
83 RrSurfaceY(sur), RrSurfaceY(sur) + RrSurfaceHeight(sur),
85 glMatrixMode(GL_MODELVIEW);
86 glViewport(0, 0, RrSurfaceWidth(sur), RrSurfaceHeight(sur));
90 glTranslatef(-RrSurfaceX(sur),
92 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
97 surx += RrSurfaceX(p);
98 sury += RrSurfaceY(p);
102 switch (RrSurfaceType(sur)) {
103 case RR_SURFACE_PLANAR:
104 RrPlanarPaint(sur, surx, sury);
106 case RR_SURFACE_NONPLANAR:
109 case RR_SURFACE_NONE:
113 for (i = 0; i < sur->ntextures; ++i)
114 RrTexturePaint(sur, &sur->texture[i]);
118 glXSwapBuffers(RrDisplay(inst), RrSurfaceWindow(sur));
120 /* recurse and paint children */
121 for (it = RrSurfaceChildren(sur); it; it = g_slist_next(it)) {
123 RrPaint(it->data, 1);
125 switch (RrSurfaceType(((struct RrSurface*)it->data))) {
126 case RR_SURFACE_NONE:
128 case RR_SURFACE_PLANAR:
129 if (RrPlanarHasAlpha(it->data))
130 RrPaint(it->data, 0);
132 case RR_SURFACE_NONPLANAR: