From 58b05425844addf01239c3326a61ce65e7d05fe4 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 26 May 2003 16:35:26 +0000 Subject: [PATCH] add surface prototypes --- render2/render.h | 4 ++++ render2/surface.c | 13 +++++++++++++ render2/surface.h | 18 ++++++++---------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/render2/render.h b/render2/render.h index b0344093..1eb682ca 100644 --- a/render2/render.h +++ b/render2/render.h @@ -110,6 +110,10 @@ enum RrSurfaceColorType { RR_SURFACE_PYRAMID }; +/*! Create a new RrSurface prototype that can't render. A prototype can be + copied to a new RrSurface that can render. */ +struct RrSurface *RrSurfaceNewProto(enum RrSurfaceType type, + int numtex); /*! Create a new top-level RrSurface for a Window. */ struct RrSurface *RrSurfaceNew(struct RrInstance *inst, enum RrSurfaceType type, diff --git a/render2/surface.c b/render2/surface.c index 1620606e..bd77dca9 100644 --- a/render2/surface.c +++ b/render2/surface.c @@ -21,6 +21,18 @@ static struct RrSurface *surface_new(enum RrSurfaceType type, return sur; } +struct RrSurface *RrSurfaceNewProto(enum RrSurfaceType type, + int numtex) +{ + struct RrSurface *sur; + + sur = surface_new(type, numtex); + sur->inst = inst; + sur->win = None; + sur->parent = NULL; + return sur; +} + struct RrSurface *RrSurfaceNew(struct RrInstance *inst, enum RrSurfaceType type, Window win, @@ -63,6 +75,7 @@ static struct RrSurface *surface_copy(struct RrSurface *orig) break; case RR_SURFACE_NONPLANAR: assert(0); + break; } sur->ntextures = orig->ntextures; sur->texture = malloc(sizeof(struct RrTexture) * sur->ntextures); diff --git a/render2/surface.h b/render2/surface.h index e6ea418b..1a0ff756 100644 --- a/render2/surface.h +++ b/render2/surface.h @@ -2,15 +2,7 @@ #define __render_surface_h #include "render.h" - -union RrTextureData { - int foo; -}; - -struct RrTexture { - enum RrTextureType type; - union RrTextureData data; -}; +#include "texture.h" struct RrPlanarSurface { enum RrSurfaceColorType colortype; @@ -34,7 +26,13 @@ struct RrSurface { enum RrSurfaceType type; union RrSurfaceData data; - Window win; /* this can optionally be None if parent != NULL ... */ + /* This member is created inside Render if parent != NULL, but is passed + in if parent == NULL and should not be destroyed! + + Always check for this to be None before rendering it. Just skip by + (and assert) if it is None. + */ + Window win; /* XXX this can optionally be None if parent != NULL ... */ int ntextures; struct RrTexture *texture; -- 2.34.1