📄 pixman-access.c
字号:
static FASTCALL uint32_tfbFetchPixel_x1b5g5r5 (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 & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; return (0xff000000 | r | g | b);}static FASTCALL uint32_tfbFetchPixel_a4r4g4b4 (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 = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16; r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); return (a | r | g | b);}static FASTCALL uint32_tfbFetchPixel_x4r4g4b4 (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 & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); return (0xff000000 | r | g | b);}static FASTCALL uint32_tfbFetchPixel_a4b4g4r4 (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 = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16; b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4; g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16; return (a | r | g | b);}static FASTCALL uint32_tfbFetchPixel_x4b4g4r4 (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 & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4; g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16; return (0xff000000 | r | g | b);}static FASTCALL uint32_tfbFetchPixel_a8 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint8_t *) bits + offset); return pixel << 24;}static FASTCALL uint32_tfbFetchPixel_r3g3b2 (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, (uint8_t *) bits + offset); r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16; g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8; b = (((pixel & 0x03) ) | ((pixel & 0x03) << 2) | ((pixel & 0x03) << 4) | ((pixel & 0x03) << 6)); return (0xff000000 | r | g | b);}static FASTCALL uint32_tfbFetchPixel_b2g3r3 (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, (uint8_t *) bits + offset); b = (((pixel & 0xc0) ) | ((pixel & 0xc0) >> 2) | ((pixel & 0xc0) >> 4) | ((pixel & 0xc0) >> 6)); g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8; r = (((pixel & 0x07) ) | ((pixel & 0x07) << 3) | ((pixel & 0x06) << 6)) << 16; return (0xff000000 | r | g | b);}static FASTCALL uint32_tfbFetchPixel_a2r2g2b2 (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, (uint8_t *) bits + offset); a = ((pixel & 0xc0) * 0x55) << 18; r = ((pixel & 0x30) * 0x55) << 12; g = ((pixel & 0x0c) * 0x55) << 6; b = ((pixel & 0x03) * 0x55); return a|r|g|b;}static FASTCALL uint32_tfbFetchPixel_a2b2g2r2 (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, (uint8_t *) bits + offset); a = ((pixel & 0xc0) * 0x55) << 18; b = ((pixel & 0x30) * 0x55) >> 6; g = ((pixel & 0x0c) * 0x55) << 6; r = ((pixel & 0x03) * 0x55) << 16; return a|r|g|b;}static FASTCALL uint32_tfbFetchPixel_c8 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint8_t *) bits + offset); const pixman_indexed_t * indexed = pict->indexed; return indexed->rgba[pixel];}static FASTCALL uint32_tfbFetchPixel_x4a4 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, (uint8_t *) bits + offset); return ((pixel & 0xf) | ((pixel & 0xf) << 4)) << 24;}static FASTCALL uint32_tfbFetchPixel_a4 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = Fetch4(pict, bits, offset); pixel |= pixel << 4; return pixel << 24;}static FASTCALL uint32_tfbFetchPixel_r1g2b1 (bits_image_t *pict, int offset, int line){ uint32_t r,g,b; uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = Fetch4(pict, bits, offset); r = ((pixel & 0x8) * 0xff) << 13; g = ((pixel & 0x6) * 0x55) << 7; b = ((pixel & 0x1) * 0xff); return 0xff000000|r|g|b;}static FASTCALL uint32_tfbFetchPixel_b1g2r1 (bits_image_t *pict, int offset, int line){ uint32_t r,g,b; uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = Fetch4(pict, bits, offset); b = ((pixel & 0x8) * 0xff) >> 3; g = ((pixel & 0x6) * 0x55) << 7; r = ((pixel & 0x1) * 0xff) << 16; return 0xff000000|r|g|b;}static FASTCALL uint32_tfbFetchPixel_a1r1g1b1 (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 = Fetch4(pict, bits, offset); a = ((pixel & 0x8) * 0xff) << 21; r = ((pixel & 0x4) * 0xff) << 14; g = ((pixel & 0x2) * 0xff) << 7; b = ((pixel & 0x1) * 0xff); return a|r|g|b;}static FASTCALL uint32_tfbFetchPixel_a1b1g1r1 (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 = Fetch4(pict, bits, offset); a = ((pixel & 0x8) * 0xff) << 21; r = ((pixel & 0x4) * 0xff) >> 3; g = ((pixel & 0x2) * 0xff) << 7; b = ((pixel & 0x1) * 0xff) << 16; return a|r|g|b;}static FASTCALL uint32_tfbFetchPixel_c4 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = Fetch4(pict, bits, offset); const pixman_indexed_t * indexed = pict->indexed; return indexed->rgba[pixel];}static FASTCALL uint32_tfbFetchPixel_a1 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, bits + (offset >> 5)); uint32_t a;#if BITMAP_BIT_ORDER == MSBFirst a = pixel >> (0x1f - (offset & 0x1f));#else a = pixel >> (offset & 0x1f);#endif a = a & 1; a |= a << 1; a |= a << 2; a |= a << 4; return a << 24;}static FASTCALL uint32_tfbFetchPixel_g1 (bits_image_t *pict, int offset, int line){ uint32_t *bits = pict->bits + line*pict->rowstride; uint32_t pixel = READ(pict, bits + (offset >> 5)); const pixman_indexed_t * indexed = pict->indexed; uint32_t a;#if BITMAP_BIT_ORDER == MSBFirst a = pixel >> (0x1f - (offset & 0x1f));#else a = pixel >> (offset & 0x1f);#endif a = a & 1; return indexed->rgba[a];}static FASTCALL uint32_tfbFetchPixel_yuy2 (bits_image_t *pict, int offset, int line){ int16_t y, u, v; int32_t r, g, b; const uint32_t *bits = pict->bits + pict->rowstride * line; y = ((uint8_t *) bits)[offset << 1] - 16; u = ((uint8_t *) bits)[((offset << 1) & -4) + 1] - 128; v = ((uint8_t *) bits)[((offset << 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; return 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 uint32_tfbFetchPixel_yv12 (bits_image_t *pict, int offset, int line){ YV12_SETUP(pict); int16_t y = YV12_Y (line)[offset] - 16; int16_t u = YV12_U (line)[offset >> 1] - 128; int16_t v = YV12_V (line)[offset >> 1] - 128; int32_t r, g, b; /* 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; return 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);}fetchPixelProc FETCH_PIXEL_PROC_FOR_PICTURE (bits_image_t * pict){ switch(pict->format) { case PIXMAN_a8r8g8b8: return fbFetchPixel_a8r8g8b8; case PIXMAN_x8r8g8b8: return fbFetchPixel_x8r8g8b8; case PIXMAN_a8b8g8r8: return fbFetchPixel_a8b8g8r8; case PIXMAN_x8b8g8r8: return fbFetchPixel_x8b8g8r8; /* 24bpp formats */ case PIXMAN_r8g8b8: return fbFetchPixel_r8g8b8; case PIXMAN_b8g8r8: return fbFetchPixel_b8g8r8; /* 16bpp formats */ case PIXMAN_r5g6b5: return fbFetchPixel_r5g6b5; case PIXMAN_b5g6r5: return fbFetchPixel_b5g6r5; case PIXMAN_a1r5g5b5: return fbFetchPixel_a1r5g5b5; case PIXMAN_x1r5g5b5: return fbFetchPixel_x1r5g5b5; case PIXMAN_a1b5g5r5: return fbFetchPixel_a1b5g5r5; case PIXMAN_x1b5g5r5: return fbFetchPixel_x1b5g5r5; case PIXMAN_a4r4g4b4: return fbFetchPixel_a4r4g4b4; case PIXMAN_x4r4g4b4: return fbFetchPixel_x4r4g4b4; case PIXMAN_a4b4g4r4: return fbFetchPixel_a4b4g4r4; case PIXMAN_x4b4g4r4: return fbFetchPixel_x4b4g4r4; /* 8bpp formats */ case PIXMAN_a8: return fbFetchPixel_a8; case PIXMAN_r3g3b2: return fbFetchPixel_r3g3b2; case PIXMAN_b2g3r3: return fbFetchPixel_b2g3r3; case PIXMAN_a2r2g2b2: return fbFetchPixel_a2r2g2b2; case PIXMAN_a2b2g2r2: return fbFetchPixel_a2b2g2r2; case PIXMAN_c8: return fbFetchPixel_c8; case PIXMAN_g8: return fbFetchPixel_c8; case PIXMAN_x4a4: return fbFetchPixel_x4a4; /* 4bpp formats */ case PIXMAN_a4: return fbFetchPixel_a4; case PIXMAN_r1g2b1: return fbFetchPixel_r1g2b1; case PIXMAN_b1g2r1: return fbFetchPixel_b1g2r1; case PIXMAN_a1r1g1b1: return fbFetchPixel_a1r1g1b1; case PIXMAN_a1b1g1r1: return fbFetchPixel_a1b1g1r1; case PIXMAN_c4: return fbFetchPixel_c4; case PIXMAN_g4: return fbFetchPixel_c4; /* 1bpp formats */ case PIXMAN_a1: return fbFetchPixel_a1; case PIXMAN_g1: return fbFetchPixel_g1; /* YUV formats */ case PIXMAN_yuy2: return fbFetchPixel_yuy2; case PIXMAN_yv12: return fbFetchPixel_yv12; } return NULL;}/*********************************** Store ************************************/#define Splita(v) uint32_t a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff#define Split(v) uint32_t r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xffstatic FASTCALL voidfbStore_a8r8g8b8 (pixman_image_t *image, uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed){ MEMCPY_WRAPPED(image, ((uint32_t *)bits) + x, values, width*sizeof(uint32_t));}static FASTCALL voidfbStore_x8r8g8b8 (pixman_image_t *image, uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed){ int i; uint32_t *pixel = (uint32_t *)bits + x; for (i = 0; i < width; ++i) WRITE(image, pixel++, values[i] & 0xffffff);}static FASTCALL voidfbStore_a8b8g8r8 (pixman_image_t *image, uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed){ int i; uint32_t *pixel = (uint32_t *)bits + x; for (i = 0; i < width; ++i) WRITE(image, pixel++, (values[i] & 0xff00ff00) | ((values[i] >> 16) & 0xff) | ((values[i] & 0xff) << 16));}static FASTCALL voidfbStore_x8b8g8r8 (pixman_image_t *image, uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed){ int i; uint32_t *pixel = (uint32_t *)bits + x; for (i = 0; i < width; ++i) WRITE(image, pixel++, (values[i] & 0x0000ff00) | ((values[i] >> 16) & 0xff) | ((values[i] & 0xff) << 16));}static FASTCALL voidfbStore_r8g8b8 (pixman_image_t *image, uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t * indexed){ int i; uint8_t *pixel = ((uint8_t *) bits) + 3*x; for (i = 0; i < width; ++i) { Store24(image, pixel, values[i]); pixel += 3; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -