1
0
mirror of https://github.com/brl/mutter.git synced 2025-01-11 12:12:25 +00:00

* clutter/win32/clutter-stage-win32.c

(clutter_stage_win32_realize): Use a more direct method to choose
	the best pixel format instead of ChoosePixelFormat because
	otherwise if the display's depth is 16 then it will prefer the
	non-accelerated software implementation when the requested depth
	is 24.
This commit is contained in:
Neil Roberts 2008-06-25 12:25:43 +00:00
parent 09097fc810
commit 1049959d34
2 changed files with 72 additions and 14 deletions

View File

@ -1,3 +1,12 @@
2008-06-25 Neil Roberts <neil@o-hand.com>
* clutter/win32/clutter-stage-win32.c
(clutter_stage_win32_realize): Use a more direct method to choose
the best pixel format instead of ChoosePixelFormat because
otherwise if the display's depth is 16 then it will prefer the
non-accelerated software implementation when the requested depth
is 24.
2008-06-25 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-stage.c (clutter_stage_allocate): Fix condition;

View File

@ -398,6 +398,66 @@ clutter_stage_win32_check_gl_version ()
return major > 1 || (major == 1 && minor >= 2);
}
static gboolean
clutter_stage_win32_pixel_format_is_better (const PIXELFORMATDESCRIPTOR *pfa,
const PIXELFORMATDESCRIPTOR *pfb)
{
/* Always prefer a format with a stencil buffer */
if (pfa->cStencilBits == 0)
{
if (pfb->cStencilBits > 0)
return TRUE;
}
else if (pfb->cStencilBits == 0)
return FALSE;
/* Prefer a bigger color buffer */
if (pfb->cColorBits > pfa->cColorBits)
return TRUE;
else if (pfb->cColorBits < pfa->cColorBits)
return FALSE;
/* Prefer a bigger depth buffer */
return pfb->cDepthBits > pfa->cDepthBits;
}
static int
clutter_stage_win32_choose_pixel_format (HDC dc, PIXELFORMATDESCRIPTOR *pfd)
{
int i, num_formats, best_pf = 0;
PIXELFORMATDESCRIPTOR best_pfd;
num_formats = DescribePixelFormat (dc, 0, sizeof (best_pfd), NULL);
for (i = 1; i <= num_formats; i++)
{
memset (pfd, 0, sizeof (*pfd));
if (DescribePixelFormat (dc, i, sizeof (best_pfd), pfd)
/* Check whether this format is useable by Clutter */
&& ((pfd->dwFlags & (PFD_SUPPORT_OPENGL
| PFD_DRAW_TO_WINDOW
| PFD_DOUBLEBUFFER
| PFD_GENERIC_FORMAT))
== (PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW))
&& pfd->iPixelType == PFD_TYPE_RGBA
&& pfd->cColorBits >= 16 && pfd->cColorBits <= 32
&& pfd->cDepthBits >= 16 && pfd->cDepthBits <= 32
/* Check whether this is a better format than one we've
already found */
&& (best_pf == 0
|| clutter_stage_win32_pixel_format_is_better (&best_pfd, pfd)))
{
best_pf = i;
best_pfd = *pfd;
}
}
*pfd = best_pfd;
return best_pf;
}
static void
clutter_stage_win32_realize (ClutterActor *actor)
{
@ -468,20 +528,9 @@ clutter_stage_win32_realize (ClutterActor *actor)
stage_win32->client_dc = GetDC (stage_win32->hwnd);
memset (&pfd, 0, sizeof (pfd));
pfd.nSize = sizeof (pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cAlphaBits = 8;
pfd.cDepthBits = 32;
pfd.cStencilBits = 8;
pfd.iLayerType = PFD_MAIN_PLANE;
if ((pf = ChoosePixelFormat (stage_win32->client_dc, &pfd)) == 0
|| !SetPixelFormat (stage_win32->client_dc, pf, &pfd))
pf = clutter_stage_win32_choose_pixel_format (stage_win32->client_dc, &pfd);
if (pf == 0 || !SetPixelFormat (stage_win32->client_dc, pf, &pfd))
{
g_critical ("Unable to find suitable GL pixel format");
goto fail;