diff options
Diffstat (limited to 'mesalib/src/mesa/drivers')
18 files changed, 140 insertions, 2038 deletions
diff --git a/mesalib/src/mesa/drivers/SConscript b/mesalib/src/mesa/drivers/SConscript index 9888e3306..17813da96 100644 --- a/mesalib/src/mesa/drivers/SConscript +++ b/mesalib/src/mesa/drivers/SConscript @@ -11,8 +11,5 @@ if env['dri']: 'dri/common/SConscript', ]) -if env['platform'] == 'windows': - SConscript('windows/gdi/SConscript') - if env['platform'] == 'haiku': SConscript('haiku/swrast/SConscript') diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.h b/mesalib/src/mesa/drivers/common/driverfuncs.h index 6b9a90074..385ccb8dd 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.h +++ b/mesalib/src/mesa/drivers/common/driverfuncs.h @@ -26,6 +26,10 @@ #ifndef DRIVERFUNCS_H #define DRIVERFUNCS_H +#ifdef __cplusplus +extern "C" { +#endif + extern void _mesa_init_driver_functions(struct dd_function_table *driver); @@ -33,5 +37,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver); extern void _mesa_init_driver_state(struct gl_context *ctx); +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 3636ee83b..fdc4cf1e9 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -393,7 +393,7 @@ _mesa_meta_setup_vertex_objects(GLuint *VAO, GLuint *VBO, void _mesa_meta_init(struct gl_context *ctx) { - ASSERT(!ctx->Meta); + assert(!ctx->Meta); ctx->Meta = CALLOC_STRUCT(gl_meta_state); } @@ -823,6 +823,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) void _mesa_meta_end(struct gl_context *ctx) { + assert(ctx->Meta->SaveStackDepth > 0); + struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1]; const GLbitfield state = save->SavedState; int i; @@ -1045,7 +1047,7 @@ _mesa_meta_end(struct gl_context *ctx) if (state & MESA_META_TEXTURE) { GLuint u, tgt; - ASSERT(ctx->Texture.CurrentUnit == 0); + assert(ctx->Texture.CurrentUnit == 0); /* restore texenv for unit[0] */ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode); @@ -1332,8 +1334,8 @@ _mesa_meta_alloc_texture(struct temp_texture *tex, { GLboolean newTex = GL_FALSE; - ASSERT(width <= tex->MaxSize); - ASSERT(height <= tex->MaxSize); + assert(width <= tex->MaxSize); + assert(height <= tex->MaxSize); if (width > tex->Width || height > tex->Height || @@ -1747,7 +1749,7 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl) _mesa_ClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE); } else { - ASSERT(metaSave & MESA_META_COLOR_MASK); + assert(metaSave & MESA_META_COLOR_MASK); _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); } diff --git a/mesalib/src/mesa/drivers/common/meta_blit.c b/mesalib/src/mesa/drivers/common/meta_blit.c index 3406be1ed..bb2164276 100755 --- a/mesalib/src/mesa/drivers/common/meta_blit.c +++ b/mesalib/src/mesa/drivers/common/meta_blit.c @@ -82,7 +82,7 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, y_scale = samples * 0.5; /* We expect only power of 2 samples in source multisample buffer. */ - assert((samples & (samples - 1)) == 0); + assert(samples > 0 && (samples & (samples - 1)) == 0); while (samples >> (shader_offset + 1)) { shader_offset++; } @@ -133,6 +133,8 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, sample_map = ctx->Const.SampleMap8x; break; default: + sample_number = NULL; + sample_map = NULL; _mesa_problem(ctx, "Unsupported sample count %d\n", samples); unreachable("Unsupported sample count"); } @@ -261,7 +263,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, } /* We expect only power of 2 samples in source multisample buffer. */ - assert((samples & (samples - 1)) == 0); + assert(samples > 0 && (samples & (samples - 1)) == 0); while (samples >> (shader_offset + 1)) { shader_offset++; } diff --git a/mesalib/src/mesa/drivers/common/meta_tex_subimage.c b/mesalib/src/mesa/drivers/common/meta_tex_subimage.c index 68c8273fe..e29addb73 100644 --- a/mesalib/src/mesa/drivers/common/meta_tex_subimage.c +++ b/mesalib/src/mesa/drivers/common/meta_tex_subimage.c @@ -44,7 +44,7 @@ static struct gl_texture_image * create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, - GLenum pbo_target, int width, int height, int depth, + GLenum pbo_target, int width, int height, GLenum format, GLenum type, const void *pixels, const struct gl_pixelstore_attrib *packing, GLuint *tmp_pbo, GLuint *tmp_tex) @@ -57,8 +57,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, struct gl_texture_image *tex_image; bool read_only; - if ((packing->ImageHeight != 0 && packing->ImageHeight != height) || - packing->SwapBytes || + if (packing->SwapBytes || packing->LsbFirst || packing->Invert) return NULL; @@ -79,6 +78,8 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, *tmp_pbo = 0; buffer_obj = packing->BufferObj; } else { + bool is_pixel_pack = pbo_target == GL_PIXEL_PACK_BUFFER; + assert(create_pbo); _mesa_GenBuffers(1, tmp_pbo); @@ -89,9 +90,17 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, */ _mesa_BindBuffer(pbo_target, *tmp_pbo); - _mesa_BufferData(pbo_target, row_stride * height, pixels, GL_STREAM_DRAW); + /* In case of GL_PIXEL_PACK_BUFFER, pass null pointer for the pixel + * data to avoid unnecessary data copying in _mesa_BufferData(). + */ + if (is_pixel_pack) + _mesa_BufferData(pbo_target, row_stride * height, NULL, + GL_STREAM_READ); + else + _mesa_BufferData(pbo_target, row_stride * height, pixels, + GL_STREAM_DRAW); - buffer_obj = ctx->Unpack.BufferObj; + buffer_obj = packing->BufferObj; pixels = NULL; _mesa_BindBuffer(pbo_target, 0); @@ -99,14 +108,16 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, _mesa_GenTextures(1, tmp_tex); tex_obj = _mesa_lookup_texture(ctx, *tmp_tex); - tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D; - tex_obj->Immutable = GL_TRUE; _mesa_initialize_texture_object(ctx, tex_obj, *tmp_tex, GL_TEXTURE_2D); + /* This must be set after _mesa_initialize_texture_object, not before. */ + tex_obj->Immutable = GL_TRUE; + /* This is required for interactions with ARB_texture_view. */ + tex_obj->NumLayers = 1; internal_format = _mesa_get_format_base_format(pbo_format); tex_image = _mesa_get_tex_image(ctx, tex_obj, tex_obj->Target, 0); - _mesa_init_teximage_fields(ctx, tex_image, width, height, depth, + _mesa_init_teximage_fields(ctx, tex_image, width, height, 1, 0, internal_format, pbo_format); read_only = pbo_target == GL_PIXEL_UNPACK_BUFFER; @@ -133,6 +144,7 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, const struct gl_pixelstore_attrib *packing) { GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; + int full_height, image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -166,9 +178,16 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, return true; } + /* For arrays, use a tall (height * depth) 2D texture but taking into + * account the inter-image padding specified with the image height packing + * property. + */ + image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + full_height = image_height * (depth - 1) + height; + pbo_tex_image = create_texture_for_pbo(ctx, create_pbo, GL_PIXEL_UNPACK_BUFFER, - width, height, depth, + width, full_height, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) @@ -177,8 +196,8 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (allocate_storage) ctx->Driver.AllocTextureImageBuffer(ctx, tex_image); - /* Only stash the current FBO */ - _mesa_meta_begin(ctx, 0); + _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER | + MESA_META_PIXEL_STORE)); _mesa_GenFramebuffers(2, fbos); _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]); @@ -186,8 +205,12 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { assert(depth == 1); + assert(zoffset == 0); depth = height; height = 1; + image_height = 1; + zoffset = yoffset; + yoffset = 0; } _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -214,15 +237,14 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, goto fail; for (z = 1; z < depth; z++) { - _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - pbo_tex_image, z); _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_image, zoffset + z); _mesa_update_state(ctx); _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, - 0, 0, width, height, + 0, z * image_height, + width, z * image_height + height, xoffset, yoffset, xoffset + width, yoffset + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); @@ -249,6 +271,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, const struct gl_pixelstore_attrib *packing) { GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; + int full_height, image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -282,22 +305,33 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, return true; } + /* For arrays, use a tall (height * depth) 2D texture but taking into + * account the inter-image padding specified with the image height packing + * property. + */ + image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + full_height = image_height * (depth - 1) + height; + pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER, - width, height, depth, + width, full_height * depth, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) return false; - /* Only stash the current FBO */ - _mesa_meta_begin(ctx, 0); + _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER | + MESA_META_PIXEL_STORE)); _mesa_GenFramebuffers(2, fbos); if (tex_image && tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { assert(depth == 1); + assert(zoffset == 0); depth = height; height = 1; + image_height = 1; + zoffset = yoffset; + yoffset = 0; } /* If we were given a texture, bind it to the read framebuffer. If not, @@ -336,15 +370,14 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, for (z = 1; z < depth; z++) { _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_image, zoffset + z); - _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - pbo_tex_image, z); _mesa_update_state(ctx); _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, xoffset, yoffset, xoffset + width, yoffset + height, - 0, 0, width, height, + 0, z * image_height, + width, z * image_height + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); } diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c index f2e63c0b9..bb22107e9 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.c +++ b/mesalib/src/mesa/drivers/dri/common/utils.c @@ -30,6 +30,7 @@ */ #include <string.h> +#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h> @@ -485,6 +486,7 @@ driIndexConfigAttrib(const __DRIconfig *config, int index, * Currently only the following queries are supported by this function: * * - \c __DRI2_RENDERER_VERSION + * - \c __DRI2_RENDERER_PREFERRED_PROFILE * - \c __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION * - \c __DRI2_RENDERER_OPENGL_COMPATIBLITY_PROFILE_VERSION * - \c __DRI2_RENDERER_ES_PROFILE_VERSION diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c index 6beee4eb3..a90a97fa9 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c +++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c @@ -27,10 +27,13 @@ * \author Felix Kuehling */ +#include <stdarg.h> +#include <stdio.h> #include <string.h> #include <assert.h> #include <expat.h> #include <fcntl.h> +#include <math.h> #include <unistd.h> #include <errno.h> #include "main/imports.h" diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am index da7d03480..555771685 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am @@ -52,7 +52,7 @@ POT=xmlpool.pot .PHONY: all clean pot po mo -EXTRA_DIST = gen_xmlpool.py t_options.h $(POS) SConscript +EXTRA_DIST = gen_xmlpool.py options.h t_options.h $(POS) SConscript BUILT_SOURCES = options.h CLEANFILES = $(MOS) options.h diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po index 23e9f4211..03bf29613 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po @@ -25,15 +25,15 @@ msgid "" msgstr "" "Project-Id-Version: Mesa 10.1.0-devel\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-09-25 22:29-0600\n" -"PO-Revision-Date: 2014-09-26 14:43-0700\n" +"POT-Creation-Date: 2015-02-07 02:08-0700\n" +"PO-Revision-Date: 2015-02-23 14:28-0700\n" "Last-Translator: Alex Henrie <alexhenrie24@gmail.com>\n" "Language-Team: Catalan <ca@li.org>\n" "Language: ca\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.6.9\n" +"X-Generator: Poedit 1.7.4\n" #: t_options.h:56 msgid "Debugging" @@ -83,8 +83,8 @@ msgstr "Deshabilita el GL_ARB_shader_bit_encoding" msgid "" "Force a default GLSL version for shaders that lack an explicit #version line" msgstr "" -"Força una versió GLSL per defecte en els shaders als quals falta una línia " -"#version explícita" +"Força una versió GLSL per defecte en els shaders als quals lis manca una " +"línia #version explícita" #: t_options.h:110 msgid "Allow GLSL #extension directives in the middle of shaders" @@ -92,7 +92,7 @@ msgstr "Permet les directives #extension GLSL en el mitjà dels shaders" #: t_options.h:120 msgid "Image Quality" -msgstr "Qualitat d'Imatge" +msgstr "Qualitat d'imatge" #: t_options.h:133 msgid "Texture color depth" @@ -149,11 +149,11 @@ msgstr "Mètode d'arrodoniment de color" #: t_options.h:171 msgid "Round color components downward" -msgstr "Arrondeix els components de color a baix" +msgstr "Arrodoneix els components de color a baix" #: t_options.h:172 msgid "Round to nearest color" -msgstr "Arrondeix al color més proper" +msgstr "Arrodoneix al color més proper" #: t_options.h:181 msgid "Color dithering method" @@ -181,15 +181,15 @@ msgstr "Un filtre de postprocessament per a aplicar cel shading a la sortida" #: t_options.h:200 msgid "A post-processing filter to remove the red channel" -msgstr "Un filtre de postprocessament per a treure el canal vermell" +msgstr "Un filtre de postprocessament per a eliminar el canal vermell" #: t_options.h:205 msgid "A post-processing filter to remove the green channel" -msgstr "Un filtre de postprocessament per a treure el canal verd" +msgstr "Un filtre de postprocessament per a eliminar el canal verd" #: t_options.h:210 msgid "A post-processing filter to remove the blue channel" -msgstr "Un filtre de postprocessament per a treure el canal blau" +msgstr "Un filtre de postprocessament per a eliminar el canal blau" #: t_options.h:215 msgid "" @@ -222,17 +222,17 @@ msgstr "Utilitza la canonada TCL de programari" #: t_options.h:240 msgid "Use hardware TCL as first TCL pipeline stage" -msgstr "Utilitza el TCL maquinàri com la primera fase de la canonada TCL" +msgstr "Utilitza el TCL de maquinari com a la primera fase de la canonada TCL" #: t_options.h:241 msgid "Bypass the TCL pipeline" -msgstr "Passar per alt la canonada TCL" +msgstr "Passa per alt la canonada TCL" #: t_options.h:242 msgid "" "Bypass the TCL pipeline with state-based machine code generated on-the-fly" msgstr "" -"Passar per alt la canonada TCL amb codi màquina basat en estats, generat " +"Passa per alt la canonada TCL amb codi de màquina basat en estats, generat " "sobre la marxa" #: t_options.h:251 @@ -245,7 +245,7 @@ msgstr "Espera activa pel maquinari de gràfics" #: t_options.h:253 msgid "Sleep for brief intervals while waiting for the graphics hardware" -msgstr "Dormi per intervals breus mentre s'espera al maquinari de gràfics" +msgstr "Dorm per intervals breus mentre s'espera al maquinari de gràfics" #: t_options.h:254 msgid "Let the graphics hardware emit a software interrupt and sleep" @@ -259,7 +259,7 @@ msgstr "Sincronització amb refresc vertical (intervals d'intercanvi)" #: t_options.h:265 msgid "Never synchronize with vertical refresh, ignore application's choice" msgstr "" -"Mai sincronitzis amb el refresc vertial, ignora l'elecció de l'aplicació" +"Mai sincronitzis amb el refresc vertical, ignora l'elecció de l'aplicació" #: t_options.h:266 msgid "Initial swap interval 0, obey application's choice" @@ -301,7 +301,7 @@ msgstr "Tota la memòria disponible" #: t_options.h:296 msgid "Only card memory (if available)" -msgstr "Només memòria de tarjeta (si està disponible)" +msgstr "Només memòria de targeta (si està disponible)" #: t_options.h:297 msgid "Only GART (AGP/PCIE) memory (if available)" @@ -329,4 +329,20 @@ msgstr "Inicialització" #: t_options.h:341 msgid "Define the graphic device to use if possible" -msgstr "Defineix el dispositiu de gràfics que usar si és possible" +msgstr "Defineix el dispositiu de gràfics que utilitzar si és possible" + +#: t_options.h:350 +msgid "Gallium Nine" +msgstr "Gallium Nine" + +#: t_options.h:354 +msgid "" +"Define the throttling value. -1 for no throttling, -2 for default (usually " +"2), 0 for glfinish behaviour" +msgstr "" +"Defineix el valor de regulació. -1 per a no regular, -2 per al predeterminat " +"(generalment 2), 0 per al comportament de glfinish" + +#: t_options.h:359 +msgid "Use an additional thread to submit buffers." +msgstr "Utilitza un fil addicional per a entregar els buffers." diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po index a68c329a5..f9d950ac1 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po @@ -9,8 +9,8 @@ msgid "" msgstr "" "Project-Id-Version: es\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-09-25 22:29-0600\n" -"PO-Revision-Date: 2014-09-26 14:22-0700\n" +"POT-Creation-Date: 2015-02-07 02:08-0700\n" +"PO-Revision-Date: 2015-02-23 14:54-0700\n" "Last-Translator: Alex Henrie <alexhenrie24@gmail.com>\n" "Language-Team: Spanish <es@li.org>\n" "Language: es\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 1.6.9\n" +"X-Generator: Poedit 1.7.4\n" #: t_options.h:56 msgid "Debugging" @@ -301,11 +301,11 @@ msgstr "Habilitar la extensión GL_ARB_vertex_program" #: t_options.h:323 msgid "Miscellaneous" -msgstr "Misceláneo" +msgstr "Misceláneos" #: t_options.h:327 msgid "Create all visuals with a depth buffer" -msgstr "Crear todos los visuales con buffer de profundidad" +msgstr "Crear todos los visuales con búfer de profundidad" #: t_options.h:337 msgid "Initialization" @@ -314,3 +314,19 @@ msgstr "Inicialización" #: t_options.h:341 msgid "Define the graphic device to use if possible" msgstr "Define el dispositivo de gráficos que usar si es posible" + +#: t_options.h:350 +msgid "Gallium Nine" +msgstr "Gallium Nine" + +#: t_options.h:354 +msgid "" +"Define the throttling value. -1 for no throttling, -2 for default (usually " +"2), 0 for glfinish behaviour" +msgstr "" +"Define el valor de regulación. -1 para no regular, -2 para el por defecto " +"(generalmente 2), 0 para el comportamiento de glfinish" + +#: t_options.h:359 +msgid "Use an additional thread to submit buffers." +msgstr "Usar un hilo adicional para entregar los búfer." diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index e42ba658f..e84059073 100644..100755 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -32,6 +32,7 @@ * The back-buffer is allocated by the driver and is private. */ +#include <stdio.h> #ifdef _MSC_VER #define WIN32_LEAN_AND_MEAN 1 #include <windows.h> @@ -350,7 +351,7 @@ swrast_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) } /* see bytes_per_line in libGL */ -static INLINE int +static inline int bytes_per_line(unsigned pitch_bits, unsigned mul) { unsigned mask = mul - 1; @@ -490,7 +491,7 @@ swrast_map_renderbuffer(struct gl_context *ctx, return; } - ASSERT(xrb->Base.Buffer); + assert(xrb->Base.Buffer); if (rb->AllocStorage == swrast_alloc_back_storage) { map += (rb->Height - 1) * stride; diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h index 339e4502f..8dccc2265 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -72,13 +72,13 @@ struct dri_context __DRIcontext *cPriv; }; -static INLINE struct dri_context * +static inline struct dri_context * dri_context(__DRIcontext * driContextPriv) { return (struct dri_context *)driContextPriv->driverPrivate; } -static INLINE struct dri_context * +static inline struct dri_context * swrast_context(struct gl_context *ctx) { return (struct dri_context *) ctx; @@ -96,13 +96,13 @@ struct dri_drawable char *row; }; -static INLINE struct dri_drawable * +static inline struct dri_drawable * dri_drawable(__DRIdrawable * driDrawPriv) { return (struct dri_drawable *)driDrawPriv->driverPrivate; } -static INLINE struct dri_drawable * +static inline struct dri_drawable * swrast_drawable(struct gl_framebuffer *fb) { return (struct dri_drawable *) fb; @@ -122,7 +122,7 @@ struct dri_swrast_renderbuffer { GLuint bpp; }; -static INLINE struct dri_swrast_renderbuffer * +static inline struct dri_swrast_renderbuffer * dri_swrast_renderbuffer(struct gl_renderbuffer *rb) { return (struct dri_swrast_renderbuffer *) rb; diff --git a/mesalib/src/mesa/drivers/windows/gdi/SConscript b/mesalib/src/mesa/drivers/windows/gdi/SConscript deleted file mode 100644 index 1f4d7e1fa..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/SConscript +++ /dev/null @@ -1,40 +0,0 @@ -Import('*') - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '#src', - '#src/mapi', - '#src/mesa', -]) - -env.AppendUnique(CPPDEFINES = [ - '_GDI32_', # prevent wgl* being declared __declspec(dllimport) - 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers -]) -if not env['gles']: - # prevent _glapi_* from being declared __declspec(dllimport) - env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) - -env.Prepend(LIBS = [ - mesautil, - glapi, - mesa, - glsl, - 'gdi32', - 'user32', - 'kernel32', -]) - -sources = [ - 'mesa.def', - 'wgl.c', - 'wmesa.c', -] - -mesagdi = env.SharedLibrary( - target = 'opengl32', - source = sources, -) - -env.Alias('mesagdi', mesagdi) diff --git a/mesalib/src/mesa/drivers/windows/gdi/colors.h b/mesalib/src/mesa/drivers/windows/gdi/colors.h deleted file mode 100644 index 03e512c1f..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/colors.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Values for wmesa->pixelformat: */ - -#define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */ -#define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */ -#define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */ -#define PF_DITHER8 6 /* Dithered RGB using a lookup table */ -#define PF_LOOKUP 7 /* Undithered RGB using a lookup table */ -#define PF_GRAYSCALE 10 /* Grayscale or StaticGray */ -#define PF_BADFORMAT 11 -#define PF_INDEX8 12 - - -#define BGR8(r,g,b) (unsigned)(((BYTE)((b & 0xc0) | ((g & 0xe0)>>2) | \ - ((r & 0xe0)>>5)))) - -/* Windows uses 5,5,5 for 16-bit */ -#define BGR16(r,g,b) ( (((unsigned short)b ) >> 3) | \ - (((unsigned short)g & 0xf8) << 2) | \ - (((unsigned short)r & 0xf8) << 7) ) - -#define BGR24(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)| \ - ((WORD)((BYTE)(g))<<8))| \ - (((DWORD)(BYTE)(r))<<16))) - -#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)| \ - ((WORD)((BYTE)(g))<<8))| \ - (((DWORD)(BYTE)(r))<<16))) - - diff --git a/mesalib/src/mesa/drivers/windows/gdi/mesa.def b/mesalib/src/mesa/drivers/windows/gdi/mesa.def deleted file mode 100644 index a52207b63..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/mesa.def +++ /dev/null @@ -1,385 +0,0 @@ -; -; Module definition file for Mesa (OPENGL32.DLL) -; -; Note: The OpenGL functions use the STDCALL -; function calling convention. Microsoft's -; OPENGL32 uses this convention and so must the -; Mesa OPENGL32 so that the Mesa DLL can be used -; as a drop-in replacement. -; -; The linker exports STDCALL entry points with -; 'decorated' names; e.g., _glBegin@0, where the -; trailing number is the number of bytes of -; parameter data pushed onto the stack. The -; callee is responsible for popping this data -; off the stack, usually via a RETF n instruction. -; -; However, the Microsoft OPENGL32.DLL does not export -; the decorated names, even though the calling convention -; is STDCALL. So, this module definition file is -; needed to force the Mesa OPENGL32.DLL to export the -; symbols in the same manner as the Microsoft DLL. -; Were it not for this problem, this file would not -; be needed (for the gl* functions) since the entry -; points are compiled with dllexport declspec. -; -EXPORTS - glAccum - glAlphaFunc - glAreTexturesResident - glArrayElement - glBegin - glBindTexture - glBitmap - glBlendFunc - glCallList - glCallLists - glClear - glClearAccum - glClearColor - glClearDepth - glClearIndex - glClearStencil - glClipPlane - glColor3b - glColor3bv - glColor3d - glColor3dv - glColor3f - glColor3fv - glColor3i - glColor3iv - glColor3s - glColor3sv - glColor3ub - glColor3ubv - glColor3ui - glColor3uiv - glColor3us - glColor3usv - glColor4b - glColor4bv - glColor4d - glColor4dv - glColor4f - glColor4fv - glColor4i - glColor4iv - glColor4s - glColor4sv - glColor4ub - glColor4ubv - glColor4ui - glColor4uiv - glColor4us - glColor4usv - glColorMask - glColorMaterial - glColorPointer - glCopyPixels - glCopyTexImage1D - glCopyTexImage2D - glCopyTexSubImage1D - glCopyTexSubImage2D - glCullFace - glDeleteLists - glDeleteTextures - glDepthFunc - glDepthMask - glDepthRange - glDisable - glDisableClientState - glDrawArrays - glDrawBuffer - glDrawElements - glDrawPixels - glEdgeFlag - glEdgeFlagPointer - glEdgeFlagv - glEnable - glEnableClientState - glEnd - glEndList - glEvalCoord1d - glEvalCoord1dv - glEvalCoord1f - glEvalCoord1fv - glEvalCoord2d - glEvalCoord2dv - glEvalCoord2f - glEvalCoord2fv - glEvalMesh1 - glEvalMesh2 - glEvalPoint1 - glEvalPoint2 - glFeedbackBuffer - glFinish - glFlush - glFogf - glFogfv - glFogi - glFogiv - glFrontFace - glFrustum - glGenLists - glGenTextures - glGetBooleanv - glGetClipPlane - glGetDoublev - glGetError - glGetFloatv - glGetIntegerv - glGetLightfv - glGetLightiv - glGetMapdv - glGetMapfv - glGetMapiv - glGetMaterialfv - glGetMaterialiv - glGetPixelMapfv - glGetPixelMapuiv - glGetPixelMapusv - glGetPointerv - glGetPolygonStipple - glGetString - glGetTexEnvfv - glGetTexEnviv - glGetTexGendv - glGetTexGenfv - glGetTexGeniv - glGetTexImage - glGetTexLevelParameterfv - glGetTexLevelParameteriv - glGetTexParameterfv - glGetTexParameteriv - glHint - glIndexMask - glIndexPointer - glIndexd - glIndexdv - glIndexf - glIndexfv - glIndexi - glIndexiv - glIndexs - glIndexsv - glIndexub - glIndexubv - glInitNames - glInterleavedArrays - glIsEnabled - glIsList - glIsTexture - glLightModelf - glLightModelfv - glLightModeli - glLightModeliv - glLightf - glLightfv - glLighti - glLightiv - glLineStipple - glLineWidth - glListBase - glLoadIdentity - glLoadMatrixd - glLoadMatrixf - glLoadName - glLogicOp - glMap1d - glMap1f - glMap2d - glMap2f - glMapGrid1d - glMapGrid1f - glMapGrid2d - glMapGrid2f - glMaterialf - glMaterialfv - glMateriali - glMaterialiv - glMatrixMode - glMultMatrixd - glMultMatrixf - glNewList - glNormal3b - glNormal3bv - glNormal3d - glNormal3dv - glNormal3f - glNormal3fv - glNormal3i - glNormal3iv - glNormal3s - glNormal3sv - glNormalPointer - glOrtho - glPassThrough - glPixelMapfv - glPixelMapuiv - glPixelMapusv - glPixelStoref - glPixelStorei - glPixelTransferf - glPixelTransferi - glPixelZoom - glPointSize - glPolygonMode - glPolygonOffset - glPolygonStipple - glPopAttrib - glPopClientAttrib - glPopMatrix - glPopName - glPrioritizeTextures - glPushAttrib - glPushClientAttrib - glPushMatrix - glPushName - glRasterPos2d - glRasterPos2dv - glRasterPos2f - glRasterPos2fv - glRasterPos2i - glRasterPos2iv - glRasterPos2s - glRasterPos2sv - glRasterPos3d - glRasterPos3dv - glRasterPos3f - glRasterPos3fv - glRasterPos3i - glRasterPos3iv - glRasterPos3s - glRasterPos3sv - glRasterPos4d - glRasterPos4dv - glRasterPos4f - glRasterPos4fv - glRasterPos4i - glRasterPos4iv - glRasterPos4s - glRasterPos4sv - glReadBuffer - glReadPixels - glRectd - glRectdv - glRectf - glRectfv - glRecti - glRectiv - glRects - glRectsv - glRenderMode - glRotated - glRotatef - glScaled - glScalef - glScissor - glSelectBuffer - glShadeModel - glStencilFunc - glStencilMask - glStencilOp - glTexCoord1d - glTexCoord1dv - glTexCoord1f - glTexCoord1fv - glTexCoord1i - glTexCoord1iv - glTexCoord1s - glTexCoord1sv - glTexCoord2d - glTexCoord2dv - glTexCoord2f - glTexCoord2fv - glTexCoord2i - glTexCoord2iv - glTexCoord2s - glTexCoord2sv - glTexCoord3d - glTexCoord3dv - glTexCoord3f - glTexCoord3fv - glTexCoord3i - glTexCoord3iv - glTexCoord3s - glTexCoord3sv - glTexCoord4d - glTexCoord4dv - glTexCoord4f - glTexCoord4fv - glTexCoord4i - glTexCoord4iv - glTexCoord4s - glTexCoord4sv - glTexCoordPointer - glTexEnvf - glTexEnvfv - glTexEnvi - glTexEnviv - glTexGend - glTexGendv - glTexGenf - glTexGenfv - glTexGeni - glTexGeniv - glTexImage1D - glTexImage2D - glTexParameterf - glTexParameterfv - glTexParameteri - glTexParameteriv - glTexSubImage1D - glTexSubImage2D - glTranslated - glTranslatef - glVertex2d - glVertex2dv - glVertex2f - glVertex2fv - glVertex2i - glVertex2iv - glVertex2s - glVertex2sv - glVertex3d - glVertex3dv - glVertex3f - glVertex3fv - glVertex3i - glVertex3iv - glVertex3s - glVertex3sv - glVertex4d - glVertex4dv - glVertex4f - glVertex4fv - glVertex4i - glVertex4iv - glVertex4s - glVertex4sv - glVertexPointer - glViewport - wglChoosePixelFormat - wglCopyContext - wglCreateContext - wglCreateLayerContext - wglDeleteContext - wglDescribeLayerPlane - wglDescribePixelFormat - wglGetCurrentContext - wglGetCurrentDC - wglGetLayerPaletteEntries - wglGetPixelFormat - wglGetProcAddress - wglMakeCurrent - wglRealizeLayerPalette - wglSetLayerPaletteEntries - wglSetPixelFormat - wglShareLists - wglSwapBuffers - wglSwapLayerBuffers - wglUseFontBitmapsA - wglUseFontBitmapsW - wglUseFontOutlinesA - wglUseFontOutlinesW diff --git a/mesalib/src/mesa/drivers/windows/gdi/wgl.c b/mesalib/src/mesa/drivers/windows/gdi/wgl.c deleted file mode 100644 index 3458cc9f3..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wgl.c +++ /dev/null @@ -1,689 +0,0 @@ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* - * File name : wgl.c - * WGL stuff. Added by Oleg Letsinsky, ajl@ultersys.ru - * Some things originated from the 3Dfx WGL functions - */ - -/* - * This file contains the implementation of the wgl* functions for - * Mesa on Windows. Since these functions are provided by Windows in - * GDI/OpenGL, we must supply our versions that work with Mesa here. - */ - - -#include <windows.h> - -#include "main/config.h" -#include "glapi/glapi.h" -#include "swrast/swrast.h" -#include "GL/wmesa.h" /* protos for wmesa* functions */ - -/* - * Pixel Format Descriptors - */ - -/* Extend the PFD to include DB flag */ -struct __pixelformat__ -{ - PIXELFORMATDESCRIPTOR pfd; - GLboolean doubleBuffered; -}; - - - -/* These are the PFD's supported by this driver. */ -struct __pixelformat__ pfd[] = -{ -#if 0 - /* Double Buffer, alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 8, 24, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_TRUE - }, - /* Single Buffer, alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 8, 24, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_FALSE - }, -#endif - /* Double Buffer, no alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 0, 0, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_TRUE - }, - /* Single Buffer, no alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 0, 0, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_FALSE - }, -}; - -int npfd = sizeof(pfd) / sizeof(pfd[0]); - - -/* - * Contexts - */ - -typedef struct { - WMesaContext ctx; -} MesaWglCtx; - -#define MESAWGL_CTX_MAX_COUNT 20 - -static MesaWglCtx wgl_ctx[MESAWGL_CTX_MAX_COUNT]; - -static unsigned ctx_count = 0; -static int ctx_current = -1; -static unsigned curPFD = 0; - -static HDC CurrentHDC = 0; - - -WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc) -{ - int i = 0; - if (!ctx_count) { - for(i=0;i<MESAWGL_CTX_MAX_COUNT;i++) { - wgl_ctx[i].ctx = NULL; - } - } - for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == NULL ) { - wgl_ctx[i].ctx = - WMesaCreateContext(hdc, NULL, (GLboolean)GL_TRUE, - (GLboolean) (pfd[curPFD-1].doubleBuffered ? - GL_TRUE : GL_FALSE), - (GLboolean)(pfd[curPFD-1].pfd.cAlphaBits ? - GL_TRUE : GL_FALSE) ); - if (wgl_ctx[i].ctx == NULL) - break; - ctx_count++; - return ((HGLRC)wgl_ctx[i].ctx); - } - } - SetLastError(0); - return(NULL); -} - -WINGDIAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc) -{ - int i; - for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ){ - WMesaMakeCurrent((WMesaContext) hglrc, NULL); - WMesaDestroyContext(wgl_ctx[i].ctx); - wgl_ctx[i].ctx = NULL; - ctx_count--; - return(TRUE); - } - } - SetLastError(0); - return(FALSE); -} - -WINGDIAPI HGLRC GLAPIENTRY wglGetCurrentContext(VOID) -{ - if (ctx_current < 0) - return 0; - else - return (HGLRC) wgl_ctx[ctx_current].ctx; -} - -WINGDIAPI HDC GLAPIENTRY wglGetCurrentDC(VOID) -{ - return CurrentHDC; -} - -WINGDIAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc, HGLRC hglrc) -{ - int i; - - CurrentHDC = hdc; - - if (!hdc || !hglrc) { - WMesaMakeCurrent(NULL, NULL); - ctx_current = -1; - return TRUE; - } - - for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ) { - WMesaMakeCurrent( (WMesaContext) hglrc, hdc ); - ctx_current = i; - return TRUE; - } - } - return FALSE; -} - - -WINGDIAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc, - CONST - PIXELFORMATDESCRIPTOR *ppfd) -{ - int i,best = -1,bestdelta = 0x7FFFFFFF,delta; - (void) hdc; - - if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) - { - SetLastError(0); - return(0); - } - for(i = 0; i < npfd;i++) - { - delta = 0; - if( - (ppfd->dwFlags & PFD_DRAW_TO_WINDOW) && - !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW)) - continue; - if( - (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) && - !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP)) - continue; - if( - (ppfd->dwFlags & PFD_SUPPORT_GDI) && - !(pfd[i].pfd.dwFlags & PFD_SUPPORT_GDI)) - continue; - if( - (ppfd->dwFlags & PFD_SUPPORT_OPENGL) && - !(pfd[i].pfd.dwFlags & PFD_SUPPORT_OPENGL)) - continue; - if( - !(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) && - ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != - (pfd[i].pfd.dwFlags & PFD_DOUBLEBUFFER))) - continue; - if( - !(ppfd->dwFlags & PFD_STEREO_DONTCARE) && - ((ppfd->dwFlags & PFD_STEREO) != - (pfd[i].pfd.dwFlags & PFD_STEREO))) - continue; - if(ppfd->iPixelType != pfd[i].pfd.iPixelType) - delta++; - if(ppfd->cAlphaBits != pfd[i].pfd.cAlphaBits) - delta++; - if(delta < bestdelta) - { - best = i + 1; - bestdelta = delta; - if(bestdelta == 0) - break; - } - } - if(best == -1) - { - SetLastError(0); - return(0); - } - return(best); -} - -WINGDIAPI int GLAPIENTRY wglDescribePixelFormat(HDC hdc, - int iPixelFormat, - UINT nBytes, - LPPIXELFORMATDESCRIPTOR ppfd) -{ - (void) hdc; - - if(ppfd == NULL) - return(npfd); - if(iPixelFormat < 1 || iPixelFormat > npfd || - nBytes != sizeof(PIXELFORMATDESCRIPTOR)) - { - SetLastError(0); - return(0); - } - *ppfd = pfd[iPixelFormat - 1].pfd; - return(npfd); -} - -WINGDIAPI PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc) -{ - PROC p = (PROC) _glapi_get_proc_address((const char *) lpszProc); - if (p) - return p; - - SetLastError(0); - return(NULL); -} - -WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc) -{ - (void) hdc; - if(curPFD == 0) { - SetLastError(0); - return(0); - } - return(curPFD); -} - -WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat, - const PIXELFORMATDESCRIPTOR *ppfd) -{ - (void) hdc; - - /* SetPixelFormat (hence wglSetPixelFormat) must not touch ppfd, per - * http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx - */ - (void) ppfd; - - if(iPixelFormat < 1 || iPixelFormat > npfd) { - SetLastError(0); - return(FALSE); - } - curPFD = iPixelFormat; - return(TRUE); -} - -WINGDIAPI BOOL GLAPIENTRY wglSwapBuffers(HDC hdc) -{ - WMesaSwapBuffers(hdc); - return TRUE; -} - -static FIXED FixedFromDouble(double d) -{ - long l = (long) (d * 65536L); - return *(FIXED *) (void *) &l; -} - - -/* -** This is cribbed from FX/fxwgl.c, and seems to implement support -** for bitmap fonts where the wglUseFontBitmapsA() code implements -** support for outline fonts. In combination they hopefully give -** fairly generic support for fonts. -*/ -static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, - DWORD numChars, DWORD listBase) -{ -#define VERIFY(a) (void)(a) - - TEXTMETRIC metric; - BITMAPINFO *dibInfo; - HDC bitDevice; - COLORREF tempColor; - int i; - - VERIFY(GetTextMetrics(fontDevice, &metric)); - - dibInfo = calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1); - dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - dibInfo->bmiHeader.biPlanes = 1; - dibInfo->bmiHeader.biBitCount = 1; - dibInfo->bmiHeader.biCompression = BI_RGB; - - bitDevice = CreateCompatibleDC(fontDevice); - - /* Swap fore and back colors so the bitmap has the right polarity */ - tempColor = GetBkColor(bitDevice); - SetBkColor(bitDevice, GetTextColor(bitDevice)); - SetTextColor(bitDevice, tempColor); - - /* Place chars based on base line */ - VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0); - - for(i = 0; i < (int)numChars; i++) { - SIZE size; - char curChar; - int charWidth,charHeight,bmapWidth,bmapHeight,numBytes,res; - HBITMAP bitObject; - HGDIOBJ origBmap; - unsigned char *bmap; - - curChar = (char)(i + firstChar); - - /* Find how high/wide this character is */ - VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size)); - - /* Create the output bitmap */ - charWidth = size.cx; - charHeight = size.cy; - /* Round up to the next multiple of 32 bits */ - bmapWidth = ((charWidth + 31) / 32) * 32; - bmapHeight = charHeight; - bitObject = CreateCompatibleBitmap(bitDevice, - bmapWidth, - bmapHeight); - /* VERIFY(bitObject); */ - - /* Assign the output bitmap to the device */ - origBmap = SelectObject(bitDevice, bitObject); - (void) VERIFY(origBmap); - - VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) ); - - /* Use our source font on the device */ - VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT))); - - /* Draw the character */ - VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1)); - - /* Unselect our bmap object */ - VERIFY(SelectObject(bitDevice, origBmap)); - - /* Convert the display dependant representation to a 1 bit deep DIB */ - numBytes = (bmapWidth * bmapHeight) / 8; - bmap = malloc(numBytes); - dibInfo->bmiHeader.biWidth = bmapWidth; - dibInfo->bmiHeader.biHeight = bmapHeight; - res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap, - dibInfo, - DIB_RGB_COLORS); - /* VERIFY(res); */ - - /* Create the GL object */ - glNewList(i + listBase, GL_COMPILE); - glBitmap(bmapWidth, bmapHeight, 0.0, (GLfloat)metric.tmDescent, - (GLfloat)charWidth, 0.0, - bmap); - glEndList(); - /* CheckGL(); */ - - /* Destroy the bmap object */ - DeleteObject(bitObject); - - /* Deallocate the bitmap data */ - free(bmap); - } - - /* Destroy the DC */ - VERIFY(DeleteDC(bitDevice)); - - free(dibInfo); - - return TRUE; -#undef VERIFY -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first, - DWORD count, DWORD listBase) -{ - int i; - GLuint font_list; - DWORD size; - GLYPHMETRICS gm; - HANDLE hBits; - LPSTR lpBits; - MAT2 mat; - int success = TRUE; - - if (count == 0) - return FALSE; - - font_list = listBase; - - mat.eM11 = FixedFromDouble(1); - mat.eM12 = FixedFromDouble(0); - mat.eM21 = FixedFromDouble(0); - mat.eM22 = FixedFromDouble(-1); - - memset(&gm,0,sizeof(gm)); - - /* - ** If we can't get the glyph outline, it may be because this is a fixed - ** font. Try processing it that way. - */ - if( GetGlyphOutline(hdc, first, GGO_BITMAP, &gm, 0, NULL, &mat) - == GDI_ERROR ) { - return wglUseFontBitmaps_FX( hdc, first, count, listBase ); - } - - /* - ** Otherwise process all desired characters. - */ - for (i = 0; i < (int)count; i++) { - DWORD err; - - glNewList( font_list+i, GL_COMPILE ); - - /* allocate space for the bitmap/outline */ - size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, - &gm, 0, NULL, &mat); - if (size == GDI_ERROR) { - glEndList( ); - err = GetLastError(); - success = FALSE; - continue; - } - - hBits = GlobalAlloc(GHND, size+1); - lpBits = GlobalLock(hBits); - - err = - GetGlyphOutline(hdc, /* handle to device context */ - first + i, /* character to query */ - GGO_BITMAP, /* format of data to return */ - &gm, /* ptr to structure for metrics*/ - size, /* size of buffer for data */ - lpBits, /* pointer to buffer for data */ - &mat /* pointer to transformation */ - /* matrix structure */ - ); - - if (err == GDI_ERROR) { - GlobalUnlock(hBits); - GlobalFree(hBits); - - glEndList( ); - err = GetLastError(); - success = FALSE; - continue; - } - - glBitmap(gm.gmBlackBoxX,gm.gmBlackBoxY, - (GLfloat)-gm.gmptGlyphOrigin.x, - (GLfloat)gm.gmptGlyphOrigin.y, - (GLfloat)gm.gmCellIncX, - (GLfloat)gm.gmCellIncY, - (const GLubyte * )lpBits); - - GlobalUnlock(hBits); - GlobalFree(hBits); - - glEndList( ); - } - - return success; -} - -WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1, - HGLRC hglrc2) -{ - WMesaShareLists((WMesaContext)hglrc1, (WMesaContext)hglrc2); - return(TRUE); -} - - - -/* NOT IMPLEMENTED YET */ -WINGDIAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc, - HGLRC hglrcDst, - UINT mask) -{ - (void) hglrcSrc; (void) hglrcDst; (void) mask; - return(FALSE); -} - -WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc, - int iLayerPlane) -{ - SetLastError(0); - if (iLayerPlane == 0) - return wglCreateContext( hdc ); - return(NULL); -} - - -WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase) -{ - (void) hdc; (void) first; (void) count; (void) listBase; - return FALSE; -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase, - FLOAT deviation, - FLOAT extrusion, - int format, - LPGLYPHMETRICSFLOAT lpgmf) -{ - (void) hdc; (void) first; (void) count; - (void) listBase; (void) deviation; (void) extrusion; (void) format; - (void) lpgmf; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase, - FLOAT deviation, - FLOAT extrusion, - int format, - LPGLYPHMETRICSFLOAT lpgmf) -{ - (void) hdc; (void) first; (void) count; - (void) listBase; (void) deviation; (void) extrusion; (void) format; - (void) lpgmf; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglDescribeLayerPlane(HDC hdc, - int iPixelFormat, - int iLayerPlane, - UINT nBytes, - LPLAYERPLANEDESCRIPTOR plpd) -{ - (void) hdc; (void) iPixelFormat; (void) iLayerPlane; - (void) nBytes; (void) plpd; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC hdc, - int iLayerPlane, - int iStart, - int cEntries, - CONST COLORREF *pcr) -{ - (void) hdc; (void) iLayerPlane; (void) iStart; - (void) cEntries; (void) pcr; - SetLastError(0); - return(0); -} - -WINGDIAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC hdc, - int iLayerPlane, - int iStart, - int cEntries, - COLORREF *pcr) -{ - (void) hdc; (void) iLayerPlane; (void) iStart; (void) cEntries; (void) pcr; - SetLastError(0); - return(0); -} - -WINGDIAPI BOOL GLAPIENTRY wglRealizeLayerPalette(HDC hdc, - int iLayerPlane, - BOOL bRealize) -{ - (void) hdc; (void) iLayerPlane; (void) bRealize; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc, - UINT fuPlanes) -{ - (void) hdc; (void) fuPlanes; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI const char * GLAPIENTRY wglGetExtensionsStringARB(HDC hdc) -{ - return "WGL_ARB_extensions_string"; -} diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c deleted file mode 100644 index c1a9c28b1..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c +++ /dev/null @@ -1,791 +0,0 @@ -/* - * Windows (Win32/Win64) device driver for Mesa - * - */ - -#include "wmesadef.h" -#include "colors.h" -#include "GL/wmesa.h" -#include <winuser.h> -#include "main/context.h" -#include "main/api_exec.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/macros.h" -#include "main/version.h" -#include "main/vtxfmt.h" -#include "drivers/common/driverfuncs.h" -#include "drivers/common/meta.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast/s_renderbuffer.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - - -/* linked list of our Framebuffers (windows) */ -static WMesaFramebuffer FirstFramebuffer = NULL; - - -/** - * Create a new WMesaFramebuffer object which will correspond to the - * given HDC (Window handle). - */ -static WMesaFramebuffer -wmesa_new_framebuffer(HDC hdc, struct gl_config *visual) -{ - WMesaFramebuffer pwfb - = malloc(sizeof(struct wmesa_framebuffer)); - if (pwfb) { - _mesa_initialize_window_framebuffer(&pwfb->Base, visual); - pwfb->hDC = hdc; - /* insert at head of list */ - pwfb->next = FirstFramebuffer; - FirstFramebuffer = pwfb; - } - return pwfb; -} - -/** - * Given an hdc, free the corresponding WMesaFramebuffer - */ -static void -wmesa_free_framebuffer(HDC hdc) -{ - WMesaFramebuffer pwfb, prev; - for (pwfb = FirstFramebuffer; pwfb; pwfb = pwfb->next) { - if (pwfb->hDC == hdc) - break; - prev = pwfb; - } - if (pwfb) { - struct gl_framebuffer *fb; - if (pwfb == FirstFramebuffer) - FirstFramebuffer = pwfb->next; - else - prev->next = pwfb->next; - fb = &pwfb->Base; - _mesa_reference_framebuffer(&fb, NULL); - } -} - -/** - * Given an hdc, return the corresponding WMesaFramebuffer - */ -static WMesaFramebuffer -wmesa_lookup_framebuffer(HDC hdc) -{ - WMesaFramebuffer pwfb; - for (pwfb = FirstFramebuffer; pwfb; pwfb = pwfb->next) { - if (pwfb->hDC == hdc) - return pwfb; - } - return NULL; -} - - -/** - * Given a struct gl_framebuffer, return the corresponding WMesaFramebuffer. - */ -static WMesaFramebuffer wmesa_framebuffer(struct gl_framebuffer *fb) -{ - return (WMesaFramebuffer) fb; -} - - -/** - * Given a struct gl_context, return the corresponding WMesaContext. - */ -static WMesaContext wmesa_context(const struct gl_context *ctx) -{ - return (WMesaContext) ctx; -} - - -/* - * Every driver should implement a GetString function in order to - * return a meaningful GL_RENDERER string. - */ -static const GLubyte *wmesa_get_string(struct gl_context *ctx, GLenum name) -{ - return (name == GL_RENDERER) ? - (GLubyte *) "Mesa Windows GDI Driver" : NULL; -} - - -/* - * Determine the pixel format based on the pixel size. - */ -static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC) -{ - pwfb->cColorBits = GetDeviceCaps(hDC, BITSPIXEL); - - /* Only 16 and 32 bit targets are supported now */ - assert(pwfb->cColorBits == 0 || - pwfb->cColorBits == 16 || - pwfb->cColorBits == 24 || - pwfb->cColorBits == 32); - - switch(pwfb->cColorBits){ - case 8: - pwfb->pixelformat = PF_INDEX8; - break; - case 16: - pwfb->pixelformat = PF_5R6G5B; - break; - case 24: - case 32: - pwfb->pixelformat = PF_8R8G8B; - break; - default: - pwfb->pixelformat = PF_BADFORMAT; - } -} - - -/** - * Create DIB for back buffer. - * We write into this memory with the span routines and then blit it - * to the window on a buffer swap. - */ -static BOOL wmCreateBackingStore(WMesaFramebuffer pwfb, long lxSize, long lySize) -{ - LPBITMAPINFO pbmi = &(pwfb->bmi); - HDC hic; - - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biWidth = lxSize; - pbmi->bmiHeader.biHeight= -lySize; - pbmi->bmiHeader.biPlanes = 1; - pbmi->bmiHeader.biBitCount = GetDeviceCaps(pwfb->hDC, BITSPIXEL); - pbmi->bmiHeader.biCompression = BI_RGB; - pbmi->bmiHeader.biSizeImage = 0; - pbmi->bmiHeader.biXPelsPerMeter = 0; - pbmi->bmiHeader.biYPelsPerMeter = 0; - pbmi->bmiHeader.biClrUsed = 0; - pbmi->bmiHeader.biClrImportant = 0; - - pwfb->cColorBits = pbmi->bmiHeader.biBitCount; - pwfb->ScanWidth = (lxSize * (pwfb->cColorBits / 8) + 3) & ~3; - - hic = CreateIC("display", NULL, NULL, NULL); - pwfb->dib_hDC = CreateCompatibleDC(hic); - - pwfb->hbmDIB = CreateDIBSection(hic, - &pwfb->bmi, - DIB_RGB_COLORS, - (void **)&(pwfb->pbPixels), - 0, - 0); - pwfb->hOldBitmap = SelectObject(pwfb->dib_hDC, pwfb->hbmDIB); - - DeleteDC(hic); - - wmSetPixelFormat(pwfb, pwfb->hDC); - return TRUE; -} - - -static void wmDeleteBackingStore(WMesaFramebuffer pwfb) -{ - if (pwfb->hbmDIB) { - SelectObject(pwfb->dib_hDC, pwfb->hOldBitmap); - DeleteDC(pwfb->dib_hDC); - DeleteObject(pwfb->hbmDIB); - } -} - - -/** - * Find the width and height of the window named by hdc. - */ -static void -get_window_size(HDC hdc, GLuint *width, GLuint *height) -{ - if (WindowFromDC(hdc)) { - RECT rect; - GetClientRect(WindowFromDC(hdc), &rect); - *width = rect.right - rect.left; - *height = rect.bottom - rect.top; - } - else { /* Memory context */ - /* From contributed code - use the size of the desktop - * for the size of a memory context (?) */ - *width = GetDeviceCaps(hdc, HORZRES); - *height = GetDeviceCaps(hdc, VERTRES); - } -} - - -static void -wmesa_get_buffer_size(struct gl_framebuffer *buffer, GLuint *width, GLuint *height) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(buffer); - get_window_size(pwfb->hDC, width, height); -} - - -static void wmesa_flush(struct gl_context *ctx) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->WinSysDrawBuffer); - - if (ctx->Visual.doubleBufferMode == 1) { - BitBlt(pwfb->hDC, 0, 0, pwfb->Base.Width, pwfb->Base.Height, - pwfb->dib_hDC, 0, 0, SRCCOPY); - } - else { - /* Do nothing for single buffer */ - } -} - - -/**********************************************************************/ -/***** CLEAR Functions *****/ -/**********************************************************************/ - -/* - * Clear the color/depth/stencil buffers. - */ -static void clear(struct gl_context *ctx, GLbitfield mask) -{ -#define FLIP(Y) (ctx->DrawBuffer->Height - (Y) - 1) - const GLint x = ctx->DrawBuffer->_Xmin; - const GLint y = ctx->DrawBuffer->_Ymin; - const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; - - WMesaContext pwc = wmesa_context(ctx); - WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); - int done = 0; - - /* Let swrast do all the work if the masks are not set to - * clear all channels. */ - if (!ctx->Color.ColorMask[0][0] || - !ctx->Color.ColorMask[0][1] || - !ctx->Color.ColorMask[0][2] || - !ctx->Color.ColorMask[0][3]) { - _swrast_Clear(ctx, mask); - return; - } - - if (mask & BUFFER_BITS_COLOR) { - /* setup the clearing color */ - const union gl_color_union color = ctx->Color.ClearColor; - GLubyte col[3]; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], color.f[0]); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], color.f[1]); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], color.f[2]); - pwc->clearColorRef = RGB(col[0], col[1], col[2]); - DeleteObject(pwc->clearPen); - DeleteObject(pwc->clearBrush); - pwc->clearPen = CreatePen(PS_SOLID, 1, pwc->clearColorRef); - pwc->clearBrush = CreateSolidBrush(pwc->clearColorRef); - } - - /* Back buffer */ - if (mask & BUFFER_BIT_BACK_LEFT) { - - int i, rowSize; - UINT bytesPerPixel = pwfb->cColorBits / 8; - LPBYTE lpb, clearRow; - LPWORD lpw; - BYTE bColor; - WORD wColor; - BYTE r, g, b; - DWORD dwColor; - LPDWORD lpdw; - - /* Try for a fast clear - clearing entire buffer with a single - * byte value. */ - if (width == ctx->DrawBuffer->Width && - height == ctx->DrawBuffer->Height) { /* entire buffer */ - /* Now check for an easy clear value */ - switch (bytesPerPixel) { - case 1: - bColor = BGR8(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - memset(pwfb->pbPixels, bColor, - pwfb->ScanWidth * height); - done = 1; - break; - case 2: - wColor = BGR16(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - if (((wColor >> 8) & 0xff) == (wColor & 0xff)) { - memset(pwfb->pbPixels, wColor & 0xff, - pwfb->ScanWidth * height); - done = 1; - } - break; - case 3: - /* fall through */ - case 4: - if (GetRValue(pwc->clearColorRef) == - GetGValue(pwc->clearColorRef) && - GetRValue(pwc->clearColorRef) == - GetBValue(pwc->clearColorRef)) { - memset(pwfb->pbPixels, - GetRValue(pwc->clearColorRef), - pwfb->ScanWidth * height); - done = 1; - } - break; - default: - break; - } - } /* all */ - - if (!done) { - /* Need to clear a row at a time. Begin by setting the first - * row in the area to be cleared to the clear color. */ - - clearRow = pwfb->pbPixels + - pwfb->ScanWidth * FLIP(y) + - bytesPerPixel * x; - switch (bytesPerPixel) { - case 1: - lpb = clearRow; - bColor = BGR8(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - memset(lpb, bColor, width); - break; - case 2: - lpw = (LPWORD)clearRow; - wColor = BGR16(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - for (i=0; i<width; i++) - *lpw++ = wColor; - break; - case 3: - lpb = clearRow; - r = GetRValue(pwc->clearColorRef); - g = GetGValue(pwc->clearColorRef); - b = GetBValue(pwc->clearColorRef); - for (i=0; i<width; i++) { - *lpb++ = b; - *lpb++ = g; - *lpb++ = r; - } - break; - case 4: - lpdw = (LPDWORD)clearRow; - dwColor = BGR32(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - for (i=0; i<width; i++) - *lpdw++ = dwColor; - break; - default: - break; - } /* switch */ - - /* copy cleared row to other rows in buffer */ - lpb = clearRow - pwfb->ScanWidth; - rowSize = width * bytesPerPixel; - for (i=1; i<height; i++) { - memcpy(lpb, clearRow, rowSize); - lpb -= pwfb->ScanWidth; - } - } /* not done */ - mask &= ~BUFFER_BIT_BACK_LEFT; - } /* back buffer */ - - /* front buffer */ - if (mask & BUFFER_BIT_FRONT_LEFT) { - HDC DC = pwc->hDC; - HPEN Old_Pen = SelectObject(DC, pwc->clearPen); - HBRUSH Old_Brush = SelectObject(DC, pwc->clearBrush); - Rectangle(DC, - x, - FLIP(y) + 1, - x + width + 1, - FLIP(y) - height + 1); - SelectObject(DC, Old_Pen); - SelectObject(DC, Old_Brush); - mask &= ~BUFFER_BIT_FRONT_LEFT; - } /* front buffer */ - - /* Call swrast if there is anything left to clear (like DEPTH) */ - if (mask) - _swrast_Clear(ctx, mask); - -#undef FLIP -} - - - -/**********************************************************************/ -/***** BUFFER Functions *****/ -/**********************************************************************/ - - - - -static void -wmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) -{ - _mesa_delete_renderbuffer(ctx, rb); -} - - -/** - * This is called by Mesa whenever it determines that the window size - * has changed. Do whatever's needed to cope with that. - */ -static GLboolean -wmesa_renderbuffer_storage(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, - GLuint height) -{ - rb->Width = width; - rb->Height = height; - return GL_TRUE; -} - - -/** - * Called by ctx->Driver.ResizeBuffers() - * Resize the front/back colorbuffers to match the latest window size. - */ -static void -wmesa_resize_buffers(struct gl_context *ctx, struct gl_framebuffer *buffer, - GLuint width, GLuint height) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(buffer); - - if (pwfb->Base.Width != width || pwfb->Base.Height != height) { - /* Realloc back buffer */ - if (ctx->Visual.doubleBufferMode == 1) { - wmDeleteBackingStore(pwfb); - wmCreateBackingStore(pwfb, width, height); - } - } - _mesa_resize_framebuffer(ctx, buffer, width, height); -} - - -/** - * Called by glViewport. - * This is a good time for us to poll the current window size and adjust - * our renderbuffers to match the current window size. - * Remember, we have no opportunity to respond to conventional - * resize events since the driver has no event loop. - * Thus, we poll. - * MakeCurrent also ends up making a call here, so that ensures - * we get the viewport set correctly, even if the app does not call - * glViewport and relies on the defaults. - */ -static void wmesa_viewport(struct gl_context *ctx) -{ - GLuint new_width, new_height; - - wmesa_get_buffer_size(ctx->WinSysDrawBuffer, &new_width, &new_height); - - /** - * Resize buffers if the window size changed. - */ - wmesa_resize_buffers(ctx, ctx->WinSysDrawBuffer, new_width, new_height); - ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ -} - - - - -/** - * Called when the driver should update it's state, based on the new_state - * flags. - */ -static void wmesa_update_state(struct gl_context *ctx, GLuint new_state) -{ - _swrast_InvalidateState(ctx, new_state); - _swsetup_InvalidateState(ctx, new_state); - _vbo_InvalidateState(ctx, new_state); - _tnl_InvalidateState(ctx, new_state); - - /* TODO - This code is not complete yet because I - * don't know what to do for all state updates. - */ - - if (new_state & _NEW_BUFFERS) { - } -} - - - - - -/**********************************************************************/ -/***** WMESA Functions *****/ -/**********************************************************************/ - -WMesaContext WMesaCreateContext(HDC hDC, - HPALETTE* Pal, - GLboolean rgb_flag, - GLboolean db_flag, - GLboolean alpha_flag) -{ - WMesaContext c; - struct dd_function_table functions; - GLint red_bits, green_bits, blue_bits, alpha_bits; - struct gl_context *ctx; - struct gl_config *visual; - - (void) Pal; - - /* Indexed mode not supported */ - if (!rgb_flag) - return NULL; - - /* Allocate wmesa context */ - c = CALLOC_STRUCT(wmesa_context); - if (!c) - return NULL; - -#if 0 - /* I do not understand this contributed code */ - /* Support memory and device contexts */ - if(WindowFromDC(hDC) != NULL) { - c->hDC = GetDC(WindowFromDC(hDC)); /* huh ???? */ - } - else { - c->hDC = hDC; - } -#else - c->hDC = hDC; -#endif - - /* Get data for visual */ - /* Dealing with this is actually a bit of overkill because Mesa will end - * up treating all color component size requests less than 8 by using - * a single byte per channel. In addition, the interface to the span - * routines passes colors as an entire byte per channel anyway, so there - * is nothing to be saved by telling the visual to be 16 bits if the device - * is 16 bits. That is, Mesa is going to compute colors down to 8 bits per - * channel anyway. - * But we go through the motions here anyway. - */ - switch (GetDeviceCaps(c->hDC, BITSPIXEL)) { - case 16: - red_bits = green_bits = blue_bits = 5; - alpha_bits = 0; - break; - default: - red_bits = green_bits = blue_bits = 8; - alpha_bits = 8; - break; - } - /* Create visual based on flags */ - visual = _mesa_create_visual(db_flag, /* db_flag */ - GL_FALSE, /* stereo */ - red_bits, green_bits, blue_bits, /* color RGB */ - alpha_flag ? alpha_bits : 0, /* color A */ - DEFAULT_SOFTWARE_DEPTH_BITS, /* depth_bits */ - 8, /* stencil_bits */ - 16,16,16, /* accum RGB */ - alpha_flag ? 16 : 0, /* accum A */ - 1); /* num samples */ - - if (!visual) { - free(c); - return NULL; - } - - /* Set up driver functions */ - _mesa_init_driver_functions(&functions); - functions.GetString = wmesa_get_string; - functions.UpdateState = wmesa_update_state; - functions.Flush = wmesa_flush; - functions.Clear = clear; - functions.ResizeBuffers = wmesa_resize_buffers; - functions.Viewport = wmesa_viewport; - - /* initialize the Mesa context data */ - ctx = &c->gl_ctx; - _mesa_initialize_context(ctx, API_OPENGL_COMPAT, visual, - NULL, &functions); - - /* visual no longer needed - it was copied by _mesa_initialize_context() */ - _mesa_destroy_visual(visual); - - _mesa_enable_sw_extensions(ctx); - - _mesa_meta_init(ctx); - - /* Initialize the software rasterizer and helper modules. */ - if (!_swrast_CreateContext(ctx) || - !_vbo_CreateContext(ctx) || - !_tnl_CreateContext(ctx) || - !_swsetup_CreateContext(ctx)) { - _mesa_free_context_data(ctx); - free(c); - return NULL; - } - _swsetup_Wakeup(ctx); - TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; - - _mesa_compute_version(ctx); - - /* Exec table initialization requires the version to be computed */ - _mesa_initialize_dispatch_tables(ctx); - _mesa_initialize_vbo_vtxfmt(ctx); - - return c; -} - - -void WMesaDestroyContext( WMesaContext pwc ) -{ - struct gl_context *ctx = &pwc->gl_ctx; - WMesaFramebuffer pwfb; - GET_CURRENT_CONTEXT(cur_ctx); - - if (cur_ctx == ctx) { - /* unbind current if deleting current context */ - WMesaMakeCurrent(NULL, NULL); - } - - /* clean up frame buffer resources */ - pwfb = wmesa_lookup_framebuffer(pwc->hDC); - if (pwfb) { - if (ctx->Visual.doubleBufferMode == 1) - wmDeleteBackingStore(pwfb); - wmesa_free_framebuffer(pwc->hDC); - } - - /* Release for device, not memory contexts */ - if (WindowFromDC(pwc->hDC) != NULL) - { - ReleaseDC(WindowFromDC(pwc->hDC), pwc->hDC); - } - DeleteObject(pwc->clearPen); - DeleteObject(pwc->clearBrush); - - _mesa_meta_free(ctx); - - _swsetup_DestroyContext(ctx); - _tnl_DestroyContext(ctx); - _vbo_DestroyContext(ctx); - _swrast_DestroyContext(ctx); - - _mesa_free_context_data(ctx); - free(pwc); -} - - -/** - * Create a new color renderbuffer. - */ -static struct gl_renderbuffer * -wmesa_new_renderbuffer(void) -{ - struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); - if (!rb) - return NULL; - - _mesa_init_renderbuffer(rb, (GLuint)0); - - rb->_BaseFormat = GL_RGBA; - rb->InternalFormat = GL_RGBA; - rb->Delete = wmesa_delete_renderbuffer; - rb->AllocStorage = wmesa_renderbuffer_storage; - return rb; -} - - -void WMesaMakeCurrent(WMesaContext c, HDC hdc) -{ - WMesaFramebuffer pwfb; - - { - /* return if already current */ - GET_CURRENT_CONTEXT(ctx); - WMesaContext pwc = wmesa_context(ctx); - if (pwc && c == pwc && pwc->hDC == hdc) - return; - } - - pwfb = wmesa_lookup_framebuffer(hdc); - - /* Lazy creation of framebuffers */ - if (c && !pwfb && hdc) { - struct gl_renderbuffer *rb; - struct gl_config *visual = &c->gl_ctx.Visual; - GLuint width, height; - - get_window_size(hdc, &width, &height); - - c->clearPen = CreatePen(PS_SOLID, 1, 0); - c->clearBrush = CreateSolidBrush(0); - - pwfb = wmesa_new_framebuffer(hdc, visual); - - /* Create back buffer if double buffered */ - if (visual->doubleBufferMode == 1) { - wmCreateBackingStore(pwfb, width, height); - } - - /* make render buffers */ - if (visual->doubleBufferMode == 1) { - rb = wmesa_new_renderbuffer(); - _mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb); - } - rb = wmesa_new_renderbuffer(); - _mesa_add_renderbuffer(&pwfb->Base, BUFFER_FRONT_LEFT, rb); - - /* Let Mesa own the Depth, Stencil, and Accum buffers */ - _swrast_add_soft_renderbuffers(&pwfb->Base, - GL_FALSE, /* color */ - visual->depthBits > 0, - visual->stencilBits > 0, - visual->accumRedBits > 0, - visual->alphaBits >0, - GL_FALSE); - } - - if (c && pwfb) - _mesa_make_current(&c->gl_ctx, &pwfb->Base, &pwfb->Base); - else - _mesa_make_current(NULL, NULL, NULL); -} - - -void WMesaSwapBuffers( HDC hdc ) -{ - GET_CURRENT_CONTEXT(ctx); - WMesaContext pwc = wmesa_context(ctx); - WMesaFramebuffer pwfb = wmesa_lookup_framebuffer(hdc); - - if (!pwfb) { - _mesa_problem(NULL, "wmesa: swapbuffers on unknown hdc"); - return; - } - - /* If we're swapping the buffer associated with the current context - * we have to flush any pending rendering commands first. - */ - if (pwc->hDC == hdc) { - _mesa_notifySwapBuffers(ctx); - - BitBlt(pwfb->hDC, 0, 0, pwfb->Base.Width, pwfb->Base.Height, - pwfb->dib_hDC, 0, 0, SRCCOPY); - } - else { - /* XXX for now only allow swapping current window */ - _mesa_problem(NULL, "wmesa: can't swap non-current window"); - } -} - -void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx) -{ - _mesa_share_state(&ctx->gl_ctx, &ctx_to_share->gl_ctx); -} - diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h b/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h deleted file mode 100644 index 9fda88390..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef WMESADEF_H -#define WMESADEF_H - -#include <windows.h> - -#include "main/context.h" - - -/** - * The Windows Mesa rendering context, derived from struct gl_context. - */ -struct wmesa_context { - struct gl_context gl_ctx; /* The core GL/Mesa context */ - HDC hDC; - COLORREF clearColorRef; - HPEN clearPen; - HBRUSH clearBrush; -}; - - -/** - * Windows framebuffer, derived from gl_framebuffer - */ -struct wmesa_framebuffer -{ - struct gl_framebuffer Base; - HDC hDC; - int pixelformat; - GLuint ScanWidth; - int cColorBits; - /* back buffer DIB fields */ - HDC dib_hDC; - BITMAPINFO bmi; - HBITMAP hbmDIB; - HBITMAP hOldBitmap; - PBYTE pbPixels; - struct wmesa_framebuffer *next; -}; - -typedef struct wmesa_framebuffer *WMesaFramebuffer; - - -#endif /* WMESADEF_H */ |