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

📄 xm_span.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
   register GLuint i;   register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            ptr[i] = PACK_8A8B8G8R( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );         }      }   }   else {      /* draw all pixels */      for (i=0;i<n;i++) {         ptr[i] = PACK_8A8B8G8R( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );      }   }}/* * Write a span of PF_8A8R8G8B-format pixels to an ximage. */static void put_row_8A8R8G8B_ximage( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   GET_XRB(xrb);   register GLuint i;   register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            ptr[i] = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );         }      }   }   else {      /* draw all pixels */      for (i=0;i<n;i++) {         ptr[i] = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );      }   }}/* * Write a span of PF_8A8R8G8B-format pixels to an ximage (no alpha). */static void put_row_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   GET_XRB(xrb);   register GLuint i;   register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            ptr[i] = PACK_8A8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );         }      }   }   else {      /* draw all pixels */      for (i=0;i<n;i++) {         ptr[i] = PACK_8A8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );      }   }}/* * Write a span of PF_8R8G8B-format pixels to an ximage. */static void put_row_8R8G8B_ximage( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   GET_XRB(xrb);   register GLuint i;   register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            ptr[i] = PACK_8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);         }      }   }   else {      for (i=0;i<n;i++) {         ptr[i] = PACK_8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);      }   }}/* * Write a span of PF_8R8G8B24-format pixels to an ximage. */static void put_row_8R8G8B24_ximage( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   GET_XRB(xrb);   register GLuint i;   register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y );   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            GLuint *ptr4 = (GLuint *) ptr;            register GLuint pixel = *ptr4;            switch (3 & (int)(ptr - (GLubyte*)ptr4)) {               case 0:                  pixel &= 0xff000000;                  pixel |= rgba[i][BCOMP];                  pixel |= rgba[i][GCOMP] << 8;                  pixel |= rgba[i][RCOMP] << 16;                  *ptr4 = pixel;                  break;               case 3:                  pixel &= 0x00ffffff;                  pixel |= rgba[i][BCOMP] << 24;                  *ptr4++ = pixel;                  pixel = *ptr4 & 0xffff0000;                  pixel |= rgba[i][GCOMP];                  pixel |= rgba[i][RCOMP] << 8;                  *ptr4 = pixel;                  break;               case 2:                  pixel &= 0x0000ffff;                  pixel |= rgba[i][BCOMP] << 16;                  pixel |= rgba[i][GCOMP] << 24;                  *ptr4++ = pixel;                  pixel = *ptr4 & 0xffffff00;                  pixel |= rgba[i][RCOMP];                  *ptr4 = pixel;                  break;               case 1:                  pixel &= 0x000000ff;                  pixel |= rgba[i][BCOMP] << 8;                  pixel |= rgba[i][GCOMP] << 16;                  pixel |= rgba[i][RCOMP] << 24;                  *ptr4 = pixel;                  break;            }         }	 ptr += 3;      }   }   else {      /* write all pixels */      int w = n;      GLuint *ptr4 = (GLuint *) ptr;      register GLuint pixel = *ptr4;      int index = (int)(ptr - (GLubyte *)ptr4);      register GLuint i = 0;      switch (index) {         case 0:            break;         case 1:            pixel &= 0x00ffffff;            pixel |= rgba[i][BCOMP] << 24;            *ptr4++ = pixel;            pixel = *ptr4 & 0xffff0000;            pixel |= rgba[i][GCOMP];            pixel |= rgba[i++][RCOMP] << 8;            *ptr4 = pixel;            if (0 == --w)               break;         case 2:            pixel &= 0x0000ffff;            pixel |= rgba[i][BCOMP] << 16;            pixel |= rgba[i][GCOMP] << 24;            *ptr4++ = pixel;            pixel = *ptr4 & 0xffffff00;            pixel |= rgba[i++][RCOMP];            *ptr4 = pixel;            if (0 == --w)               break;         case 3:            pixel &= 0x000000ff;            pixel |= rgba[i][BCOMP] << 8;            pixel |= rgba[i][GCOMP] << 16;            pixel |= rgba[i++][RCOMP] << 24;            *ptr4++ = pixel;            if (0 == --w)               break;            break;      }      while (w > 3) {         pixel = rgba[i][BCOMP];         pixel |= rgba[i][GCOMP] << 8;         pixel |= rgba[i++][RCOMP] << 16;         pixel |= rgba[i][BCOMP] << 24;         *ptr4++ = pixel;         pixel = rgba[i][GCOMP];         pixel |= rgba[i++][RCOMP] << 8;         pixel |= rgba[i][BCOMP] << 16;         pixel |= rgba[i][GCOMP] << 24;         *ptr4++ = pixel;         pixel = rgba[i++][RCOMP];         pixel |= rgba[i][BCOMP] << 8;         pixel |= rgba[i][GCOMP] << 16;         pixel |= rgba[i++][RCOMP] << 24;         *ptr4++ = pixel;         w -= 4;      }      switch (w) {         case 0:            break;         case 1:            pixel = *ptr4 & 0xff000000;            pixel |= rgba[i][BCOMP];            pixel |= rgba[i][GCOMP] << 8;            pixel |= rgba[i][RCOMP] << 16;            *ptr4 = pixel;            break;         case 2:            pixel = rgba[i][BCOMP];            pixel |= rgba[i][GCOMP] << 8;            pixel |= rgba[i++][RCOMP] << 16;            pixel |= rgba[i][BCOMP] << 24;            *ptr4++ = pixel;            pixel = *ptr4 & 0xffff0000;            pixel |= rgba[i][GCOMP];            pixel |= rgba[i][RCOMP] << 8;            *ptr4 = pixel;            break;         case 3:            pixel = rgba[i][BCOMP];            pixel |= rgba[i][GCOMP] << 8;            pixel |= rgba[i++][RCOMP] << 16;            pixel |= rgba[i][BCOMP] << 24;            *ptr4++ = pixel;            pixel = rgba[i][GCOMP];            pixel |= rgba[i++][RCOMP] << 8;            pixel |= rgba[i][BCOMP] << 16;            pixel |= rgba[i][GCOMP] << 24;            *ptr4++ = pixel;            pixel = *ptr4 & 0xffffff00;            pixel |= rgba[i][RCOMP];            *ptr4 = pixel;            break;      }   }}/* * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha). */static void put_row_rgb_8R8G8B_ximage( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   GET_XRB(xrb);   register GLuint i;   register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            ptr[i] = PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);         }      }   }   else {      /* draw all pixels */      for (i=0;i<n;i++) {         ptr[i] = PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);      }   }}/* * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha). */static void put_row_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   GET_XRB(xrb);   register GLuint i;   register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y);   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            *ptr++ = rgb[i][BCOMP];            *ptr++ = rgb[i][GCOMP];            *ptr++ = rgb[i][RCOMP];         }         else {            ptr += 3;         }      }   }   else {      /* draw all pixels */      for (i=0;i<n;i++) {         *ptr++ = rgb[i][BCOMP];         *ptr++ = rgb[i][GCOMP];         *ptr++ = rgb[i][RCOMP];      }   }}/* * Write a span of PF_5R6G5B-format pixels to an ximage. */static void put_row_5R6G5B_ximage( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   GET_XRB(xrb);   register GLuint i;   register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            ptr[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );         }      }   }   else {      /* draw all pixels */#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */      GLuint *ptr32 = (GLuint *) ptr;      GLuint extraPixel = (n & 1);      n -= extraPixel;      for (i = 0; i < n; i += 2) {         GLuint p0, p1;         p0 = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);         p1 = PACK_5R6G5B(rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP]);         *ptr32++ = (p1 << 16) | p0;      }      if (extraPixel) {         ptr[n] = PACK_5R6G5B(rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);      }#else      for (i = 0; i < n; i++) {         ptr[i] = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);      }#endif   }}/* * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage. */static void put_row_DITHER_5R6G5B_ximage( PUT_ROW_ARGS ){   const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;   GET_XRB(xrb);   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   register GLuint i;   register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);   const GLint y2 = YFLIP(xrb, y);   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );         }      }   }   else {      /* draw all pixels */#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */      GLuint *ptr32 = (GLuint *) ptr;      GLuint extraPixel = (n & 1);      n -= extraPixel;      for (i = 0; i < n; i += 2, x += 2) {         GLuint p0, p1;         PACK_TRUEDITHER( p0, x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );         PACK_TRUEDITHER( p1, x+1, y2, rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP] );         *ptr32++ = (p1 << 16) | p0;      }      if (extraPixel) {         PACK_TRUEDITHER( ptr[n], x+n, y2, rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);      }#else      for (i = 0; i < n; i++, x++) {         PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);      }#endif   }}/* * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha). */static void put_row_rgb_5R6G5B_ximage( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   GET_XRB(xrb);   register GLuint i;   register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);   if (mask) {      for (i=0;i<n;i++) {         if (mask[i]) {            ptr[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );         }      }   }   else {      /* draw all pixels */#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */      GLuint *ptr32 = (GLuint *) ptr;      GLuint extraPixel = (n & 1);      n -= extraPixel;      for (i = 0; i < n; i += 2) {         GLuint p0, p1;         p0 = PACK_5R6G5B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);         p1 = PACK_5R6G5B(rgb[i+1][RCOMP], rgb[i+1][GCOMP], rgb[i+1][BCOMP]);         *ptr32++ = (p1 << 16) | p0;      }      if (extraPixel) {         ptr[n] = PACK_5R6G5B(rgb[n][RCOMP], rgb[n][GCOMP], rgb[n][BCOMP]);      }#else      for (i=0;i<n;i++) {         ptr[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );      }#endif   }}/* * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha). */static void put_row_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS ){   const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;   GET_XRB(xrb);   const XMesaContext xmesa = XMESA_CONTEXT(ctx);   register GLuint i;   register GLushort *ptr = PIXEL_ADDR2(xrb, x, y );   if (mask) {      for (i=0;i<n;i++,x++) {         if (mask[i]) {            PACK_TRUEDITHER( ptr[i], x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );         }      }   }   else {      /* draw all pixels */#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */      GLuint *ptr32 = (GLuint *) ptr;      GLuint extraPixel = (n & 1);      n -= extraPixel;      for (i = 0; i < n; i += 2, x += 2) {         GLuint p0, p1;

⌨️ 快捷键说明

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