From: Kristian Høgsberg Date: Mon, 26 Apr 2010 13:53:23 +0000 (-0400) Subject: mesa: Move drawtex functionality to main/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1904ba7936eb5a3fa76875a498eb54f3bd5f90a5;p=mesa.git mesa: Move drawtex functionality to main/ --- diff --git a/src/mesa/es/main/drawtex.c b/src/mesa/es/main/drawtex.c deleted file mode 100644 index 42f44093972..00000000000 --- a/src/mesa/es/main/drawtex.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2009 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "drawtex.h" -#include "main/state.h" -#include "main/imports.h" - -#include "main/dispatch.h" - - -#if FEATURE_OES_draw_texture - - -static void -draw_texture(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, - GLfloat width, GLfloat height) -{ - if (!ctx->Extensions.OES_draw_texture) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawTex(unsupported)"); - return; - } - if (width <= 0.0f || height <= 0.0f) { - _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTex(width or height <= 0)"); - return; - } - - if (ctx->NewState) - _mesa_update_state(ctx); - - ASSERT(ctx->Driver.DrawTex); - ctx->Driver.DrawTex(ctx, x, y, z, width, height); -} - - -void GLAPIENTRY -_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, x, y, z, width, height); -} - - -void GLAPIENTRY -_mesa_DrawTexfv(const GLfloat *coords) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, coords[0], coords[1], coords[2], coords[3], coords[4]); -} - - -void GLAPIENTRY -_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, - (GLfloat) width, (GLfloat) height); -} - - -void GLAPIENTRY -_mesa_DrawTexiv(const GLint *coords) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], - (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); -} - - -void GLAPIENTRY -_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, - (GLfloat) width, (GLfloat) height); -} - - -void GLAPIENTRY -_mesa_DrawTexsv(const GLshort *coords) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], - (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); -} - - -void GLAPIENTRY -_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, - (GLfloat) x / 65536.0f, - (GLfloat) y / 65536.0f, - (GLfloat) z / 65536.0f, - (GLfloat) width / 65536.0f, - (GLfloat) height / 65536.0f); -} - - -void GLAPIENTRY -_mesa_DrawTexxv(const GLfixed *coords) -{ - GET_CURRENT_CONTEXT(ctx); - draw_texture(ctx, - (GLfloat) coords[0] / 65536.0f, - (GLfloat) coords[1] / 65536.0f, - (GLfloat) coords[2] / 65536.0f, - (GLfloat) coords[3] / 65536.0f, - (GLfloat) coords[4] / 65536.0f); -} - - -void -_mesa_init_drawtex_dispatch(struct _glapi_table *disp) -{ - SET_DrawTexfOES(disp, _mesa_DrawTexf); - SET_DrawTexfvOES(disp, _mesa_DrawTexfv); - SET_DrawTexiOES(disp, _mesa_DrawTexi); - SET_DrawTexivOES(disp, _mesa_DrawTexiv); - SET_DrawTexsOES(disp, _mesa_DrawTexs); - SET_DrawTexsvOES(disp, _mesa_DrawTexsv); - SET_DrawTexxOES(disp, _mesa_DrawTexx); - SET_DrawTexxvOES(disp, _mesa_DrawTexxv); -} - - -#endif /* FEATURE_OES_draw_texture */ diff --git a/src/mesa/es/main/drawtex.h b/src/mesa/es/main/drawtex.h deleted file mode 100644 index 0f3bac38c77..00000000000 --- a/src/mesa/es/main/drawtex.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2009 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef DRAWTEX_H -#define DRAWTEX_H - - -#include "main/mtypes.h" - - -#if FEATURE_OES_draw_texture - -#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) \ - do { \ - (driver)->DrawTex = impl ## DrawTex; \ - } while (0) - -extern void GLAPIENTRY -_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); - -extern void GLAPIENTRY -_mesa_DrawTexfv(const GLfloat *coords); - -extern void GLAPIENTRY -_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height); - -extern void GLAPIENTRY -_mesa_DrawTexiv(const GLint *coords); - -extern void GLAPIENTRY -_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); - -extern void GLAPIENTRY -_mesa_DrawTexsv(const GLshort *coords); - -extern void GLAPIENTRY -_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); - -extern void GLAPIENTRY -_mesa_DrawTexxv(const GLfixed *coords); - -extern void -_mesa_init_drawtex_dispatch(struct _glapi_table *disp); - -#else /* FEATURE_OES_draw_texture */ - -#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) do { } while (0) - -static INLINE void -_mesa_init_drawtex_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_OES_draw_texture */ - - -#endif /* DRAWTEX_H */ diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak index fd3592cf2b6..6ddbcfdffc6 100644 --- a/src/mesa/es/sources.mak +++ b/src/mesa/es/sources.mak @@ -3,7 +3,6 @@ include $(MESA)/sources.mak # LOCAL sources LOCAL_ES1_SOURCES := \ - main/drawtex.c \ glapi/glapi-es1/main/enums.c LOCAL_ES1_GALLIUM_SOURCES := \ diff --git a/src/mesa/main/drawtex.c b/src/mesa/main/drawtex.c new file mode 100644 index 00000000000..d24ca4ca5bb --- /dev/null +++ b/src/mesa/main/drawtex.c @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "main/drawtex.h" +#include "main/state.h" +#include "main/imports.h" + +#include "main/dispatch.h" + + +#if FEATURE_OES_draw_texture + + +static void +draw_texture(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height) +{ + if (!ctx->Extensions.OES_draw_texture) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawTex(unsupported)"); + return; + } + if (width <= 0.0f || height <= 0.0f) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTex(width or height <= 0)"); + return; + } + + if (ctx->NewState) + _mesa_update_state(ctx); + + ASSERT(ctx->Driver.DrawTex); + ctx->Driver.DrawTex(ctx, x, y, z, width, height); +} + + +void GLAPIENTRY +_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, x, y, z, width, height); +} + + +void GLAPIENTRY +_mesa_DrawTexfv(const GLfloat *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, coords[0], coords[1], coords[2], coords[3], coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, + (GLfloat) width, (GLfloat) height); +} + + +void GLAPIENTRY +_mesa_DrawTexiv(const GLint *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], + (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, + (GLfloat) width, (GLfloat) height); +} + + +void GLAPIENTRY +_mesa_DrawTexsv(const GLshort *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], + (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, + (GLfloat) x / 65536.0f, + (GLfloat) y / 65536.0f, + (GLfloat) z / 65536.0f, + (GLfloat) width / 65536.0f, + (GLfloat) height / 65536.0f); +} + + +void GLAPIENTRY +_mesa_DrawTexxv(const GLfixed *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, + (GLfloat) coords[0] / 65536.0f, + (GLfloat) coords[1] / 65536.0f, + (GLfloat) coords[2] / 65536.0f, + (GLfloat) coords[3] / 65536.0f, + (GLfloat) coords[4] / 65536.0f); +} + + +void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp) +{ + SET_DrawTexfOES(disp, _mesa_DrawTexf); + SET_DrawTexfvOES(disp, _mesa_DrawTexfv); + SET_DrawTexiOES(disp, _mesa_DrawTexi); + SET_DrawTexivOES(disp, _mesa_DrawTexiv); + SET_DrawTexsOES(disp, _mesa_DrawTexs); + SET_DrawTexsvOES(disp, _mesa_DrawTexsv); + SET_DrawTexxOES(disp, _mesa_DrawTexx); + SET_DrawTexxvOES(disp, _mesa_DrawTexxv); +} + + +#endif /* FEATURE_OES_draw_texture */ diff --git a/src/mesa/main/drawtex.h b/src/mesa/main/drawtex.h new file mode 100644 index 00000000000..0f3bac38c77 --- /dev/null +++ b/src/mesa/main/drawtex.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef DRAWTEX_H +#define DRAWTEX_H + + +#include "main/mtypes.h" + + +#if FEATURE_OES_draw_texture + +#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) \ + do { \ + (driver)->DrawTex = impl ## DrawTex; \ + } while (0) + +extern void GLAPIENTRY +_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); + +extern void GLAPIENTRY +_mesa_DrawTexfv(const GLfloat *coords); + +extern void GLAPIENTRY +_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height); + +extern void GLAPIENTRY +_mesa_DrawTexiv(const GLint *coords); + +extern void GLAPIENTRY +_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); + +extern void GLAPIENTRY +_mesa_DrawTexsv(const GLshort *coords); + +extern void GLAPIENTRY +_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); + +extern void GLAPIENTRY +_mesa_DrawTexxv(const GLfixed *coords); + +extern void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_OES_draw_texture */ + +#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) do { } while (0) + +static INLINE void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_OES_draw_texture */ + + +#endif /* DRAWTEX_H */ diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index 1dcaad1854e..2733a62d559 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -27,6 +27,7 @@ MAIN_SOURCES = \ main/dlist.c \ main/dlopen.c \ main/drawpix.c \ + main/drawtex.c \ main/enable.c \ main/enums.c \ main/eval.c \