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

📄 fxdd.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
   if (mode == GL_FRONT_LEFT) {      fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;      grRenderBuffer(fxMesa->currentFB);   }   else if (mode == GL_BACK_LEFT) {      fxMesa->currentFB = GR_BUFFER_BACKBUFFER;      grRenderBuffer(fxMesa->currentFB);   }   else if (mode == GL_NONE) {      fxDisableColor(fxMesa);   }   else {      /* we'll need a software fallback */      /* XXX not implemented */   }   /* update s/w fallback state */   _swrast_DrawBuffer(ctx, mode);}static voidfxDDDrawBitmap2 (GLcontext *ctx, GLint px, GLint py,		 GLsizei width, GLsizei height,		 const struct gl_pixelstore_attrib *unpack,		 const GLubyte *bitmap){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   SWcontext *swrast = SWRAST_CONTEXT(ctx);   GrLfbInfo_t info;   GrLfbWriteMode_t mode;   FxU16 color;   const struct gl_pixelstore_attrib *finalUnpack;   struct gl_pixelstore_attrib scissoredUnpack;   /* check if there's any raster operations enabled which we can't handle */   if (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)) {      _swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap);      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 (px < ctx->Scissor.X) {	 scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);	 width -= (ctx->Scissor.X - px);	 px = ctx->Scissor.X;      }      /* clip right */      if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {	 width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));      }      /* clip bottom */      if (py < ctx->Scissor.Y) {	 scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);	 height -= (ctx->Scissor.Y - py);	 py = ctx->Scissor.Y;      }      /* clip top */      if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {	 height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));      }      if (width <= 0 || height <= 0)	 return;   }   else {      finalUnpack = unpack;   }   /* compute pixel value */   {      GLint r = (GLint) (ctx->Current.RasterColor[RCOMP] * 255.0f);      GLint g = (GLint) (ctx->Current.RasterColor[GCOMP] * 255.0f);      GLint b = (GLint) (ctx->Current.RasterColor[BCOMP] * 255.0f);      GLint a = (GLint) (ctx->Current.RasterColor[ACOMP] * 255.0f);      if (fxMesa->colDepth == 15) {         color = TDFXPACKCOLOR1555(b, g, r, a);         mode = GR_LFBWRITEMODE_1555;      } else {         color = fxMesa->bgrOrder ? TDFXPACKCOLOR565(r, g, b) : TDFXPACKCOLOR565(b, g, r);         mode = GR_LFBWRITEMODE_565;      }   }   info.size = sizeof(info);   if (!grLfbLock(GR_LFB_WRITE_ONLY,		  fxMesa->currentFB,		  mode,		  GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) {      _swrast_Bitmap(ctx, px, py, width, height, finalUnpack, bitmap);      return;   }   {      const GLint winX = 0;      const GLint winY = 0;      /* The dest stride depends on the hardware and whether we're drawing       * to the front or back buffer.  This compile-time test seems to do       * the job for now.       */      const GLint dstStride = info.strideInBytes / 2;	/* stride in GLushorts */      GLint row;      /* compute dest address of bottom-left pixel in bitmap */      GLushort *dst = (GLushort *) info.lfbPtr	 + (winY + py) * dstStride + (winX + px);      for (row = 0; row < height; row++) {	 const GLubyte *src =	    (const GLubyte *) _mesa_image_address2d(finalUnpack,                                                    bitmap, width, height,                                                    GL_COLOR_INDEX, GL_BITMAP,                                                    row, 0);	 if (finalUnpack->LsbFirst) {	    /* least significan bit first */	    GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);	    GLint col;	    for (col = 0; col < width; col++) {	       if (*src & mask) {		  dst[col] = color;	       }	       if (mask == 128U) {		  src++;		  mask = 1U;	       }	       else {		  mask = mask << 1;	       }	    }	    if (mask != 1)	       src++;	 }	 else {	    /* most significan bit first */	    GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);	    GLint col;	    for (col = 0; col < width; col++) {	       if (*src & mask) {		  dst[col] = color;	       }	       if (mask == 1U) {		  src++;		  mask = 128U;	       }	       else {		  mask = mask >> 1;	       }	    }	    if (mask != 128)	       src++;	 }	 dst += dstStride;      }   }   grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);}static voidfxDDDrawBitmap4 (GLcontext *ctx, GLint px, GLint py,		 GLsizei width, GLsizei height,		 const struct gl_pixelstore_attrib *unpack,		 const GLubyte *bitmap){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   SWcontext *swrast = SWRAST_CONTEXT(ctx);   GrLfbInfo_t info;   FxU32 color;   const struct gl_pixelstore_attrib *finalUnpack;   struct gl_pixelstore_attrib scissoredUnpack;   /* check if there's any raster operations enabled which we can't handle */   if ((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 |*/ /* masking ok, we're in 32bpp */			      MULTI_DRAW_BIT |			      OCCLUSION_BIT |   /* nope! at least not yet */			      TEXTURE_BIT |			      FRAGPROG_BIT))      ) {      _swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap);      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 (px < ctx->Scissor.X) {	 scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);	 width -= (ctx->Scissor.X - px);	 px = ctx->Scissor.X;      }      /* clip right */      if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {	 width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));      }      /* clip bottom */      if (py < ctx->Scissor.Y) {	 scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);	 height -= (ctx->Scissor.Y - py);	 py = ctx->Scissor.Y;      }      /* clip top */      if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {	 height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));      }      if (width <= 0 || height <= 0)	 return;   }   else {      finalUnpack = unpack;   }   /* compute pixel value */   {      GLint r = (GLint) (ctx->Current.RasterColor[RCOMP] * 255.0f);      GLint g = (GLint) (ctx->Current.RasterColor[GCOMP] * 255.0f);      GLint b = (GLint) (ctx->Current.RasterColor[BCOMP] * 255.0f);      GLint a = (GLint) (ctx->Current.RasterColor[ACOMP] * 255.0f);      color = TDFXPACKCOLOR8888(b, g, r, a);   }   info.size = sizeof(info);   if (!grLfbLock(GR_LFB_WRITE_ONLY,		  fxMesa->currentFB,		  GR_LFBWRITEMODE_8888,		  GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) {      _swrast_Bitmap(ctx, px, py, width, height, finalUnpack, bitmap);      return;   }   {      const GLint winX = 0;      const GLint winY = 0;      /* The dest stride depends on the hardware and whether we're drawing       * to the front or back buffer.  This compile-time test seems to do       * the job for now.       */      const GLint dstStride = info.strideInBytes / 4;	/* stride in GLuints */      GLint row;      /* compute dest address of bottom-left pixel in bitmap */      GLuint *dst = (GLuint *) info.lfbPtr	 + (winY + py) * dstStride + (winX + px);      for (row = 0; row < height; row++) {	 const GLubyte *src =	    (const GLubyte *) _mesa_image_address2d(finalUnpack,                                                    bitmap, width, height,                                                    GL_COLOR_INDEX, GL_BITMAP,                                                    row, 0);	 if (finalUnpack->LsbFirst) {	    /* least significan bit first */	    GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);	    GLint col;	    for (col = 0; col < width; col++) {	       if (*src & mask) {		  dst[col] = color;	       }	       if (mask == 128U) {		  src++;		  mask = 1U;	       }	       else {		  mask = mask << 1;	       }	    }	    if (mask != 1)	       src++;	 }	 else {	    /* most significan bit first */	    GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);	    GLint col;	    for (col = 0; col < width; col++) {	       if (*src & mask) {		  dst[col] = color;	       }	       if (mask == 1U) {		  src++;		  mask = 128U;	       }	       else {		  mask = mask >> 1;	       }	    }	    if (mask != 128)	       src++;	 }	 dst += dstStride;      }   }   grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);}static voidfxDDReadPixels565 (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 5R6G5B 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 >> 11) & 0x1f];                  *d++ = FX_rgb_scale_6[(pixel >> 5)  & 0x3f];                  *d++ = FX_rgb_scale_5[ pixel        & 0x1f];                  *d++ = FX_rgb_scale_5[(pixel >> 27) & 0x1f];                  *d++ = FX_rgb_scale_6[(pixel >> 21) & 0x3f];                  *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f];	       }	       if (extraPixel) {		  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];	       }	       dst += dstStride;	       src -= srcStride;

⌨️ 快捷键说明

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