summaryrefslogtreecommitdiff
path: root/xc/extras/Mesa/src/drawpix.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/extras/Mesa/src/drawpix.c')
-rw-r--r--xc/extras/Mesa/src/drawpix.c108
1 files changed, 65 insertions, 43 deletions
diff --git a/xc/extras/Mesa/src/drawpix.c b/xc/extras/Mesa/src/drawpix.c
index f89d80a70..7fb93abcc 100644
--- a/xc/extras/Mesa/src/drawpix.c
+++ b/xc/extras/Mesa/src/drawpix.c
@@ -33,11 +33,14 @@
#include "feedback.h"
#include "image.h"
#include "macros.h"
+#include "mem.h"
#include "mmath.h"
#include "pixel.h"
+#include "pixeltex.h"
#include "span.h"
#include "state.h"
#include "stencil.h"
+#include "texture.h"
#include "types.h"
#include "zoom.h"
#endif
@@ -112,24 +115,17 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
return GL_TRUE;
}
- if (ctx->NewState) {
- gl_update_state(ctx);
- }
-
- /* see if device driver can do the drawpix */
- if (ctx->Driver.DrawPixels
- && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type,
- unpack, pixels)) {
- return GL_TRUE;
- }
-
if ((ctx->RasterMask&(~(SCISSOR_BIT|WINCLIP_BIT)))==0
- && ctx->Pixel.RedBias==0.0 && ctx->Pixel.RedScale==1.0
- && ctx->Pixel.GreenBias==0.0 && ctx->Pixel.GreenScale==1.0
- && ctx->Pixel.BlueBias==0.0 && ctx->Pixel.BlueScale==1.0
- && ctx->Pixel.AlphaBias==0.0 && ctx->Pixel.AlphaScale==1.0
+ && !ctx->Pixel.ScaleOrBiasRGBA
+ && !ctx->Pixel.ScaleOrBiasRGBApcm
+ && ctx->ColorMatrix.type == MATRIX_IDENTITY
+ && !ctx->Pixel.ColorTableEnabled
+ && !ctx->Pixel.PostColorMatrixColorTableEnabled
+ && !ctx->Pixel.MinMaxEnabled
+ && !ctx->Pixel.HistogramEnabled
&& ctx->Pixel.IndexShift==0 && ctx->Pixel.IndexOffset==0
&& ctx->Pixel.MapColorFlag==0
+ && ctx->Texture.ReallyEnabled == 0
&& unpack->Alignment==1
&& !unpack->SwapBytes
&& !unpack->LsbFirst) {
@@ -180,7 +176,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
}
else {
/* setup array of fragment Z value to pass to zoom function */
- GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
+ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
GLint i;
assert(drawWidth < MAX_WIDTH);
for (i=0; i<drawWidth; i++)
@@ -347,7 +343,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
assert(drawWidth < MAX_WIDTH);
- gl_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
(*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY,
(const GLubyte (*)[4])rgba,
NULL);
@@ -361,7 +357,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row=0; row<drawHeight; row++) {
assert(drawWidth < MAX_WIDTH);
- gl_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba);
gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY,
zSpan, (void *) rgba, zoomY0);
src += rowLength;
@@ -418,7 +414,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
/* Fragment depth values */
if (ctx->Depth.Test || ctx->Fog.Enabled) {
- GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
+ GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
GLint i;
for (i = 0; i < drawWidth; i++) {
zspan[i] = zval;
@@ -430,7 +426,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
*/
for (row = 0; row < height; row++, y++) {
GLuint indexes[MAX_WIDTH];
- const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack,
+ const GLvoid *source = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
_mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT, indexes,
type, source, &ctx->Unpack, GL_TRUE);
@@ -455,6 +451,7 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
GLenum type, const GLvoid *pixels )
{
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
+ const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
const GLint desty = y;
GLint row, drawWidth;
@@ -476,17 +473,23 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
GLstencil values[MAX_WIDTH];
GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte))
? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
- const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack,
+ const GLvoid *source = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
_mesa_unpack_index_span(ctx, drawWidth, destType, values,
- type, source, &ctx->Unpack, GL_TRUE);
+ type, source, &ctx->Unpack, GL_FALSE);
+ if (shift_or_offset) {
+ _mesa_shift_and_offset_stencil( ctx, drawWidth, values );
+ }
+ if (ctx->Pixel.MapStencilFlag) {
+ _mesa_map_stencil( ctx, drawWidth, values );
+ }
if (zoom) {
gl_write_zoomed_stencil_span( ctx, (GLuint) drawWidth, x, y,
values, desty );
}
else {
- gl_write_stencil_span( ctx, (GLuint) drawWidth, x, y, values );
+ _mesa_write_stencil_span( ctx, (GLuint) drawWidth, x, y, values );
}
}
}
@@ -545,30 +548,23 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
/* Special case: directly write 16-bit depth values */
GLint row;
for (row = 0; row < height; row++, y++) {
- const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack,
+ GLdepth zspan[MAX_WIDTH];
+ const GLushort *zptr = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
- gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP );
+ GLint i;
+ for (i = 0; i < width; i++)
+ zspan[i] = zptr[i];
+ gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP );
}
}
- else if (type==GL_UNSIGNED_INT && sizeof(GLdepth)==sizeof(GLuint)
+ else if (type==GL_UNSIGNED_INT && ctx->Visual->DepthBits == 32
&& !bias_or_scale && !zoom && ctx->Visual->RGBAflag) {
/* Special case: directly write 32-bit depth values */
- GLint i, row;
- /* Compute shift value to scale 32-bit uints down to depth values. */
- GLuint shift = 0;
- GLuint max = MAX_DEPTH;
- while ((max & 0x80000000) == 0) {
- max = max << 1;
- shift++;
- }
+ GLint row;
for (row = 0; row < height; row++, y++) {
- GLdepth zspan[MAX_WIDTH];
- const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack,
+ const GLuint *zptr = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
- for (i=0;i<width;i++) {
- zspan[i] = zptr[i] >> shift;
- }
- gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP );
+ gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP );
}
}
else {
@@ -576,7 +572,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row = 0; row < height; row++, y++) {
GLdepth zspan[MAX_WIDTH];
- const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack,
+ const GLvoid *src = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
_mesa_unpack_depth_span( ctx, drawWidth, zspan, type, src,
&ctx->Unpack, GL_TRUE );
@@ -625,7 +621,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
/* Fragment depth values */
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
- GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
+ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
GLint i;
for (i=0;i<width;i++) {
zspan[i] = z;
@@ -652,10 +648,23 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
if (width > MAX_WIDTH)
width = MAX_WIDTH;
for (row = 0; row < height; row++, y++) {
- const GLvoid *source = gl_pixel_addr_in_image(unpack,
+ const GLvoid *source = _mesa_image_address(unpack,
pixels, width, height, format, type, 0, row, 0);
_mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba,
format, type, source, unpack, GL_TRUE);
+ if (ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink)
+ continue;
+
+ if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
+ GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
+ GLuint unit;
+ /* XXX not sure how multitexture is supposed to work here */
+ for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
+ _mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba,
+ s, t, r, q);
+ gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba);
+ }
+ }
if (quickDraw) {
(*ctx->Driver.WriteRGBASpan)( ctx, width, x, y,
@@ -690,9 +699,22 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
return;
}
+ if (ctx->NewState) {
+ gl_update_state(ctx);
+ }
+
x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
+ ctx->OcclusionResult = GL_TRUE;
+
+ /* see if device driver can do the drawpix */
+ if (ctx->Driver.DrawPixels
+ && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type,
+ &ctx->Unpack, pixels)) {
+ return;
+ }
+
switch (format) {
case GL_STENCIL_INDEX:
draw_stencil_pixels( ctx, x, y, width, height, type, pixels );