📄 pixman-access.c
字号:
{ const uint32_t *bits = pict->bits + y*pict->rowstride; const pixman_indexed_t * indexed = pict->indexed; const uint8_t *pixel = (const uint8_t *)bits + x; const uint8_t *end = pixel + width; while (pixel < end) { uint32_t p = READ(pict, pixel++); *buffer++ = indexed->rgba[p]; }}static FASTCALL voidfbFetch_x4a4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ const uint32_t *bits = pict->bits + y*pict->rowstride; const uint8_t *pixel = (const uint8_t *)bits + x; const uint8_t *end = pixel + width; while (pixel < end) { uint8_t p = READ(pict, pixel++) & 0xf; *buffer++ = (p | (p << 4)) << 24; }}#define Fetch8(img,l,o) (READ(img, (uint8_t *)(l) + ((o) >> 2)))#if IMAGE_BYTE_ORDER == MSBFirst#define Fetch4(img,l,o) ((o) & 2 ? Fetch8(img,l,o) & 0xf : Fetch8(img,l,o) >> 4)#else#define Fetch4(img,l,o) ((o) & 2 ? Fetch8(img,l,o) >> 4 : Fetch8(img,l,o) & 0xf)#endifstatic FASTCALL voidfbFetch_a4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ const uint32_t *bits = pict->bits + y*pict->rowstride; int i; for (i = 0; i < width; ++i) { uint32_t p = Fetch4(pict, bits, i + x); p |= p << 4; *buffer++ = p << 24; }}static FASTCALL voidfbFetch_r1g2b1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ uint32_t r,g,b; const uint32_t *bits = pict->bits + y*pict->rowstride; int i; for (i = 0; i < width; ++i) { uint32_t p = Fetch4(pict, bits, i + x); r = ((p & 0x8) * 0xff) << 13; g = ((p & 0x6) * 0x55) << 7; b = ((p & 0x1) * 0xff); *buffer++ = 0xff000000|r|g|b; }}static FASTCALL voidfbFetch_b1g2r1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ uint32_t r,g,b; const uint32_t *bits = pict->bits + y*pict->rowstride; int i; for (i = 0; i < width; ++i) { uint32_t p = Fetch4(pict, bits, i + x); b = ((p & 0x8) * 0xff) >> 3; g = ((p & 0x6) * 0x55) << 7; r = ((p & 0x1) * 0xff) << 16; *buffer++ = 0xff000000|r|g|b; }}static FASTCALL voidfbFetch_a1r1g1b1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ uint32_t a,r,g,b; const uint32_t *bits = pict->bits + y*pict->rowstride; int i; for (i = 0; i < width; ++i) { uint32_t p = Fetch4(pict, bits, i + x); a = ((p & 0x8) * 0xff) << 21; r = ((p & 0x4) * 0xff) << 14; g = ((p & 0x2) * 0xff) << 7; b = ((p & 0x1) * 0xff); *buffer++ = a|r|g|b; }}static FASTCALL voidfbFetch_a1b1g1r1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ uint32_t a,r,g,b; const uint32_t *bits = pict->bits + y*pict->rowstride; int i; for (i = 0; i < width; ++i) { uint32_t p = Fetch4(pict, bits, i + x); a = ((p & 0x8) * 0xff) << 21; r = ((p & 0x4) * 0xff) >> 3; g = ((p & 0x2) * 0xff) << 7; b = ((p & 0x1) * 0xff) << 16; *buffer++ = a|r|g|b; }}static FASTCALL voidfbFetch_c4 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ const uint32_t *bits = pict->bits + y*pict->rowstride; const pixman_indexed_t * indexed = pict->indexed; int i; for (i = 0; i < width; ++i) { uint32_t p = Fetch4(pict, bits, i + x); *buffer++ = indexed->rgba[p]; }}static FASTCALL voidfbFetch_a1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ const uint32_t *bits = pict->bits + y*pict->rowstride; int i; for (i = 0; i < width; ++i) { uint32_t p = READ(pict, bits + ((i + x) >> 5)); uint32_t a;#if BITMAP_BIT_ORDER == MSBFirst a = p >> (0x1f - ((i+x) & 0x1f));#else a = p >> ((i+x) & 0x1f);#endif a = a & 1; a |= a << 1; a |= a << 2; a |= a << 4; *buffer++ = a << 24; }}static FASTCALL voidfbFetch_g1 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer){ const uint32_t *bits = pict->bits + y*pict->rowstride; const pixman_indexed_t * indexed = pict->indexed; int i; for (i = 0; i < width; ++i) { uint32_t p = READ(pict, bits + ((i+x) >> 5)); uint32_t a;#if BITMAP_BIT_ORDER == MSBFirst a = p >> (0x1f - ((i+x) & 0x1f));#else a = p >> ((i+x) & 0x1f);#endif a = a & 1; *buffer++ = indexed->rgba[a]; }}static FASTCALL voidfbFetch_yuy2 (bits_image_t *pict, int x, int line, int width, uint32_t *buffer){ int16_t y, u, v; int32_t r, g, b; int i; const uint32_t *bits = pict->bits + pict->rowstride * line; for (i = 0; i < width; i++) { y = ((uint8_t *) bits)[(x + i) << 1] - 16; u = ((uint8_t *) bits)[(((x + i) << 1) & -4) + 1] - 128; v = ((uint8_t *) bits)[(((x + i) << 1) & -4) + 3] - 128; /* R = 1.164(Y - 16) + 1.596(V - 128) */ r = 0x012b27 * y + 0x019a2e * v; /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */ g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u; /* B = 1.164(Y - 16) + 2.018(U - 128) */ b = 0x012b27 * y + 0x0206a2 * u; WRITE(pict, buffer++, 0xff000000 | (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) | (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) | (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0)); }}static FASTCALL voidfbFetch_yv12 (bits_image_t *pict, int x, int line, int width, uint32_t *buffer){ YV12_SETUP(pict); uint8_t *pY = YV12_Y (line); uint8_t *pU = YV12_U (line); uint8_t *pV = YV12_V (line); int16_t y, u, v; int32_t r, g, b; int i; for (i = 0; i < width; i++) { y = pY[x + i] - 16; u = pU[(x + i) >> 1] - 128; v = pV[(x + i) >> 1] - 128; /* R = 1.164(Y - 16) + 1.596(V - 128) */ r = 0x012b27 * y + 0x019a2e * v; /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */ g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u; /* B = 1.164(Y - 16) + 2.018(U - 128) */ b = 0x012b27 * y + 0x0206a2 * u; WRITE(pict, buffer++, 0xff000000 | (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) | (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) | (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0)); }}fetchProc FETCH_PROC_FOR_PICTURE (bits_image_t * pict){ switch(pict->format) { case PIXMAN_a8r8g8b8: return fbFetch_a8r8g8b8; case PIXMAN_x8r8g8b8: return fbFetch_x8r8g8b8; case PIXMAN_a8b8g8r8: return fbFetch_a8b8g8r8; case PIXMAN_x8b8g8r8: return fbFetch_x8b8g8r8; /* 24bpp formats */ case PIXMAN_r8g8b8: return fbFetch_r8g8b8; case PIXMAN_b8g8r8: return fbFetch_b8g8r8; /* 16bpp formats */ case PIXMAN_r5g6b5: return fbFetch_r5g6b5; case PIXMAN_b5g6r5: return fbFetch_b5g6r5; case PIXMAN_a1r5g5b5: return fbFetch_a1r5g5b5; case PIXMAN_x1r5g5b5: return fbFetch_x1r5g5b5; case PIXMAN_a1b5g5r5: return fbFetch_a1b5g5r5; case PIXMAN_x1b5g5r5: return fbFetch_x1b5g5r5; case PIXMAN_a4r4g4b4: return fbFetch_a4r4g4b4; case PIXMAN_x4r4g4b4: return fbFetch_x4r4g4b4; case PIXMAN_a4b4g4r4: return fbFetch_a4b4g4r4; case PIXMAN_x4b4g4r4: return fbFetch_x4b4g4r4; /* 8bpp formats */ case PIXMAN_a8: return fbFetch_a8; case PIXMAN_r3g3b2: return fbFetch_r3g3b2; case PIXMAN_b2g3r3: return fbFetch_b2g3r3; case PIXMAN_a2r2g2b2: return fbFetch_a2r2g2b2; case PIXMAN_a2b2g2r2: return fbFetch_a2b2g2r2; case PIXMAN_c8: return fbFetch_c8; case PIXMAN_g8: return fbFetch_c8; case PIXMAN_x4a4: return fbFetch_x4a4; /* 4bpp formats */ case PIXMAN_a4: return fbFetch_a4; case PIXMAN_r1g2b1: return fbFetch_r1g2b1; case PIXMAN_b1g2r1: return fbFetch_b1g2r1; case PIXMAN_a1r1g1b1: return fbFetch_a1r1g1b1; case PIXMAN_a1b1g1r1: return fbFetch_a1b1g1r1; case PIXMAN_c4: return fbFetch_c4; case PIXMAN_g4: return fbFetch_c4; /* 1bpp formats */ case PIXMAN_a1: return fbFetch_a1; case PIXMAN_g1: return fbFetch_g1; /* YUV formats */ case PIXMAN_yuy2: return fbFetch_yuy2; case PIXMAN_yv12: return fbFetch_yv12; } return NULL;}/**************************** Pixel wise fetching *****************************/static FASTCALL uint32_tfbFetchPixel_a8r8g8b8 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; return READ(pict, (uint32_t *)bits + offset);}static FASTCALL uint32_tfbFetchPixel_x8r8g8b8 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; return READ(pict, (uint32_t *)bits + offset) | 0xff000000;}static FASTCALL uint32_tfbFetchPixel_a8b8g8r8 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint32_t *)bits + offset); return ((pixel & 0xff000000) | ((pixel >> 16) & 0xff) | (pixel & 0x0000ff00) | ((pixel & 0xff) << 16));}static FASTCALL uint32_tfbFetchPixel_x8b8g8r8 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint32_t *)bits + offset); return ((0xff000000) | ((pixel >> 16) & 0xff) | (pixel & 0x0000ff00) | ((pixel & 0xff) << 16));}static FASTCALL uint32_tfbFetchPixel_r8g8b8 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint8_t *pixel = ((uint8_t *) bits) + (offset*3);#if IMAGE_BYTE_ORDER == MSBFirst return (0xff000000 | (READ(pict, pixel + 0) << 16) | (READ(pict, pixel + 1) << 8) | (READ(pict, pixel + 2)));#else return (0xff000000 | (READ(pict, pixel + 2) << 16) | (READ(pict, pixel + 1) << 8) | (READ(pict, pixel + 0)));#endif}static FASTCALL uint32_tfbFetchPixel_b8g8r8 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint8_t *pixel = ((uint8_t *) bits) + (offset*3);#if IMAGE_BYTE_ORDER == MSBFirst return (0xff000000 | (READ(pict, pixel + 2) << 16) | (READ(pict, pixel + 1) << 8) | (READ(pict, pixel + 0)));#else return (0xff000000 | (READ(pict, pixel + 0) << 16) | (READ(pict, pixel + 1) << 8) | (READ(pict, pixel + 2)));#endif}static FASTCALL uint32_tfbFetchPixel_r5g6b5 (bits_image_t *pict, int offset, int line){ uint32_t r,g,b; uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint16_t *) bits + offset); r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8; g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; return (0xff000000 | r | g | b);}static FASTCALL uint32_tfbFetchPixel_b5g6r5 (bits_image_t *pict, int offset, int line){ uint32_t r,g,b; uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint16_t *) bits + offset); b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8; g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; return (0xff000000 | r | g | b);}static FASTCALL uint32_tfbFetchPixel_a1r5g5b5 (bits_image_t *pict, int offset, int line){ uint32_t a,r,g,b; uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint16_t *) bits + offset); a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24; r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; return (a | r | g | b);}static FASTCALL uint32_tfbFetchPixel_x1r5g5b5 (bits_image_t *pict, int offset, int line){ uint32_t r,g,b; uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint16_t *) bits + offset); r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; return (0xff000000 | r | g | b);}static FASTCALL uint32_tfbFetchPixel_a1b5g5r5 (bits_image_t *pict, int offset, int line){ uint32_t a,r,g,b; uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint16_t *) bits + offset); a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24; b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; return (a | r | g | b);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -