4 #define WIN32_LEAN_AND_MEAN
6 #undef WIN32_LEAN_AND_MEAN
9 #include "evas_common.h"
10 #include "evas_engine.h"
13 typedef LONG (*fct_DirectDrawCreate)(LPGUID, LPUNKNOWN *, LPUNKNOWN *);
15 fct_DirectDrawCreate lib_DirectDrawCreate;
17 typedef struct Evas_Engine_WinCE_DDraw_Priv Evas_Engine_WinCE_DDraw_Priv;
19 struct Evas_Engine_WinCE_DDraw_Priv
23 LPDIRECTDRAWSURFACE surface;
30 evas_software_wince_ddraw_init(HWND window,
34 DDSURFACEDESC surface_desc;
35 Evas_Engine_WinCE_DDraw_Priv *priv;
38 priv = (Evas_Engine_WinCE_DDraw_Priv *)malloc(sizeof(Evas_Engine_WinCE_DDraw_Priv));
42 priv->module = LoadLibrary(L"ddraw.dll");
45 std::cerr << "[Evas] [Engine] [WinCE DDraw] Can not load ddraw.dll" << std::endl;
49 lib_DirectDrawCreate = (fct_DirectDrawCreate)GetProcAddress(priv->module, L"DirectDrawCreate");
50 if (!lib_DirectDrawCreate)
52 std::cerr << "[Evas] [Engine] [WinCE DDraw] Can not initialize DirectDraw" << std::endl;
56 res = lib_DirectDrawCreate(NULL, (IUnknown**)&priv->object, NULL);
59 std::cerr << "[Evas] [Engine] [WinCE DDraw] Can not create DirectDraw object" << std::endl;
63 res = priv->object->SetCooperativeLevel(window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
66 std::cerr<< "[Evas] [Engine] [WinCE DDraw] Can not set window to fullscreen" << std::endl;
70 memset(&surface_desc, 0, sizeof(surface_desc));
71 surface_desc.dwSize = sizeof(surface_desc);
72 surface_desc.dwFlags = DDSD_CAPS;
73 surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
75 res = priv->object->CreateSurface(&surface_desc, &priv->surface, NULL);
78 std::cerr << "[Evas] [Engine] [WinCE DDraw] Can not create surface" << std::endl;
82 memset(&surface_desc, 0, sizeof(surface_desc));
83 surface_desc.dwSize = sizeof(surface_desc);
84 res = priv->surface->Lock(NULL, &surface_desc, DDLOCK_READONLY, NULL);
87 std::cerr << "[Evas] [Engine] [WinCE DDraw] Can not lock surface" << std::endl;
91 priv->width = surface_desc.dwWidth;
92 priv->height = surface_desc.dwHeight;
93 priv->stride = surface_desc.lPitch / 2;
95 if ((priv->width != width) ||
96 (priv->height != height))
98 std::cerr << "[Evas] [Engine] [WinCE DDraw] Size mismatch" << std::endl;
99 std::cerr << "[Evas] [Engine] [WinCE DDraw] asked: " << width << "x" << height << std::endl;
100 std::cerr << "[Evas] [Engine] [WinCE DDraw] got : " << priv->width << "x" << priv->height << std::endl;
101 goto release_surface;
104 res = priv->surface->Unlock(NULL);
107 std::cerr << "[Evas] [Engine] [WinCE DDraw] Can not unlock surface" << std::endl;
108 goto release_surface;
114 priv->surface->Release();
116 priv->object->Release();
118 FreeLibrary(priv->module);
126 evas_software_wince_ddraw_shutdown(void *priv)
128 ((Evas_Engine_WinCE_DDraw_Priv *)priv)->surface->Release();
129 ((Evas_Engine_WinCE_DDraw_Priv *)priv)->object->Release();
130 FreeLibrary(((Evas_Engine_WinCE_DDraw_Priv *)priv)->module);
136 evas_software_wince_ddraw_output_buffer_new(void *priv,
140 FB_Output_Buffer *fbob;
143 fbob = (FB_Output_Buffer *)calloc(1, sizeof(FB_Output_Buffer));
144 if (!fbob) return NULL;
146 buffer = malloc (width * height * 2); /* we are sure to have 16bpp */
155 fbob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), width, height, (DATA32 *)buffer, 0, EVAS_COLORSPACE_RGB565_A5P);
157 fbob->im->stride = ((Evas_Engine_WinCE_DDraw_Priv *)priv)->stride;
163 evas_software_wince_ddraw_output_buffer_free(FB_Output_Buffer *fbob)
165 free(fbob->im->pixels);
170 evas_software_wince_ddraw_output_buffer_paste(FB_Output_Buffer *fbob)
172 DDSURFACEDESC surface_desc;
173 Evas_Engine_WinCE_DDraw_Priv *priv;
176 priv = (Evas_Engine_WinCE_DDraw_Priv *)fbob->priv;
178 memset(&surface_desc, 0, sizeof(surface_desc));
179 surface_desc.dwSize = sizeof(surface_desc);
180 res = priv->surface->Lock(NULL, &surface_desc, DDLOCK_WRITEONLY, NULL);
184 if ((fbob->im->cache_entry.w == surface_desc.dwWidth) &&
185 (fbob->im->cache_entry.h == surface_desc.dwHeight))
186 memcpy(surface_desc.lpSurface, fbob->im->pixels,
187 surface_desc.dwWidth * surface_desc.dwHeight * 2);
189 priv->surface->Unlock(NULL);
193 evas_software_wince_ddraw_surface_resize(FB_Output_Buffer *fbob)