ReactOS  0.4.13-dev-455-g28ed234
swimpl.c File Reference
#include "opengl32.h"
#include <context.h>
#include <matrix.h>
#include "glfuncs.h"
Include dependency graph for swimpl.c:

Go to the source code of this file.

Classes

struct  pixel_format
 
struct  sw_framebuffer
 
struct  sw_context
 

Macros

#define WIDTH_BYTES_ALIGN32(cx, bpp)   ((((cx) * (bpp) + 31) & ~31) >> 3)
 
#define WIDTH_BYTES_ALIGN16(cx, bpp)   ((((cx) * (bpp) + 15) & ~15) >> 3)
 
#define SB_FLAGS   (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT)
 
#define SB_FLAGS_WINDOW   (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT)
 
#define SB_FLAGS_PALETTE   (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT | PFD_NEED_PALETTE)
 
#define DB_FLAGS   (PFD_DOUBLEBUFFER | PFD_SWAP_COPY | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT)
 
#define DB_FLAGS_PALETTE   (PFD_DOUBLEBUFFER | PFD_SWAP_COPY | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_FORMAT | PFD_NEED_PALETTE)
 
#define HANDLE_BPP(__x__)
 
#define CLEAR_INDEX(__bpp, __type)
 
#define CLEAR_COLOR(__bpp)
 
#define CLEAR(__bpp, __type, __pixel_size)
 
#define SET_INDEX(__bpp)
 
#define SET_COLOR(__bpp)
 
#define WRITE_COLOR_SPAN_FRONTBUFFER(__bpp)
 
#define WRITE_COLOR_SPAN(__bpp, __type, __pixel_size)
 
#define WRITE_MONOCOLOR_SPAN(__bpp, __type, __pixel_size)
 
#define WRITE_COLOR_PIXELS(__bpp, __type, __pixel_size)
 
#define WRITE_MONOCOLOR_PIXELS(__bpp, __type, __pixel_size)
 
#define READ_COLOR_SPAN(__bpp, __type, __pixel_size)
 
#define READ_COLOR_PIXELS(__bpp, __type, __pixel_size)
 
#define HANDLE_BPP(__bpp)
 
#define USE_GL_FUNC(name, proto_args, call_args, offset, stack)   extern void WINAPI _mesa_##name proto_args ;
 
#define USE_GL_FUNC_RET(name, ret_type, proto_args, call_args, offset, stack)   extern ret_type WINAPI _mesa_##name proto_args ;
 
#define USE_GL_FUNC(name, proto_args, call_args, offset, stack)   _mesa_##name,
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (opengl32)
 
static const struct pixel_formatget_format (INT pf_index, INT *pf_count)
 
INT sw_DescribePixelFormat (HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr)
 
BOOL sw_SetPixelFormat (HDC hdc, struct wgl_dc_data *dc_data, INT format)
 
DHGLRC sw_CreateContext (struct wgl_dc_data *dc_data)
 
BOOL sw_DeleteContext (DHGLRC dhglrc)
 
void APIENTRY _mesa_ColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const void *)
 
void APIENTRY _mesa_ColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const void *)
 
void APIENTRY _mesa_GetColorTableEXT (GLenum, GLenum, GLenum, void *)
 
void APIENTRY _mesa_GetColorTableParameterivEXT (GLenum, GLenum, GLfloat *)
 
void APIENTRY _mesa_GetColorTableParameterfvEXT (GLenum, GLenum, GLint *)
 
static void APIENTRY _swimpl_AddSwapHintRectWIN (GLint x, GLint y, GLsizei width, GLsizei height)
 
PROC sw_GetProcAddress (LPCSTR name)
 
BOOL sw_CopyContext (DHGLRC dhglrcSrc, DHGLRC dhglrcDst, UINT mask)
 
BOOL sw_ShareLists (DHGLRC dhglrcSrc, DHGLRC dhglrcDst)
 
static LRESULT CALLBACK sw_call_window_proc (int nCode, WPARAM wParam, LPARAM lParam)
 
static const charrenderer_string (void)
 
static void PUT_PIXEL_8 (BYTE *Buffer, BYTE Value)
 
static void PUT_PIXEL_16 (USHORT *Buffer, USHORT Value)
 
static void PUT_PIXEL_24 (ULONG *Buffer, ULONG Value)
 
static void PUT_PIXEL_32 (ULONG *Buffer, ULONG Value)
 
static BYTE GET_PIXEL_8 (BYTE *Buffer)
 
static USHORT GET_PIXEL_16 (USHORT *Buffer)
 
static ULONG GET_PIXEL_24 (ULONG *Buffer)
 
static ULONG GET_PIXEL_32 (ULONG *Buffer)
 
static COLORREF MAKE_COLORREF_8 (const struct pixel_format *format, BYTE Color)
 
static COLORREF MAKE_COLORREF_16 (const struct pixel_format *format, USHORT Color)
 
static COLORREF MAKE_COLORREF_24 (const struct pixel_format *format, ULONG Color)
 
static COLORREF MAKE_COLORREF_32 (const struct pixel_format *format, ULONG Color)
 
static BYTE PACK_COLOR_8 (GLubyte r, GLubyte g, GLubyte b)
 
static USHORT PACK_COLOR_16 (GLubyte r, GLubyte g, GLubyte b)
 
static ULONG PACK_COLOR_24 (GLubyte r, GLubyte g, GLubyte b)
 
static ULONG PACK_COLOR_32 (GLubyte r, GLubyte g, GLubyte b)
 
static COLORREF PACK_COLORREF_8 (GLubyte r, GLubyte g, GLubyte b)
 
static COLORREF PACK_COLORREF_16 (GLubyte r, GLubyte g, GLubyte b)
 
static COLORREF PACK_COLORREF_24 (GLubyte r, GLubyte g, GLubyte b)
 
static COLORREF PACK_COLORREF_32 (GLubyte r, GLubyte g, GLubyte b)
 
static void UNPACK_COLOR_8 (BYTE Color, GLubyte *r, GLubyte *g, GLubyte *b)
 
static void UNPACK_COLOR_16 (USHORT Color, GLubyte *r, GLubyte *g, GLubyte *b)
 
static void UNPACK_COLOR_24 (ULONG Color, GLubyte *r, GLubyte *g, GLubyte *b)
 
static void UNPACK_COLOR_32 (ULONG Color, GLubyte *r, GLubyte *g, GLubyte *b)
 
static void UNPACK_COLORREF_8 (COLORREF Color, GLubyte *r, GLubyte *g, GLubyte *b)
 
static void UNPACK_COLORREF_16 (COLORREF Color, GLubyte *r, GLubyte *g, GLubyte *b)
 
static void UNPACK_COLORREF_24 (COLORREF Color, GLubyte *r, GLubyte *g, GLubyte *b)
 
static void UNPACK_COLORREF_32 (COLORREF Color, GLubyte *r, GLubyte *g, GLubyte *b)
 
static void clear_frontbuffer (struct sw_context *sw_ctx, struct sw_framebuffer *fb, GLint x, GLint y, GLint width, GLint height, COLORREF ClearColor)
 
static GLboolean set_buffer (GLcontext *ctx, GLenum mode)
 
static void buffer_size (GLcontext *ctx, GLuint *width, GLuint *height)
 
static void write_monocolor_span_frontbuffer (struct sw_framebuffer *fb, GLuint n, GLint x, GLint y, const GLubyte mask[], COLORREF Color)
 
static void write_monocolor_pixels_frontbuffer (struct sw_framebuffer *fb, GLuint n, const GLint x[], const GLint y[], const GLubyte mask[], COLORREF Color)
 
static void write_index_span (GLcontext *ctx, GLuint n, GLint x, GLint y, const GLuint index[], const GLubyte mask[])
 
static void write_index_pixels (GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLuint index[], const GLubyte mask[])
 
static void read_index_span (GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint index[])
 
static void read_index_pixels (GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLuint index[], const GLubyte mask[])
 
static void setup_DD_pointers (GLcontext *ctx)
 
GLcontextgl_get_thread_context (void)
 
BOOL sw_SetContext (struct wgl_dc_data *dc_data, DHGLRC dhglrc)
 
void sw_ReleaseContext (DHGLRC dhglrc)
 
BOOL sw_SwapBuffers (HDC hdc, struct wgl_dc_data *dc_data)
 

Variables

static const struct pixel_format pixel_formats_32 []
 
static const struct pixel_format pixel_formats_24 []
 
static const struct pixel_format pixel_formats_16 []
 
static const struct pixel_format pixel_formats_8 []
 
static GLCLTPROCTABLE sw_api_table
 

Macro Definition Documentation

◆ CLEAR

#define CLEAR (   __bpp,
  __type,
  __pixel_size 
)

Definition at line 837 of file swimpl.c.

◆ CLEAR_COLOR

#define CLEAR_COLOR (   __bpp)
Value:
static void clear_color_##__bpp( GLcontext* ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a ) \
{ \
struct sw_context* sw_ctx = ctx->DriverCtx; \
\
sw_ctx->u##__bpp.ClearColor = PACK_COLOR_##__bpp(r, g, b); \
TRACE("Set Clear color %u, %u, %u.\n", r, g, b); \
}
unsigned char GLubyte
Definition: gl.h:157
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
BYTE ClearColor
Definition: swimpl.c:251

Definition at line 791 of file swimpl.c.

◆ CLEAR_INDEX

#define CLEAR_INDEX (   __bpp,
  __type 
)
Value:
static void clear_index_##__bpp(GLcontext* ctx, GLuint index) \
{ \
struct sw_context* sw_ctx = ctx->DriverCtx; \
\
sw_ctx->u##__bpp.ClearColor = (__type)index; \
}
GLuint index
Definition: glext.h:6031
unsigned int GLuint
Definition: gl.h:159
BYTE ClearColor
Definition: swimpl.c:251

Definition at line 775 of file swimpl.c.

◆ DB_FLAGS

◆ DB_FLAGS_PALETTE

◆ HANDLE_BPP [1/2]

#define HANDLE_BPP (   __x__)
Value:
case __x__: \
nb_format = ARRAYSIZE(pixel_formats_##__x__); \
if ((pf_index > nb_format) || (pf_index <= 0)) \
ret = NULL; \
else \
ret = &pixel_formats_##__x__[pf_index - 1]; \
break
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
smooth NULL
Definition: ftsmooth.c:416

◆ HANDLE_BPP [2/2]

#define HANDLE_BPP (   __bpp)
Value:
case __bpp: \
ctx->Driver.ClearIndex = clear_index_##__bpp; \
ctx->Driver.ClearColor = clear_color_##__bpp; \
ctx->Driver.Clear = clear_##__bpp; \
ctx->Driver.Index = set_index_##__bpp; \
ctx->Driver.Color = set_color_##__bpp; \
ctx->Driver.WriteColorSpan = write_color_span_##__bpp; \
ctx->Driver.WriteMonocolorSpan = write_monocolor_span_##__bpp; \
ctx->Driver.WriteMonoindexSpan = write_monocolor_span_##__bpp; \
ctx->Driver.WriteColorPixels = write_color_pixels_##__bpp; \
ctx->Driver.WriteMonocolorPixels = write_monocolor_pixels_##__bpp; \
ctx->Driver.WriteMonoindexPixels = write_monocolor_pixels_##__bpp; \
ctx->Driver.ReadColorSpan = read_color_span_##__bpp; \
ctx->Driver.ReadColorPixels = read_color_pixels_##__bpp; \
break

◆ READ_COLOR_PIXELS

#define READ_COLOR_PIXELS (   __bpp,
  __type,
  __pixel_size 
)

Definition at line 1303 of file swimpl.c.

◆ READ_COLOR_SPAN

#define READ_COLOR_SPAN (   __bpp,
  __type,
  __pixel_size 
)

Definition at line 1254 of file swimpl.c.

◆ SB_FLAGS

Definition at line 20 of file swimpl.c.

◆ SB_FLAGS_PALETTE

◆ SB_FLAGS_WINDOW

Definition at line 21 of file swimpl.c.

◆ SET_COLOR

#define SET_COLOR (   __bpp)
Value:
static void set_color_##__bpp( GLcontext* ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a ) \
{ \
struct sw_context* sw_ctx = ctx->DriverCtx; \
\
sw_ctx->u##__bpp.CurrentColor = PACK_COLOR_##__bpp(r, g, b); \
}
unsigned char GLubyte
Definition: gl.h:157
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
BYTE CurrentColor
Definition: swimpl.c:252
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Definition at line 894 of file swimpl.c.

◆ SET_INDEX

#define SET_INDEX (   __bpp)
Value:
static void set_index_##__bpp(GLcontext* ctx, GLuint index) \
{ \
struct sw_context* sw_ctx = ctx->DriverCtx; \
\
sw_ctx->u##__bpp.CurrentColor = index; \
}
GLuint index
Definition: glext.h:6031
#define index(s, c)
Definition: various.h:29
unsigned int GLuint
Definition: gl.h:159
BYTE CurrentColor
Definition: swimpl.c:252

Definition at line 880 of file swimpl.c.

◆ USE_GL_FUNC [1/2]

#define USE_GL_FUNC (   name,
  proto_args,
  call_args,
  offset,
  stack 
)    extern void WINAPI _mesa_##name proto_args ;

Definition at line 1408 of file swimpl.c.

◆ USE_GL_FUNC [2/2]

#define USE_GL_FUNC (   name,
  proto_args,
  call_args,
  offset,
  stack 
)    _mesa_##name,

Definition at line 1408 of file swimpl.c.

◆ USE_GL_FUNC_RET

#define USE_GL_FUNC_RET (   name,
  ret_type,
  proto_args,
  call_args,
  offset,
  stack 
)    extern ret_type WINAPI _mesa_##name proto_args ;

Definition at line 1409 of file swimpl.c.

◆ WIDTH_BYTES_ALIGN16

#define WIDTH_BYTES_ALIGN16 (   cx,
  bpp 
)    ((((cx) * (bpp) + 15) & ~15) >> 3)

Definition at line 17 of file swimpl.c.

◆ WIDTH_BYTES_ALIGN32

#define WIDTH_BYTES_ALIGN32 (   cx,
  bpp 
)    ((((cx) * (bpp) + 31) & ~31) >> 3)

Definition at line 16 of file swimpl.c.

◆ WRITE_COLOR_PIXELS

#define WRITE_COLOR_PIXELS (   __bpp,
  __type,
  __pixel_size 
)

Definition at line 1134 of file swimpl.c.

◆ WRITE_COLOR_SPAN

#define WRITE_COLOR_SPAN (   __bpp,
  __type,
  __pixel_size 
)

Definition at line 1020 of file swimpl.c.

◆ WRITE_COLOR_SPAN_FRONTBUFFER

#define WRITE_COLOR_SPAN_FRONTBUFFER (   __bpp)
Value:
static void write_color_span_frontbuffer_##__bpp(struct sw_framebuffer* fb, \
const GLubyte red[], const GLubyte green[], \
const GLubyte blue[], const GLubyte mask[] ) \
{ \
TRACE("Writing color span at %u, %u (%u)\n", x, y, n); \
if (mask) \
{ \
while (n--) \
{ \
if (mask[n]) \
{ \
SetPixel(fb->Hdc, x + n, fb->height - y, \
PACK_COLORREF_##__bpp(red[n], green[n], blue[n])); \
} \
} \
} \
else \
{ \
while (n--) \
{ \
SetPixel(fb->Hdc, x + n, fb->height - y, \
PACK_COLORREF_##__bpp(red[n], green[n], blue[n])); \
} \
} \
}
unsigned char GLubyte
Definition: gl.h:157
GLdouble n
Definition: glext.h:7729
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLenum GLint GLuint mask
Definition: glext.h:6028
GLclampf GLclampf blue
Definition: gl.h:1740
if(!(yy_init))
Definition: macro.lex.yy.c:714
GLclampf green
Definition: gl.h:1740
#define red
Definition: linetest.c:67
unsigned int GLuint
Definition: gl.h:159
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
int GLint
Definition: gl.h:156

Definition at line 986 of file swimpl.c.

◆ WRITE_MONOCOLOR_PIXELS

#define WRITE_MONOCOLOR_PIXELS (   __bpp,
  __type,
  __pixel_size 
)
Value:
static void write_monocolor_pixels_##__bpp(GLcontext* ctx, GLuint n, \
const GLint x[], const GLint y[], \
const GLubyte mask[] ) \
{ \
struct sw_context* sw_ctx = ctx->DriverCtx; \
struct sw_framebuffer* fb = sw_ctx->fb; \
if (sw_ctx->Mode == GL_FRONT) \
{ \
write_monocolor_pixels_frontbuffer(fb, n, x, y, mask, \
MAKE_COLORREF_##__bpp(fb->pixel_format, sw_ctx->u##__bpp.CurrentColor)); \
\
return; \
} \
while (n--) \
{ \
if (mask[n]) \
{ \
BYTE* Buffer = fb->BackBuffer + y[n] * WIDTH_BYTES_ALIGN32(fb->width, 32) \
+ x[n] * __pixel_size; \
PUT_PIXEL_##__bpp((__type*)Buffer, sw_ctx->u##__bpp.CurrentColor); \
} \
} \
}
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
unsigned char GLubyte
Definition: gl.h:157
GLdouble n
Definition: glext.h:7729
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
while(1)
Definition: macro.lex.yy.c:740
GLenum GLint GLuint mask
Definition: glext.h:6028
#define GL_FRONT
Definition: gl.h:270
Definition: bufpool.h:45
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned int GLuint
Definition: gl.h:159
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
int GLint
Definition: gl.h:156

Definition at line 1198 of file swimpl.c.

◆ WRITE_MONOCOLOR_SPAN

#define WRITE_MONOCOLOR_SPAN (   __bpp,
  __type,
  __pixel_size 
)

Definition at line 1092 of file swimpl.c.

Function Documentation

◆ _mesa_ColorSubTableEXT()

void APIENTRY _mesa_ColorSubTableEXT ( GLenum  ,
GLsizei  ,
GLsizei  ,
GLenum  ,
GLenum  ,
const void  
)

Definition at line 2839 of file api.c.

2842 {
2843  struct gl_image *image;
2844  GET_CONTEXT;
2846  (*CC->API.ColorSubTable)( CC, target, start, image );
2847  if (image->RefCount == 0)
2849 }
#define GET_CONTEXT
Definition: api.h:64
GLeglImageOES image
Definition: gl.h:2204
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
void gl_free_image(struct gl_image *image)
Definition: image.c:661
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
struct gl_image * gl_unpack_image(GLcontext *ctx, GLint width, GLint height, GLenum srcFormat, GLenum srcType, const GLvoid *pixels)
Definition: image.c:314
struct gl_api_table API
Definition: types.h:1268
GLuint start
Definition: gl.h:1545
GLenum target
Definition: glext.h:7315
GLcontext * CC

Referenced by sw_GetProcAddress().

◆ _mesa_ColorTableEXT()

void APIENTRY _mesa_ColorTableEXT ( GLenum  ,
GLenum  ,
GLsizei  ,
GLenum  ,
GLenum  ,
const void  
)

Definition at line 2826 of file api.c.

2829 {
2830  struct gl_image *image;
2831  GET_CONTEXT;
2833  (*CC->API.ColorTable)( CC, target, internalFormat, image );
2834  if (image->RefCount == 0)
2836 }
#define GET_CONTEXT
Definition: api.h:64
GLeglImageOES image
Definition: gl.h:2204
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
void gl_free_image(struct gl_image *image)
Definition: image.c:661
GLenum internalFormat
Definition: glext.h:8404
struct gl_image * gl_unpack_image(GLcontext *ctx, GLint width, GLint height, GLenum srcFormat, GLenum srcType, const GLvoid *pixels)
Definition: image.c:314
struct gl_api_table API
Definition: types.h:1268
GLenum target
Definition: glext.h:7315
GLcontext * CC

Referenced by sw_GetProcAddress().

◆ _mesa_GetColorTableEXT()

void APIENTRY _mesa_GetColorTableEXT ( GLenum  ,
GLenum  ,
GLenum  ,
void  
)

Definition at line 2851 of file api.c.

2853 {
2854  GET_CONTEXT;
2855  (*CC->API.GetColorTable)(CC, target, format, type, table);
2856 }
#define GET_CONTEXT
Definition: api.h:64
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
struct gl_api_table API
Definition: types.h:1268
GLenum target
Definition: glext.h:7315
GLcontext * CC

Referenced by sw_GetProcAddress().

◆ _mesa_GetColorTableParameterfvEXT()

void APIENTRY _mesa_GetColorTableParameterfvEXT ( GLenum  ,
GLenum  ,
GLint  
)

Referenced by sw_GetProcAddress().

◆ _mesa_GetColorTableParameterivEXT()

void APIENTRY _mesa_GetColorTableParameterivEXT ( GLenum  ,
GLenum  ,
GLfloat  
)

Referenced by sw_GetProcAddress().

◆ _swimpl_AddSwapHintRectWIN()

static void APIENTRY _swimpl_AddSwapHintRectWIN ( GLint  x,
GLint  y,
GLsizei  width,
GLsizei  height 
)
static

Definition at line 473 of file swimpl.c.

474 {
476 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by sw_GetProcAddress().

◆ buffer_size()

static void buffer_size ( GLcontext ctx,
GLuint width,
GLuint height 
)
static

Definition at line 927 of file swimpl.c.

928 {
929  struct sw_context* sw_ctx = ctx->DriverCtx;
930  struct sw_framebuffer* fb = sw_ctx->fb;
931  HWND Window = WindowFromDC(fb->Hdc);
932 
933  if (Window)
934  {
935  RECT client_rect;
936  GetClientRect(Window, &client_rect);
937  *width = client_rect.right - client_rect.left;
938  *height = client_rect.bottom - client_rect.top;
939  }
940  else
941  {
942  /* We are drawing to a bitmap */
943  BITMAP bm;
944  HBITMAP Hbm;
945 
946  Hbm = GetCurrentObject(fb->Hdc, OBJ_BITMAP);
947 
948  if (!GetObjectW(Hbm, sizeof(bm), &bm))
949  return;
950 
951  TRACE("Framebuffer size : %i, %i\n", bm.bmWidth, bm.bmHeight);
952 
953  *width = bm.bmWidth;
954  *height = bm.bmHeight;
955  }
956 
957  if ((*width != fb->width) || (*height != fb->height))
958  {
959  const struct pixel_format* pixel_format = fb->pixel_format;
960 
962  {
963  /* Allocate a new backbuffer */
965  if (!fb->BackBuffer)
966  {
968  }
969  else
970  {
972  }
973  if (!fb->BackBuffer)
974  {
975  ERR("Failed allocating back buffer !.\n");
976  return;
977  }
978  }
979 
980  fb->width = *width;
981  fb->height = *height;
982  }
983 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
BYTE cColorBits
Definition: swimpl.c:31
GLuint width
Definition: swimpl.c:230
BYTE * BackBuffer
Definition: swimpl.c:233
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
struct sw_framebuffer * fb
Definition: swimpl.c:244
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:300
Definition: window.c:29
DWORD dwFlags
Definition: swimpl.c:29
HWND WINAPI WindowFromDC(_In_ HDC hDC)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define BufferSize
Definition: classpnp.h:419
void * DriverCtx
Definition: types.h:1278
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
const struct pixel_format * pixel_format
Definition: swimpl.c:226
#define ERR(fmt,...)
Definition: debug.h:109
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
Definition: bl.h:1331
#define HeapReAlloc
Definition: compat.h:393
GLuint height
Definition: swimpl.c:230
LONG bottom
Definition: windef.h:294
static HBITMAP
Definition: button.c:44
#define OBJ_BITMAP
Definition: objidl.idl:1415
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439

Referenced by __ConvertToCP(), deque< IncompleteClass >::_M_fill_initialize(), _Deque_base< String, _Alloc >::_M_initialize_map(), deque< IncompleteClass >::_M_new_elements_at_back(), deque< IncompleteClass >::_M_new_elements_at_front(), BitmapClipper_CopyPixels(), BitmapScaler_CopyPixels(), checkConvertedFrameAndBounds(), deque< IncompleteClass >::clear(), CLRMetaHost_GetVersionFromFile(), CLRRuntimeInfo_GetRuntimeDirectory(), CLRRuntimeInfo_GetVersionString(), ComponentInfo_GetStringValue(), d3dx9_mesh_GenerateAdjacency(), D3DXLoadMeshFromXInMemory(), D3DXLoadSkinMeshFromXof(), EDIT_MakeFit(), generate_effects(), get_parameter_fc(), getConvertedFrameAndBounds(), GetDeviceData(), IAssemblyName_GetPath(), IWICPixelFormatInfo_GetChannelMask_Proxy_W(), ME_CallWordBreakProc(), METAFILE_GraphicsDeleted(), midi_IDirectMusicPort_GetFormat(), PrintAllAssociations(), ReadByte(), SearchCHM_File(), server_thread(), setup_DD_pointers(), SetupGetSourceFileLocationA(), SetupGetSourceFileLocationW(), SetupGetSourceInfoA(), SetupGetSourceInfoW(), SetupGetTargetPathA(), SetupGetTargetPathW(), sheet_callback(), START_TEST(), test_SetupDecompressOrCopyFile(), test_SetWinMetaFileBits(), validate_resource_view(), WNetUseConnectionA(), WNetUseConnectionW(), write_buffer_to_file(), and xmlStringLenDecodeEntities().

◆ clear_frontbuffer()

static void clear_frontbuffer ( struct sw_context sw_ctx,
struct sw_framebuffer fb,
GLint  x,
GLint  y,
GLint  width,
GLint  height,
COLORREF  ClearColor 
)
static

Definition at line 810 of file swimpl.c.

818 {
819  HBRUSH Brush;
820  BOOL ret;
821 
822  TRACE("Clearing front buffer (%u, %u, %u, %u), color 0x%08x.\n", x, y, width, height, ClearColor);
823 
824  Brush = CreateSolidBrush(ClearColor);
825  Brush = SelectObject(fb->Hdc, Brush);
826 
827  ret = PatBlt(fb->Hdc, x, fb->height - (y + height), width, height, PATCOPY);
828  if (!ret)
829  {
830  ERR("PatBlt failed. last Error %d.\n", GetLastError());
831  }
832 
833  Brush = SelectObject(fb->Hdc, Brush);
835 }
GLint GLint GLsizei width
Definition: gl.h:1546
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
unsigned int BOOL
Definition: ntddk_ex.h:94
void Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG style)
Definition: drawing.cpp:160
#define TRACE(s)
Definition: solgame.cpp:4
int ret
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define PATCOPY
Definition: wingdi.h:334
#define ERR(fmt,...)
Definition: debug.h:109
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint height
Definition: swimpl.c:230

◆ get_format()

static const struct pixel_format* get_format ( INT  pf_index,
INT pf_count 
)
static

Definition at line 274 of file swimpl.c.

275 {
276  HDC hdc;
277  INT bpp, nb_format;
278  const struct pixel_format* ret;
279 
280  hdc = GetDC(NULL);
282  ReleaseDC(NULL, hdc);
283 
284  switch (bpp)
285  {
286 #define HANDLE_BPP(__x__) \
287  case __x__: \
288  nb_format = ARRAYSIZE(pixel_formats_##__x__); \
289  if ((pf_index > nb_format) || (pf_index <= 0)) \
290  ret = NULL; \
291  else \
292  ret = &pixel_formats_##__x__[pf_index - 1]; \
293  break
294 
295  HANDLE_BPP(32);
296  HANDLE_BPP(24);
297  HANDLE_BPP(16);
298  HANDLE_BPP(8);
299 #undef HANDLE_BPP
300  default:
301  FIXME("Unhandled bit depth %u, defaulting to 32bpp\n", bpp);
302  nb_format = ARRAYSIZE(pixel_formats_32);
303  if ((pf_index > nb_format) || (pf_index == 0))
304  ret = NULL;
305  else
306  ret = &pixel_formats_32[pf_index - 1];
307  }
308 
309  if (pf_count)
310  *pf_count = nb_format;
311 
312  return ret;
313 }
#define BITSPIXEL
Definition: wingdi.h:719
#define HANDLE_BPP(__x__)
static const struct pixel_format pixel_formats_32[]
Definition: swimpl.c:41
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
int32_t INT
Definition: typedefs.h:56
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
int ret
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
DWORD bpp
Definition: surface.c:181

Referenced by sw_DescribePixelFormat(), and sw_SetPixelFormat().

◆ GET_PIXEL_16()

static USHORT GET_PIXEL_16 ( USHORT Buffer)
inlinestatic

Definition at line 604 of file swimpl.c.

605 {
606  return *Buffer;
607 }
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ GET_PIXEL_24()

static ULONG GET_PIXEL_24 ( ULONG Buffer)
inlinestatic

Definition at line 609 of file swimpl.c.

610 {
611  return *Buffer & 0x00FFFFFF;
612 }
Definition: bufpool.h:45

◆ GET_PIXEL_32()

static ULONG GET_PIXEL_32 ( ULONG Buffer)
inlinestatic

Definition at line 614 of file swimpl.c.

615 {
616  return *Buffer;
617 }
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ GET_PIXEL_8()

static BYTE GET_PIXEL_8 ( BYTE Buffer)
inlinestatic

Definition at line 599 of file swimpl.c.

600 {
601  return *Buffer;
602 }
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ gl_get_thread_context()

GLcontext* gl_get_thread_context ( void  )

Definition at line 1422 of file swimpl.c.

1423 {
1424  struct sw_context* sw_ctx = (struct sw_context*)IntGetCurrentDHGLRC();
1425  return sw_ctx->gl_ctx;
1426 }
GLcontext * gl_ctx
Definition: swimpl.c:238
FORCEINLINE DHGLRC IntGetCurrentDHGLRC(void)
Definition: opengl32.h:177

◆ MAKE_COLORREF_16()

static COLORREF MAKE_COLORREF_16 ( const struct pixel_format format,
USHORT  Color 
)
inlinestatic

Definition at line 633 of file swimpl.c.

634 {
635  BYTE R,G,B;
636 
637  if (format->iPixelType == PFD_TYPE_COLORINDEX)
638  return PALETTEINDEX(Color);
639 
640  R = (Color & 0x7) << 5;
641  G = (Color & 0x38) << 2;
642  B = Color & 0xC;
643 
644  return RGB(R, G, B);
645 }
#define R(b, x)
Definition: sha2.c:134
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define RGB(r, g, b)
Definition: wingdi.h:2918
unsigned char BYTE
Definition: mem.h:68
#define G(x, y, z)
Definition: md5.c:52
#define B(row, col)
#define PALETTEINDEX(i)
Definition: wingdi.h:2921

◆ MAKE_COLORREF_24()

static COLORREF MAKE_COLORREF_24 ( const struct pixel_format format,
ULONG  Color 
)
inlinestatic

Definition at line 647 of file swimpl.c.

648 {
649  BYTE R,G,B;
650 
651  if (format->iPixelType == PFD_TYPE_COLORINDEX)
652  return PALETTEINDEX(Color);
653 
654  R = (Color & 0xFF0000) >> 16;
655  G = (Color & 0x00FF00) >> 8;
656  B = Color & 0xFF;
657 
658  return RGB(R, G, B);
659 }
#define R(b, x)
Definition: sha2.c:134
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define RGB(r, g, b)
Definition: wingdi.h:2918
unsigned char BYTE
Definition: mem.h:68
#define G(x, y, z)
Definition: md5.c:52
#define B(row, col)
#define PALETTEINDEX(i)
Definition: wingdi.h:2921

◆ MAKE_COLORREF_32()

static COLORREF MAKE_COLORREF_32 ( const struct pixel_format format,
ULONG  Color 
)
inlinestatic

Definition at line 661 of file swimpl.c.

662 {
663  BYTE R,G,B;
664 
665  if (format->iPixelType == PFD_TYPE_COLORINDEX)
666  return PALETTEINDEX(Color);
667 
668  R = (Color & 0xFF0000) >> 16;
669  G = (Color & 0x00FF00) >> 8;
670  B = Color & 0xFF;
671 
672  return RGB(R, G, B);
673 }
#define R(b, x)
Definition: sha2.c:134
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define RGB(r, g, b)
Definition: wingdi.h:2918
unsigned char BYTE
Definition: mem.h:68
#define G(x, y, z)
Definition: md5.c:52
#define B(row, col)
#define PALETTEINDEX(i)
Definition: wingdi.h:2921

◆ MAKE_COLORREF_8()

static COLORREF MAKE_COLORREF_8 ( const struct pixel_format format,
BYTE  Color 
)
inlinestatic

Definition at line 619 of file swimpl.c.

620 {
621  BYTE R,G,B;
622 
623  if (format->iPixelType == PFD_TYPE_COLORINDEX)
624  return PALETTEINDEX(Color);
625 
626  R = (Color & 0x7) << 5;
627  G = (Color & 0x38) << 2;
628  B = Color & 0xC;
629 
630  return RGB(R, G, B);
631 }
#define R(b, x)
Definition: sha2.c:134
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define RGB(r, g, b)
Definition: wingdi.h:2918
unsigned char BYTE
Definition: mem.h:68
#define G(x, y, z)
Definition: md5.c:52
#define B(row, col)
#define PALETTEINDEX(i)
Definition: wingdi.h:2921

◆ PACK_COLOR_16()

static USHORT PACK_COLOR_16 ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)
inlinestatic

Definition at line 681 of file swimpl.c.

682 {
683  return ((r & 0x1F) << 11) | ((g & 0x3F) << 5) | (b & 0x1F);
684 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ PACK_COLOR_24()

static ULONG PACK_COLOR_24 ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)
inlinestatic

Definition at line 686 of file swimpl.c.

687 {
688  return (r << 16) | (g << 8) | (b);
689 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ PACK_COLOR_32()

static ULONG PACK_COLOR_32 ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)
inlinestatic

Definition at line 691 of file swimpl.c.

692 {
693  return (r << 16) | (g << 8) | (b);
694 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ PACK_COLOR_8()

static BYTE PACK_COLOR_8 ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)
inlinestatic

Definition at line 676 of file swimpl.c.

677 {
678  return (r & 0x7) | ((g & 0x7) << 3) | ((b & 0x3) << 6);
679 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ PACK_COLORREF_16()

static COLORREF PACK_COLORREF_16 ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)
inlinestatic

Definition at line 701 of file swimpl.c.

702 {
703  return RGB(r << 3, g << 2, b << 3);
704 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define RGB(r, g, b)
Definition: wingdi.h:2918

◆ PACK_COLORREF_24()

static COLORREF PACK_COLORREF_24 ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)
inlinestatic

Definition at line 706 of file swimpl.c.

707 {
708  return RGB(r, g, b);
709 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define RGB(r, g, b)
Definition: wingdi.h:2918

◆ PACK_COLORREF_32()

static COLORREF PACK_COLORREF_32 ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)
inlinestatic

Definition at line 711 of file swimpl.c.

712 {
713  return RGB(r, g, b);
714 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define RGB(r, g, b)
Definition: wingdi.h:2918

◆ PACK_COLORREF_8()

static COLORREF PACK_COLORREF_8 ( GLubyte  r,
GLubyte  g,
GLubyte  b 
)
inlinestatic

Definition at line 696 of file swimpl.c.

697 {
698  return RGB(r << 5, g << 5, b << 6);
699 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define RGB(r, g, b)
Definition: wingdi.h:2918

◆ PUT_PIXEL_16()

static void PUT_PIXEL_16 ( USHORT Buffer,
USHORT  Value 
)
inlinestatic

Definition at line 585 of file swimpl.c.

586 {
587  *Buffer = Value;
588 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
Definition: bufpool.h:45

◆ PUT_PIXEL_24()

static void PUT_PIXEL_24 ( ULONG Buffer,
ULONG  Value 
)
inlinestatic

Definition at line 589 of file swimpl.c.

590 {
591  *Buffer &= 0xFF000000ul;
592  *Buffer |= Value & 0x00FFFFFF;
593 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
Definition: bufpool.h:45

◆ PUT_PIXEL_32()

static void PUT_PIXEL_32 ( ULONG Buffer,
ULONG  Value 
)
inlinestatic

Definition at line 594 of file swimpl.c.

595 {
596  *Buffer = Value;
597 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
Definition: bufpool.h:45

◆ PUT_PIXEL_8()

static void PUT_PIXEL_8 ( BYTE Buffer,
BYTE  Value 
)
inlinestatic

Definition at line 581 of file swimpl.c.

582 {
583  *Buffer = Value;
584 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
Definition: bufpool.h:45

◆ read_index_pixels()

static void read_index_pixels ( GLcontext ctx,
GLuint  n,
const GLint  x[],
const GLint  y[],
GLuint  index[],
const GLubyte  mask[] 
)
static

Definition at line 1294 of file swimpl.c.

1297 {
1298 
1299  ERR("Not implemented yet !\n");
1300 }
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by setup_DD_pointers().

◆ read_index_span()

static void read_index_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
GLuint  index[] 
)
static

Definition at line 1248 of file swimpl.c.

1249 {
1250  ERR("Not implemented yet !\n");
1251 }
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by setup_DD_pointers().

◆ renderer_string()

static const char* renderer_string ( void  )
static

Definition at line 576 of file swimpl.c.

577 {
578  return "ReactOS SW Implementation";
579 }

Referenced by setup_DD_pointers().

◆ set_buffer()

static GLboolean set_buffer ( GLcontext ctx,
GLenum  mode 
)
static

Definition at line 911 of file swimpl.c.

912 {
913  struct sw_context* sw_ctx = ctx->DriverCtx;
914  struct sw_framebuffer* fb = sw_ctx->fb;
915 
916  if (!fb->gl_visual->DBflag)
917  return GL_FALSE;
918 
919  if ((mode != GL_FRONT) && (mode != GL_BACK))
920  return GL_FALSE;
921 
922  sw_ctx->Mode = mode;
923  return GL_TRUE;
924 }
#define GL_BACK
Definition: gl.h:271
#define GL_FALSE
Definition: gl.h:173
GLvisual * gl_visual
Definition: swimpl.c:223
GLenum Mode
Definition: swimpl.c:270
struct sw_framebuffer * fb
Definition: swimpl.c:244
#define GL_FRONT
Definition: gl.h:270
void * DriverCtx
Definition: types.h:1278
GLenum mode
Definition: glext.h:6217
#define GL_TRUE
Definition: gl.h:174
GLboolean DBflag
Definition: types.h:1138

Referenced by setup_DD_pointers().

◆ setup_DD_pointers()

static void setup_DD_pointers ( GLcontext ctx)
static

Definition at line 1347 of file swimpl.c.

1348 {
1349  struct sw_context* sw_ctx = ctx->DriverCtx;
1350 
1351  ctx->Driver.RendererString = renderer_string;
1352  ctx->Driver.UpdateState = setup_DD_pointers;
1353 
1354  switch (sw_ctx->fb->pixel_format->cColorBits)
1355  {
1356 #define HANDLE_BPP(__bpp) \
1357  case __bpp: \
1358  ctx->Driver.ClearIndex = clear_index_##__bpp; \
1359  ctx->Driver.ClearColor = clear_color_##__bpp; \
1360  ctx->Driver.Clear = clear_##__bpp; \
1361  ctx->Driver.Index = set_index_##__bpp; \
1362  ctx->Driver.Color = set_color_##__bpp; \
1363  ctx->Driver.WriteColorSpan = write_color_span_##__bpp; \
1364  ctx->Driver.WriteMonocolorSpan = write_monocolor_span_##__bpp; \
1365  ctx->Driver.WriteMonoindexSpan = write_monocolor_span_##__bpp; \
1366  ctx->Driver.WriteColorPixels = write_color_pixels_##__bpp; \
1367  ctx->Driver.WriteMonocolorPixels = write_monocolor_pixels_##__bpp; \
1368  ctx->Driver.WriteMonoindexPixels = write_monocolor_pixels_##__bpp; \
1369  ctx->Driver.ReadColorSpan = read_color_span_##__bpp; \
1370  ctx->Driver.ReadColorPixels = read_color_pixels_##__bpp; \
1371  break
1372 HANDLE_BPP(8);
1373 HANDLE_BPP(16);
1374 HANDLE_BPP(24);
1375 HANDLE_BPP(32);
1376 #undef HANDLE_BPP
1377  default:
1378  ERR("Unhandled bit depth %u, defaulting to 32bpp.\n", sw_ctx->fb->pixel_format->cColorBits);
1379  ctx->Driver.ClearIndex = clear_index_32;
1380  ctx->Driver.ClearColor = clear_color_32;
1381  ctx->Driver.Clear = clear_32;
1382  ctx->Driver.Index = set_index_32;
1383  ctx->Driver.Color = set_color_32;
1384  ctx->Driver.WriteColorSpan = write_color_span_32;
1385  ctx->Driver.WriteMonocolorSpan = write_monocolor_span_32;
1386  ctx->Driver.WriteMonoindexSpan = write_monocolor_span_32;
1387  ctx->Driver.WriteColorPixels = write_color_pixels_32;
1388  ctx->Driver.WriteMonocolorPixels = write_monocolor_pixels_32;
1389  ctx->Driver.WriteMonoindexPixels = write_monocolor_pixels_32;
1390  ctx->Driver.ReadColorSpan = read_color_span_32;
1391  ctx->Driver.ReadColorPixels = read_color_pixels_32;
1392  break;
1393  }
1394 
1395  ctx->Driver.SetBuffer = set_buffer;
1396  ctx->Driver.GetBufferSize = buffer_size;
1397 
1398  /* Pixel/span writing functions: */
1399  ctx->Driver.WriteIndexSpan = write_index_span;
1400  ctx->Driver.WriteIndexPixels = write_index_pixels;
1401 
1402  /* Pixel/span reading functions: */
1403  ctx->Driver.ReadIndexSpan = read_index_span;
1404  ctx->Driver.ReadIndexPixels = read_index_pixels;
1405 }
#define HANDLE_BPP(__x__)
static const char * renderer_string(void)
Definition: swimpl.c:576
static void read_index_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLuint index[], const GLubyte mask[])
Definition: swimpl.c:1294
static void setup_DD_pointers(GLcontext *ctx)
Definition: swimpl.c:1347
struct sw_framebuffer * fb
Definition: swimpl.c:244
struct dd_function_table Driver
Definition: types.h:1276
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:927
static void write_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLuint index[], const GLubyte mask[])
Definition: swimpl.c:1231
static GLboolean set_buffer(GLcontext *ctx, GLenum mode)
Definition: swimpl.c:911
void * DriverCtx
Definition: types.h:1278
#define ERR(fmt,...)
Definition: debug.h:109
static void read_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLuint index[])
Definition: swimpl.c:1248
static void write_index_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLuint index[], const GLubyte mask[])
Definition: swimpl.c:1240

Referenced by sw_SetContext().

◆ sw_call_window_proc()

static LRESULT CALLBACK sw_call_window_proc ( int  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 525 of file swimpl.c.

529 {
530  struct wgl_dc_data* dc_data = IntGetCurrentDcData();
531  struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC();
532  PCWPSTRUCT pParams = (PCWPSTRUCT)lParam;
533 
534  if((!dc_data) || (!ctx))
535  return 0;
536 
537  if(!(dc_data->flags & WGL_DC_OBJ_DC))
538  return 0;
539 
540  if((nCode < 0) || (dc_data->owner.hwnd != pParams->hwnd) || (dc_data->sw_data == NULL))
541  return CallNextHookEx(ctx->hook, nCode, wParam, lParam);
542 
543  if (pParams->message == WM_WINDOWPOSCHANGED)
544  {
545  /* We handle WM_WINDOWPOSCHANGED instead of WM_SIZE because according to
546  * http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx
547  * WM_SIZE is generated from WM_WINDOWPOSCHANGED by DefWindowProc so it
548  * can be masked out by the application. */
549  LPWINDOWPOS lpWindowPos = (LPWINDOWPOS)pParams->lParam;
550  if((lpWindowPos->flags & SWP_SHOWWINDOW) ||
551  !(lpWindowPos->flags & SWP_NOMOVE) ||
552  !(lpWindowPos->flags & SWP_NOSIZE))
553  {
554  /* Size in WINDOWPOS includes the window frame, so get the size
555  * of the client area via GetClientRect. */
556  RECT client_rect;
557  UINT width, height;
558 
559  TRACE("Got WM_WINDOWPOSCHANGED\n");
560 
561  GetClientRect(pParams->hwnd, &client_rect);
562  width = client_rect.right - client_rect.left;
563  height = client_rect.bottom - client_rect.top;
564  /* Do not reallocate for minimized windows */
565  if(width <= 0 || height <= 0)
566  goto end;
567  /* Propagate to mesa */
569  }
570  }
571 
572 end:
573  return CallNextHookEx(ctx->hook, nCode, wParam, lParam);
574 }
struct tagCWPSTRUCT * PCWPSTRUCT
GLint GLint GLsizei width
Definition: gl.h:1546
ULONG flags
Definition: opengl32.h:94
HWND hwnd
Definition: opengl32.h:90
LONG top
Definition: windef.h:292
GLcontext * gl_ctx
Definition: swimpl.c:238
GLuint GLuint end
Definition: gl.h:1545
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
WPARAM wParam
Definition: combotst.c:138
void * sw_data
Definition: opengl32.h:105
static struct wgl_dc_data * IntGetCurrentDcData(void)
Definition: opengl32.h:156
smooth NULL
Definition: ftsmooth.c:416
union wgl_dc_data::@281 owner
UINT flags
Definition: winuser.h:3536
#define TRACE(s)
Definition: solgame.cpp:4
LPARAM lParam
Definition: winuser.h:2978
UINT message
Definition: winuser.h:2980
#define WGL_DC_OBJ_DC
Definition: opengl32.h:84
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define SWP_NOSIZE
Definition: winuser.h:1230
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
FORCEINLINE DHGLRC IntGetCurrentDHGLRC(void)
Definition: opengl32.h:177
unsigned int UINT
Definition: ndis.h:50
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
void gl_ResizeBuffersMESA(GLcontext *ctx)
Definition: context.c:1497
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
LONG bottom
Definition: windef.h:294
#define SWP_NOMOVE
Definition: winuser.h:1229
HHOOK hook
Definition: swimpl.c:241
struct _WINDOWPOS * LPWINDOWPOS
LPARAM lParam
Definition: combotst.c:139

Referenced by sw_SetContext().

◆ sw_CopyContext()

BOOL sw_CopyContext ( DHGLRC  dhglrcSrc,
DHGLRC  dhglrcDst,
UINT  mask 
)

Definition at line 498 of file swimpl.c.

499 {
500  FIXME("Software wglCopyContext is UNIMPLEMENTED, mask %lx.\n", mask);
501  return FALSE;
502 }
GLenum GLint GLuint mask
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by wglCopyContext().

◆ sw_CreateContext()

DHGLRC sw_CreateContext ( struct wgl_dc_data dc_data)

Definition at line 422 of file swimpl.c.

423 {
424  struct sw_context* sw_ctx;
425  struct sw_framebuffer* fb = dc_data->sw_data;
426 
427  sw_ctx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*sw_ctx));
428  if(!sw_ctx)
429  return NULL;
430 
431  /* Initialize the context */
432  sw_ctx->gl_ctx = gl_create_context(fb->gl_visual, NULL, sw_ctx);
433  if(!sw_ctx->gl_ctx)
434  {
435  ERR("Failed to initialize the mesa context.\n");
436  HeapFree(GetProcessHeap(), 0, sw_ctx);
437  return NULL;
438  }
439 
440  sw_ctx->fb = fb;
441 
442  /* Choose relevant default */
443  sw_ctx->Mode = fb->gl_visual->DBflag ? GL_BACK : GL_FRONT;
444 
445  return (DHGLRC)sw_ctx;
446 }
#define GL_BACK
Definition: gl.h:271
GLvisual * gl_visual
Definition: swimpl.c:223
GLenum Mode
Definition: swimpl.c:270
GLcontext * gl_ctx
Definition: swimpl.c:238
void * sw_data
Definition: opengl32.h:105
struct sw_framebuffer * fb
Definition: swimpl.c:244
#define GL_FRONT
Definition: gl.h:270
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ERR(fmt,...)
Definition: debug.h:109
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
GLboolean DBflag
Definition: types.h:1138
GLcontext * gl_create_context(GLvisual *visual, GLcontext *share_list, void *driver_ctx)
Definition: context.c:1093
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by wglCreateContext(), and wglCreateLayerContext().

◆ sw_DeleteContext()

BOOL sw_DeleteContext ( DHGLRC  dhglrc)

Definition at line 448 of file swimpl.c.

449 {
450  struct sw_context* sw_ctx = (struct sw_context*)dhglrc;
451  /* Those get clobbered by _mesa_free_context_data via _glapi_set{context,dispath_table} */
452  void* icd_save = IntGetCurrentICDPrivate();
453  const GLDISPATCHTABLE* table_save = IntGetCurrentDispatchTable();
454 
455  /* Destroy everything */
456  gl_destroy_context(sw_ctx->gl_ctx);
457 
458  HeapFree(GetProcessHeap(), 0, sw_ctx);
459 
460  /* Restore this */
461  IntSetCurrentDispatchTable(table_save);
462  IntSetCurrentICDPrivate(icd_save);
463 
464  return TRUE;
465 }
#define TRUE
Definition: types.h:120
FORCEINLINE void * IntGetCurrentICDPrivate(void)
Definition: opengl32.h:170
GLcontext * gl_ctx
Definition: swimpl.c:238
FORCEINLINE void IntSetCurrentICDPrivate(void *value)
Definition: opengl32.h:163
#define GetProcessHeap()
Definition: compat.h:395
void gl_destroy_context(GLcontext *ctx)
Definition: context.c:1186
FORCEINLINE void IntSetCurrentDispatchTable(const GLDISPATCHTABLE *table)
Definition: opengl32.h:124
FORCEINLINE const GLDISPATCHTABLE * IntGetCurrentDispatchTable(void)
Definition: opengl32.h:117
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by wglCreateContext(), wglCreateLayerContext(), and wglDeleteContext().

◆ sw_DescribePixelFormat()

INT sw_DescribePixelFormat ( HDC  hdc,
INT  format,
UINT  size,
PIXELFORMATDESCRIPTOR descr 
)

Definition at line 315 of file swimpl.c.

316 {
317  INT ret;
318  const struct pixel_format *pixel_format;
319 
320  TRACE("Describing format %i.\n", format);
321 
323  if(!descr)
324  return ret;
325  if((format > ret) || (size != sizeof(*descr)))
326  return 0;
327 
328  /* Fill the structure */
329  descr->nSize = sizeof(*descr);
330  descr->nVersion = 1;
331  descr->dwFlags = pixel_format->dwFlags;
332  descr->iPixelType = pixel_format->iPixelType;
333  descr->cColorBits = pixel_format->cColorBits;
334  descr->cRedBits = pixel_format->cRedBits;
335  descr->cRedShift = pixel_format->cRedShift;
336  descr->cGreenBits = pixel_format->cGreenBits;
337  descr->cGreenShift = pixel_format->cGreenShift;
338  descr->cBlueBits = pixel_format->cBlueBits;
339  descr->cBlueShift = pixel_format->cBlueShift;
340  descr->cAlphaBits = pixel_format->cAlphaBits;
341  descr->cAlphaShift = pixel_format->cAlphaShift;
342  descr->cAccumBits = pixel_format->cAccumBits;
343  descr->cAccumRedBits = pixel_format->cAccumRedBits;
344  descr->cAccumGreenBits = pixel_format->cAccumGreenBits;
345  descr->cAccumBlueBits = pixel_format->cAccumBlueBits;
346  descr->cAccumAlphaBits = pixel_format->cAccumAlphaBits;
347  descr->cDepthBits = pixel_format->cDepthBits;
348  descr->cStencilBits = STENCIL_BITS;
349  descr->cAuxBuffers = 0;
350  descr->iLayerType = PFD_MAIN_PLANE;
351  descr->bReserved = 0;
352  descr->dwLayerMask = 0;
353  descr->dwVisibleMask = 0;
354  descr->dwDamageMask = 0;
355 
356  return ret;
357 }
BYTE cAccumGreenBits
Definition: swimpl.c:37
BYTE cGreenShift
Definition: swimpl.c:33
#define PFD_MAIN_PLANE
Definition: wingdi.h:297
BYTE cColorBits
Definition: swimpl.c:31
BYTE cAccumBits
Definition: swimpl.c:36
BYTE cAccumBlueBits
Definition: swimpl.c:37
static const struct pixel_format * get_format(INT pf_index, INT *pf_count)
Definition: swimpl.c:274
BYTE cAccumAlphaBits
Definition: swimpl.c:37
BYTE cAlphaBits
Definition: swimpl.c:35
int32_t INT
Definition: typedefs.h:56
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define STENCIL_BITS
Definition: config.h:152
BYTE cGreenBits
Definition: swimpl.c:33
DWORD dwFlags
Definition: swimpl.c:29
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
BYTE cAlphaShift
Definition: swimpl.c:35
int ret
BYTE cRedShift
Definition: swimpl.c:32
BYTE cBlueShift
Definition: swimpl.c:34
const char * descr
Definition: boot.c:42
BYTE cAccumRedBits
Definition: swimpl.c:37
BYTE cBlueBits
Definition: swimpl.c:34
BYTE cDepthBits
Definition: swimpl.c:38
BYTE iPixelType
Definition: swimpl.c:30
BYTE cRedBits
Definition: swimpl.c:32

Referenced by get_dc_data_ex(), and wglDescribePixelFormat().

◆ sw_GetProcAddress()

PROC sw_GetProcAddress ( LPCSTR  name)

Definition at line 478 of file swimpl.c.

479 {
480  /* GL_EXT_paletted_texture */
481  if (strcmp(name, "glColorTableEXT") == 0)
482  return (PROC)_mesa_ColorTableEXT;
483  if (strcmp(name, "glColorSubTableEXT") == 0)
485  if (strcmp(name, "glColorGetTableEXT") == 0)
487  if (strcmp(name, "glGetColorTableParameterivEXT") == 0)
489  if (strcmp(name, "glGetColorTableParameterfvEXT") == 0)
491  if (strcmp(name, "glAddSwapHintRectWIN") == 0)
493 
494  WARN("Asking for proc address %s, returning NULL.\n", name);
495  return NULL;
496 }
void APIENTRY _mesa_ColorTableEXT(GLenum, GLenum, GLsizei, GLenum, GLenum, const void *)
Definition: api.c:2826
#define WARN(fmt,...)
Definition: debug.h:111
void APIENTRY _mesa_GetColorTableEXT(GLenum, GLenum, GLenum, void *)
Definition: api.c:2851
void APIENTRY _mesa_ColorSubTableEXT(GLenum, GLsizei, GLsizei, GLenum, GLenum, const void *)
Definition: api.c:2839
smooth NULL
Definition: ftsmooth.c:416
void APIENTRY _mesa_GetColorTableParameterivEXT(GLenum, GLenum, GLfloat *)
static void APIENTRY _swimpl_AddSwapHintRectWIN(GLint x, GLint y, GLsizei width, GLsizei height)
Definition: swimpl.c:473
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
INT_PTR(WINAPI * PROC)()
Definition: windef.h:250
void APIENTRY _mesa_GetColorTableParameterfvEXT(GLenum, GLenum, GLint *)

Referenced by wglGetProcAddress().

◆ sw_ReleaseContext()

void sw_ReleaseContext ( DHGLRC  dhglrc)

Definition at line 1516 of file swimpl.c.

1517 {
1518  struct sw_context* sw_ctx = (struct sw_context*)dhglrc;
1519 
1520  /* Forward to mesa */
1522 
1523  /* Unhook */
1524  if(sw_ctx->hook)
1525  {
1526  UnhookWindowsHookEx(sw_ctx->hook);
1527  sw_ctx->hook = NULL;
1528  }
1529 }
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
void gl_make_current(GLcontext *ctx, GLframebuffer *buffer)
Definition: context.c:1276
HHOOK hook
Definition: swimpl.c:241

Referenced by wglMakeCurrent().

◆ sw_SetContext()

BOOL sw_SetContext ( struct wgl_dc_data dc_data,
DHGLRC  dhglrc 
)

Definition at line 1429 of file swimpl.c.

1430 {
1431  struct sw_context* sw_ctx = (struct sw_context*)dhglrc;
1432  struct sw_framebuffer* fb = dc_data->sw_data;
1433  UINT width, height;
1434 
1435  /* Get framebuffer size */
1436  if(dc_data->flags & WGL_DC_OBJ_DC)
1437  {
1438  HWND hwnd = dc_data->owner.hwnd;
1439  RECT client_rect;
1440  if(!hwnd)
1441  {
1442  ERR("Physical DC without a window!\n");
1443  return FALSE;
1444  }
1445  if(!GetClientRect(hwnd, &client_rect))
1446  {
1447  ERR("GetClientRect failed!\n");
1448  return FALSE;
1449  }
1450 
1451  /* This is a physical DC. Setup the hook */
1454  NULL,
1455  GetCurrentThreadId());
1456 
1457  /* Calculate width & height */
1458  width = client_rect.right - client_rect.left;
1459  height = client_rect.bottom - client_rect.top;
1460  }
1461  else /* OBJ_MEMDC */
1462  {
1463  BITMAP bm;
1464  HBITMAP hbmp;
1465  HDC hdc = dc_data->owner.hdc;
1466 
1467  if(fb->gl_visual->DBflag)
1468  {
1469  ERR("Memory DC called with a double buffered format.\n");
1470  return FALSE;
1471  }
1472 
1474  if(!hbmp)
1475  {
1476  ERR("No Bitmap!\n");
1477  return FALSE;
1478  }
1479  if(GetObject(hbmp, sizeof(bm), &bm) == 0)
1480  {
1481  ERR("GetObject failed!\n");
1482  return FALSE;
1483  }
1484  width = bm.bmWidth;
1485  height = bm.bmHeight;
1486  }
1487 
1488  if(!width) width = 1;
1489  if(!height) height = 1;
1490 
1491  /* Also make the mesa context current to mesa */
1492  gl_make_current(sw_ctx->gl_ctx, fb->gl_buffer);
1493 
1494  /* Setup our functions */
1495  setup_DD_pointers(sw_ctx->gl_ctx);
1496 
1497  /* Set the viewport if this is the first time we initialize this context */
1498  if(sw_ctx->gl_ctx->Viewport.X == 0 &&
1499  sw_ctx->gl_ctx->Viewport.Y == 0 &&
1500  sw_ctx->gl_ctx->Viewport.Width == 0 &&
1501  sw_ctx->gl_ctx->Viewport.Height == 0)
1502  {
1503  gl_Viewport(sw_ctx->gl_ctx, 0, 0, width, height);
1504  }
1505 
1506  /* update the framebuffer size */
1507  gl_ResizeBuffersMESA(sw_ctx->gl_ctx);
1508 
1509  /* Use our API table */
1511 
1512  /* We're good */
1513  return TRUE;
1514 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLint GLint GLsizei width
Definition: gl.h:1546
void gl_Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height)
Definition: matrix.c:1014
#define TRUE
Definition: types.h:120
ULONG flags
Definition: opengl32.h:94
HWND hwnd
Definition: opengl32.h:90
GLvisual * gl_visual
Definition: swimpl.c:223
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:292
GLcontext * gl_ctx
Definition: swimpl.c:238
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
void * sw_data
Definition: opengl32.h:105
static void setup_DD_pointers(GLcontext *ctx)
Definition: swimpl.c:1347
static LRESULT CALLBACK sw_call_window_proc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: swimpl.c:525
smooth NULL
Definition: ftsmooth.c:416
union wgl_dc_data::@281 owner
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
HBITMAP hbmp
#define SetWindowsHookEx
Definition: winuser.h:5722
#define GetObject
Definition: wingdi.h:4446
#define WH_CALLWNDPROC
Definition: winuser.h:34
HDC hdc
Definition: main.c:9
#define WGL_DC_OBJ_DC
Definition: opengl32.h:84
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ERR(fmt,...)
Definition: debug.h:109
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
FORCEINLINE void IntSetCurrentDispatchTable(const GLDISPATCHTABLE *table)
Definition: opengl32.h:124
Definition: bl.h:1331
struct gl_viewport_attrib Viewport
Definition: types.h:1336
void gl_make_current(GLcontext *ctx, GLframebuffer *buffer)
Definition: context.c:1276
unsigned int UINT
Definition: ndis.h:50
GLDISPATCHTABLE glDispatchTable
Definition: icd.h:357
static GLCLTPROCTABLE sw_api_table
Definition: swimpl.c:1412
void gl_ResizeBuffersMESA(GLcontext *ctx)
Definition: context.c:1497
GLframebuffer * gl_buffer
Definition: swimpl.c:224
GLboolean DBflag
Definition: types.h:1138
LONG bottom
Definition: windef.h:294
static HBITMAP
Definition: button.c:44
HHOOK hook
Definition: swimpl.c:241
#define OBJ_BITMAP
Definition: objidl.idl:1415
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439

Referenced by wglMakeCurrent().

◆ sw_SetPixelFormat()

BOOL sw_SetPixelFormat ( HDC  hdc,
struct wgl_dc_data dc_data,
INT  format 
)

Definition at line 359 of file swimpl.c.

360 {
361  struct sw_framebuffer* fb;
362  const struct pixel_format *pixel_format;
363 
364  /* So, someone is crazy enough to ask for sw implementation. Announce it. */
365  TRACE("OpenGL software implementation START for hdc %p, format %i!\n", hdc, format);
366 
368  if (!pixel_format)
369  return FALSE;
370 
371  /* allocate our structure */
372  fb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*fb));
373  if(!fb)
374  {
375  ERR("HeapAlloc FAILED!\n");
376  return FALSE;
377  }
378  /* Set the format */
380 
383  pixel_format->cAlphaBits != 0,
386  STENCIL_BITS,
389  ((1ul << pixel_format->cRedBits) - 1),
390  ((1ul << pixel_format->cGreenBits) - 1),
391  ((1ul << pixel_format->cBlueBits) - 1),
392  pixel_format->cAlphaBits != 0 ? ((1ul << pixel_format->cAlphaBits) - 1) : 255.0f,
397 
398  if(!fb->gl_visual)
399  {
400  ERR("Failed to allocate a GL visual.\n");
401  HeapFree(GetProcessHeap(), 0, fb);
402  return FALSE;
403  }
404 
405  /* Allocate the framebuffer structure */
407  if (!fb->gl_buffer) {
408  ERR("Failed to allocate the mesa framebuffer structure.\n");
410  HeapFree(GetProcessHeap(), 0, fb);
411  return FALSE;
412  }
413 
414  /* Save our DC */
415  fb->Hdc = hdc;
416 
417  /* Everything went fine */
418  dc_data->sw_data = fb;
419  return TRUE;
420 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
BYTE cAccumGreenBits
Definition: swimpl.c:37
BYTE cColorBits
Definition: swimpl.c:31
void gl_destroy_visual(GLvisual *vis)
Definition: context.c:1029
GLvisual * gl_visual
Definition: swimpl.c:223
BYTE cAccumBlueBits
Definition: swimpl.c:37
static const struct pixel_format * get_format(INT pf_index, INT *pf_count)
Definition: swimpl.c:274
BYTE cAccumAlphaBits
Definition: swimpl.c:37
BYTE cAlphaBits
Definition: swimpl.c:35
GLframebuffer * gl_create_framebuffer(GLvisual *visual)
Definition: context.c:1230
void * sw_data
Definition: opengl32.h:105
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define STENCIL_BITS
Definition: config.h:152
#define PFD_DOUBLEBUFFER
Definition: wingdi.h:300
BYTE cGreenBits
Definition: swimpl.c:33
DWORD dwFlags
Definition: swimpl.c:29
GLvisual * gl_create_visual(GLboolean rgb_flag, GLboolean alpha_flag, GLboolean db_flag, GLint depth_bits, GLint stencil_bits, GLint accum_bits, GLint index_bits, GLfloat red_scale, GLfloat green_scale, GLfloat blue_scale, GLfloat alpha_scale, GLint red_bits, GLint green_bits, GLint blue_bits, GLint alpha_bits)
Definition: context.c:936
smooth NULL
Definition: ftsmooth.c:416
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define PFD_TYPE_RGBA
Definition: wingdi.h:295
HDC hdc
Definition: main.c:9
const struct pixel_format * pixel_format
Definition: swimpl.c:226
#define ERR(fmt,...)
Definition: debug.h:109
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
GLframebuffer * gl_buffer
Definition: swimpl.c:224
BYTE cAccumRedBits
Definition: swimpl.c:37
BYTE cBlueBits
Definition: swimpl.c:34
BYTE cDepthBits
Definition: swimpl.c:38
BYTE iPixelType
Definition: swimpl.c:30
#define HeapFree(x, y, z)
Definition: compat.h:394
BYTE cRedBits
Definition: swimpl.c:32

Referenced by wglSetPixelFormat().

◆ sw_ShareLists()

BOOL sw_ShareLists ( DHGLRC  dhglrcSrc,
DHGLRC  dhglrcDst 
)

Definition at line 504 of file swimpl.c.

505 {
506 #if 0
507  struct sw_context* sw_ctx_src = (struct sw_context*)dhglrcSrc;
508  struct sw_context* sw_ctx_dst = (struct sw_context*)dhglrcDst;
509 
510  /* See if it was already shared */
511  if(sw_ctx_dst->gl_ctx->Shared->RefCount > 1)
512  return FALSE;
513 
514  /* Unreference the old, share the new */
515  gl_reference_shared_state(sw_ctx_dst->gl_ctx,
516  &sw_ctx_dst->gl_ctx->Shared,
517  sw_ctx_src->gl_ctx->Shared);
518 #endif
519  FIXME("Unimplemented!\n");
520  return TRUE;
521 }
#define TRUE
Definition: types.h:120
GLcontext * gl_ctx
Definition: swimpl.c:238
#define FIXME(fmt,...)
Definition: debug.h:110
struct gl_shared_state * Shared
Definition: types.h:1265

Referenced by wglShareLists().

◆ sw_SwapBuffers()

BOOL sw_SwapBuffers ( HDC  hdc,
struct wgl_dc_data dc_data 
)

Definition at line 1531 of file swimpl.c.

1532 {
1533  struct sw_framebuffer* fb = dc_data->sw_data;
1534  char Buffer[sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD)];
1535  BITMAPINFO *bmi = (BITMAPINFO*)Buffer;
1536  BYTE Bpp = fb->pixel_format->cColorBits;
1537 
1538  if (!fb->gl_visual->DBflag)
1539  return TRUE;
1540 
1541  if (!fb->BackBuffer)
1542  return FALSE;
1543 
1544  bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
1545  bmi->bmiHeader.biBitCount = Bpp;
1546  bmi->bmiHeader.biClrImportant = 0;
1547  bmi->bmiHeader.biClrUsed = 0;
1548  bmi->bmiHeader.biPlanes = 1;
1549  bmi->bmiHeader.biSizeImage = WIDTH_BYTES_ALIGN32(fb->width, Bpp) * fb->height;
1550  bmi->bmiHeader.biXPelsPerMeter = 0;
1551  bmi->bmiHeader.biYPelsPerMeter = 0;
1552  bmi->bmiHeader.biHeight = fb->height;
1553  bmi->bmiHeader.biWidth = fb->width;
1554  bmi->bmiHeader.biCompression = Bpp == 16 ? BI_BITFIELDS : BI_RGB;
1555 
1556  if (Bpp == 16)
1557  {
1558  DWORD* BitMasks = (DWORD*)(&bmi->bmiColors[0]);
1559  BitMasks[0] = 0x0000F800;
1560  BitMasks[1] = 0x000007E0;
1561  BitMasks[2] = 0x0000001F;
1562  }
1563 
1564  return SetDIBitsToDevice(fb->Hdc, 0, 0, fb->width, fb->height, 0, 0, 0, fb->height, fb->BackBuffer, bmi,
1565  fb->pixel_format->iPixelType == PFD_TYPE_COLORINDEX ? DIB_PAL_COLORS : DIB_RGB_COLORS) != 0;
1566 }
#define TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1454
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
DWORD biClrImportant
Definition: amvideo.idl:40
#define DIB_PAL_COLORS
Definition: wingdi.h:365
LONG biXPelsPerMeter
Definition: amvideo.idl:37
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
GLvisual * gl_visual
Definition: swimpl.c:223
GLuint width
Definition: swimpl.c:230
BYTE * BackBuffer
Definition: swimpl.c:233
LONG biYPelsPerMeter
Definition: amvideo.idl:38
#define BI_BITFIELDS
Definition: mmreg.h:507
void * sw_data
Definition: opengl32.h:105
DWORD biCompression
Definition: amvideo.idl:35
#define PFD_TYPE_COLORINDEX
Definition: wingdi.h:296
Definition: bufpool.h:45
RGBQUAD bmiColors[1]
Definition: wingdi.h:1455
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD biSizeImage
Definition: amvideo.idl:36
unsigned char BYTE
Definition: mem.h:68
const struct pixel_format * pixel_format
Definition: swimpl.c:226
int WINAPI SetDIBitsToDevice(_In_ HDC, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ int, _In_ int, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
GLuint height
Definition: swimpl.c:230
GLboolean DBflag
Definition: types.h:1138
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define BI_RGB
Definition: precomp.h:35

Referenced by wglSwapBuffers().

◆ UNPACK_COLOR_16()

static void UNPACK_COLOR_16 ( USHORT  Color,
GLubyte r,
GLubyte g,
GLubyte b 
)
inlinestatic

Definition at line 723 of file swimpl.c.

724 {
725  *r = (Color >> 11) & 0x1F;
726  *g = (Color >> 5) & 0x3F;
727  *b = Color & 0x1F;
728 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ UNPACK_COLOR_24()

static void UNPACK_COLOR_24 ( ULONG  Color,
GLubyte r,
GLubyte g,
GLubyte b 
)
inlinestatic

Definition at line 730 of file swimpl.c.

731 {
732  *r = (Color >> 16) & 0xFF;
733  *g = (Color >> 8) & 0xFF;
734  *b = Color & 0xFF;
735 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ UNPACK_COLOR_32()

static void UNPACK_COLOR_32 ( ULONG  Color,
GLubyte r,
GLubyte g,
GLubyte b 
)
inlinestatic

Definition at line 737 of file swimpl.c.

738 {
739  *r = (Color >> 16) & 0xFF;
740  *g = (Color >> 8) & 0xFF;
741  *b = Color & 0xFF;
742 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ UNPACK_COLOR_8()

static void UNPACK_COLOR_8 ( BYTE  Color,
GLubyte r,
GLubyte g,
GLubyte b 
)
inlinestatic

Definition at line 716 of file swimpl.c.

717 {
718  *r = Color & 0x7;
719  *g = (Color >> 3) & 0x7;
720  *b = (Color >> 6) & 0x3;
721 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ UNPACK_COLORREF_16()

static void UNPACK_COLORREF_16 ( COLORREF  Color,
GLubyte r,
GLubyte g,
GLubyte b 
)
inlinestatic

Definition at line 751 of file swimpl.c.

752 {
753  *r = GetRValue(Color) >> 3;
754  *g = GetGValue(Color) >> 2;
755  *b = GetBValue(Color) >> 3;
756 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2913
#define GetGValue(rgb)
Definition: wingdi.h:2914
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define GetBValue(rgb)
Definition: wingdi.h:2915

◆ UNPACK_COLORREF_24()

static void UNPACK_COLORREF_24 ( COLORREF  Color,
GLubyte r,
GLubyte g,
GLubyte b 
)
inlinestatic

Definition at line 758 of file swimpl.c.

759 {
760  *r = GetRValue(Color);
761  *g = GetGValue(Color);
762  *b = GetBValue(Color);
763 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2913
#define GetGValue(rgb)
Definition: wingdi.h:2914
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define GetBValue(rgb)
Definition: wingdi.h:2915

◆ UNPACK_COLORREF_32()

static void UNPACK_COLORREF_32 ( COLORREF  Color,
GLubyte r,
GLubyte g,
GLubyte b 
)
inlinestatic

Definition at line 765 of file swimpl.c.

766 {
767  *r = GetRValue(Color);
768  *g = GetGValue(Color);
769  *b = GetBValue(Color);
770 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2913
#define GetGValue(rgb)
Definition: wingdi.h:2914
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define GetBValue(rgb)
Definition: wingdi.h:2915

◆ UNPACK_COLORREF_8()

static void UNPACK_COLORREF_8 ( COLORREF  Color,
GLubyte r,
GLubyte g,
GLubyte b 
)
inlinestatic

Definition at line 744 of file swimpl.c.

745 {
746  *r = GetRValue(Color) >> 5;
747  *g = GetGValue(Color) >> 5;
748  *b = GetBValue(Color) >> 6;
749 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2913
#define GetGValue(rgb)
Definition: wingdi.h:2914
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define GetBValue(rgb)
Definition: wingdi.h:2915

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( opengl32  )

◆ write_index_pixels()

static void write_index_pixels ( GLcontext ctx,
GLuint  n,
const GLint  x[],
const GLint  y[],
const GLuint  index[],
const GLubyte  mask[] 
)
static

Definition at line 1240 of file swimpl.c.

1243 {
1244  ERR("Not implemented yet !\n");
1245 }
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by setup_DD_pointers().

◆ write_index_span()

static void write_index_span ( GLcontext ctx,
GLuint  n,
GLint  x,
GLint  y,
const GLuint  index[],
const GLubyte  mask[] 
)
static

Definition at line 1231 of file swimpl.c.

1235 {
1236  ERR("Not implemented yet !\n");
1237 }
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by setup_DD_pointers().

◆ write_monocolor_pixels_frontbuffer()

static void write_monocolor_pixels_frontbuffer ( struct sw_framebuffer fb,
GLuint  n,
const GLint  x[],
const GLint  y[],
const GLubyte  mask[],
COLORREF  Color 
)
static

Definition at line 1178 of file swimpl.c.

1182 {
1183  TRACE("Writing monocolor pixels to front buffer.\n");
1184 
1185  while (n--)
1186  {
1187  if (mask[n])
1188  {
1189  SetPixel(fb->Hdc, x[n], fb->height - y[n], Color);
1190  }
1191  }
1192 }
GLdouble n
Definition: glext.h:7729
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLenum GLint GLuint mask
Definition: glext.h:6028
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:99
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint height
Definition: swimpl.c:230

◆ write_monocolor_span_frontbuffer()

static void write_monocolor_span_frontbuffer ( struct sw_framebuffer fb,
GLuint  n,
GLint  x,
GLint  y,
const GLubyte  mask[],
COLORREF  Color 
)
static

Definition at line 1067 of file swimpl.c.

1069 {
1070  TRACE("Writing monocolor span at %u %u (%u), Color 0x%08x", x, y, n, Color);
1071 
1072  if (mask)
1073  {
1074  while (n--)
1075  {
1076  if (mask[n])
1077  SetPixel(fb->Hdc, x + n, y, Color);
1078  }
1079  }
1080  else
1081  {
1082  HBRUSH Brush = CreateSolidBrush(Color);
1083  Brush = SelectObject(fb->Hdc, Brush);
1084 
1085  PatBlt(fb->Hdc, x, fb->height - y, n, 1, PATCOPY);
1086 
1087  Brush = SelectObject(fb->Hdc, Brush);
1089  }
1090 }
GLdouble n
Definition: glext.h:7729
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
GLenum GLint GLuint mask
Definition: glext.h:6028
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:99
#define TRACE(s)
Definition: solgame.cpp:4
#define PATCOPY
Definition: wingdi.h:334
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint height
Definition: swimpl.c:230

Variable Documentation

◆ pixel_formats_16

const struct pixel_format pixel_formats_16[]
static

Definition at line 131 of file swimpl.c.

◆ pixel_formats_24

const struct pixel_format pixel_formats_24[]
static

Definition at line 86 of file swimpl.c.

◆ pixel_formats_32

const struct pixel_format pixel_formats_32[]
static

Definition at line 41 of file swimpl.c.

Referenced by get_format().

◆ pixel_formats_8

const struct pixel_format pixel_formats_8[]
static

Definition at line 176 of file swimpl.c.

◆ sw_api_table

GLCLTPROCTABLE sw_api_table
static

Definition at line 1412 of file swimpl.c.

Referenced by sw_SetContext().