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

📄 xm_span.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLuint *ptr4 = (GLuint *) rowimg->data;      for (i=0;i<n;i++) {         *ptr4++ = PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_8R8G8B pixels to a pixmap. */static void put_row_8R8G8B_pixmap( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   register GLuint i;   y = YFLIP(xrb, y);   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLuint *ptr4 = (GLuint *) rowimg->data;      for (i=0;i<n;i++) {         *ptr4++ = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_8R8G8B24 pixels to a pixmap. */static void put_row_8R8G8B24_pixmap( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   y = YFLIP(xrb, y);   if (mask) {      register GLuint i;      for (i=0;i<n;i++,x++) {         if (mask[i]) {            XMesaSetForeground( dpy, gc,               PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLuint *ptr4 = (GLuint *) rowimg->data;      register GLuint pixel;      static const GLuint shift[4] = {0, 8, 16, 24};      register GLuint i = 0;      int w = n;      while (w > 3) {         pixel  = rgba[i][BCOMP] /* << shift[0]*/;         pixel |= rgba[i][GCOMP]    << shift[1];         pixel |= rgba[i++][RCOMP]  << shift[2];         pixel |= rgba[i][BCOMP]    << shift[3];         *ptr4++ = pixel;         pixel  = rgba[i][GCOMP] /* << shift[0]*/;         pixel |= rgba[i++][RCOMP]  << shift[1];         pixel |= rgba[i][BCOMP]    << shift[2];         pixel |= rgba[i][GCOMP]    << shift[3];         *ptr4++ = pixel;         pixel  = rgba[i++][RCOMP]/* << shift[0]*/;         pixel |= rgba[i][BCOMP]     << shift[1];         pixel |= rgba[i][GCOMP]     << shift[2];         pixel |= rgba[i++][RCOMP]   << shift[3];         *ptr4++ = pixel;         w -= 4;      }      switch (w) {         case 3:            pixel = 0;            pixel |= rgba[i][BCOMP] /*<< shift[0]*/;            pixel |= rgba[i][GCOMP]   << shift[1];            pixel |= rgba[i++][RCOMP] << shift[2];            pixel |= rgba[i][BCOMP]   << shift[3];            *ptr4++ = pixel;            pixel = 0;            pixel |= rgba[i][GCOMP] /*<< shift[0]*/;            pixel |= rgba[i++][RCOMP] << shift[1];            pixel |= rgba[i][BCOMP]   << shift[2];            pixel |= rgba[i][GCOMP]   << shift[3];            *ptr4++ = pixel;            pixel = 0xffffff00 & *ptr4;            pixel |= rgba[i][RCOMP] /*<< shift[0]*/;            *ptr4 = pixel;            break;         case 2:            pixel = 0;            pixel |= rgba[i][BCOMP] /*<< shift[0]*/;            pixel |= rgba[i][GCOMP]   << shift[1];            pixel |= rgba[i++][RCOMP] << shift[2];            pixel |= rgba[i][BCOMP]   << shift[3];            *ptr4++ = pixel;            pixel = 0xffff0000 & *ptr4;            pixel |= rgba[i][GCOMP] /*<< shift[0]*/;            pixel |= rgba[i][RCOMP]   << shift[1];            *ptr4 = pixel;            break;         case 1:            pixel = 0xff000000 & *ptr4;            pixel |= rgba[i][BCOMP] /*<< shift[0]*/;            pixel |= rgba[i][GCOMP] << shift[1];            pixel |= rgba[i][RCOMP] << shift[2];            *ptr4 = pixel;            break;         case 0:            break;      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_8R8G8B pixels to a pixmap (no alpha). */static void put_row_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   register GLuint i;   y = YFLIP(xrb, y);   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLuint *ptr4 = (GLuint *) rowimg->data;      for (i=0;i<n;i++) {         *ptr4++ = PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha). */static void put_row_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   y = YFLIP(xrb, y);   if (mask) {      register GLuint i;      for (i=0;i<n;i++,x++) {         if (mask[i]) {            XMesaSetForeground( dpy, gc,                  PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLuint *ptr4 = (GLuint *) rowimg->data;      register GLuint pixel;      static const GLuint shift[4] = {0, 8, 16, 24};      unsigned w = n;      register GLuint i = 0;      while (w > 3) {         pixel = 0;         pixel |= rgb[i][BCOMP]/* << shift[0]*/;         pixel |= rgb[i][GCOMP] << shift[1];         pixel |= rgb[i++][RCOMP] << shift[2];         pixel |= rgb[i][BCOMP] <<shift[3];         *ptr4++ = pixel;         pixel = 0;         pixel |= rgb[i][GCOMP]/* << shift[0]*/;         pixel |= rgb[i++][RCOMP] << shift[1];         pixel |= rgb[i][BCOMP] << shift[2];         pixel |= rgb[i][GCOMP] << shift[3];         *ptr4++ = pixel;         pixel = 0;         pixel |= rgb[i++][RCOMP]/* << shift[0]*/;         pixel |= rgb[i][BCOMP] << shift[1];         pixel |= rgb[i][GCOMP] << shift[2];         pixel |= rgb[i++][RCOMP] << shift[3];         *ptr4++ = pixel;         w -= 4;      }      switch (w) {         case 3:            pixel = 0;            pixel |= rgb[i][BCOMP]/* << shift[0]*/;            pixel |= rgb[i][GCOMP] << shift[1];            pixel |= rgb[i++][RCOMP] << shift[2];            pixel |= rgb[i][BCOMP] << shift[3];            *ptr4++ = pixel;            pixel = 0;            pixel |= rgb[i][GCOMP]/* << shift[0]*/;            pixel |= rgb[i++][RCOMP] << shift[1];            pixel |= rgb[i][BCOMP] << shift[2];            pixel |= rgb[i][GCOMP] << shift[3];            *ptr4++ = pixel;            pixel = *ptr4;            pixel &= 0xffffff00;            pixel |= rgb[i++][RCOMP]/* << shift[0]*/;            *ptr4++ = pixel;            break;         case 2:            pixel = 0;            pixel |= rgb[i][BCOMP]/* << shift[0]*/;            pixel |= rgb[i][GCOMP] << shift[1];            pixel |= rgb[i++][RCOMP] << shift[2];            pixel |= rgb[i][BCOMP]  << shift[3];            *ptr4++ = pixel;            pixel = *ptr4;            pixel &= 0xffff0000;            pixel |= rgb[i][GCOMP]/* << shift[0]*/;            pixel |= rgb[i++][RCOMP] << shift[1];            *ptr4++ = pixel;            break;         case 1:            pixel = *ptr4;            pixel &= 0xff000000;            pixel |= rgb[i][BCOMP]/* << shift[0]*/;            pixel |= rgb[i][GCOMP] << shift[1];            pixel |= rgb[i++][RCOMP] << shift[2];            *ptr4++ = pixel;            break;         case 0:            break;      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_5R6G5B pixels to a pixmap. */static void put_row_5R6G5B_pixmap( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   register GLuint i;   y = YFLIP(xrb, y);   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLushort *ptr2 = (GLushort *) rowimg->data;      for (i=0;i<n;i++) {         ptr2[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_DITHER_5R6G5B pixels to a pixmap. */static void put_row_DITHER_5R6G5B_pixmap( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   register GLuint i;   y = YFLIP(xrb, y);   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            unsigned long p;            PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);            XMesaSetForeground( dpy, gc, p );            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLushort *ptr2 = (GLushort *) rowimg->data;      for (i=0;i<n;i++) {         PACK_TRUEDITHER( ptr2[i], x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_5R6G5B pixels to a pixmap (no alpha). */static void put_row_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   register GLuint i;   y = YFLIP(xrb, y);   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLushort *ptr2 = (GLushort *) rowimg->data;      for (i=0;i<n;i++) {         ptr2[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha). */static void put_row_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   register GLuint i;   y = YFLIP(xrb, y);   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            unsigned long p;            PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);            XMesaSetForeground( dpy, gc, p );            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      register GLushort *ptr2 = (GLushort *) rowimg->data;      for (i=0;i<n;i++) {         PACK_TRUEDITHER( ptr2[i], x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_DITHER pixels to a pixmap. */static void put_row_DITHER_pixmap( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   GET_XRB(xrb);   XMesaDisplay *dpy = xmesa->xm_visual->display;   XMesaDrawable buffer = xrb->drawable;   XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;   register GLuint i;   XDITHER_SETUP(y);   y = YFLIP(xrb, y);   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            XMesaSetForeground( dpy, gc, XDITHER(x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );            XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );         }      }   }   else {      /* draw all pixels */      XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;      for (i=0;i<n;i++) {         XMesaPutPixel( rowimg, i, 0, XDITHER(x+i, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );      }      XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );   }}/* * Write a span of PF_DITHER pixels to a pixmap (no alpha). */static void put_row_rgb_DITHER_pixmap( RGB_SPAN_ARGS )

⌨️ 快捷键说明

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