📄 fxdd.c
字号:
const GLint halfWidth = width >> 1; const GLint extraPixel = (width & 1); for (row = 0; row < height; row++) { GLubyte *d = dst; for (col = 0; col < halfWidth; col++) { const GLuint pixel = ((const GLuint *) src)[col]; *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f]; *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f]; *d++ = FX_rgb_scale_5[ pixel & 0x1f]; *d++ = 255; *d++ = FX_rgb_scale_5[(pixel >> 27) & 0x1f]; *d++ = FX_rgb_scale_6[(pixel >> 21) & 0x3f]; *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f]; *d++ = 255; } if (extraPixel) { const GLushort pixel = src[width - 1]; *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f]; *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f]; *d++ = FX_rgb_scale_5[ pixel & 0x1f]; *d++ = 255; } dst += dstStride; src -= srcStride; } } else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { /* directly memcpy 5R6G5B pixels into client's buffer */ const GLint widthInBytes = width * 2; GLint row; for (row = 0; row < height; row++) { MEMCPY(dst, src, widthInBytes); dst += dstStride; src -= srcStride; } } else { grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); END_BOARD_LOCK(); _swrast_ReadPixels(ctx, x, y, width, height, format, type, packing, dstImage); return; } grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); } END_BOARD_LOCK(); }}static voidfxDDReadPixels555 (GLcontext * ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *packing, GLvoid *dstImage){ if (ctx->_ImageTransferState/* & (IMAGE_SCALE_BIAS_BIT|IMAGE_MAP_COLOR_BIT)*/) { _swrast_ReadPixels(ctx, x, y, width, height, format, type, packing, dstImage); return; } else { fxMesaContext fxMesa = FX_CONTEXT(ctx); GrLfbInfo_t info; BEGIN_BOARD_LOCK(); info.size = sizeof(info); if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB, GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { const GLint winX = 0; const GLint winY = fxMesa->height - 1; const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ const GLushort *src = (const GLushort *) info.lfbPtr + (winY - y) * srcStride + (winX + x); GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage, width, height, format, type, 0, 0); GLint dstStride = _mesa_image_row_stride(packing, width, format, type); if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { /* convert 5R5G5B into 8R8G8B */ GLint row, col; const GLint halfWidth = width >> 1; const GLint extraPixel = (width & 1); for (row = 0; row < height; row++) { GLubyte *d = dst; for (col = 0; col < halfWidth; col++) { const GLuint pixel = ((const GLuint *) src)[col]; *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f]; *d++ = FX_rgb_scale_5[ pixel & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 26) & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 21) & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f]; } if (extraPixel) { GLushort pixel = src[width - 1]; *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f]; *d++ = FX_rgb_scale_5[ pixel & 0x1f]; } dst += dstStride; src -= srcStride; } } else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { /* convert 5R6G5B into 8R8G8B8A */ GLint row, col; const GLint halfWidth = width >> 1; const GLint extraPixel = (width & 1); for (row = 0; row < height; row++) { GLubyte *d = dst; for (col = 0; col < halfWidth; col++) { const GLuint pixel = ((const GLuint *) src)[col]; *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f]; *d++ = FX_rgb_scale_5[ pixel & 0x1f]; *d++ = (pixel & 0x8000) ? 255 : 0; *d++ = FX_rgb_scale_5[(pixel >> 26) & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 21) & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f]; *d++ = (pixel & 0x80000000) ? 255 : 0; } if (extraPixel) { const GLushort pixel = src[width - 1]; *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f]; *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f]; *d++ = FX_rgb_scale_5[ pixel & 0x1f]; *d++ = (pixel & 0x8000) ? 255 : 0; } dst += dstStride; src -= srcStride; } } else if (format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { /* directly memcpy 5R5G5B pixels into client's buffer */ const GLint widthInBytes = width * 2; GLint row; for (row = 0; row < height; row++) { MEMCPY(dst, src, widthInBytes); dst += dstStride; src -= srcStride; } } else { grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); END_BOARD_LOCK(); _swrast_ReadPixels(ctx, x, y, width, height, format, type, packing, dstImage); return; } grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); } END_BOARD_LOCK(); }}static voidfxDDReadPixels8888 (GLcontext * ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *packing, GLvoid *dstImage){ if (ctx->_ImageTransferState/* & (IMAGE_SCALE_BIAS_BIT|IMAGE_MAP_COLOR_BIT)*/) { _swrast_ReadPixels(ctx, x, y, width, height, format, type, packing, dstImage); return; } else { fxMesaContext fxMesa = FX_CONTEXT(ctx); GrLfbInfo_t info; BEGIN_BOARD_LOCK(); info.size = sizeof(info); if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB, GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) { const GLint winX = 0; const GLint winY = fxMesa->height - 1; const GLint srcStride = info.strideInBytes / 4; /* stride in GLuints */ const GLuint *src = (const GLuint *) info.lfbPtr + (winY - y) * srcStride + (winX + x); GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage, width, height, format, type, 0, 0); GLint dstStride = _mesa_image_row_stride(packing, width, format, type); if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { /* convert 8A8R8G8B into 8R8G8B */ GLint row, col; for (row = 0; row < height; row++) { GLubyte *d = dst; for (col = 0; col < width; col++) { const GLuint pixel = ((const GLuint *) src)[col]; *d++ = pixel >> 16; *d++ = pixel >> 8; *d++ = pixel; } dst += dstStride; src -= srcStride; } } else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { /* 8A8R8G8B pixels into client's buffer */ GLint row, col; for (row = 0; row < height; row++) { GLubyte *d = dst; for (col = 0; col < width; col++) { const GLuint pixel = ((const GLuint *) src)[col]; *d++ = pixel >> 16; *d++ = pixel >> 8; *d++ = pixel; *d++ = pixel >> 24; } dst += dstStride; src -= srcStride; } } else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { /* convert 8A8R8G8B into 5R6G5B */ GLint row, col; for (row = 0; row < height; row++) { GLushort *d = (GLushort *)dst; for (col = 0; col < width; col++) { const GLuint pixel = ((const GLuint *) src)[col]; *d++ = (((pixel >> 16) & 0xf8) << 8) | (((pixel >> 8) & 0xfc) << 3) | ((pixel & 0xf8) >> 3); } dst += dstStride; src -= srcStride; } } else { grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); END_BOARD_LOCK(); _swrast_ReadPixels(ctx, x, y, width, height, format, type, packing, dstImage); return; } grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); } END_BOARD_LOCK(); }}static voidfxDDDrawPixels555 (GLcontext * ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid * pixels){ fxMesaContext fxMesa = FX_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx); GrLfbInfo_t info; const struct gl_pixelstore_attrib *finalUnpack; struct gl_pixelstore_attrib scissoredUnpack; if (ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F || (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT| IMAGE_MAP_COLOR_BIT)) || (swrast->_RasterMask & (ALPHATEST_BIT | /*BLEND_BIT |*/ /* blending ok, through pixpipe */ DEPTH_BIT | /* could be done with RGB:DEPTH */ FOG_BIT | /* could be done with RGB:DEPTH */ LOGIC_OP_BIT | /*CLIP_BIT |*/ /* clipping ok, below */ STENCIL_BIT | MASKING_BIT | MULTI_DRAW_BIT | OCCLUSION_BIT | /* nope! at least not yet */ TEXTURE_BIT | FRAGPROG_BIT)) || fxMesa->fallback) { _swrast_DrawPixels( ctx, x, y, width, height, format, type, unpack, pixels ); return; } /* make sure the pixelpipe is configured correctly */ fxSetupFXUnits(ctx); /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */ if (ctx->Scissor.Enabled) { /* This is a bit tricky, but by carefully adjusting the px, py, * width, height, skipPixels and skipRows values we can do * scissoring without special code in the rendering loop. */ /* we'll construct a new pixelstore struct */ finalUnpack = &scissoredUnpack; scissoredUnpack = *unpack; if (scissoredUnpack.RowLength == 0) scissoredUnpack.RowLength = width; /* clip left */ if (x < ctx->Scissor.X) { scissoredUnpack.SkipPixels += (ctx->Scissor.X - x); width -= (ctx->Scissor.X - x); x = ctx->Scissor.X; } /* clip right */ if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) { width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width)); } /* clip bottom */ if (y < ctx->Scissor.Y) { scissoredUnpack.SkipRows += (ctx->Scissor.Y - y); height -= (ctx->Scissor.Y - y); y = ctx->Scissor.Y; } /* clip top */ if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) { height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height)); } if (width <= 0 || height <= 0) return; } else { finalUnpack = unpack; } info.size = sizeof(info); if (!grLfbLock(GR_LFB_WRITE_ONLY, fxMesa->currentFB, GR_LFBWRITEMODE_1555, GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) { _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); return; } { const GLint winX = 0; const GLint winY = 0; const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */ GLushort *dst = (GLushort *) info.lfbPtr + (winY + y) * dstStride + (winX + x); if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, pixels, width, height, format, type, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], src[3]); src += 4; } dst += dstStride; } } else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { GLint row; for (row = 0; row < height; row++) { GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack, pixels, width, height, format, type, row, 0); GLint col; for (col = 0; col < width; col++) { dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], 255); src += 3; } dst += dstStride; } } else { grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels); return; } } grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);}static voidfxDDDrawPixels565 (GLcontext * ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid * pixels){ fxMesaContext fxMesa = FX_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx); GrLfbInfo_t info; const struct gl_pixelstore_attrib *finalUnpack;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -