add fullscreen support in software directdraw engine (win xp)

SVN revision: 37887
This commit is contained in:
Vincent Torri 2008-12-01 20:38:05 +00:00
parent 9cf7c7c3a3
commit 6a06a92ac8
5 changed files with 124 additions and 63 deletions

View File

@ -19,6 +19,7 @@ struct _Evas_Engine_Info_Software_DDraw
HWND window;
int depth;
int rotation;
unsigned int fullscreen : 1;
} info;
};

View File

@ -4,12 +4,11 @@
int
evas_software_ddraw_init (HWND window,
int depth,
int fullscreen,
Outbuf *buf)
{
DDSURFACEDESC surface_desc;
DDPIXELFORMAT pixel_format;
RECT rect;
LPDIRECTDRAW o;
HRESULT res;
int width;
int height;
@ -17,18 +16,64 @@ evas_software_ddraw_init (HWND window,
if (!buf)
return 0;
if (!GetClientRect(window, &rect))
return 0;
width = rect.right - rect.left;
height = rect.bottom - rect.top;
buf->priv.dd.window = window;
res = DirectDrawCreate(NULL, &buf->priv.dd.object, NULL);
if (FAILED(res))
return 0;
if (buf->priv.dd.fullscreen)
{
DDSCAPS caps;
res = buf->priv.dd.object->SetCooperativeLevel(window,
DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
if (FAILED(res))
goto release_object;
width = GetSystemMetrics(SM_CXSCREEN);
height = GetSystemMetrics(SM_CYSCREEN);
ZeroMemory(&pixel_format, sizeof(pixel_format));
pixel_format.dwSize = sizeof(pixel_format);
buf->priv.dd.surface_primary->GetPixelFormat(&pixel_format);
if (pixel_format.dwRGBBitCount != depth)
goto release_object;
buf->priv.dd.depth = depth;
res = buf->priv.dd.object->SetDisplayMode(width, height, depth);
if (FAILED(res))
goto release_object;
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
surface_desc.dwBackBufferCount = 1;
res = buf->priv.dd.object->CreateSurface(&surface_desc,
&buf->priv.dd.surface_primary, NULL);
if (FAILED(res))
goto release_object;
caps.dwCaps = DDSCAPS_BACKBUFFER;
res = buf->priv.dd.surface_primary->GetAttachedSurface(&caps,
&buf->priv.dd.surface_back);
if (FAILED(res))
goto release_surface_primary;
}
else
{
RECT rect;
if (!GetClientRect(window, &rect))
goto release_object;
width = rect.right - rect.left;
height = rect.bottom - rect.top;
res = buf->priv.dd.object->SetCooperativeLevel(window, DDSCL_NORMAL);
if (FAILED(res))
goto release_object;
@ -73,6 +118,7 @@ evas_software_ddraw_init (HWND window,
goto release_surface_back;
buf->priv.dd.depth = depth;
}
return 1;
@ -81,6 +127,7 @@ evas_software_ddraw_init (HWND window,
release_surface_primary:
buf->priv.dd.surface_primary->Release();
release_clipper:
if (buf->priv.dd.fullscreen)
buf->priv.dd.clipper->Release();
release_object:
buf->priv.dd.object->Release();
@ -94,9 +141,15 @@ evas_software_ddraw_shutdown(Outbuf *buf)
if (!buf)
return;
if (buf->priv.dd.fullscreen)
if (buf->priv.dd.surface_back)
buf->priv.dd.surface_back->Release();
if (buf->priv.dd.surface_primary)
buf->priv.dd.surface_primary->Release();
if (buf->priv.dd.fullscreen)
if (buf->priv.dd.clipper)
buf->priv.dd.clipper->Release();
if (buf->priv.dd.object)
buf->priv.dd.object->Release();
}

View File

@ -24,7 +24,8 @@ _output_setup(int width,
int height,
int rot,
HWND window,
int depth)
int depth,
int fullscreen)
{
Render_Engine *re;
@ -51,7 +52,7 @@ _output_setup(int width,
re->ob = evas_software_ddraw_outbuf_setup(width, height, rot,
OUTBUF_DEPTH_INHERIT,
window, depth);
window, depth, fullscreen);
if (!re->ob)
{
free(re);
@ -116,7 +117,8 @@ eng_setup(Evas *e, void *in)
e->output.h,
info->info.rotation,
info->info.window,
info->info.depth);
info->info.depth,
info->info.fullscreen);
else
{
int ponebuf = 0;
@ -129,7 +131,8 @@ eng_setup(Evas *e, void *in)
info->info.rotation,
OUTBUF_DEPTH_INHERIT,
info->info.window,
info->info.depth);
info->info.depth,
info->info.fullscreen);
re->ob->onebuf = ponebuf;
}
if (!e->engine.data.output) return;

View File

@ -42,6 +42,7 @@ struct _Outbuf
LPDIRECTDRAWSURFACE surface_back;
LPDIRECTDRAWCLIPPER clipper;
int depth;
unsigned char fullscreen : 1;
unsigned char swap : 1;
unsigned char bit_swap : 1;
} dd;
@ -97,7 +98,8 @@ Outbuf *evas_software_ddraw_outbuf_setup(int width,
int rotation,
Outbuf_Depth depth,
HWND window,
int w_depth);
int w_depth,
int fullscreen);
void evas_software_ddraw_outbuf_reconfigure(Outbuf *buf,
int width,
@ -168,6 +170,7 @@ extern "C" {
int evas_software_ddraw_init (HWND window,
int depth,
int fullscreen,
Outbuf *buf);
void evas_software_ddraw_shutdown(Outbuf *buf);

View File

@ -103,7 +103,8 @@ evas_software_ddraw_outbuf_setup(int width,
int rotation,
Outbuf_Depth depth,
HWND window,
int w_depth)
int w_depth,
int fullscreen)
{
Outbuf *buf;
@ -116,7 +117,7 @@ evas_software_ddraw_outbuf_setup(int width,
buf->depth = depth;
buf->rot = rotation;
if (!evas_software_ddraw_init(window, w_depth, buf))
if (!evas_software_ddraw_init(window, w_depth, fullscreen, buf))
{
free(buf);
return NULL;