summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-08-13 10:17:48 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-08-13 10:17:48 +0000
commit6bf7790fa7d861ac39a12178631f9d1750f74769 (patch)
tree9b81ab02b287845898e8068d105104b2da24f3f5 /src
parent2fc8dfa0521d2395dbf68687b9d55be81b7cf457 (diff)
vincent wanted 16bit ddraw gone from expedite.. so it shall be!
SVN revision: 75204
Diffstat (limited to 'src')
-rw-r--r--src/bin/Makefile.am7
-rw-r--r--src/bin/engine_software_16_ddraw.cpp392
-rw-r--r--src/bin/engine_software_16_ddraw.h20
3 files changed, 1 insertions, 418 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index d9519b6..fa7901a 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -144,7 +144,7 @@ proxy_text_random.c
144 144
145expedite_CFLAGS = @WIN32_CFLAGS@ 145expedite_CFLAGS = @WIN32_CFLAGS@
146expedite_CXXFLAGS = @EXPEDITE_CXXFLAGS@ 146expedite_CXXFLAGS = @EXPEDITE_CXXFLAGS@
147expedite_LDADD = @SDL_LIBS@ @x_libs@ @gdi_libs@ @ddraw_libs@ @ddraw_16_libs@ @d3d_libs@ @wince_16_libs@ @DIRECTFB_LIBS@ @XCB_LIBS@ @EVAS_LIBS@ @EINA_LIBS@ @EVIL_LIBS@ @gl_cocoa_libs@ -lm 147expedite_LDADD = @SDL_LIBS@ @x_libs@ @gdi_libs@ @ddraw_libs@ @d3d_libs@ @wince_16_libs@ @DIRECTFB_LIBS@ @XCB_LIBS@ @EVAS_LIBS@ @EINA_LIBS@ @EVIL_LIBS@ @gl_cocoa_libs@ -lm
148expedite_LDFLAGS = @lt_enable_auto_import@ 148expedite_LDFLAGS = @lt_enable_auto_import@
149 149
150if BUILD_SOFTWARE_XLIB 150if BUILD_SOFTWARE_XLIB
@@ -222,11 +222,6 @@ expedite_SOURCES += \
222engine_software_16_x11.c engine_software_16_x11.h 222engine_software_16_x11.c engine_software_16_x11.h
223endif 223endif
224 224
225if BUILD_SOFTWARE_16_DDRAW
226expedite_SOURCES += \
227engine_software_16_ddraw.cpp engine_software_16_ddraw.h
228endif
229
230if BUILD_SOFTWARE_16_WINCE 225if BUILD_SOFTWARE_16_WINCE
231expedite_SOURCES += \ 226expedite_SOURCES += \
232engine_software_16_wince.c engine_software_16_wince.h engine_software_16_wince.rc 227engine_software_16_wince.c engine_software_16_wince.h engine_software_16_wince.rc
diff --git a/src/bin/engine_software_16_ddraw.cpp b/src/bin/engine_software_16_ddraw.cpp
deleted file mode 100644
index 6fd48bb..0000000
--- a/src/bin/engine_software_16_ddraw.cpp
+++ /dev/null
@@ -1,392 +0,0 @@
1#include "main.h"
2
3#include <windowsx.h>
4#include <Evas_Engine_Software_16_DDraw.h>
5
6
7static HWND window;
8static HINSTANCE instance;
9
10
11static int
12_directdraw_init (HWND window,
13 int width,
14 int height,
15 LPDIRECTDRAW *object,
16 LPDIRECTDRAWSURFACE *surface_primary,
17 LPDIRECTDRAWSURFACE *surface_back,
18 LPDIRECTDRAWSURFACE *surface_source,
19 int *depth)
20{
21 DDSURFACEDESC surface_desc;
22 DDPIXELFORMAT pixel_format;
23 LPDIRECTDRAW o;
24 void *source;
25 HRESULT res;
26
27 res = DirectDrawCreate (NULL, &o, NULL);
28 if (FAILED(res))
29 return 0;
30
31 res = o->SetCooperativeLevel (window, DDSCL_NORMAL);
32 if (FAILED(res))
33 {
34 o->Release ();
35 return 0;
36 }
37
38 memset(&surface_desc, 0, sizeof(surface_desc));
39 surface_desc.dwSize = sizeof(surface_desc);
40 surface_desc.dwFlags = DDSD_CAPS;
41 surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
42
43 res = o->CreateSurface (&surface_desc, surface_primary, NULL);
44 if (FAILED(res))
45 {
46 o->Release ();
47 return 0;
48 }
49
50 memset (&surface_desc, 0, sizeof(surface_desc));
51 surface_desc.dwSize = sizeof(surface_desc);
52 surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
53 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
54 surface_desc.dwWidth = width;
55 surface_desc.dwHeight = height;
56
57 res = o->CreateSurface (&surface_desc, surface_back, NULL);
58 if (FAILED(res))
59 {
60 (*surface_primary)->Release ();
61 o->Release ();
62 return 0;
63 }
64
65 ZeroMemory(&pixel_format, sizeof(pixel_format));
66 pixel_format.dwSize = sizeof(pixel_format);
67 (*surface_primary)->GetPixelFormat(&pixel_format);
68
69 source = malloc(width * height * 2);
70 if (!source)
71 {
72 (*surface_primary)->Release ();
73 o->Release ();
74 return 0;
75 }
76
77 memset (&surface_desc, 0, sizeof (surface_desc));
78 surface_desc.dwSize = sizeof (surface_desc);
79 surface_desc.dwFlags =
80 DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH |
81 DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
82 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
83 surface_desc.dwWidth = width;
84 surface_desc.dwHeight = height;
85 surface_desc.lPitch = 2 * surface_desc.dwWidth;
86 surface_desc.lpSurface = source;
87 surface_desc.ddpfPixelFormat = pixel_format;
88
89 if (FAILED(o->CreateSurface(&surface_desc, surface_source, NULL)))
90 {
91 free(source);
92 (*surface_primary)->Release ();
93 o->Release ();
94 return 0;
95 }
96
97 *object = o;
98 *depth = pixel_format.dwRGBBitCount;
99
100 return 1;
101}
102
103static LRESULT CALLBACK
104MainWndProc(HWND hwnd,
105 UINT uMsg,
106 WPARAM wParam,
107 LPARAM lParam)
108{
109 switch (uMsg)
110 {
111 case WM_CREATE:
112 return 0;
113 case WM_DESTROY:
114 PostQuitMessage(0);
115 return 0;
116 case WM_CLOSE:
117 PostQuitMessage(0);
118 return 0;
119 case WM_WINDOWPOSCHANGED: {
120 PAINTSTRUCT ps;
121 HDC hdc;
122
123 hdc = BeginPaint (window, &ps);
124 evas_damage_rectangle_add(evas,
125 ps.rcPaint.left, ps.rcPaint.top,
126 ps.rcPaint.right - ps.rcPaint.left,
127 ps.rcPaint.bottom - ps.rcPaint.top);
128 EndPaint(window, &ps);
129 return 0;
130 }
131 case WM_SIZING:
132 {
133 PRECT rect = (PRECT)lParam;
134
135 evas_output_viewport_set(evas, 0, 0,
136 rect->right - rect->left,
137 rect->bottom - rect->top);
138 evas_output_size_set(evas,
139 rect->right - rect->left,
140 rect->bottom - rect->top);
141 win_w = rect->right - rect->left;
142 win_h = rect->bottom - rect->top;
143 return 0;
144 }
145 case WM_RBUTTONDOWN:
146 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
147 evas_event_feed_mouse_down(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
148 return 0;
149 case WM_LBUTTONDOWN:
150 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
151 evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
152 return 0;
153 case WM_LBUTTONUP:
154 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
155 evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
156 return 0;
157 case WM_RBUTTONUP:
158 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
159 evas_event_feed_mouse_up(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
160 return 0;
161 case WM_MOUSEMOVE:
162 if (!evas_pointer_inside_get(evas)) evas_event_feed_mouse_in(evas, 0, NULL);
163 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
164 return 0;
165 case WM_MOUSELEAVE:
166 evas_event_feed_mouse_out(evas, 0, NULL);
167 return 0;
168 /* FIXME : can't find an event when the mouse is entering */
169 case WM_KEYDOWN:
170 case WM_SYSKEYDOWN: {
171 int key;
172
173 key = LOWORD(wParam);
174
175 if ((key == VK_SHIFT) ||
176 (key == VK_LSHIFT) ||
177 (key == VK_RSHIFT))
178 evas_key_modifier_on(evas, "Shift");
179 if ((key == VK_CONTROL) ||
180 (key == VK_LCONTROL) ||
181 (key == VK_RCONTROL))
182 evas_key_modifier_on(evas, "Control");
183 if ((key == VK_MENU) ||
184 (key == VK_LMENU) ||
185 (key == VK_RMENU))
186 evas_key_modifier_on(evas, "Alt");
187 if ((key == VK_LWIN) ||
188 (key == VK_RWIN))
189 evas_key_modifier_on(evas, "Super");
190
191 if (key == VK_CAPITAL)
192 {
193 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
194 evas_key_lock_off(evas, "Caps_Lock");
195 else
196 evas_key_lock_on(evas, "Caps_Lock");
197 }
198 if (key == VK_NUMLOCK)
199 {
200 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Num_Lock"))
201 evas_key_lock_off(evas, "Num_Lock");
202 else
203 evas_key_lock_on(evas, "Num_Lock");
204 }
205 if (key == VK_SCROLL)
206 {
207 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Scroll_Lock"))
208 evas_key_lock_off(evas, "Scroll_Lock");
209 else
210 evas_key_lock_on(evas, "Scroll_Lock");
211 }
212 if (key == VK_ESCAPE)
213 evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
214 if (key == VK_RETURN)
215 evas_event_feed_key_down(evas, "Return", "Return", NULL, NULL, 0, NULL);
216 if (key == VK_LEFT)
217 evas_event_feed_key_down(evas, "Left", "Left", NULL, NULL, 0, NULL);
218 if (key == VK_RIGHT)
219 evas_event_feed_key_down(evas, "Right", "Right", NULL, NULL, 0, NULL);
220 if (key == 81)
221 evas_event_feed_key_down(evas, "Q", "Q", NULL, NULL, 0, NULL);
222 if (key == 113)
223 evas_event_feed_key_down(evas, "q", "q", NULL, NULL, 0, NULL);
224 return 0;
225 }
226 case WM_KEYUP:
227 case WM_SYSKEYUP: {
228 int key;
229
230 key = LOWORD(wParam);
231
232 if ((key == VK_SHIFT) ||
233 (key == VK_LSHIFT) ||
234 (key == VK_RSHIFT))
235 evas_key_modifier_off(evas, "Shift");
236 if ((key == VK_CONTROL) ||
237 (key == VK_LCONTROL) ||
238 (key == VK_RCONTROL))
239 evas_key_modifier_off(evas, "Control");
240 if ((key == VK_MENU) ||
241 (key == VK_LMENU) ||
242 (key == VK_RMENU))
243 evas_key_modifier_off(evas, "Alt");
244 if ((key == VK_LWIN) ||
245 (key == VK_RWIN))
246 evas_key_modifier_off(evas, "Super");
247 if (key == VK_ESCAPE)
248 evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
249 if (key == VK_RETURN)
250 evas_event_feed_key_up(evas, "Return", "Return", NULL, NULL, 0, NULL);
251 if (key == VK_LEFT)
252 evas_event_feed_key_up(evas, "Left", "Left", NULL, NULL, 0, NULL);
253 if (key == VK_RIGHT)
254 evas_event_feed_key_up(evas, "Right", "Right", NULL, NULL, 0, NULL);
255 if (key == 81)
256 evas_event_feed_key_up(evas, "Q", "Q", NULL, NULL, 0, NULL);
257 if (key == 113)
258 evas_event_feed_key_up(evas, "q", "q", NULL, NULL, 0, NULL);
259 return 0;
260 }
261 default:
262 return DefWindowProc(hwnd, uMsg, wParam, lParam);
263 }
264}
265
266Eina_Bool
267engine_software_16_ddraw_args(const char *engine, int width, int height)
268{
269 WNDCLASS wc;
270 RECT rect;
271 LPDIRECTDRAW object;
272 LPDIRECTDRAWSURFACE surface_primary;
273 LPDIRECTDRAWSURFACE surface_back;
274 LPDIRECTDRAWSURFACE surface_source;
275 Evas_Engine_Info_Software_16_DDraw *einfo;
276 DWORD style;
277 DWORD exstyle;
278 int depth;
279 int i;
280
281 instance = GetModuleHandle(NULL);
282 if (!instance) return EINA_FALSE;
283
284 wc.style = CS_HREDRAW | CS_VREDRAW;
285 wc.lpfnWndProc = MainWndProc;
286 wc.cbClsExtra = 0;
287 wc.cbWndExtra = 0;
288 wc.hInstance = instance;
289 wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
290 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
291 wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
292 wc.lpszMenuName = NULL;
293 wc.lpszClassName = "Evas_Software_16_DDraw_Test";
294
295 if(!RegisterClass(&wc))
296 goto free_library;
297
298 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
299 exstyle = 0;
300
301 rect.left = 0;
302 rect.top = 0;
303 rect.right = width;
304 rect.bottom = height;
305 AdjustWindowRectEx(&rect, style, FALSE, exstyle);
306
307 window = CreateWindowEx(exstyle,
308 "Evas_Software_16_DDraw_Test",
309 "Evas_Software_16_DDraw_Test",
310 style,
311 CW_USEDEFAULT, CW_USEDEFAULT,
312 rect.right - rect.left, rect.bottom - rect.top,
313 NULL, NULL, instance, NULL);
314 if (!window)
315 goto unregister_class;
316
317 /* make the window non resizable */
318 style = GetWindowLong(window, GWL_STYLE);
319 style &= ~WS_THICKFRAME;
320 if (!SetWindowLong(window, GWL_STYLE, style))
321 goto unregister_class;
322
323 if (!_directdraw_init(window, width, height,
324 &object,
325 &surface_primary,
326 &surface_back,
327 &surface_source,
328 &depth))
329 goto destroy_window;
330
331 evas_output_method_set(evas, evas_render_method_lookup("software_16_ddraw"));
332 einfo = (Evas_Engine_Info_Software_16_DDraw *)evas_engine_info_get(evas);
333 if (!einfo)
334 {
335 fprintf(stderr, "Evas does not support the 16 bits Software DirectDraw Engine\n");
336 /* should shutdown ddraw */
337 goto destroy_window;
338 }
339
340 einfo->info.window = window;
341 einfo->info.object = object;
342 einfo->info.surface_primary = surface_primary;
343 einfo->info.surface_back = surface_back;
344 einfo->info.surface_source = surface_source;
345 einfo->info.depth = depth;
346 einfo->info.rotation = 0;
347 if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo))
348 {
349 printf("Evas can not setup the informations of the 16 bits Software DirectDraw Engine\n");
350 goto destroy_window;
351 }
352
353 /* the second parameter is ignored, as it's the first call of ShowWindow */
354 ShowWindow(window, SW_SHOWDEFAULT);
355 UpdateWindow(window);
356
357 return EINA_TRUE;
358
359 destroy_window:
360 DestroyWindow(window);
361 unregister_class:
362 UnregisterClass("Evas_Software_16_DDraw_Test", instance);
363 free_library:
364 FreeLibrary(instance);
365
366 return EINA_FALSE;
367}
368
369void
370engine_software_16_ddraw_loop(void)
371{
372 MSG msg;
373 int res;
374
375 again:
376 if (!PeekMessage (&msg, window, 0, 0, PM_NOREMOVE))
377 return;
378
379 res = GetMessage (&msg, NULL, 0, 0);
380 TranslateMessage (&msg);
381 DispatchMessage (&msg);
382
383 goto again;
384}
385
386void
387engine_software_16_ddraw_shutdown(void)
388{
389 DestroyWindow(window);
390 UnregisterClass("Evas_Software_16_DDraw_Test", instance);
391 FreeLibrary(instance);
392}
diff --git a/src/bin/engine_software_16_ddraw.h b/src/bin/engine_software_16_ddraw.h
deleted file mode 100644
index 2f4e969..0000000
--- a/src/bin/engine_software_16_ddraw.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef __ENGINE_SOFTWARE_16_DDRAW_H__
2#define __ENGINE_SOFTWARE_16_DDRAW_H__
3
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9
10Eina_Bool engine_software_16_ddraw_args(const char *engine, int width, int height);
11void engine_software_16_ddraw_loop(void);
12void engine_software_16_ddraw_shutdown(void);
13
14
15#ifdef __cplusplus
16}
17#endif
18
19
20#endif /* __ENGINE_SOFTWARE_16_DDRAW_H__ */