debug.lo
color.lo
font.lo
+surface.lo
rendertest_SOURCES=test.c
lib_LTLIBRARIES=libobrender2.la
-libobrender2_la_SOURCES=init.c instance.c color.c debug.c font.c
+libobrender2_la_SOURCES=init.c instance.c color.c debug.c font.c surface.c
-
-noinst_HEADERS=render.h instance.h debug.h
+noinst_HEADERS=render.h instance.h debug.h surface.h
MAINTAINERCLEANFILES=Makefile.in
int RrFontHeight(struct RrFont *font);
int RrFontMaxCharWidth(struct RrFont *font);
+/* surfaces */
+
+struct RrSurface;
+struct RrTexture;
+
+enum RrSurfaceType {
+ RR_SURFACE_PLANAR,
+ RR_SURFACE_NONPLANAR
+};
+
+enum RrTextureType {
+ RR_TEXTURE_FOO
+};
+
+/*! The options available for the background of an RrSurface */
+enum RrSurfaceColorType {
+ /*! No rendering on the surface background, its contents will be
+ undefined. */
+ RR_SURFACE_NONE,
+ /*! Solid color fill. */
+ RR_SURFACE_SOLID,
+ /*! Horizontal gradient. */
+ RR_SURFACE_HORIZONTAL,
+ /*! Vertical gradient. */
+ RR_SURFACE_VERTICAL,
+ /*! Diagonal (TL->BR) gradient. */
+ RR_SURFACE_DIAGONAL,
+ /*! Cross-Diagonal (TR->BL) gradient. */
+ RR_SURFACE_CROSSDIAGONAL,
+ /*! Pipecross gradient. */
+ RR_SURFACE_PIPECROSS,
+ /*! Rectangle gradient. */
+ RR_SURFACE_RECTANGLE,
+ /*! Pyramid gradient. */
+ RR_SURFACE_PYRAMID
+};
+
+/*! Create a new top-level RrSurface for a Window. */
+struct RrSurface *RrSurfaceNew(struct RrInstance *inst,
+ enum RrSurfaceType type,
+ Window win,
+ int numtex);
+/*! Create a new RrSurface which is a child of another. */
+struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type,
+ struct RrSurface *parent,
+ int numtex);
+/*! Copy an RrSurface, creating a new top-level RrSurface for a Window. */
+struct RrSurface *RrSurfaceCopy(struct RrInstance *inst,
+ struct RrSurface *sur,
+ Window win);
+/*! Copy an RrSurface, creating a nwe RrSurface which is a child of another. */
+struct RrSurface *RrSurfaceCopyChild(struct RrSurface *sur,
+ struct RrSurface *parent);
+void RrSurfaceFree(struct RrSurface *sur);
+
+struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum);
+
#endif
--- /dev/null
+#include "surface.h"
+#include "instance.h"
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* doesn't set win or parent */
+static struct RrSurface *surface_new(enum RrSurfaceType type,
+ int numtex)
+{
+ struct RrSurface *sur;
+
+ sur = malloc(sizeof(struct RrSurface));
+ sur->type = type;
+ sur->ntextures = numtex;
+ if (numtex) {
+ sur->texture = malloc(sizeof(struct RrTexture) * numtex);
+ memset(sur->texture, 0, sizeof(struct RrTexture) * numtex);
+ } else
+ sur->texture = NULL;
+ return sur;
+}
+
+struct RrSurface *RrSurfaceNew(struct RrInstance *inst,
+ enum RrSurfaceType type,
+ Window win,
+ int numtex)
+{
+ struct RrSurface *sur;
+
+ sur = surface_new(type, numtex);
+ sur->inst = inst;
+ sur->win = win;
+ sur->parent = NULL;
+ return sur;
+}
+
+struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type,
+ struct RrSurface *parent,
+ int numtex)
+{
+ struct RrSurface *sur;
+
+ sur = surface_new(type, numtex);
+ sur->inst = parent->inst;
+ sur->win = None; /* XXX XCreateWindow? */
+ sur->parent = parent;
+ sur->parentx = 0;
+ sur->parenty = 0;
+ return sur;
+}
+
+/* doesn't set win or parent */
+static struct RrSurface *surface_copy(struct RrSurface *orig)
+{
+ struct RrSurface *sur;
+
+ sur = malloc(sizeof(struct RrSurface));
+ sur->type = orig->type;
+ switch (sur->type) {
+ case RR_SURFACE_PLANAR:
+ sur->data = orig->data;
+ break;
+ case RR_SURFACE_NONPLANAR:
+ assert(0);
+ }
+ sur->ntextures = orig->ntextures;
+ sur->texture = malloc(sizeof(struct RrTexture) * sur->ntextures);
+ memcpy(sur->texture, orig->texture,
+ sizeof(struct RrTexture) * sur->ntextures);
+ return sur;
+}
+
+struct RrSurface *RrSurfaceCopy(struct RrInstance *inst,
+ struct RrSurface *orig,
+ Window win)
+{
+ struct RrSurface *sur;
+
+ sur = surface_copy(orig);
+ sur->inst = inst;
+ sur->win = win;
+ sur->parent = NULL;
+ return sur;
+}
+
+struct RrSurface *RrSurfaceCopyChild(struct RrSurface *orig,
+ struct RrSurface *parent)
+{
+ struct RrSurface *sur;
+
+ sur = surface_copy(orig);
+ sur->inst = parent->inst;
+ sur->win = None; /* XXX XCreateWindow? */
+ sur->parent = parent;
+ return sur;
+}
+
+void RrSurfaceFree(struct RrSurface *sur)
+{
+ if (sur) {
+ if (sur->ntextures)
+ free(sur->texture);
+ if (sur->parent && sur->win)
+ XDestroyWindow(RrDisplay(sur->inst), sur->win);
+ free(sur);
+ }
+}
+
+struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum)
+{
+ assert(texnum < sur->ntextures);
+ return &(sur->texture[texnum]);
+}
--- /dev/null
+#ifndef __render_surface_h
+#define __render_surface_h
+
+#include "render.h"
+
+union RrTextureData {
+ int foo;
+};
+
+struct RrTexture {
+ enum RrTextureType type;
+ union RrTextureData data;
+};
+
+struct RrPlanarSurface {
+ enum RrSurfaceColorType colortype;
+
+ struct RrColor primary;
+ struct RrColor secondary;
+};
+
+struct RrNonPlanarSurface {
+ int foo;
+};
+
+union RrSurfaceData {
+ struct RrPlanarSurface planar;
+ struct RrNonPlanarSurface nonplanar;
+};
+
+struct RrSurface {
+ struct RrInstance *inst;
+
+ enum RrSurfaceType type;
+ union RrSurfaceData data;
+
+ Window win; /* this can optionally be None if parent != NULL ... */
+
+ int ntextures;
+ struct RrTexture *texture;
+
+ struct RrSurface *parent;
+ int parentx;
+ int parenty;
+};
+
+#endif