summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Knoll <lars@trolltech.com>2005-07-01 10:04:51 +0000
committerLars Knoll <lars@trolltech.com>2005-07-01 10:04:51 +0000
commit9359b40d8c41901844924060a864a854dac4adbf (patch)
tree7d9845d7c4a0ad78c2bb7d2e60052a012b56cf20
parent60cc17fd8fac9b28363e0979d6b0443be6838613 (diff)
Add support for gradients and solid fills to Render.
-rw-r--r--include/X11/extensions/Xrender.h44
-rw-r--r--src/Picture.c123
2 files changed, 166 insertions, 1 deletions
diff --git a/include/X11/extensions/Xrender.h b/include/X11/extensions/Xrender.h
index bbfdc6c..4e4723a 100644
--- a/include/X11/extensions/Xrender.h
+++ b/include/X11/extensions/Xrender.h
@@ -65,7 +65,7 @@ typedef struct {
#define PictFormatColormap (1 << 11)
typedef struct _XRenderPictureAttributes {
- Bool repeat;
+ int repeat;
Picture alpha_map;
int alpha_x_origin;
int alpha_y_origin;
@@ -143,6 +143,12 @@ typedef struct _XTriangle {
XPointFixed p1, p2, p3;
} XTriangle;
+typedef struct _XCircle {
+ XFixed x;
+ XFixed y;
+ XFixed radius;
+} XCircle;
+
typedef struct _XTrapezoid {
XFixed top, bottom;
XLineFixed left, right;
@@ -177,6 +183,21 @@ typedef struct _XTrap {
XSpanFix top, bottom;
} XTrap;
+typedef struct _XLinearGradient {
+ XPointFixed p1;
+ XPointFixed p2;
+} XLinearGradient;
+
+typedef struct _XRadialGradient {
+ XCircle inner;
+ XCircle outer;
+} XRadialGradient;
+
+typedef struct _XConicalGradient {
+ XPointFixed center;
+ XFixed angle; /* in degrees */
+} XConicalGradient;
+
_XFUNCPROTOBEGIN
Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep);
@@ -481,6 +502,27 @@ XRenderAddTraps (Display *dpy,
_Xconst XTrap *traps,
int ntrap);
+Picture XRenderCreateSolidFill (Display *dpy,
+ const XRenderColor *color);
+
+Picture XRenderCreateLinearGradient (Display *dpy,
+ const XLinearGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+Picture XRenderCreateRadialGradient (Display *dpy,
+ const XRadialGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
+Picture XRenderCreateConicalGradient (Display *dpy,
+ const XConicalGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nstops);
+
_XFUNCPROTOEND
#endif /* _XRENDER_H_ */
diff --git a/src/Picture.c b/src/Picture.c
index f5c5a2a..5b08bf3 100644
--- a/src/Picture.c
+++ b/src/Picture.c
@@ -241,3 +241,126 @@ XRenderFreePicture (Display *dpy,
UnlockDisplay(dpy);
SyncHandle();
}
+
+
+Picture XRenderCreateSolidFill(Display *dpy,
+ const XRenderColor *color)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreateSolidFillReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateSolidFill, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateSolidFill;
+
+ req->pid = pid = XAllocID(dpy);
+ req->color.red = color->red;
+ req->color.green = color->green;
+ req->color.blue = color->blue;
+ req->color.alpha = color->alpha;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
+
+
+Picture XRenderCreateLinearGradient(Display *dpy,
+ const XLinearGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nStops)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreateLinearGradientReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateLinearGradient, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateLinearGradient;
+
+ req->pid = pid = XAllocID(dpy);
+ req->p1.x = gradient->p1.x;
+ req->p1.y = gradient->p1.y;
+ req->p2.x = gradient->p2.x;
+ req->p2.y = gradient->p2.y;
+
+ req->nStops = nStops;
+ DataInt32(dpy, stops, nStops * 4);
+ Data16(dpy, colors, nStops * 8);
+ req->length += nStops*3;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
+
+Picture XRenderCreateRadialGradient(Display *dpy,
+ const XRadialGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nStops)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreateRadialGradientReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateRadialGradient, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateRadialGradient;
+
+ req->pid = pid = XAllocID(dpy);
+ req->inner.x = gradient->inner.x;
+ req->inner.y = gradient->inner.y;
+ req->outer.x = gradient->outer.x;
+ req->outer.y = gradient->outer.y;
+ req->inner_radius = gradient->inner.radius;
+ req->outer_radius = gradient->outer.radius;
+
+ req->nStops = nStops;
+ DataInt32(dpy, stops, nStops * 4);
+ Data16(dpy, colors, nStops * 8);
+ req->length += nStops*3;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}
+
+Picture XRenderCreateConicalGradient(Display *dpy,
+ const XConicalGradient *gradient,
+ const XFixed *stops,
+ const XRenderColor *colors,
+ int nStops)
+{
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ Picture pid;
+ xRenderCreateConicalGradientReq *req;
+
+ RenderCheckExtension (dpy, info, 0);
+ LockDisplay(dpy);
+ GetReq(RenderCreateConicalGradient, req);
+ req->reqType = info->codes->major_opcode;
+ req->renderReqType = X_RenderCreateConicalGradient;
+
+ req->pid = pid = XAllocID(dpy);
+ req->center.x = gradient->center.x;
+ req->center.y = gradient->center.y;
+ req->angle = gradient->angle;
+
+ req->nStops = nStops;
+ DataInt32(dpy, stops, nStops * 4);
+ Data16(dpy, colors, nStops * 8);
+ req->length += nStops*3;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return pid;
+}