From d518b419c55b846b371bddee69702a8c2818441d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 20 Jan 2012 14:40:36 +0000 Subject: [PATCH] Add fdo bug 40920 example. --- src/egl/openvg/CMakeLists.txt | 1 + src/egl/openvg/fdo40920.c | 175 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 0 deletions(-) create mode 100644 src/egl/openvg/fdo40920.c diff --git a/src/egl/openvg/CMakeLists.txt b/src/egl/openvg/CMakeLists.txt index adcc755..b84000a 100644 --- a/src/egl/openvg/CMakeLists.txt +++ b/src/egl/openvg/CMakeLists.txt @@ -19,6 +19,7 @@ endif () # Targets that can be built both for fullscreen EGL and X11 set (targets + fdo40920 lion sp ) diff --git a/src/egl/openvg/fdo40920.c b/src/egl/openvg/fdo40920.c new file mode 100644 index 0000000..848fd0c --- /dev/null +++ b/src/egl/openvg/fdo40920.c @@ -0,0 +1,175 @@ +// https://bugs.freedesktop.org/show_bug.cgi?id=40920 + +#include +#include +#include + +#include "eglut.h" + +static VGint width, height; + +VGfloat s_dashOn = 10.0f; + +static void +draw(void) +{ +#if 0 + vgClear(0, 0, width, height); + + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadIdentity(); + vgTranslate(width/2, height/2); + vgTranslate(-width/2, -height/2); + + vgFlush(); +#endif + + VGfloat ClearColor[ 4 ] ; + + ClearColor[ 0 ] = 0.2f ; /* R */ + ClearColor[ 1 ] = 0.2f ; /* G */ + ClearColor[ 2 ] = 0.2f ; /* B */ + ClearColor[ 3 ] = 0.0f ; /* A */ + + vgSetfv( VG_CLEAR_COLOR, ( VGint )(( sizeof ClearColor ) / ( sizeof ( VGfloat ))), ClearColor ) ; + vgClear( 0, 0, width, height ) ; + + VGint clipRect[4] = + { + 0, 0, width, height + }; + + // enable clipping + vgSeti(VG_SCISSORING, VG_TRUE); + vgSetiv(VG_SCISSOR_RECTS, 4, clipRect); + +VGfloat s_defaultMatrix[] = {1.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, height, 1.0f}; + + vgLoadMatrix(s_defaultMatrix); + + vgTranslate(width + 100, height/2); + vgScale(0.9f, 0.9f); + vgTranslate(-width/2, -height/2); + + VGPaint strokePaint = vgCreatePaint(); + VGfloat color[4] = {0.0f, 0.8f ,0.0f, 1.0f}; + vgSetParameterfv(strokePaint, VG_PAINT_COLOR, 4, color); + vgSetPaint(strokePaint, VG_STROKE_PATH); + vgSetf(VG_STROKE_LINE_WIDTH, 2.0f); + + VGfloat dashPattern[2] = {s_dashOn, 20.0f}; + s_dashOn++; + if (s_dashOn > 10000) + { + s_dashOn = 0; + } + + vgSetfv(VG_STROKE_DASH_PATTERN, 2, dashPattern); + vgSetf(VG_STROKE_DASH_PHASE, 0.0f); + vgSeti(VG_STROKE_DASH_PHASE_RESET, VG_FALSE); + + + VGPath shapePath = vgCreatePath( + VG_PATH_FORMAT_STANDARD, + VG_PATH_DATATYPE_F, + 1.0f, 0.0f, + 12, + 62, + VG_PATH_CAPABILITY_APPEND_TO); + + VGubyte triangle_segments [12] = + { + VG_MOVE_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CUBIC_TO_ABS, + VG_CLOSE_PATH + }; + // define coordinates for rectangle + VGfloat afPathmCoords[62] = + { + -332.7857, 410.4081, + -357.0934, 407.054, -379.7178, 397.2152, -396.4451, 382.7241, + -410.9494, 370.1588, -423.7087, 349.0457, -428.9955, 328.8622, + -431.5813, 318.9902, -431.7468, 317.0763, -431.7625, 296.8622, + -431.7801, 274.2322, -431.0129, 268.4703, -426.104, 254.3622, + -419.7086, 235.9817, -406.8737, 218.2509, -391.5357, 206.6073, + -388.6482, 204.4153, -386.2866, 202.1134, -386.2876, 201.492, + -386.2887, 200.8706, -388.5975, 198.7891, -391.4182, 196.8665, + -408.4568, 185.2533, -422.4738, 162.1653, -427.5256, 137.3922, + -430.0309, 125.1075, -430.5237, 98.29367, -428.4453, 87.36218, + -421.5526, 51.11037, -400.1021, 22.80175, -367.4087, 6.811264, + }; + + vgAppendPathData( + shapePath, + 12, + triangle_segments, + afPathmCoords); + + vgDrawPath(shapePath, VG_STROKE_PATH); + + vgDestroyPath(shapePath); + vgDestroyPaint(strokePaint); + vgFlush(); + + eglutPostRedisplay(); +} + + +/* new window size or exposure */ +static void +reshape(int w, int h) +{ + width = w; + height = h; +} + + +static void +init(void) +{ + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER); + vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_BETTER); + +#ifdef OPENVG_VERSION_1_1 + VGfloat colorTransformation [] = {1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0}; + + vgSetfv(VG_COLOR_TRANSFORM_VALUES,8,colorTransformation); + + vgSeti(VG_COLOR_TRANSFORM,VG_TRUE); +#endif + + vgSeti(VG_TILE_FILL_COLOR, 0x00000000); + vgSeti(VG_CLEAR_COLOR, 0x00000000); +} + + +int +main(int argc, char *argv[]) +{ + eglutInitWindowSize(800, 480); + eglutInitAPIMask(EGLUT_OPENVG_BIT); + eglutInit(argc, argv); + + eglutCreateWindow("Lion Example"); + + eglutReshapeFunc(reshape); + eglutDisplayFunc(draw); + + init(); + + eglutMainLoop(); + + return 0; +} -- 1.7.7.3