Demos (master): egl/openvg: Add a demo for VGImage functions.
Chia-I Wu
olv at kemper.freedesktop.org
Mon Nov 29 10:41:22 UTC 2010
Module: Demos
Branch: master
Commit: 083558f5afcb675bf27901c7e706f7361cd5fc9d
URL: http://cgit.freedesktop.org/mesa/demos/commit/?id=083558f5afcb675bf27901c7e706f7361cd5fc9d
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Sun Nov 28 22:47:37 2010 +0800
egl/openvg: Add a demo for VGImage functions.
---
src/egl/openvg/trivial/Makefile.am | 2 +
src/egl/openvg/trivial/image.c | 81 ++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/src/egl/openvg/trivial/Makefile.am b/src/egl/openvg/trivial/Makefile.am
index f85c70d..d694b67 100644
--- a/src/egl/openvg/trivial/Makefile.am
+++ b/src/egl/openvg/trivial/Makefile.am
@@ -52,6 +52,7 @@ noinst_PROGRAMS = \
ellipse \
filter \
gradorigin \
+ image \
lineto \
lingrad \
lookup \
@@ -77,6 +78,7 @@ dash_LDADD = libcommon.la
ellipse_LDADD = libcommon.la
filter_LDADD = libcommon.la
gradorigin_LDADD = libcommon.la
+image_LDADD = libcommon.la
lineto_LDADD = libcommon.la
lingrad_LDADD = libcommon.la
lookup_LDADD = libcommon.la
diff --git a/src/egl/openvg/trivial/image.c b/src/egl/openvg/trivial/image.c
new file mode 100644
index 0000000..7733213
--- /dev/null
+++ b/src/egl/openvg/trivial/image.c
@@ -0,0 +1,81 @@
+#include "eglcommon.h"
+
+#include <VG/openvg.h>
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+static void
+init(void)
+{
+}
+
+/* new window size or exposure */
+static void
+reshape(int w, int h)
+{
+}
+
+static const VGfloat red[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
+static const VGfloat black[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
+static const VGfloat white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+static void
+draw(void)
+{
+ const VGint w = 48;
+ VGImage img1, img2;
+ VGint x, y;
+
+ vgSetfv(VG_CLEAR_COLOR, 4, white);
+ vgClear(0, 0, window_width(), window_height());
+
+ img1 = vgCreateImage(VG_sRGBA_8888, w, w,
+ VG_IMAGE_QUALITY_NONANTIALIASED);
+ img2 = vgCreateImage(VG_sRGBA_8888, w, w,
+ VG_IMAGE_QUALITY_NONANTIALIASED);
+
+ x = 5;
+ y = (window_height() - w) / 2;
+
+ /* test vgSetPixels */
+ vgSetfv(VG_CLEAR_COLOR, 4, red);
+ vgClearImage(img1, 0, 0, w, w / 2);
+ vgSetfv(VG_CLEAR_COLOR, 4, black);
+ vgClearImage(img1, 0, w / 2, w, w / 2);
+ vgSetPixels(x, y, img1, 0, 0, w, w);
+
+ x += w + 5;
+
+ /* test vgDrawImage */
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ vgLoadIdentity();
+ vgTranslate(x, y);
+ vgDrawImage(img1);
+
+ /* test vgGetPixels */
+ vgGetPixels(img1, 0, 0, x, y, w, w);
+ x += w + 5;
+ vgSetPixels(x, y, img1, 0, 0, w, w);
+
+ x += w + 5;
+
+ /* test vgCopyImage */
+ vgCopyImage(img2, 0, 0, img1, 0, 0, w, w, VG_FALSE);
+ vgSetPixels(x, y, img2, 0, 0, w, w);
+
+ /* vgCopyPixels */
+ vgCopyPixels(x + w + 5, y, x, y, w, w);
+
+ vgDestroyImage(img1);
+ vgDestroyImage(img2);
+}
+
+
+int main(int argc, char **argv)
+{
+ set_window_size(300, 300);
+ return run(argc, argv, init, reshape,
+ draw, 0);
+}
More information about the mesa-commit
mailing list