mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-30 21:21:39 +02:00
svga: remove pixelformat helpers from stw shared interface
Keep these internal structs private to wgl/shared. Pull in some pixelformat choosing code from wgl/wgl to avoid exporting them more generally.
This commit is contained in:
parent
66059cd3c9
commit
906230d16e
7 changed files with 108 additions and 149 deletions
|
|
@ -24,7 +24,6 @@ if env['platform'] in ['windows']:
|
|||
'icd/stw_icd.c',
|
||||
|
||||
'wgl/stw_wgl.c',
|
||||
'wgl/stw_wgl_pixelformat.c',
|
||||
|
||||
'shared/stw_context.c',
|
||||
'shared/stw_device.c',
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
#include "shared/stw_public.h"
|
||||
#include "icd/stw_icd.h"
|
||||
#include "wgl/stw_wgl.h"
|
||||
#include "stw.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@
|
|||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "shared/stw_public.h"
|
||||
#include "stw_public.h"
|
||||
#include "stw_pixelformat.h"
|
||||
#include "stw_arbpixelformat.h"
|
||||
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "pipe/p_debug.h"
|
||||
#include "stw_pixelformat.h"
|
||||
#include "stw_public.h"
|
||||
|
||||
#define MAX_PIXELFORMATS 16
|
||||
|
||||
|
|
@ -178,6 +179,58 @@ stw_pixelformat_describe(
|
|||
return count;
|
||||
}
|
||||
|
||||
/* Only used by the wgl code, but have it here to avoid exporting the
|
||||
* pixelformat.h functionality.
|
||||
*/
|
||||
int stw_pixelformat_choose( HDC hdc,
|
||||
CONST PIXELFORMATDESCRIPTOR *ppfd )
|
||||
{
|
||||
uint count;
|
||||
uint index;
|
||||
uint bestindex;
|
||||
uint bestdelta;
|
||||
|
||||
(void) hdc;
|
||||
|
||||
count = pixelformat_get_count();
|
||||
bestindex = count;
|
||||
bestdelta = 0xffffffff;
|
||||
|
||||
for (index = 0; index < count; index++) {
|
||||
uint delta = 0;
|
||||
const struct pixelformat_info *pf = pixelformat_get_info( index );
|
||||
|
||||
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
|
||||
!!(ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
|
||||
!!(pf->flags & PF_FLAG_DOUBLEBUFFER))
|
||||
continue;
|
||||
|
||||
if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits)
|
||||
delta += 8;
|
||||
|
||||
if (ppfd->cDepthBits != pf->depth.depthbits)
|
||||
delta += 4;
|
||||
|
||||
if (ppfd->cStencilBits != pf->depth.stencilbits)
|
||||
delta += 2;
|
||||
|
||||
if (ppfd->cAlphaBits != pf->alpha.alphabits)
|
||||
delta++;
|
||||
|
||||
if (delta < bestdelta) {
|
||||
bestindex = index;
|
||||
bestdelta = delta;
|
||||
if (bestdelta == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestindex == count)
|
||||
return 0;
|
||||
|
||||
return bestindex + 1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
stw_pixelformat_get(
|
||||
|
|
|
|||
|
|
@ -76,23 +76,6 @@ pixelformat_get_extended_count( void );
|
|||
const struct pixelformat_info *
|
||||
pixelformat_get_info( uint index );
|
||||
|
||||
|
||||
int
|
||||
stw_pixelformat_describe(
|
||||
HDC hdc,
|
||||
int iPixelFormat,
|
||||
UINT nBytes,
|
||||
LPPIXELFORMATDESCRIPTOR ppfd );
|
||||
|
||||
int
|
||||
stw_pixelformat_get(
|
||||
HDC hdc );
|
||||
|
||||
BOOL
|
||||
stw_pixelformat_set(
|
||||
HDC hdc,
|
||||
int iPixelFormat );
|
||||
|
||||
int stw_query_sample_buffers( void );
|
||||
int stw_query_samples( void );
|
||||
|
||||
|
|
|
|||
|
|
@ -123,6 +123,59 @@ wglGetProcAddress(
|
|||
}
|
||||
|
||||
|
||||
WINGDIAPI int APIENTRY
|
||||
wglChoosePixelFormat(
|
||||
HDC hdc,
|
||||
CONST PIXELFORMATDESCRIPTOR *ppfd )
|
||||
{
|
||||
if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
|
||||
return 0;
|
||||
if (ppfd->iPixelType != PFD_TYPE_RGBA)
|
||||
return 0;
|
||||
if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
|
||||
return 0;
|
||||
if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
|
||||
return 0;
|
||||
if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
|
||||
return 0;
|
||||
if (ppfd->dwFlags & PFD_SUPPORT_GDI)
|
||||
return 0;
|
||||
if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
|
||||
return 0;
|
||||
|
||||
return stw_pixelformat_choose( hdc, ppfd );
|
||||
}
|
||||
|
||||
WINGDIAPI int APIENTRY
|
||||
wglDescribePixelFormat(
|
||||
HDC hdc,
|
||||
int iPixelFormat,
|
||||
UINT nBytes,
|
||||
LPPIXELFORMATDESCRIPTOR ppfd )
|
||||
{
|
||||
return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd );
|
||||
}
|
||||
|
||||
WINGDIAPI int APIENTRY
|
||||
wglGetPixelFormat(
|
||||
HDC hdc )
|
||||
{
|
||||
return stw_pixelformat_get( hdc );
|
||||
}
|
||||
|
||||
WINGDIAPI BOOL APIENTRY
|
||||
wglSetPixelFormat(
|
||||
HDC hdc,
|
||||
int iPixelFormat,
|
||||
const PIXELFORMATDESCRIPTOR *ppfd )
|
||||
{
|
||||
if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
|
||||
return FALSE;
|
||||
|
||||
return stw_pixelformat_set( hdc, iPixelFormat );
|
||||
}
|
||||
|
||||
|
||||
WINGDIAPI BOOL APIENTRY
|
||||
wglUseFontBitmapsA(
|
||||
HDC hdc,
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_debug.h"
|
||||
#include "shared/stw_public.h"
|
||||
#include "stw_wgl.h"
|
||||
|
||||
WINGDIAPI int APIENTRY
|
||||
wglChoosePixelFormat(
|
||||
HDC hdc,
|
||||
CONST PIXELFORMATDESCRIPTOR *ppfd )
|
||||
{
|
||||
uint count;
|
||||
uint index;
|
||||
uint bestindex;
|
||||
uint bestdelta;
|
||||
|
||||
(void) hdc;
|
||||
|
||||
count = pixelformat_get_count();
|
||||
bestindex = count;
|
||||
bestdelta = 0xffffffff;
|
||||
|
||||
if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
|
||||
return 0;
|
||||
if (ppfd->iPixelType != PFD_TYPE_RGBA)
|
||||
return 0;
|
||||
if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
|
||||
return 0;
|
||||
if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
|
||||
return 0;
|
||||
if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
|
||||
return 0;
|
||||
if (ppfd->dwFlags & PFD_SUPPORT_GDI)
|
||||
return 0;
|
||||
if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
|
||||
return 0;
|
||||
|
||||
for (index = 0; index < count; index++) {
|
||||
uint delta = 0;
|
||||
const struct pixelformat_info *pf = pixelformat_get_info( index );
|
||||
|
||||
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE)) {
|
||||
if ((ppfd->dwFlags & PFD_DOUBLEBUFFER) && !(pf->flags & PF_FLAG_DOUBLEBUFFER))
|
||||
continue;
|
||||
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER) && (pf->flags & PF_FLAG_DOUBLEBUFFER))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits)
|
||||
delta += 8;
|
||||
|
||||
if (ppfd->cDepthBits != pf->depth.depthbits)
|
||||
delta += 4;
|
||||
|
||||
if (ppfd->cStencilBits != pf->depth.stencilbits)
|
||||
delta += 2;
|
||||
|
||||
if (ppfd->cAlphaBits != pf->alpha.alphabits)
|
||||
delta++;
|
||||
|
||||
if (delta < bestdelta) {
|
||||
bestindex = index;
|
||||
bestdelta = delta;
|
||||
if (bestdelta == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestindex == count)
|
||||
return 0;
|
||||
return bestindex + 1;
|
||||
}
|
||||
|
||||
WINGDIAPI int APIENTRY
|
||||
wglDescribePixelFormat(
|
||||
HDC hdc,
|
||||
int iPixelFormat,
|
||||
UINT nBytes,
|
||||
LPPIXELFORMATDESCRIPTOR ppfd )
|
||||
{
|
||||
return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd );
|
||||
}
|
||||
|
||||
WINGDIAPI int APIENTRY
|
||||
wglGetPixelFormat(
|
||||
HDC hdc )
|
||||
{
|
||||
return stw_pixelformat_get( hdc );
|
||||
}
|
||||
|
||||
WINGDIAPI BOOL APIENTRY
|
||||
wglSetPixelFormat(
|
||||
HDC hdc,
|
||||
int iPixelFormat,
|
||||
const PIXELFORMATDESCRIPTOR *ppfd )
|
||||
{
|
||||
if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
|
||||
return FALSE;
|
||||
|
||||
return stw_pixelformat_set( hdc, iPixelFormat );
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue