Update with current status
[gnash.git] / librender / testr_gtk.cpp
blobce3c6df1e6693befc241d43f7f139004d98d6af6
1 //
2 // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifdef HAVE_CONFIG_H
20 #include "gnashconfig.h"
21 #endif
23 #include <iostream>
24 #include <string>
25 #include <cstdlib>
26 #include <vector>
27 #include <map>
28 #include <cassert>
29 #include <regex.h>
30 #include <boost/assign/list_of.hpp>
32 #ifdef HAVE_GTK2
33 # include <gtk/gtk.h>
34 # include <gdk/gdk.h>
35 #endif
36 #ifdef RENDERER_AGG
37 # include "agg/Renderer_agg.h"
38 #endif
39 #ifdef RENDERER_OPENGL
40 # include "opengl/Renderer_ogl.h"
41 #endif
42 #ifdef RENDERER_OPENVG
43 # include <VG/vgu.h>
44 # ifdef OPENVG_VERSION_1_1
45 # include <VG/ext.h>
46 # else
47 # include <VG/vgext.h>
48 # endif
49 # include <VG/openvg.h>
50 #endif
51 #ifdef RENDERER_GLES1
52 # include "opengles1/Renderer_gles1.h"
53 #endif
54 # ifdef RENDERER_GLES2
55 # include "opengles2/Renderer_gles2.h"
56 # endif
57 #ifdef RENDERER_CAIRO
58 # include "cairo/Renderer_cairo.h"
59 #endif
61 #ifdef BUILD_EGL_DEVICE
62 # include <egl/eglDevice.h>
63 #endif
64 #ifdef BUILD_DIRECTFB_DEVICE
65 # include <directfb/directfb.h>
66 #endif
67 #ifdef BUILD_X11_DEVICE
68 # include <x11/X11Device.h>
69 #endif
71 #include "log.h"
72 #include "SWFMatrix.h"
73 #include "Renderer.h"
74 #include "Transform.h"
75 #include "GnashVaapiImage.h"
76 #include "GnashVaapiImageProxy.h"
78 using namespace gnash;
79 using namespace std;
81 const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
82 const VGfloat color[4] = {0.4, 0.1, 1.0, 1.0};
84 VGPath path;
85 VGPaint paint;
86 VGPaint fill;
88 // The debug log used by all the gnash libraries.
89 static LogFile& dbglogfile = LogFile::getDefaultInstance();
92 static void
93 initVGDemo(void)
95 VGfloat clearColor[] = {0.0f, 0.0f, 0.0f, 1.0f};/* black color */
96 VGfloat greenColor[] = {0.0f, 1.0f, 0.0f, 1.0f};/* green color */
97 VGint arcType = VGU_ARC_OPEN;
98 VGfloat x, y, w, h, startAngle, angleExtent;
100 x = 150;
101 y = 150;
102 w = 150;
103 h = 150;
104 #if 0
105 startAngle = -540.0f;
106 angleExtent = 270.0f;
107 #else
108 startAngle = 270.0f;
109 angleExtent = 90.0f;
110 #endif
111 paint = vgCreatePaint();
113 vgSetPaint(paint, VG_STROKE_PATH);
114 vgSetParameterfv(paint, VG_PAINT_COLOR, 4, greenColor);
115 vgSetParameteri( paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
116 vgSetf(VG_STROKE_LINE_WIDTH, 6.0f);
117 vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
118 vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
120 path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
121 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
123 vguArc(path, x, y, w, h, startAngle, angleExtent, (VGUArcType)arcType);
125 vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
126 vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_BEVEL);
127 vgSetf(VG_STROKE_MITER_LIMIT, 4.0f);
130 /* new window size or exposure */
131 static void
132 init(void)
134 static const VGubyte sqrCmds[5] = {VG_MOVE_TO_ABS, VG_HLINE_TO_ABS,
135 VG_VLINE_TO_ABS, VG_HLINE_TO_ABS, VG_CLOSE_PATH};
136 static const VGfloat sqrCoords[5] = {50.0f, 50.0f, 250.0f, 250.0f, 50.0f};
137 path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
138 VG_PATH_CAPABILITY_APPEND_TO);
139 vgAppendPathData(path, 5, sqrCmds, sqrCoords);
141 VGPaint fill = vgCreatePaint();
142 vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
143 vgSetPaint(fill, VG_FILL_PATH);
145 vgSetfv(VG_CLEAR_COLOR, 4, white_color);
146 vgSetf(VG_STROKE_LINE_WIDTH, 10);
147 vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
148 vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND);
149 vgSetf(VG_STROKE_MITER_LIMIT, 4.0f);
151 // printVGParams();
154 static void
155 reshape(int w, int h)
157 vgLoadIdentity();
160 static void
161 draw(void)
163 vgClear(0, 0, 640, 480);
164 vgSeti(VG_MATRIX_MODE, VG_MATRIX_STROKE_PAINT_TO_USER);
165 vgLoadIdentity();
166 vgScale(2.25, 2.25);
167 vgDrawPath(path, VG_STROKE_PATH);
169 vgFlush();
172 // Local Variables:
173 // mode: C++
174 // indent-tabs-mode: nil
175 // End: