opc.h

Go to the documentation of this file.
00001 
00007 #ifndef OPC_H
00008 #define OPC_H
00009 
00010 #ifndef RECT_H
00011 #include "rect.h"
00012 #endif
00013 
00017 typedef struct OPC
00018 {
00019     uint8*      origin; /* Points at 0,0  */
00020     int         pitch;  /* Byte offset from current line to next lower line */
00021     Rect        clip;   /* Clipping rectangle */
00022 } OPC;
00023 #define OPC_GetOrigin(opc)  ((opc)->origin) 
00024 #define OPC_GetPitch(opc)   ((opc)->pitch)  
00025 #define OPC_GetClip(opc)    ((opc)->clip)   
00034 #define OPC_Init_Basic( opc, org, lineOff, cl,ct,cr,cb ) \
00035 {\
00036     (opc)->clip.left = (cl); (opc)->clip.top = (ct); (opc)->clip.right = (cr); (opc)->clip.bottom = (cb);\
00037     (opc)->pitch = (lineOff);\
00038     (opc)->origin = (uint8*)(org) - ((opc)->pitch*(ct)) - (sizeof(PIXEL)*(cl));\
00039 }
00040 
00041 #define OPC_Init_SDL_Surface( opc, sdl ) \
00042     OPC_Init_Basic( opc, (sdl)->pixels, (sdl)->pitch, (sdl)->clip_rect.x, (sdl)->clip_rect.y, (sdl)->clip_rect.x + (sdl)->clip_rect.w, (sdl)->clip_rect.y + (sdl)->clip_rect.h )
00043 /* See bmp.h for a windows BITMAPINFO version - BMI_OPC */
00044 
00045 
00056 typedef struct OPCShape
00057 {
00058     int16       xOff;   /* Add to x, aligns upper-left corner of shape */
00059     int16       yOff;   /* Add to y, aligns upper-left corner of shape */
00060     uint16      wide;   /* Width of shape */
00061     uint16      high;   /* Height of shape */
00062     /*
00063      * Define OPC_POINTERS if OPCShape contains pointers to its data, instead of data offsets
00064      */
00065 #ifdef OPC_POINTERS
00066     const int8* code;   /* Pack code array */
00067     const void* data;   /* Pointer to color data array, or NULL if there isn't any */
00068     const void* pack;   /* Pointer to packed data index array, or NULL if there isn't any */
00069 #else
00070     uint32      code;   /* Byte offset to pack code array from OPCShape* */
00071     uint32      data;   /* Byte offset to color data array, or 0 if there isn't any */
00072     uint32      pack;   /* Byte offset to packed data index array, or 0 if there isn't any */
00073 #endif
00074 } OPCShape;
00075 /*
00076  * RLE/SKIP compression constants
00077  * The odd construction of RUN+DUMP is so we can do mask shapes a little more simple
00078  * Since minimum size of RUN is DUMP, and RUN>DUMP, any run/dump code is equivalent to masking code.
00079  * Since DUMP copies are short, they are more matchable, and unrollable
00080  * Since RUN copy matches are longer, we don't eat extra time to 'switch channels' between run/dump 
00081  */
00082 #define MAX_SKIP        127 /* We want to favor runs divisible by 4 */
00083 #define MAX_DUMP        48  /* We want to favor runs divisible by 4, and short, readily matched dumps for external compression */
00084 #define MIN_RUN         MAX_DUMP+1  /* We don't want to wast time switching channels over short runs */
00085 #define MAX_RUN         127         /* Skip encoding: Len > MAX_DUMP is RUN of color; one pixel is stored in output data */
00086 #define IS_EOL(v)       ((v)==-128)
00087 #define IS_EOS(v)       (0 == (v))
00088 #define IS_SKIP(v)      ((v)<0)
00089 #define SKIP_CODE(v)    ((int8)(-(v)))
00090 #define SKIP_LEN(v)     (-(v))
00091 #define IS_RUNDUMP(v)   ((v)>0)
00092 #define IS_RUN(v)       ((v) >= MIN_RUN)
00093 #define RUN_CODE(v)     ((int8)(v))
00094 #define RUN_LEN(v)      (v)
00095 #define IS_DUMP(v)      ((v) > 0 && (v) <= MAX_DUMP)
00096 #define DUMP_CODE(v)    ((int8)(v))
00097 #define DUMP_LEN(v)     (v)
00098 #define opc_pack_type   uint8
00099 #define opc_pack_max    255
00100 
00101 #endif /* OPC_H */
00102 
00103 
00104 #ifdef PIXEL
00105 
00111 #ifndef OPC_NAMING
00112 #define OPC_NAMING(label)   OPC_##label
00113 #endif
00114 
00118 typedef PIXEL   OPC_NAMING(Pixel);
00119 
00126 size_t OPC_NAMING(Needs)( int wide, int high );
00127 void OPC_NAMING(Init)( OPC* opc, int xOff, int yOff, const Rect* clip, void* buffer );
00128 void OPC_NAMING(Clip)( OPC* opc, const OPC* src, const Rect* clip );
00129 void OPC_NAMING(Window)( OPC* opc, const OPC* src, const Rect* clip, int orgX, int orgY );
00130 OPC_NAMING(Pixel)* OPC_NAMING(Ptr)( const OPC* dst, int x, int y );
00131 void OPC_NAMING(Plot)( const OPC* dst, int x, int y, OPC_NAMING(Pixel) color );
00132 OPC_NAMING(Pixel) OPC_NAMING(Peek)( const OPC* opc, int x, int y );
00133 void OPC_NAMING(HLine)( const OPC* dst, int x, int y, int wide, OPC_NAMING(Pixel) color );
00134 void OPC_NAMING(VLine)( const OPC* dst, int x, int y, int high, OPC_NAMING(Pixel) color );
00135 void OPC_NAMING(HCopy)( const OPC* dst, int x, int y, int wide, const OPC_NAMING(Pixel)* src );
00136 void OPC_NAMING(Blit)( const OPC* dst, const Rect* rdst, const OPC* src, int sx, int sy );
00137 void OPC_NAMING(Stamp)( const OPC* dst, int dx, int dy, const OPC* src );
00138 void OPC_NAMING(Fill)( const OPC* dst, const Rect* rdst, OPC_NAMING(Pixel) color );
00139 void OPC_NAMING(Shape)( const OPC* dst, const OPCShape* shape, int x, int y );
00140 void OPC_NAMING(Shape_Mask)( const OPC* dst, const OPCShape* shape, int x, int y, OPC_NAMING(Pixel) color );
00141 void OPC_NAMING(Shape_Bound)( Rect* posn, const OPCShape* shape, int x, int y );
00142 OPC_NAMING(Pixel) OPC_NAMING(Shape_MaskColor)( OPC_NAMING(Pixel) color );
00143 size_t OPC_NAMING(Shape_TotalSize)( const OPCShape* shape );
00144 size_t OPC_NAMING(Shape_PackLutSize)( const OPCShape* shape );
00145 size_t OPC_NAMING(Shape_CodeSize)( const OPCShape* shape );
00146 size_t OPC_NAMING(Shape_DataSize)( const OPCShape* shape );
00147 
00148 
00149 #endif /* PIXEL */
00150 
00151 

Generated on Fri Jan 2 15:28:34 2009 for Squat by  doxygen 1.5.6