From 3cd979034645fcb55bb700fcb4309b3fc141b442 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 26 May 2003 20:50:58 +0000 Subject: [PATCH] can render.. only it doesnt work yet --- render2/.cvsignore | 1 + render2/Makefile.am | 5 +- render2/color.h | 17 +++ render2/paint.c | 292 ++------------------------------------------ render2/planar.c | 279 ++++++++++++++++++++++++++++++++++++++++++ render2/planar.h | 19 +++ render2/render.h | 73 ++++++----- render2/surface.h | 12 +- render2/test.c | 21 +++- 9 files changed, 380 insertions(+), 339 deletions(-) create mode 100644 render2/color.h create mode 100644 render2/planar.c create mode 100644 render2/planar.h diff --git a/render2/.cvsignore b/render2/.cvsignore index da8adfca..98a69ed8 100644 --- a/render2/.cvsignore +++ b/render2/.cvsignore @@ -13,3 +13,4 @@ font.lo surface.lo paint.lo texture.lo +planar.lo diff --git a/render2/Makefile.am b/render2/Makefile.am index 3e3fe1fb..fd61115c 100644 --- a/render2/Makefile.am +++ b/render2/Makefile.am @@ -22,6 +22,7 @@ libobrender2_la_SOURCES=\ debug.c \ font.c \ surface.c \ + planar.c \ texture.c \ paint.c @@ -30,7 +31,9 @@ noinst_HEADERS=\ instance.h \ debug.h \ surface.h \ - texture.h + planar.h \ + texture.h \ + color.h MAINTAINERCLEANFILES=Makefile.in diff --git a/render2/color.h b/render2/color.h new file mode 100644 index 00000000..667ab37b --- /dev/null +++ b/render2/color.h @@ -0,0 +1,17 @@ +#ifndef __render_color_h +#define __render_color_h + +#include "render.h" + +#define RrColor3f(c) glColor3f((c)->r, (c)->g, (c)->b) +#define RrColor4f(c) glColor4f((c)->r, (c)->g, (c)->b, (c)->a) + +#define RrColorAvg(avg, c1, c2) \ + RrColorSet((avg), \ + ((c1)->r + (c2)->r) / 2.0, \ + ((c1)->g + (c2)->g) / 2.0, \ + ((c1)->b + (c2)->b) / 2.0, \ + ((c1)->a + (c2)->a) / 2.0) + + +#endif diff --git a/render2/paint.c b/render2/paint.c index 2443c5c3..3490add8 100644 --- a/render2/paint.c +++ b/render2/paint.c @@ -5,292 +5,14 @@ #include #include -void planar_copy_parent(struct RrSurface *sur) -{ - int ncols; - int copy; - - switch (RrPlanarColorType(sur)) { - case RR_SURFACE_NONE: - return; - case RR_SURFACE_SOLID: - ncols = 1; - break; - case RR_SURFACE_HORIZONTAL: - ncols = 2; - break; - case RR_SURFACE_VERTICAL: - ncols = 2; - break; - case RR_SURFACE_DIAGONAL: - ncols = 2; - break; - case RR_SURFACE_CROSSDIAGONAL: - ncols = 2; - break; - case RR_SURFACE_PYRAMID: - ncols = 2; - break; - case RR_SURFACE_PIPECROSS: - ncols = 2; - break; - case RR_SURFACE_RECTANGLE: - ncols = 2; - break; - } - - copy = 0; - if (ncols >= 1 && RrColorHasAlpha(RrPlanarPrimaryColor(sur))) - copy = 1; - if (ncols >= 1 && RrColorHasAlpha(RrPlanarSecondaryColor(sur))) - copy = 1; - if (copy) { - /* - struct RrSurface *parent = RrSurfaceParent(sur); - - XXX COPY PARENT PLS - */ - } -} - -void paint_planar(struct RrSurface *sur, int x, int y, int w, int h) -{ - float pr,pg,pb; - float sr, sg, sb; - float ar, ag, ab; - - pr = RrColorRed(RrPlanarPrimaryColor(sur)); - pg = RrColorGreen(RrPlanarPrimaryColor(sur)); - pb = RrColorBlue(RrPlanarPrimaryColor(sur)); - sr = RrColorRed(RrPlanarSecondaryColor(sur)); - sg = RrColorGreen(RrPlanarSecondaryColor(sur)); - sb = RrColorBlue(RrPlanarSecondaryColor(sur)); - switch (RrPlanarColorType(sur)) { - case RR_SURFACE_NONE: - return; - case RR_SURFACE_SOLID: - glBegin(GL_TRIANGLES); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glVertex2i(x+w, y); - glVertex2i(x+w, y+h); - - glVertex2i(x+w, y+h); - glVertex2i(x, y+h); - glVertex2i(x, y); - glEnd(); - break; - case RR_SURFACE_HORIZONTAL: - glBegin(GL_TRIANGLES); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w, y); - glVertex2i(x+w, y+h); - - glVertex2i(x+w, y+h); - glColor3f(pr, pg, pb); - glVertex2i(x, y+h); - glVertex2i(x, y); - glEnd(); - break; - case RR_SURFACE_VERTICAL: - glBegin(GL_TRIANGLES); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glVertex2i(x+w, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w, y+h); - - glVertex2i(x+w, y+h); - glVertex2i(x, y+h); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glEnd(); - break; - case RR_SURFACE_DIAGONAL: - ar = (pr + sr) / 2.0; - ag = (pg + sg) / 2.0; - ab = (pb + sb) / 2.0; - glBegin(GL_TRIANGLES); - glColor3f(ar, ag, ab); - glVertex2i(x, y); - glColor3f(pr, pg, pb); - glVertex2i(x+w, y); - glColor3f(ar, ag, ab); - glVertex2i(x+w, y+h); - - glColor3f(ar, ag, ab); - glVertex2i(x+w, y+h); - glColor3f(sr, sg, sb); - glVertex2i(x, y+h); - glColor3f(ar, ag, ab); - glVertex2i(x, y); - glEnd(); - break; - case RR_SURFACE_CROSSDIAGONAL: - ar = (pr + sr) / 2.0; - ag = (pg + sg) / 2.0; - ab = (pb + sb) / 2.0; - glBegin(GL_TRIANGLES); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glColor3f(ar, ag, ab); - glVertex2i(x+w, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w, y+h); - - glColor3f(sr, sg, sb); - glVertex2i(x+w, y+h); - glColor3f(ar, ag, ab); - glVertex2i(x, y+h); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glEnd(); - break; - case RR_SURFACE_PYRAMID: - ar = (pr + sr) / 2.0; - ag = (pg + sg) / 2.0; - ab = (pb + sb) / 2.0; - glBegin(GL_TRIANGLES); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(ar, ag, ab); - glVertex2i(x, y+h/2); - - glVertex2i(x, y+h/2); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x, y+h); - - glVertex2i(x, y+h); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(ar, ag, ab); - glVertex2i(x+w/2, y+h); - - glVertex2i(x+w/2, y+h); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x+w, y+h); - - glVertex2i(x+w, y+h); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(ar, ag, ab); - glVertex2i(x+w, y+h/2); - - glVertex2i(x+w, y+h/2); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x+w, y); - - glVertex2i(x+w, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(ar, ag, ab); - glVertex2i(x+w/2, y); - - glVertex2i(x+w/2, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glEnd(); - break; - case RR_SURFACE_PIPECROSS: - glBegin(GL_TRIANGLES); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glVertex2i(x, y+h/2); - - glVertex2i(x, y+h/2); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x, y+h); - - glVertex2i(x, y+h); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glVertex2i(x+w/2, y+h); - - glVertex2i(x+w/2, y+h); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x+w, y+h); - - glVertex2i(x+w, y+h); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glVertex2i(x+w, y+h/2); - - glVertex2i(x+w, y+h/2); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x+w, y); - - glVertex2i(x+w, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glVertex2i(x+w/2, y); - - glVertex2i(x+w/2, y); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glEnd(); - break; - case RR_SURFACE_RECTANGLE: - glBegin(GL_TRIANGLES); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x, y+h); - - glVertex2i(x, y+h); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x+w, y+h); - - glVertex2i(x+w, y+h); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x+w, y); - - glVertex2i(x+w, y); - glColor3f(sr, sg, sb); - glVertex2i(x+w/2, y+h/2); - glColor3f(pr, pg, pb); - glVertex2i(x, y); - - glEnd(); - break; - } -} - /*! Paints the surface, and all its children */ -void RrSurfacePaint(struct RrSurface *sur) +void RrPaint(struct RrSurface *sur) { - RrSurfacePaintArea(sur, 0, 0, RrSurfaceWidth(sur), RrSurfaceHeight(sur)); + RrPaintArea(sur, 0, 0, RrSurfaceWidth(sur), RrSurfaceHeight(sur)); } /*! Paints the surface, and all its children, but only in the given area. */ -void RrSurfacePaintArea(struct RrSurface *sur, - int x, - int y, - int w, - int h) +void RrPaintArea(struct RrSurface *sur, int x, int y, int w, int h) { struct RrInstance *inst; int ok; @@ -303,8 +25,9 @@ void RrSurfacePaintArea(struct RrSurface *sur, assert(x >= 0 && y >= 0); if (!(x >= 0 && y >= 0)) return; - assert(x + w < RrSurfaceWidth(sur) && y + h < RrSurfaceHeight(sur)); - if (!(x + w < RrSurfaceWidth(sur) && y + h < RrSurfaceHeight(sur))) return; + assert(x + w <= RrSurfaceWidth(sur) && y + h <= RrSurfaceHeight(sur)); + if (!(x + w <= RrSurfaceWidth(sur) && y + h <= RrSurfaceHeight(sur))) + return; RrDebug("making %p, %p, %p current\n", RrDisplay(inst), RrSurfaceWindow(sur), RrContext(inst)); @@ -326,8 +49,7 @@ void RrSurfacePaintArea(struct RrSurface *sur, switch (RrSurfaceType(sur)) { case RR_SURFACE_PLANAR: - planar_copy_parent(sur); - paint_planar(sur, x, y, w, h); + RrPlanarPaint(sur, x, y, w, h); break; case RR_SURFACE_NONPLANAR: assert(0); diff --git a/render2/planar.c b/render2/planar.c new file mode 100644 index 00000000..8110d4f7 --- /dev/null +++ b/render2/planar.c @@ -0,0 +1,279 @@ +#include "planar.h" +#include "surface.h" +#include "color.h" +#include + +void RrPlanarSet(struct RrSurface *sur, + enum RrSurfaceColorType type, + struct RrColor *primary, + struct RrColor *secondary) +{ + sur->data.planar.colortype = type; + sur->data.planar.primary = *primary; + sur->data.planar.secondary = *secondary; +} + +static void copy_parent(struct RrSurface *sur) +{ + int ncols; + int copy; + + switch (RrPlanarColorType(sur)) { + case RR_PLANAR_NONE: + return; + case RR_PLANAR_SOLID: + ncols = 1; + break; + case RR_PLANAR_HORIZONTAL: + ncols = 2; + break; + case RR_PLANAR_VERTICAL: + ncols = 2; + break; + case RR_PLANAR_DIAGONAL: + ncols = 2; + break; + case RR_PLANAR_CROSSDIAGONAL: + ncols = 2; + break; + case RR_PLANAR_PYRAMID: + ncols = 2; + break; + case RR_PLANAR_PIPECROSS: + ncols = 2; + break; + case RR_PLANAR_RECTANGLE: + ncols = 2; + break; + } + + copy = 0; + if (ncols >= 1 && RrColorHasAlpha(RrPlanarPrimaryColor(sur))) + copy = 1; + if (ncols >= 1 && RrColorHasAlpha(RrPlanarSecondaryColor(sur))) + copy = 1; + if (copy) { + /* + struct RrSurface *parent = RrSurfaceParent(sur); + + XXX COPY PARENT PLS + */ + } +} + +void RrPlanarPaint(struct RrSurface *sur, int x, int y, int w, int h) +{ + struct RrColor *pri, *sec, avg; + + copy_parent(sur); + + pri = &RrPlanarPrimaryColor(sur); + sec = &RrPlanarSecondaryColor(sur); + + switch (RrPlanarColorType(sur)) { + case RR_PLANAR_NONE: + return; + case RR_PLANAR_SOLID: + glBegin(GL_TRIANGLES); + RrColor3f(pri); + glVertex2i(x, y); + glVertex2i(x+w, y); + glVertex2i(x+w, y+h); + + glVertex2i(x+w, y+h); + glVertex2i(x, y+h); + glVertex2i(x, y); + glEnd(); + break; + case RR_PLANAR_HORIZONTAL: + glBegin(GL_TRIANGLES); + RrColor3f(pri); + glVertex2i(x, y); + RrColor3f(sec); + glVertex2i(x+w, y); + glVertex2i(x+w, y+h); + + glVertex2i(x+w, y+h); + RrColor3f(pri); + glVertex2i(x, y+h); + glVertex2i(x, y); + glEnd(); + break; + case RR_PLANAR_VERTICAL: + glBegin(GL_TRIANGLES); + RrColor3f(pri); + glVertex2i(x, y); + glVertex2i(x+w, y); + RrColor3f(sec); + glVertex2i(x+w, y+h); + + glVertex2i(x+w, y+h); + glVertex2i(x, y+h); + RrColor3f(pri); + glVertex2i(x, y); + glEnd(); + break; + case RR_PLANAR_DIAGONAL: + RrColorAvg(&avg, pri, sec); + glBegin(GL_TRIANGLES); + RrColor3f(&avg); + glVertex2i(x, y); + RrColor3f(pri); + glVertex2i(x+w, y); + RrColor3f(&avg); + glVertex2i(x+w, y+h); + + RrColor3f(&avg); + glVertex2i(x+w, y+h); + RrColor3f(sec); + glVertex2i(x, y+h); + RrColor3f(&avg); + glVertex2i(x, y); + glEnd(); + break; + case RR_PLANAR_CROSSDIAGONAL: + RrColorAvg(&avg, pri, sec); + glBegin(GL_TRIANGLES); + RrColor3f(pri); + glVertex2i(x, y); + RrColor3f(&avg); + glVertex2i(x+w, y); + RrColor3f(sec); + glVertex2i(x+w, y+h); + + RrColor3f(sec); + glVertex2i(x+w, y+h); + RrColor3f(&avg); + glVertex2i(x, y+h); + RrColor3f(pri); + glVertex2i(x, y); + glEnd(); + break; + case RR_PLANAR_PYRAMID: + RrColorAvg(&avg, pri, sec); + glBegin(GL_TRIANGLES); + RrColor3f(pri); + glVertex2i(x, y); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(&avg); + glVertex2i(x, y+h/2); + + glVertex2i(x, y+h/2); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x, y+h); + + glVertex2i(x, y+h); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(&avg); + glVertex2i(x+w/2, y+h); + + glVertex2i(x+w/2, y+h); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x+w, y+h); + + glVertex2i(x+w, y+h); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(&avg); + glVertex2i(x+w, y+h/2); + + glVertex2i(x+w, y+h/2); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x+w, y); + + glVertex2i(x+w, y); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(&avg); + glVertex2i(x+w/2, y); + + glVertex2i(x+w/2, y); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x, y); + glEnd(); + break; + case RR_PLANAR_PIPECROSS: + glBegin(GL_TRIANGLES); + RrColor3f(pri); + glVertex2i(x, y); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + glVertex2i(x, y+h/2); + + glVertex2i(x, y+h/2); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x, y+h); + + glVertex2i(x, y+h); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + glVertex2i(x+w/2, y+h); + + glVertex2i(x+w/2, y+h); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x+w, y+h); + + glVertex2i(x+w, y+h); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + glVertex2i(x+w, y+h/2); + + glVertex2i(x+w, y+h/2); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x+w, y); + + glVertex2i(x+w, y); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + glVertex2i(x+w/2, y); + + glVertex2i(x+w/2, y); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x, y); + glEnd(); + break; + case RR_PLANAR_RECTANGLE: + glBegin(GL_TRIANGLES); + RrColor3f(pri); + glVertex2i(x, y); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x, y+h); + + glVertex2i(x, y+h); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x+w, y+h); + + glVertex2i(x+w, y+h); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x+w, y); + + glVertex2i(x+w, y); + RrColor3f(sec); + glVertex2i(x+w/2, y+h/2); + RrColor3f(pri); + glVertex2i(x, y); + + glEnd(); + break; + } +} diff --git a/render2/planar.h b/render2/planar.h new file mode 100644 index 00000000..907ff839 --- /dev/null +++ b/render2/planar.h @@ -0,0 +1,19 @@ +#ifndef __render_planar_h +#define __render_planar_h + +#include "render.h" + +struct RrPlanarSurface { + enum RrSurfaceColorType colortype; + + struct RrColor primary; + struct RrColor secondary; +}; + +#define RrPlanarColorType(sur) ((sur)->data.planar.colortype) +#define RrPlanarPrimaryColor(sur) ((sur)->data.planar.primary) +#define RrPlanarSecondaryColor(sur) ((sur)->data.planar.primary) + +void RrPlanarPaint(struct RrSurface *sur, int x, int y, int w, int h); + +#endif diff --git a/render2/render.h b/render2/render.h index 4151b0b0..bdb01527 100644 --- a/render2/render.h +++ b/render2/render.h @@ -39,14 +39,6 @@ struct RrColor { float a; }; -/*! Returns the red component for an RrColor */ -#define RrColorRed(c) (c).r -/*! Returns the green component for an RrColor */ -#define RrColorGreen(c) (c).g -/*! Returns the blue component for an RrColor */ -#define RrColorBlue(c) (c).b -/*! Returns the alpha component for an RrColor */ -#define RrColorAlpha(c) (c).a /*! Returns if an RrColor is non-opaque */ #define RrColorHasAlpha(c) ((c).a > 0.0000001) @@ -84,29 +76,6 @@ enum RrSurfaceType { RR_SURFACE_NONPLANAR }; -/*! 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 RrSurface prototype that can't render. A prototype can be copied to a new RrSurface that can render. */ struct RrSurface *RrSurfaceNewProto(enum RrSurfaceType type, @@ -137,6 +106,36 @@ void RrSurfaceSetArea(struct RrSurface *sur, Window RrSurfaceWindow(struct RrSurface *sur); +/* planar surfaces */ + +/*! The options available for the background of an RrSurface */ +enum RrSurfaceColorType { + /*! No rendering on the surface background, its contents will be + undefined. */ + RR_PLANAR_NONE, + /*! Solid color fill. */ + RR_PLANAR_SOLID, + /*! Horizontal gradient. */ + RR_PLANAR_HORIZONTAL, + /*! Vertical gradient. */ + RR_PLANAR_VERTICAL, + /*! Diagonal (TL->BR) gradient. */ + RR_PLANAR_DIAGONAL, + /*! Cross-Diagonal (TR->BL) gradient. */ + RR_PLANAR_CROSSDIAGONAL, + /*! Pipecross gradient. */ + RR_PLANAR_PIPECROSS, + /*! Rectangle gradient. */ + RR_PLANAR_RECTANGLE, + /*! Pyramid gradient. */ + RR_PLANAR_PYRAMID +}; + +void RrPlanarSet(struct RrSurface *sur, + enum RrSurfaceColorType type, + struct RrColor *primary, + struct RrColor *secondary); + /* textures */ enum RrLayout { @@ -173,12 +172,12 @@ void RrTextureSetText(struct RrSurface *sur, /* drawing */ /*! Paints the surface, and all its children */ -void RrSurfacePaint(struct RrSurface *sur); +void RrPaint(struct RrSurface *sur); /*! Paints the surface, and all its children, but only in the given area. */ -void RrSurfacePaintArea(struct RrSurface *sur, - int x, - int y, - int w, - int h); +void RrPaintArea(struct RrSurface *sur, + int x, + int y, + int w, + int h); #endif diff --git a/render2/surface.h b/render2/surface.h index 6391beb9..850ba36f 100644 --- a/render2/surface.h +++ b/render2/surface.h @@ -3,13 +3,7 @@ #include "render.h" #include "texture.h" - -struct RrPlanarSurface { - enum RrSurfaceColorType colortype; - - struct RrColor primary; - struct RrColor secondary; -}; +#include "planar.h" struct RrNonPlanarSurface { int foo; @@ -57,8 +51,4 @@ struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum); #define RrSurfaceWidth(sur) ((sur)->w) #define RrSurfaceHeight(sur) ((sur)->h) -#define RrPlanarColorType(sur) ((sur)->data.planar.colortype) -#define RrPlanarPrimaryColor(sur) ((sur)->data.planar.primary) -#define RrPlanarSecondaryColor(sur) ((sur)->data.planar.primary) - #endif diff --git a/render2/test.c b/render2/test.c index 080b5d8d..bddf546b 100644 --- a/render2/test.c +++ b/render2/test.c @@ -19,12 +19,15 @@ int main() { Display *display; Window win; - struct RrInstance *inst; XEvent report; XClassHint chint; Atom delete_win, protocols; int quit; + struct RrInstance *inst; + struct RrSurface *sur; + struct RrColor pri, sec; + if (!(display = XOpenDisplay(NULL))) { fprintf(stderr, "couldn't connect to X server in DISPLAY\n"); return EXIT_FAILURE; @@ -55,7 +58,12 @@ int main() return EXIT_FAILURE; } - /*paint(win, look);*/ + sur = RrSurfaceNew(inst, RR_SURFACE_PLANAR, win, 0); + RrSurfaceSetArea(sur, 10, 10, 100, 100); + RrColorSet(&pri, 0, 0, 0, 0); + RrColorSet(&pri, 1, 1, 1, 0); + RrPlanarSet(sur, RR_PLANAR_VERTICAL, &pri, &sec); + quit = 0; while (!quit) { XNextEvent(display, &report); @@ -65,11 +73,14 @@ int main() if ((Atom)report.xclient.data.l[0] == delete_win) quit = 1; case Expose: + RrPaint(sur); break; case ConfigureNotify: - /*look->area.width = report.xconfigure.width; - look->area.height = report.xconfigure.height; - paint(win, look);*/ + RrSurfaceSetArea(sur, + report.xconfigure.x, + report.xconfigure.y, + report.xconfigure.width, + report.xconfigure.height); break; } -- 2.34.1