diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/evas/src/modules/engines/software_16_wince/evas_wince_gapi_buffer.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to 'libraries/evas/src/modules/engines/software_16_wince/evas_wince_gapi_buffer.c')
-rw-r--r-- | libraries/evas/src/modules/engines/software_16_wince/evas_wince_gapi_buffer.c | 341 |
1 files changed, 0 insertions, 341 deletions
diff --git a/libraries/evas/src/modules/engines/software_16_wince/evas_wince_gapi_buffer.c b/libraries/evas/src/modules/engines/software_16_wince/evas_wince_gapi_buffer.c deleted file mode 100644 index c23c863..0000000 --- a/libraries/evas/src/modules/engines/software_16_wince/evas_wince_gapi_buffer.c +++ /dev/null | |||
@@ -1,341 +0,0 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_engine.h" | ||
3 | |||
4 | |||
5 | typedef int (*evas_engine_wince_close_display)(); | ||
6 | |||
7 | typedef struct Evas_Engine_WinCE_GAPI_Priv Evas_Engine_WinCE_GAPI_Priv; | ||
8 | |||
9 | |||
10 | #define GETGXINFO 0x00020000 | ||
11 | |||
12 | typedef struct | ||
13 | { | ||
14 | long Version; //00 (should filled with 100 before calling ExtEscape) | ||
15 | void *pvFrameBuffer; //04 | ||
16 | unsigned long cbStride; //08 | ||
17 | unsigned long cxWidth; //0c | ||
18 | unsigned long cyHeight; //10 | ||
19 | unsigned long cBPP; //14 | ||
20 | unsigned long ffFormat; //18 | ||
21 | char Unused[0x84 - 7 * 4]; | ||
22 | } _GXDeviceInfo; | ||
23 | |||
24 | |||
25 | #define LINK(type,name,import) \ | ||
26 | name = (gapi_##type)GetProcAddress (gapi_lib, import) | ||
27 | |||
28 | #define GX_FULLSCREEN 0x01 | ||
29 | #define GX_NORMALKEYS 0x02 | ||
30 | |||
31 | #define kfDirect555 0x40 | ||
32 | #define kfDirect565 0x80 | ||
33 | |||
34 | |||
35 | typedef struct | ||
36 | { | ||
37 | DWORD cxWidth; | ||
38 | DWORD cyHeight; | ||
39 | LONG cbxPitch; | ||
40 | LONG cbyPitch; | ||
41 | LONG cBPP; | ||
42 | DWORD ffFormat; | ||
43 | } _GAPI_Display_Properties; | ||
44 | |||
45 | typedef int (*gapi_display_open)(HWND hWnd, DWORD dwFlags); | ||
46 | typedef int (*gapi_display_close)(); | ||
47 | typedef _GAPI_Display_Properties (*gapi_display_properties_get)(void); | ||
48 | typedef void* (*gapi_draw_begin)(void); | ||
49 | typedef int (*gapi_draw_end)(void); | ||
50 | typedef int (*gapi_suspend)(void); | ||
51 | typedef int (*gapi_resume)(void); | ||
52 | |||
53 | gapi_suspend suspend = NULL; | ||
54 | gapi_resume resume = NULL; | ||
55 | |||
56 | int | ||
57 | evas_software_wince_gapi_suspend(void) | ||
58 | { | ||
59 | if (suspend) | ||
60 | return suspend(); | ||
61 | else | ||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | int | ||
66 | evas_software_wince_gapi_resume(void) | ||
67 | { | ||
68 | if (resume) | ||
69 | return resume(); | ||
70 | else | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | |||
75 | struct Evas_Engine_WinCE_GAPI_Priv | ||
76 | { | ||
77 | HMODULE lib; | ||
78 | gapi_display_close close_display; | ||
79 | gapi_draw_begin draw_begin; | ||
80 | gapi_draw_end draw_end; | ||
81 | void *buffer; | ||
82 | int width; | ||
83 | int height; | ||
84 | int stride; | ||
85 | }; | ||
86 | |||
87 | void * | ||
88 | evas_software_wince_gapi_init(HWND window, | ||
89 | int width, | ||
90 | int height) | ||
91 | { | ||
92 | WCHAR oemstr[100]; | ||
93 | _GAPI_Display_Properties prop; | ||
94 | HMODULE gapi_lib; | ||
95 | Evas_Engine_WinCE_GAPI_Priv *priv; | ||
96 | |||
97 | gapi_display_open display_open = NULL; | ||
98 | gapi_display_close display_close = NULL; | ||
99 | gapi_display_properties_get display_properties_get = NULL; | ||
100 | gapi_draw_begin draw_begin = NULL; | ||
101 | gapi_draw_end draw_end = NULL; | ||
102 | |||
103 | priv = (Evas_Engine_WinCE_GAPI_Priv *)malloc(sizeof(Evas_Engine_WinCE_GAPI_Priv)); | ||
104 | if (!priv) | ||
105 | return NULL; | ||
106 | |||
107 | gapi_lib = LoadLibrary(L"\\Windows\\gx.dll"); | ||
108 | if (!gapi_lib) | ||
109 | { | ||
110 | gapi_lib = LoadLibrary(L"gx.dll"); | ||
111 | if (!gapi_lib) | ||
112 | { | ||
113 | ERR("[Engine] [WinCE GAPI] Can not load gx.dll"); | ||
114 | goto free_priv; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | LINK(display_open, display_open, L"?GXOpenDisplay@@YAHPAUHWND__@@K@Z"); | ||
119 | LINK(display_close, display_close, L"?GXCloseDisplay@@YAHXZ"); | ||
120 | LINK(display_properties_get, display_properties_get, L"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ"); | ||
121 | LINK(draw_begin, draw_begin, L"?GXBeginDraw@@YAPAXXZ"); | ||
122 | LINK(draw_end, draw_end, L"?GXEndDraw@@YAHXZ"); | ||
123 | LINK(suspend, suspend, L"?GXSuspend@@YAHXZ" ); | ||
124 | LINK(resume, resume, L"?GXResume@@YAHXZ" ); | ||
125 | |||
126 | if (!display_open || | ||
127 | !display_close || | ||
128 | !display_properties_get || | ||
129 | !draw_begin || | ||
130 | !draw_end || | ||
131 | !suspend || | ||
132 | !resume) | ||
133 | { | ||
134 | ERR("[Engine] [WinCE GAPI] Can not find valid symbols"); | ||
135 | goto free_lib; | ||
136 | } | ||
137 | |||
138 | if (!display_open(window, GX_FULLSCREEN)) | ||
139 | { | ||
140 | ERR("[Engine] [WinCE GAPI] Can not open display"); | ||
141 | goto free_lib; | ||
142 | } | ||
143 | |||
144 | prop = display_properties_get(); | ||
145 | |||
146 | // verify pixel format | ||
147 | if(!(prop.ffFormat & kfDirect565) || (prop.cBPP != 16)) | ||
148 | { | ||
149 | ERR("display format mismatch"); | ||
150 | goto close_display; | ||
151 | } | ||
152 | |||
153 | // verify we have a vga device | ||
154 | if ((GetSystemMetrics(SM_CXSCREEN) != (int)prop.cxWidth) || | ||
155 | (GetSystemMetrics(SM_CYSCREEN) != (int)prop.cyHeight)) | ||
156 | { | ||
157 | ERR("display size mismatch"); | ||
158 | goto close_display; | ||
159 | } | ||
160 | |||
161 | priv->lib = gapi_lib; | ||
162 | priv->close_display = display_close; | ||
163 | priv->draw_begin = draw_begin; | ||
164 | priv->draw_end = draw_end; | ||
165 | |||
166 | /* GAPI on Ipaq H38** and H39** is completely buggy */ | ||
167 | /* They are detected as portrait device (width = 240 and height = 320) */ | ||
168 | /* but the framebuffer is managed like a landscape device : */ | ||
169 | /* | ||
170 | 240 | ||
171 | +---------+ | ||
172 | | | | ||
173 | | | | ||
174 | | | | ||
175 | | | | ||
176 | | | 320 | ||
177 | | ^^^ | | ||
178 | | ||| | | ||
179 | | ||| | | ||
180 | | ||| | | ||
181 | +---------+ | ||
182 | ----> | ||
183 | |||
184 | */ | ||
185 | /* So these devices are considered as landscape devices */ | ||
186 | /* and width and height are switched. */ | ||
187 | /* Other devices are managed normally : */ | ||
188 | /* | ||
189 | 240 | ||
190 | +---------+ | ||
191 | | |---> | | ||
192 | | |---> | | ||
193 | | |---> | | ||
194 | v | | | ||
195 | | | 320 | ||
196 | | | | ||
197 | | | | ||
198 | | | | ||
199 | | | | ||
200 | +---------+ | ||
201 | |||
202 | */ | ||
203 | |||
204 | SystemParametersInfo (SPI_GETOEMINFO, sizeof (oemstr), oemstr, 0); | ||
205 | |||
206 | if (((oemstr[12] == 'H') && | ||
207 | (oemstr[13] == '3') && | ||
208 | (oemstr[14] == '8')) || | ||
209 | ((oemstr[12] == 'H') && | ||
210 | (oemstr[13] == '3') && | ||
211 | (oemstr[14] == '9'))) | ||
212 | { | ||
213 | _GXDeviceInfo gxInfo = { 0 }; | ||
214 | HDC dc; | ||
215 | int result; | ||
216 | |||
217 | priv->width = prop.cyHeight; | ||
218 | priv->height = prop.cxWidth; | ||
219 | priv->stride = prop.cbxPitch; | ||
220 | |||
221 | dc = GetDC (window); | ||
222 | if (!dc) | ||
223 | { | ||
224 | ERR("Can not get device"); | ||
225 | goto close_display; | ||
226 | } | ||
227 | |||
228 | gxInfo.Version = 100; | ||
229 | result = ExtEscape(dc, GETGXINFO, 0, NULL, sizeof(gxInfo), | ||
230 | (char *) &gxInfo); | ||
231 | if (result <= 0) | ||
232 | { | ||
233 | ERR("ExtEscape failed"); | ||
234 | ReleaseDC(window, dc); | ||
235 | goto close_display; | ||
236 | } | ||
237 | |||
238 | priv->buffer = gxInfo.pvFrameBuffer; | ||
239 | ReleaseDC(window, dc); | ||
240 | } | ||
241 | else | ||
242 | { | ||
243 | priv->width = prop.cxWidth; | ||
244 | priv->height = prop.cyHeight; | ||
245 | priv->stride = prop.cbyPitch; | ||
246 | priv->buffer = NULL; | ||
247 | } | ||
248 | |||
249 | if ((priv->width != width) || | ||
250 | (priv->height != height)) | ||
251 | { | ||
252 | ERR("Size mismatch: asked: %dx%d, got: %dx%d", | ||
253 | width, height, priv->width, priv->height); | ||
254 | goto close_display; | ||
255 | } | ||
256 | |||
257 | return priv; | ||
258 | |||
259 | close_display: | ||
260 | display_close(); | ||
261 | free_lib: | ||
262 | FreeLibrary(gapi_lib); | ||
263 | free_priv: | ||
264 | free(priv); | ||
265 | return NULL; | ||
266 | } | ||
267 | |||
268 | void | ||
269 | evas_software_wince_gapi_shutdown(void *priv) | ||
270 | { | ||
271 | Evas_Engine_WinCE_GAPI_Priv *p; | ||
272 | |||
273 | p = (Evas_Engine_WinCE_GAPI_Priv *)priv; | ||
274 | p->close_display(); | ||
275 | suspend = NULL; | ||
276 | resume = NULL; | ||
277 | FreeLibrary(p->lib); | ||
278 | free(p); | ||
279 | } | ||
280 | |||
281 | |||
282 | FB_Output_Buffer * | ||
283 | evas_software_wince_gapi_output_buffer_new(void *priv, | ||
284 | int width, | ||
285 | int height) | ||
286 | { | ||
287 | FB_Output_Buffer *fbob; | ||
288 | void *buffer; | ||
289 | |||
290 | fbob = calloc(1, sizeof(FB_Output_Buffer)); | ||
291 | if (!fbob) return NULL; | ||
292 | |||
293 | buffer = malloc (width * height * 2); /* we are sure to have 16bpp */ | ||
294 | if (!buffer) | ||
295 | { | ||
296 | free(fbob); | ||
297 | return NULL; | ||
298 | } | ||
299 | |||
300 | fbob->priv = priv; | ||
301 | |||
302 | fbob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), width, height, (DATA32 *)buffer, 0, EVAS_COLORSPACE_RGB565_A5P); | ||
303 | if (fbob->im) | ||
304 | fbob->im->stride = ((Evas_Engine_WinCE_GAPI_Priv *)priv)->stride >> 1; | ||
305 | |||
306 | return fbob; | ||
307 | } | ||
308 | |||
309 | void | ||
310 | evas_software_wince_gapi_output_buffer_free(FB_Output_Buffer *fbob) | ||
311 | { | ||
312 | free(fbob->im->pixels); | ||
313 | free(fbob); | ||
314 | } | ||
315 | |||
316 | void | ||
317 | evas_software_wince_gapi_output_buffer_paste(FB_Output_Buffer *fbob) | ||
318 | { | ||
319 | Evas_Engine_WinCE_GAPI_Priv *priv; | ||
320 | void *buffer; | ||
321 | |||
322 | priv = (Evas_Engine_WinCE_GAPI_Priv *)fbob->priv; | ||
323 | |||
324 | buffer = priv->draw_begin(); | ||
325 | if (!buffer) | ||
326 | return; | ||
327 | |||
328 | if (priv->buffer) buffer = priv->buffer; | ||
329 | |||
330 | if ((fbob->im->cache_entry.w == priv->width) && | ||
331 | (fbob->im->cache_entry.h == priv->height)) | ||
332 | memcpy(buffer, fbob->im->pixels, | ||
333 | priv->width * priv->height * 2); | ||
334 | |||
335 | priv->draw_end(); | ||
336 | } | ||
337 | |||
338 | void | ||
339 | evas_software_wince_gapi_surface_resize(FB_Output_Buffer *fbob) | ||
340 | { | ||
341 | } | ||