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

📄 texstore.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
         GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,                  srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);         GLubyte *dstRow = (GLubyte *) dstAddr            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes            + dstYoffset * dstRowStride            + dstXoffset * dstFormat->TexelBytes;         for (row = 0; row < srcHeight; row++) {            GLuint *d4 = (GLuint *) dstRow;            for (col = 0; col < srcWidth; col++) {               d4[col] = ((0xff                    << 24) |                          (srcRow[col * 3 + RCOMP] << 16) |                          (srcRow[col * 3 + GCOMP] <<  8) |                          (srcRow[col * 3 + BCOMP] <<  0));            }            dstRow += dstRowStride;            srcRow += srcRowStride;         }      }   }   else if (!ctx->_ImageTransferState &&            !srcPacking->SwapBytes &&	    dstFormat == &_mesa_texformat_argb8888 &&            srcFormat == GL_RGBA &&	    baseInternalFormat == GL_RGBA &&            srcType == GL_UNSIGNED_BYTE &&            littleEndian) {      /* same as above case, but src data has alpha too */      GLint img, row, col;      /* For some reason, streaming copies to write-combined regions       * are extremely sensitive to the characteristics of how the       * source data is retrieved.  By reordering the source reads to       * be in-order, the speed of this operation increases by half.       * Strangely the same isn't required for the RGB path, above.       */      for (img = 0; img < srcDepth; img++) {         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,                                                 srcWidth, srcFormat, srcType);         GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,                  srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);         GLubyte *dstRow = (GLubyte *) dstAddr            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes            + dstYoffset * dstRowStride            + dstXoffset * dstFormat->TexelBytes;         for (row = 0; row < srcHeight; row++) {            GLuint *d4 = (GLuint *) dstRow;            for (col = 0; col < srcWidth; col++) {               d4[col] = ((srcRow[col * 4 + ACOMP] << 24) |                          (srcRow[col * 4 + RCOMP] << 16) |                          (srcRow[col * 4 + GCOMP] <<  8) |                          (srcRow[col * 4 + BCOMP] <<  0));            }            dstRow += dstRowStride;            srcRow += srcRowStride;         }      }   }   else if (!ctx->_ImageTransferState &&            !srcPacking->SwapBytes &&	    dstFormat == &_mesa_texformat_argb8888 &&            srcFormat == GL_RGBA &&	    baseInternalFormat == GL_RGBA &&            srcType == GL_UNSIGNED_BYTE) {      GLint img, row, col;      for (img = 0; img < srcDepth; img++) {         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,                                                 srcWidth, srcFormat, srcType);         GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,                  srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);         GLubyte *dstRow = (GLubyte *) dstAddr            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes            + dstYoffset * dstRowStride            + dstXoffset * dstFormat->TexelBytes;         for (row = 0; row < srcHeight; row++) {            for (col = 0; col < srcWidth; col++) {               dstRow[col * 4 + 0] = srcRow[col * 4 + BCOMP];               dstRow[col * 4 + 1] = srcRow[col * 4 + GCOMP];               dstRow[col * 4 + 2] = srcRow[col * 4 + RCOMP];               dstRow[col * 4 + 3] = srcRow[col * 4 + ACOMP];            }            dstRow += dstRowStride;            srcRow += srcRowStride;         }      }   }   else if (!ctx->_ImageTransferState &&	    (srcType == GL_UNSIGNED_BYTE ||	     srcType == GL_UNSIGNED_INT_8_8_8_8 ||	     srcType == GL_UNSIGNED_INT_8_8_8_8_REV) &&	    can_swizzle(baseInternalFormat) &&	   	    can_swizzle(srcFormat)) {      GLubyte dstmap[4];      /* dstmap - how to swizzle from RGBA to dst format:       */      if ((littleEndian && dstFormat == &_mesa_texformat_argb8888) ||	  (!littleEndian && dstFormat == &_mesa_texformat_argb8888_rev)) {	 dstmap[3] = 3;		/* alpha */	 dstmap[2] = 0;		/* red */	 dstmap[1] = 1;		/* green */	 dstmap[0] = 2;		/* blue */      }      else {	 assert((littleEndian && dstFormat == &_mesa_texformat_argb8888_rev) ||		(!littleEndian && dstFormat == &_mesa_texformat_argb8888));	 dstmap[3] = 2;	 dstmap[2] = 1;	 dstmap[1] = 0;	 dstmap[0] = 3;      }       _mesa_swizzle_ubyte_image(ctx, dims,				srcFormat,				srcType,				baseInternalFormat,				dstmap, 4,				dstAddr, dstXoffset, dstYoffset, dstZoffset,				dstRowStride,                                dstImageOffsets,				srcWidth, srcHeight, srcDepth, srcAddr,				srcPacking);         }   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 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 = (GLubyte *) dstAddr            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes            + dstYoffset * dstRowStride            + dstXoffset * dstFormat->TexelBytes;         for (row = 0; row < srcHeight; row++) {            GLuint *dstUI = (GLuint *) dstRow;            if (dstFormat == &_mesa_texformat_argb8888) {               for (col = 0; col < srcWidth; col++) {                  dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]),                                                CHAN_TO_UBYTE(src[RCOMP]),                                                CHAN_TO_UBYTE(src[GCOMP]),                                                CHAN_TO_UBYTE(src[BCOMP]) );                  src += 4;               }            }            else {               for (col = 0; col < srcWidth; col++) {                  dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]),                                                    CHAN_TO_UBYTE(src[RCOMP]),                                                    CHAN_TO_UBYTE(src[GCOMP]),                                                    CHAN_TO_UBYTE(src[BCOMP]) );                  src += 4;               }            }            dstRow += dstRowStride;         }      }      _mesa_free((void *) tempImage);   }   return GL_TRUE;}GLboolean_mesa_texstore_rgb888(TEXSTORE_PARAMS){   const GLboolean littleEndian = _mesa_little_endian();   ASSERT(dstFormat == &_mesa_texformat_rgb888);   ASSERT(dstFormat->TexelBytes == 3);   if (!ctx->_ImageTransferState &&       !srcPacking->SwapBytes &&       baseInternalFormat == GL_RGB &&       srcFormat == GL_BGR &&       srcType == GL_UNSIGNED_BYTE &&       littleEndian) {      /* simple memcpy path */      memcpy_texture(ctx, dims,                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,                     dstRowStride,                     dstImageOffsets,                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,                     srcAddr, srcPacking);   }   else if (!ctx->_ImageTransferState &&            !srcPacking->SwapBytes &&            srcFormat == GL_RGBA &&            srcType == GL_UNSIGNED_BYTE) {      /* extract RGB from RGBA */      GLint img, row, col;      for (img = 0; img < srcDepth; img++) {         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,                                                 srcWidth, srcFormat, srcType);         GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,                  srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);         GLubyte *dstRow = (GLubyte *) dstAddr            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes            + dstYoffset * dstRowStride            + dstXoffset * dstFormat->TexelBytes;         for (row = 0; row < srcHeight; row++) {            for (col = 0; col < srcWidth; col++) {               dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP];               dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];               dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP];            }            dstRow += dstRowStride;            srcRow += srcRowStride;         }      }   }   else if (!ctx->_ImageTransferState &&	    srcType == GL_UNSIGNED_BYTE &&	    can_swizzle(baseInternalFormat) &&	    can_swizzle(srcFormat)) {      GLubyte dstmap[4];      /* dstmap - how to swizzle from RGBA to dst format:       */      dstmap[0] = 2;      dstmap[1] = 1;      dstmap[2] = 0;      dstmap[3] = ONE;		/* ? */            _mesa_swizzle_ubyte_image(ctx, dims,				srcFormat,				srcType,				baseInternalFormat,				dstmap, 3,				dstAddr, dstXoffset, dstYoffset, dstZoffset,				dstRowStride, dstImageOffsets,				srcWidth, srcHeight, srcDepth, srcAddr,				srcPacking);         }   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 = (const GLchan *) tempImage;      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 = (GLubyte *) dstAddr            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes            + dstYoffset * dstRowStride            + dstXoffset * dstFormat->TexelBytes;         for (row = 0; row < srcHeight; row++) {#if 0            if (littleEndian) {               for (col = 0; col < srcWidth; col++) {                  dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);                  dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);                  dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);                  srcUB += 3;               }            }            else {               for (col = 0; col < srcWidth; col++) {                  dstRow[col * 3 + 0] = srcUB[BCOMP];                  dstRow[col * 3 + 1] = srcUB[GCOMP];                  dstRow[col * 3 + 2] = srcUB[RCOMP];                  srcUB += 3;               }            }#else            for (col = 0; col < srcWidth; col++) {               dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]);               dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);               dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]);               src += 3;            }#endif            dstRow += dstRowStride;         }      }      _mesa_free((void *) tempImage);   }   return GL_TRUE;}GLboolean_mesa_texstore_bgr888(TEXSTORE_PARAMS){   const GLboolean littleEndian = _mesa_little_endian();   ASSERT(dstFormat == &_mesa_texformat_bgr888);   ASSERT(dstFormat->TexelBytes == 3);   if (!ctx->_ImageTransferState &&       !srcPacking->SwapBytes &&       baseInternalFormat == GL_RGB &&       srcFormat == GL_RGB &&       srcType == GL_UNSIGNED_BYTE &&       littleEndian) {      /* simple memcpy path */      memcpy_texture(ctx, dims,                     dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,                     dstRowStride,                     dstImageOffsets,                     srcWidth, srcHeight, srcDepth, srcFormat, srcType,                     srcAddr, srcPacking);   }   else if (!ctx->_ImageTransferState &&            !srcPacking->SwapBytes &&            srcFormat == GL_RGBA &&            srcType == GL_UNSIGNED_BYTE) {      /* extract BGR from RGBA */      int img, row, col;      for (img = 0; img < srcDepth; img++) {         const GLint srcRowStride = _mesa_image_row_stride(srcPacking,                                                 srcWidth, srcFormat, srcType);         GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,                  srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);         GLubyte *dstRow = (GLubyte *) dstAddr            + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes            + dstYoffset * dstRowStride            + dstXoffset * dstFormat->TexelBytes;         for (row = 0; row < srcHeight; row++) {            for (col = 0; col < srcWidth; col++) {               dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];               dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];               dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP];            }            dstRow += dstRowStride;            srcRow += srcRowStride;         }      }   }   else if (!ctx->_ImageTransferState &&	    srcType == GL_UNSIGNED_BYTE &&	    can_swizzle(baseInternalFormat) &&	    can_swizzle(srcFormat)) {      GLubyte dstmap[4];      /* dstmap - how to swizzle from RGBA to dst format:       */      dstmap[0] = 0;      dstmap[1] = 1;      dstmap[2] = 2;      dstmap[3] = ONE;		/* ? */            _mesa_swizzle_ubyte_image(ctx, dims,				srcFormat,				srcType,				baseInternalFormat,				dstmap, 3,				dstAddr, dstXoffset, dstYoffset, dstZoffset,				dstRowStride, dstImageOffsets,				srcWidth, srcHeight, srcDepth, srcAddr,				srcPacking);         }      else {      /* general path */      const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,                                                 baseInternalFormat,                                                 dstFormat->BaseFormat,           

⌨️ 快捷键说明

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