⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 texstore.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 5 页
字号:
   const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes;   const GLint bytesPerImage = srcHeight * bytesPerRow;   const GLint bytesPerTexture = srcDepth * bytesPerImage;   GLubyte *dstImage = (GLubyte *) dstAddr                     + dstZoffset * dstImageStride                     + dstYoffset * dstRowStride                     + dstXoffset * dstFormat->TexelBytes;   if (dstRowStride == srcRowStride &&       dstRowStride == bytesPerRow &&       ((dstImageStride == srcImageStride &&         dstImageStride == bytesPerImage) ||        (srcDepth == 1))) {      /* one big memcpy */      ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture);   }   else {      GLint img, row;      for (img = 0; img < srcDepth; img++) {         const GLubyte *srcRow = srcImage;         GLubyte *dstRow = dstImage;         for (row = 0; row < srcHeight; row++) {            ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);            dstRow += dstRowStride;            srcRow += srcRowStride;         }         srcImage += srcImageStride;         dstImage += dstImageStride;      }   }}/** * Store an image in any of the formats: *   _mesa_texformat_rgba *   _mesa_texformat_rgb *   _mesa_texformat_alpha *   _mesa_texformat_luminance *   _mesa_texformat_luminance_alpha *   _mesa_texformat_intensity *  * \param dims  either 1 or 2 or 3 * \param baseInternalFormat  user-specified base internal format * \param dstFormat  destination Mesa texture format * \param dstAddr  destination image address * \param dstX/Y/Zoffset  destination x/y/z offset (ala TexSubImage), in texels * \param dstRowStride  destination image row stride, in bytes * \param dstImageStride  destination image layer stride, in bytes * \param srcWidth/Height/Depth  source image size, in pixels * \param srcFormat  incoming image format * \param srcType  incoming image data type * \param srcAddr  source image address * \param srcPacking  source image packing parameters */GLboolean_mesa_texstore_rgba(GLcontext *ctx, GLuint dims,                    GLenum baseInternalFormat,                    const struct gl_texture_format *dstFormat,                    GLvoid *dstAddr,                    GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,                    GLint dstRowStride, GLint dstImageStride,                    GLint srcWidth, GLint srcHeight, GLint srcDepth,                    GLenum srcFormat, GLenum srcType,                    const GLvoid *srcAddr,                    const struct gl_pixelstore_attrib *srcPacking){   const GLint components = _mesa_components_in_format(baseInternalFormat);   ASSERT(dstFormat == &_mesa_texformat_rgba ||          dstFormat == &_mesa_texformat_rgb ||          dstFormat == &_mesa_texformat_alpha ||          dstFormat == &_mesa_texformat_luminance ||          dstFormat == &_mesa_texformat_luminance_alpha ||          dstFormat == &_mesa_texformat_intensity);   ASSERT(baseInternalFormat == GL_RGBA ||          baseInternalFormat == GL_RGB ||          baseInternalFormat == GL_ALPHA ||          baseInternalFormat == GL_LUMINANCE ||          baseInternalFormat == GL_LUMINANCE_ALPHA ||          baseInternalFormat == GL_INTENSITY);   ASSERT(dstFormat->TexelBytes == components * sizeof(GLchan));   if (!ctx->_ImageTransferState &&       !srcPacking->SwapBytes &&       baseInternalFormat == srcFormat &&       srcType == CHAN_TYPE) {      /* simple memcpy path */      memcpy_texture(ctx, dims,                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,                     dstRowStride, dstImageStride,                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,                     srcAddr, srcPacking);   }   else if (!ctx->_ImageTransferState &&            !srcPacking->SwapBytes &&            dstFormat == &_mesa_texformat_rgb &&            srcFormat == GL_RGBA &&            srcType == CHAN_TYPE) {      /* extract RGB from RGBA */      int img, row, col;      GLchan *dstImage = (GLchan *) (GLubyte *) dstAddr                       + dstZoffset * dstImageStride                       + dstYoffset * dstRowStride                       + dstXoffset * dstFormat->TexelBytes;      for (img = 0; img < srcDepth; img++) {         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,                                                 srcWidth, srcFormat, srcType);         GLchan *srcRow = (GLchan *) _mesa_image_address(dims, srcPacking,                  srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);         GLchan *dstRow = dstImage;         for (row = 0; row < srcHeight; row++) {            for (col = 0; col < srcWidth; col++) {               dstRow[col * 3 + RCOMP] = srcRow[col * 4 + RCOMP];               dstRow[col * 3 + GCOMP] = srcRow[col * 4 + GCOMP];               dstRow[col * 3 + BCOMP] = srcRow[col * 4 + BCOMP];            }            dstRow += dstRowStride;            srcRow = (GLchan *) ((GLubyte *) srcRow + srcRowStride);         }         dstImage += dstImageStride;      }   }   else {      /* general path */      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,                                                 baseInternalFormat,                                                 dstFormat->BaseFormat,                                                 srcWidth, srcHeight, srcDepth,                                                 srcFormat, srcType, srcAddr,                                                 srcPacking);      const GLchan *src = tempImage;      GLint bytesPerRow;      GLubyte *dstImage = (GLubyte *) dstAddr                        + dstZoffset * dstImageStride                        + dstYoffset * dstRowStride                        + dstXoffset * dstFormat->TexelBytes;      GLint img, row;      if (!tempImage)         return GL_FALSE;      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);      bytesPerRow = srcWidth * components * sizeof(GLchan);      for (img = 0; img < srcDepth; img++) {         GLubyte *dstRow = dstImage;         for (row = 0; row < srcHeight; row++) {            _mesa_memcpy(dstRow, src, bytesPerRow);            dstRow += dstRowStride;            src += srcWidth * components;         }         dstImage += dstImageStride;      }      _mesa_free((void *) tempImage);   }   return GL_TRUE;}/** * Store a floating point depth component texture image. */GLboolean_mesa_texstore_depth_component_float32(STORE_PARAMS){   (void) dims;   ASSERT(dstFormat == &_mesa_texformat_depth_component_float32);   ASSERT(dstFormat->TexelBytes == sizeof(GLfloat));   if (!ctx->_ImageTransferState &&       !srcPacking->SwapBytes &&       baseInternalFormat == GL_DEPTH_COMPONENT &&       srcFormat == GL_DEPTH_COMPONENT &&       srcType == GL_FLOAT) {      /* simple memcpy path */      memcpy_texture(ctx, dims,                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,                     dstRowStride, dstImageStride,                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,                     srcAddr, srcPacking);   }   else {      /* general path */      GLubyte *dstImage = (GLubyte *) dstAddr                        + dstZoffset * dstImageStride                        + dstYoffset * dstRowStride                        + dstXoffset * dstFormat->TexelBytes;      GLint img, row;      for (img = 0; img < srcDepth; img++) {         GLubyte *dstRow = dstImage;         for (row = 0; row < srcHeight; row++) {            const GLvoid *src = _mesa_image_address(dims, srcPacking,                srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);            _mesa_unpack_depth_span(ctx, srcWidth,                                    GL_FLOAT, (GLfloat *) dstRow, 1.0F,                                    srcType, src, srcPacking);            dstRow += dstRowStride;         }         dstImage += dstImageStride;      }   }   return GL_TRUE;}/** * Store a 16-bit integer depth component texture image. */GLboolean_mesa_texstore_depth_component16(STORE_PARAMS){   (void) dims;   ASSERT(dstFormat == &_mesa_texformat_depth_component16);   ASSERT(dstFormat->TexelBytes == sizeof(GLushort));   if (!ctx->_ImageTransferState &&       !srcPacking->SwapBytes &&       baseInternalFormat == GL_DEPTH_COMPONENT &&       srcFormat == GL_DEPTH_COMPONENT &&       srcType == GL_UNSIGNED_SHORT) {      /* simple memcpy path */      memcpy_texture(ctx, dims,                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,                     dstRowStride, dstImageStride,                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,                     srcAddr, srcPacking);   }   else {      /* general path */      GLubyte *dstImage = (GLubyte *) dstAddr                        + dstZoffset * dstImageStride                        + dstYoffset * dstRowStride                        + dstXoffset * dstFormat->TexelBytes;      GLint img, row;      for (img = 0; img < srcDepth; img++) {         GLubyte *dstRow = dstImage;         for (row = 0; row < srcHeight; row++) {            const GLvoid *src = _mesa_image_address(dims, srcPacking,                srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);            GLushort *dst16 = (GLushort *) dstRow;            _mesa_unpack_depth_span(ctx, srcWidth,                                    GL_UNSIGNED_SHORT, dst16, 65535.0F,                                    srcType, src, srcPacking);            dstRow += dstRowStride;         }         dstImage += dstImageStride;      }   }   return GL_TRUE;}/** * Store an rgb565 or rgb565_rev texture image. */GLboolean_mesa_texstore_rgb565(STORE_PARAMS){   ASSERT(dstFormat == &_mesa_texformat_rgb565 ||          dstFormat == &_mesa_texformat_rgb565_rev);   ASSERT(dstFormat->TexelBytes == 2);   if (!ctx->_ImageTransferState &&       !srcPacking->SwapBytes &&       dstFormat == &_mesa_texformat_rgb565 &&       baseInternalFormat == GL_RGB &&       srcFormat == GL_RGB &&       srcType == GL_UNSIGNED_SHORT_5_6_5) {      /* simple memcpy path */      memcpy_texture(ctx, dims,                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,                     dstRowStride, dstImageStride,                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,                     srcAddr, srcPacking);   }   else if (!ctx->_ImageTransferState &&            !srcPacking->SwapBytes &&            baseInternalFormat == GL_RGB &&            srcFormat == GL_RGB &&            srcType == GL_UNSIGNED_BYTE &&            dims == 2) {      /* do optimized tex store */      const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,                                                        srcFormat, srcType);      const GLubyte *src = (const GLubyte *)         _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,                             srcFormat, srcType, 0, 0, 0);      GLubyte *dst = (GLubyte *) dstAddr                   + dstZoffset * dstImageStride                   + dstYoffset * dstRowStride                   + dstXoffset * dstFormat->TexelBytes;      GLint row, col;      for (row = 0; row < srcHeight; row++) {         const GLubyte *srcUB = (const GLubyte *) src;         GLushort *dstUS = (GLushort *) dst;         /* check for byteswapped format */         if (dstFormat == &_mesa_texformat_rgb565) {            for (col = 0; col < srcWidth; col++) {               dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );               srcUB += 3;            }         }         else {            for (col = 0; col < srcWidth; col++) {               dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] );               srcUB += 3;            }         }         dst += dstRowStride;         src += srcRowStride;      }   }   else {      /* general path */      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,                                                 baseInternalFormat,                                                 dstFormat->BaseFormat,                                                 srcWidth, srcHeight, srcDepth,                                                 srcFormat, srcType, srcAddr,                                                 srcPacking);      const GLchan *src = tempImage;      GLubyte *dstImage = (GLubyte *) dstAddr                        + dstZoffset * dstImageStride                        + dstYoffset * dstRowStride                        + dstXoffset * dstFormat->TexelBytes;      GLint img, row, col;      if (!tempImage)         return GL_FALSE;      _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);      for (img = 0; img < srcDepth; img++) {         GLubyte *dstRow = dstImage;         for (row = 0; row < srcHeight; row++) {            GLushort *dstUS = (GLushort *) dstRow;            /* check for byteswapped format */            if (dstFormat == &_mesa_texformat_rgb565) {               for (col = 0; col < srcWidth; col++) {                  dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),                                               CHAN_TO_UBYTE(src[GCOMP]),                                               CHAN_TO_UBYTE(src[BCOMP]) );                  src += 3;               }            }            else {               for (col = 0; col < srcWidth; col++) {                  dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -