paints are now recursive for children
authorDana Jansens <danakj@orodu.net>
Tue, 27 May 2003 05:12:11 +0000 (05:12 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 27 May 2003 05:12:11 +0000 (05:12 +0000)
render2/paint.c
render2/surface.c
render2/surface.h

index 426c136d9632cd176767717fe251cbe6a9547a35..ebb876972afbfc3ddab69fa772e29987d366c4a0 100644 (file)
@@ -29,6 +29,7 @@ void RrPaintArea(struct RrSurface *sur, int x, int y, int w, int h)
     struct RrSurface *p;
     int ok;
     int surx, sury;
+    GSList *it;
 
     inst = RrSurfaceInstance(sur);
 
@@ -43,7 +44,20 @@ void RrPaintArea(struct RrSurface *sur, int x, int y, int w, int h)
     if (!(x + w <= RrSurfaceWidth(sur) && y + h <= RrSurfaceHeight(sur)))
         return;
 
-    /* XXX recurse and paint children */
+    /* recurse and paint children */
+    for (it = RrSurfaceChildren(sur); it; it = g_slist_next(it)) {
+        struct RrSurface *child = it->data;
+        /* in the area to repaint? */
+        if (RrSurfaceX(child) < x+w &&
+            RrSurfaceX(child) + RrSurfaceWidth(child) > x &&
+            RrSurfaceY(child) < y+h &&
+            RrSurfaceY(child) + RrSurfaceHeight(child))
+            RrPaintArea(child,
+                        MAX(0, x-RrSurfaceX(child)),
+                        MAX(0, y-RrSurfaceY(child)),
+                        MIN(RrSurfaceWidth(child), w-(x-RrSurfaceX(child))),
+                        MIN(RrSurfaceHeight(child), h-(y-RrSurfaceY(child))));
+    }
 
     if (!RrSurfaceVisible(sur)) return;
 
index 263af69aa6048777fefc85726d0e8f8a16ae6783..a824313017ec0f71f81fa0ec585b032fae9943b8 100644 (file)
@@ -23,6 +23,7 @@ static struct RrSurface *surface_new(enum RrSurfaceType type,
     sur->w = 1;
     sur->h = 1;
     sur->visible = 0;
+    sur->children = NULL;
     return sur;
 }
 
@@ -84,6 +85,8 @@ struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type,
     sur->parent = parent;
     RrSurfaceShow(sur);
 
+    parent->children = g_slist_append(parent->children, sur);
+
     RrInstaceAddSurface(sur);
     return sur;
 }
@@ -143,6 +146,8 @@ struct RrSurface *RrSurfaceCopyChild(struct RrSurface *orig,
     sur->parent = parent;
     RrSurfaceShow(sur);
 
+    parent->children = g_slist_append(parent->children, sur);
+
     RrInstaceAddSurface(sur);
     return sur;
 }
@@ -151,6 +156,9 @@ void RrSurfaceFree(struct RrSurface *sur)
 {
     int i;
     if (sur) {
+        if (sur->parent)
+            sur->parent->children = g_slist_remove(sur->parent->children, sur);
+
         RrInstaceRemoveSurface(sur);
         for (i = 0; i < sur->ntextures; ++i)
             RrTextureFreeContents(&sur->texture[i]);
index a8c2448ee0883be505452a27d6448f947aabfc72..d3bc9a4fc13f81d02eb9c4567786e7b962cbdcd9 100644 (file)
@@ -4,6 +4,7 @@
 #include "render.h"
 #include "texture.h"
 #include "planar.h"
+#include <glib.h>
 
 struct RrNonPlanarSurface {
     int foo;
@@ -39,6 +40,8 @@ struct RrSurface {
     int h;
 
     int visible : 1;
+
+    GSList *children;
 };
 
 struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum);
@@ -53,4 +56,6 @@ struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum);
 #define RrSurfaceWidth(sur) ((sur)->w)
 #define RrSurfaceHeight(sur) ((sur)->h)
 
+#define RrSurfaceChildren(sur) ((sur)->children)
+
 #endif