[Piglit] [PATCH] Fix windows code path

Jose Fonseca jfonseca at vmware.com
Wed Nov 2 08:25:55 PDT 2011


Morgan,

I don't think this fixes any actual bug, as SetPixelFormat's ppfd argument is not used for anything,
per http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx

But I think this is a good code cleanup regardless.


Jose

----- Original Message -----
> Hi,
> It seems there is a mistake in the windows code path. Actually
> DrawingSurfaceConfig holds a pointer to a pfd but it is invalid (as
> we
> send a pointer to a stack object). There is also two invalid
> SetPixelFormat calls. This patch fixes it.
> 
> ---
>  tests/glean/dsconfig.cpp |   42
>  +++++++++++++++++++++---------------------
>  tests/glean/dsconfig.h   |    2 +-
>  tests/glean/dsurf.cpp    |    3 +--
>  tests/glean/rc.cpp       |    4 +---
>  4 files changed, 24 insertions(+), 27 deletions(-)
> 
> diff --git a/tests/glean/dsconfig.cpp b/tests/glean/dsconfig.cpp
> index 9a4336c..69b549d 100644
> --- a/tests/glean/dsconfig.cpp
> +++ b/tests/glean/dsconfig.cpp
> @@ -367,48 +367,48 @@ DrawingSurfaceConfig::DrawingSurfaceConfig(int
> id,
> ::PIXELFORMATDESCRIPTOR *ppfd
>      if (!mapsInitialized)
>          initializeMaps();
> 
> -    pfd = ppfd;
> +    pfd = *ppfd;
>      pfdID = id;
> 
> -    canRGBA = pfd->iPixelType == PFD_TYPE_RGBA;
> -    canCI = pfd->iPixelType == PFD_TYPE_COLORINDEX;
> +    canRGBA = pfd.iPixelType == PFD_TYPE_RGBA;
> +    canCI = pfd.iPixelType == PFD_TYPE_COLORINDEX;
> 
> -    bufSize = pfd->cColorBits + pfd->cAlphaBits;
> +    bufSize = pfd.cColorBits + pfd.cAlphaBits;
> 
>      level = 0;
> 
> -    db = pfd->dwFlags & PFD_DOUBLEBUFFER;
> +    db = pfd.dwFlags & PFD_DOUBLEBUFFER;
> 
> -    stereo = pfd->dwFlags & PFD_STEREO;
> +    stereo = pfd.dwFlags & PFD_STEREO;
> 
> -    aux = pfd->cAuxBuffers;
> +    aux = pfd.cAuxBuffers;
> 
>      if (canRGBA)    {
> -        r = pfd->cRedBits;
> -        g = pfd->cGreenBits;
> -        b = pfd->cBlueBits;
> -        a = pfd->cAlphaBits;
> +        r = pfd.cRedBits;
> +        g = pfd.cGreenBits;
> +        b = pfd.cBlueBits;
> +        a = pfd.cAlphaBits;
>      }
>      else
>          r = g = b = a = 0;
> 
> -    z = pfd->cDepthBits;
> -    s = pfd->cStencilBits;
> +    z = pfd.cDepthBits;
> +    s = pfd.cStencilBits;
> 
> -    accR = pfd->cAccumRedBits;
> -    accG = pfd->cAccumGreenBits;
> -    accB = pfd->cAccumBlueBits;
> -    accA = pfd->cAccumAlphaBits;
> +    accR = pfd.cAccumRedBits;
> +    accG = pfd.cAccumGreenBits;
> +    accB = pfd.cAccumBlueBits;
> +    accA = pfd.cAccumAlphaBits;
> 
>      samples = 0; // XXX implement properly for Windows!
> 
> -    canWindow = pfd->dwFlags & PFD_DRAW_TO_WINDOW;
> +    canWindow = pfd.dwFlags & PFD_DRAW_TO_WINDOW;
> 
> -    canWinSysRender = pfd->dwFlags & PFD_SUPPORT_GDI;
> +    canWinSysRender = pfd.dwFlags & PFD_SUPPORT_GDI;
> 
> -    if (pfd->dwFlags & PFD_GENERIC_FORMAT)
> +    if (pfd.dwFlags & PFD_GENERIC_FORMAT)
>      {
> -        if (pfd->dwFlags & PFD_GENERIC_ACCELERATED)
> +        if (pfd.dwFlags & PFD_GENERIC_ACCELERATED)
>          {
>              // it's an MCD - at least it has some acceleration
>              fast = true;
> diff --git a/tests/glean/dsconfig.h b/tests/glean/dsconfig.h
> index 3827662..8df2abc 100644
> --- a/tests/glean/dsconfig.h
> +++ b/tests/glean/dsconfig.h
> @@ -93,7 +93,7 @@ class DrawingSurfaceConfig {
>      ::XID fbcID;            // Framebuffer Config ID.
>  #     endif
>  #   elif defined(__WIN__)
> -    ::PIXELFORMATDESCRIPTOR *pfd;
> +    ::PIXELFORMATDESCRIPTOR pfd;
>      int pfdID;
>  #   elif defined(__AGL__)
>      AGLPixelFormat    pf;
> diff --git a/tests/glean/dsurf.cpp b/tests/glean/dsurf.cpp
> index 2a3bea1..4e4cfd7 100644
> --- a/tests/glean/dsurf.cpp
> +++ b/tests/glean/dsurf.cpp
> @@ -155,8 +155,7 @@ legacyMethod:
> 
>      hDC = GetDC(hWindow);
> 
> -    PIXELFORMATDESCRIPTOR pfd;
> -    SetPixelFormat(hDC,config->pfdID,&pfd);
> +    SetPixelFormat(hDC,config->pfdID,&config->pfd);
> 
>  #elif defined(__BEWIN__)
> 
> diff --git a/tests/glean/rc.cpp b/tests/glean/rc.cpp
> index 8cc95b3..e432d99 100644
> --- a/tests/glean/rc.cpp
> +++ b/tests/glean/rc.cpp
> @@ -66,9 +66,7 @@ HGLRC create_context(GLEAN::DrawingSurfaceConfig
> &c)
>      if (!hDC)
>          return 0;
> 
> -    PIXELFORMATDESCRIPTOR pfd;
> -
> -    if (!SetPixelFormat(hDC,c.pfdID,&pfd))
> +    if (!SetPixelFormat(hDC,c.pfdID,&c.pfd))
>      {
>          ReleaseDC(hwnd,hDC);
>          DestroyWindow(hwnd);
> --
> 1.7.7.1.msysgit.0
> 
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
> 


More information about the Piglit mailing list