1 #include "evas_common.h"
2 #include "evas_engine.h"
5 typedef int (*evas_engine_wince_close_display)();
7 typedef struct Evas_Engine_WinCE_GAPI_Priv Evas_Engine_WinCE_GAPI_Priv;
10 #define GETGXINFO 0x00020000
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];
25 #define LINK(type,name,import) \
26 name = (gapi_##type)GetProcAddress (gapi_lib, import)
28 #define GX_FULLSCREEN 0x01
29 #define GX_NORMALKEYS 0x02
31 #define kfDirect555 0x40
32 #define kfDirect565 0x80
43 } _GAPI_Display_Properties;
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);
53 gapi_suspend suspend = NULL;
54 gapi_resume resume = NULL;
57 evas_software_wince_gapi_suspend(void)
66 evas_software_wince_gapi_resume(void)
75 struct Evas_Engine_WinCE_GAPI_Priv
78 gapi_display_close close_display;
79 gapi_draw_begin draw_begin;
80 gapi_draw_end draw_end;
88 evas_software_wince_gapi_init(HWND window,
93 _GAPI_Display_Properties prop;
95 Evas_Engine_WinCE_GAPI_Priv *priv;
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;
103 priv = (Evas_Engine_WinCE_GAPI_Priv *)malloc(sizeof(Evas_Engine_WinCE_GAPI_Priv));
107 gapi_lib = LoadLibrary(L"\\Windows\\gx.dll");
110 gapi_lib = LoadLibrary(L"gx.dll");
113 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] Can not load gx.dll\n");
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" );
128 !display_properties_get ||
134 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] Can not find valid symbols\n");
138 if (!display_open(window, GX_FULLSCREEN))
140 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] Can not open display\n");
144 prop = display_properties_get();
146 // verify pixel format
147 if(!(prop.ffFormat & kfDirect565) || (prop.cBPP != 16))
149 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] display format mismatch\n");
153 // verify we have a vga device
154 if ((GetSystemMetrics(SM_CXSCREEN) != (int)prop.cxWidth) ||
155 (GetSystemMetrics(SM_CYSCREEN) != (int)prop.cyHeight))
157 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] display size mismatch\n");
161 priv->lib = gapi_lib;
162 priv->close_display = display_close;
163 priv->draw_begin = draw_begin;
164 priv->draw_end = draw_end;
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 : */
185 /* So these devices are considered as landscape devices */
186 /* and width and height are switched. */
187 /* Other devices are managed normally : */
204 SystemParametersInfo (SPI_GETOEMINFO, sizeof (oemstr), oemstr, 0);
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')))
213 _GXDeviceInfo gxInfo = { 0 };
217 priv->width = prop.cyHeight;
218 priv->height = prop.cxWidth;
219 priv->stride = prop.cbxPitch;
224 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] Can not get device\n");
228 gxInfo.Version = 100;
229 result = ExtEscape(dc, GETGXINFO, 0, NULL, sizeof(gxInfo),
233 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] ExtEscape failed\n");
234 ReleaseDC(window, dc);
238 priv->buffer = gxInfo.pvFrameBuffer;
239 ReleaseDC(window, dc);
243 priv->width = prop.cxWidth;
244 priv->height = prop.cyHeight;
245 priv->stride = prop.cbyPitch;
249 if ((priv->width != width) ||
250 (priv->height != height))
252 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] Size mismatch\n");
253 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] asked: %dx%d\n", width, height);
254 fprintf (stderr, "[Evas] [Engine] [WinCE GAPI] got : %dx%d\n", priv->width, priv->height);
263 FreeLibrary(gapi_lib);
270 evas_software_wince_gapi_shutdown(void *priv)
272 Evas_Engine_WinCE_GAPI_Priv *p;
274 p = (Evas_Engine_WinCE_GAPI_Priv *)priv;
284 evas_software_wince_gapi_output_buffer_new(void *priv,
288 FB_Output_Buffer *fbob;
291 fbob = calloc(1, sizeof(FB_Output_Buffer));
292 if (!fbob) return NULL;
294 buffer = malloc (width * height * 2); /* we are sure to have 16bpp */
303 fbob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), width, height, (DATA32 *)buffer, 0, EVAS_COLORSPACE_RGB565_A5P);
305 fbob->im->stride = ((Evas_Engine_WinCE_GAPI_Priv *)priv)->stride >> 1;
311 evas_software_wince_gapi_output_buffer_free(FB_Output_Buffer *fbob)
313 free(fbob->im->pixels);
318 evas_software_wince_gapi_output_buffer_paste(FB_Output_Buffer *fbob)
320 Evas_Engine_WinCE_GAPI_Priv *priv;
323 priv = (Evas_Engine_WinCE_GAPI_Priv *)fbob->priv;
325 buffer = priv->draw_begin();
329 if (priv->buffer) buffer = priv->buffer;
331 if ((fbob->im->cache_entry.w == priv->width) &&
332 (fbob->im->cache_entry.h == priv->height))
333 memcpy(buffer, fbob->im->pixels,
334 priv->width * priv->height * 2);
340 evas_software_wince_gapi_surface_resize(FB_Output_Buffer *fbob)