📄 pixman-private.h
字号:
#ifndef PACKAGE# error config.h must be included before pixman-private.h#endif#ifndef PIXMAN_PRIVATE_H#define PIXMAN_PRIVATE_H#include "pixman.h"#include <time.h>#ifndef FALSE#define FALSE 0#endif#ifndef TRUE#define TRUE 1#endif#define MSBFirst 0#define LSBFirst 1#ifdef WORDS_BIGENDIAN# define IMAGE_BYTE_ORDER MSBFirst# define BITMAP_BIT_ORDER MSBFirst#else# define IMAGE_BYTE_ORDER LSBFirst# define BITMAP_BIT_ORDER LSBFirst#endif#undef DEBUG#define DEBUG 0#if defined (__GNUC__)# define FUNC ((const char*) (__PRETTY_FUNCTION__))#elif defined (__sun) || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)# define FUNC ((const char*) (__func__))#else# define FUNC ((const char*) ("???"))#endif#ifndef INT16_MIN# define INT16_MIN (-32767-1)#endif#ifndef INT16_MAX# define INT16_MAX (32767)#endif#ifndef INT32_MIN# define INT32_MIN (-2147483647-1)#endif#ifndef INT32_MAX# define INT32_MAX (2147483647)#endif#ifndef UINT32_MIN# define UINT32_MIN (0)#endif#ifndef UINT32_MAX# define UINT32_MAX (4294967295U)#endif#ifndef M_PI# define M_PI 3.14159265358979323846#endif#ifdef _MSC_VER#define inline __inline#endif#define FB_SHIFT 5#define FB_UNIT (1 << FB_SHIFT)#define FB_HALFUNIT (1 << (FB_SHIFT-1))#define FB_MASK (FB_UNIT - 1)#define FB_ALLONES ((uint32_t) -1)/* Memory allocation helpers */void *pixman_malloc_ab (unsigned int n, unsigned int b);void *pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);pixman_bool_t pixman_multiply_overflows_int (unsigned int a, unsigned int b);pixman_bool_t pixman_addition_overflows_int (unsigned int a, unsigned int b);#if DEBUG#define return_if_fail(expr) \ do \ { \ if (!(expr)) \ { \ fprintf(stderr, "In %s: %s failed\n", FUNC, #expr); \ return; \ } \ } \ while (0)#define return_val_if_fail(expr, retval) \ do \ { \ if (!(expr)) \ { \ fprintf(stderr, "In %s: %s failed\n", FUNC, #expr); \ return (retval); \ } \ } \ while (0)#else#define return_if_fail(expr) \ do \ { \ if (!(expr)) \ return; \ } \ while (0)#define return_val_if_fail(expr, retval) \ do \ { \ if (!(expr)) \ return (retval); \ } \ while (0)#endiftypedef struct image_common image_common_t;typedef struct source_image source_image_t;typedef struct solid_fill solid_fill_t;typedef struct gradient gradient_t;typedef struct linear_gradient linear_gradient_t;typedef struct horizontal_gradient horizontal_gradient_t;typedef struct vertical_gradient vertical_gradient_t;typedef struct conical_gradient conical_gradient_t;typedef struct radial_gradient radial_gradient_t;typedef struct bits_image bits_image_t;typedef struct circle circle_t;typedef struct point point_t;/* FIXME - the types and structures below should be give proper names */#define FASTCALLtypedef FASTCALL void (*CombineMaskU) (uint32_t *src, const uint32_t *mask, int width);typedef FASTCALL void (*CombineFuncU) (uint32_t *dest, const uint32_t *src, int width);typedef FASTCALL void (*CombineFuncC) (uint32_t *dest, uint32_t *src, uint32_t *mask, int width);typedef FASTCALL void (*fetchProc)(bits_image_t *pict, int x, int y, int width, uint32_t *buffer);typedef FASTCALL uint32_t (*fetchPixelProc)(bits_image_t *pict, int offset, int line);typedef FASTCALL void (*storeProc)(pixman_image_t *, uint32_t *bits, const uint32_t *values, int x, int width, const pixman_indexed_t *);typedef struct _FbComposeData { uint8_t op; pixman_image_t *src; pixman_image_t *mask; pixman_image_t *dest; int16_t xSrc; int16_t ySrc; int16_t xMask; int16_t yMask; int16_t xDest; int16_t yDest; uint16_t width; uint16_t height;} FbComposeData;typedef struct _FbComposeFunctions { CombineFuncU *combineU; CombineFuncC *combineC; CombineMaskU combineMaskU;} FbComposeFunctions;extern FbComposeFunctions pixman_composeFunctions;void pixman_composite_rect_general_accessors (const FbComposeData *data, uint32_t *scanline_buffer);void pixman_composite_rect_general (const FbComposeData *data, uint32_t *scanline_buffer);fetchProc pixman_fetchProcForPicture (bits_image_t *);fetchPixelProc pixman_fetchPixelProcForPicture (bits_image_t *);storeProc pixman_storeProcForPicture (bits_image_t *);fetchProc pixman_fetchProcForPicture_accessors (bits_image_t *);fetchPixelProc pixman_fetchPixelProcForPicture_accessors (bits_image_t *);storeProc pixman_storeProcForPicture_accessors (bits_image_t *);void pixmanFetchSourcePict(source_image_t *, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits);void fbFetchTransformed(bits_image_t *, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits);void fbStoreExternalAlpha(bits_image_t *, int x, int y, int width, uint32_t *buffer);void fbFetchExternalAlpha(bits_image_t *, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits);void fbFetchTransformed_accessors(bits_image_t *, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits);void fbStoreExternalAlpha_accessors(bits_image_t *, int x, int y, int width, uint32_t *buffer);void fbFetchExternalAlpha_accessors(bits_image_t *, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits);/* end */typedef enum{ BITS, LINEAR, CONICAL, RADIAL, SOLID} image_type_t;#define IS_SOURCE_IMAGE(img) (((image_common_t *)img)->type > BITS)typedef enum{ SOURCE_IMAGE_CLASS_UNKNOWN, SOURCE_IMAGE_CLASS_HORIZONTAL, SOURCE_IMAGE_CLASS_VERTICAL} source_pict_class_t;struct point{ int16_t x, y;};struct image_common{ image_type_t type; int32_t ref_count; pixman_region16_t full_region; pixman_region16_t clip_region; pixman_region16_t *src_clip; pixman_bool_t has_client_clip; pixman_transform_t *transform; pixman_repeat_t repeat; pixman_filter_t filter; pixman_fixed_t *filter_params; int n_filter_params; bits_image_t *alpha_map; point_t alpha_origin; pixman_bool_t component_alpha; pixman_read_memory_func_t read_func; pixman_write_memory_func_t write_func;};struct source_image{ image_common_t common; source_pict_class_t class;};struct solid_fill{ source_image_t common; uint32_t color; /* FIXME: shouldn't this be a pixman_color_t? */};struct gradient{ source_image_t common; int n_stops; pixman_gradient_stop_t * stops; int stop_range; uint32_t * color_table; int color_table_size;};struct linear_gradient{ gradient_t common; pixman_point_fixed_t p1; pixman_point_fixed_t p2;};struct circle{ pixman_fixed_t x; pixman_fixed_t y; pixman_fixed_t radius;};struct radial_gradient{ gradient_t common; circle_t c1; circle_t c2; double cdx; double cdy; double dr; double A;};struct conical_gradient{ gradient_t common; pixman_point_fixed_t center; pixman_fixed_t angle;};struct bits_image{ image_common_t common; pixman_format_code_t format; const pixman_indexed_t *indexed; int width; int height; uint32_t * bits; uint32_t * free_me; int rowstride; /* in number of uint32_t's */};union pixman_image{ image_type_t type; image_common_t common; bits_image_t bits; gradient_t gradient; linear_gradient_t linear; conical_gradient_t conical; radial_gradient_t radial; solid_fill_t solid;};extern CombineFuncU pixman_fbCombineFuncU[];extern CombineFuncC pixman_fbCombineFuncC[];FASTCALL void pixman_fbCombineMaskU (uint32_t *src, const uint32_t *mask, int width);#define LOG2_BITMAP_PAD 5#define FB_STIP_SHIFT LOG2_BITMAP_PAD#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)#define FB_STIP_MASK (FB_STIP_UNIT - 1)#define FB_STIP_ALLONES ((uint32_t) -1)#if BITMAP_BIT_ORDER == LSBFirst#define FbScrLeft(x,n) ((x) >> (n))#define FbScrRight(x,n) ((x) << (n))#define FbLeftStipBits(x,n) ((x) & ((((uint32_t) 1) << (n)) - 1))#else#define FbScrLeft(x,n) ((x) << (n))#define FbScrRight(x,n) ((x) >> (n))#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))#endif#define FbStipLeft(x,n) FbScrLeft(x,n)#define FbStipRight(x,n) FbScrRight(x,n)#define FbStipMask(x,w) (FbStipRight(FB_STIP_ALLONES,(x) & FB_STIP_MASK) & \ FbStipLeft(FB_STIP_ALLONES,(FB_STIP_UNIT - ((x)+(w))) & FB_STIP_MASK))#define FbLeftMask(x) ( ((x) & FB_MASK) ? \ FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \ FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)#define FbMaskBits(x,w,l,n,r) { \ n = (w); \ r = FbRightMask((x)+n); \ l = FbLeftMask(x); \ if (l) { \ n -= FB_UNIT - ((x) & FB_MASK); \ if (n < 0) { \ n = 0; \ l &= r; \ r = 0; \ } \ } \ n >>= FB_SHIFT; \ }#if IMAGE_BYTE_ORDER == MSBFirst#define Fetch24(img, a) ((unsigned long) (a) & 1 ? \ ((READ(img, a) << 16) | READ(img, (uint16_t *) ((a)+1))) : \ ((READ(img, (uint16_t *) (a)) << 8) | READ(img, (a)+2)))#define Store24(img,a,v) ((unsigned long) (a) & 1 ? \ (WRITE(img, a, (uint8_t) ((v) >> 16)), \ WRITE(img, (uint16_t *) ((a)+1), (uint16_t) (v))) : \ (WRITE(img, (uint16_t *) (a), (uint16_t) ((v) >> 8)), \ WRITE(img, (a)+2, (uint8_t) (v))))#else#define Fetch24(img,a) ((unsigned long) (a) & 1 ? \ (READ(img, a) | (READ(img, (uint16_t *) ((a)+1)) << 8)) : \ (READ(img, (uint16_t *) (a)) | (READ(img, (a)+2) << 16)))#define Store24(img,a,v) ((unsigned long) (a) & 1 ? \ (WRITE(img, a, (uint8_t) (v)), \ WRITE(img, (uint16_t *) ((a)+1), (uint16_t) ((v) >> 8))) : \ (WRITE(img, (uint16_t *) (a), (uint16_t) (v)), \ WRITE(img, (a)+2, (uint8_t) ((v) >> 16))))#endif#define Alpha(x) ((x) >> 24)#define Red(x) (((x) >> 16) & 0xff)#define Green(x) (((x) >> 8) & 0xff)#define Blue(x) ((x) & 0xff)#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \ (((s) >> 8) & 0xff) * 301 + \ (((s) ) & 0xff) * 58) >> 2)#define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \ (((s) >> 6) & 0x03e0) | \ (((s) >> 9) & 0x7c00))#define miIndexToEnt15(mif,rgb15) ((mif)->ent[rgb15])#define miIndexToEnt24(mif,rgb24) miIndexToEnt15(mif,miCvtR8G8B8to15(rgb24))#define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15(rgb24)])#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )#define FbIntDiv(a,b) (((uint16_t) (a) * 255) / (b))#define FbGet8(v,i) ((uint16_t) (uint8_t) ((v) >> i))#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \ (((s) >> 5) & 0x07e0) | \ (((s) >> 8) & 0xf800))#define cvt0565to0888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \ ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \ ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))/* * There are two ways of handling alpha -- either as a single unified value or * a separate value for each component, hence each macro must have two * versions. The unified alpha version has a 'U' at the end of the name, * the component version has a 'C'. Similarly, functions which deal with * this difference will have two versions using the same convention. */#define FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i), \ (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))#define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i), \ (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))#define FbInU(x,i,a,t) ((uint32_t) FbIntMult(FbGet8(x,i),(a),(t)) << (i))#define FbInC(x,i,a,t) ((uint32_t) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -