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;
00020 int pitch;
00021 Rect clip;
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
00044
00045
00056 typedef struct OPCShape
00057 {
00058 int16 xOff;
00059 int16 yOff;
00060 uint16 wide;
00061 uint16 high;
00062
00063
00064
00065 #ifdef OPC_POINTERS
00066 const int8* code;
00067 const void* data;
00068 const void* pack;
00069 #else
00070 uint32 code;
00071 uint32 data;
00072 uint32 pack;
00073 #endif
00074 } OPCShape;
00075
00076
00077
00078
00079
00080
00081
00082 #define MAX_SKIP 127
00083 #define MAX_DUMP 48
00084 #define MIN_RUN MAX_DUMP+1
00085 #define MAX_RUN 127
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
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
00150
00151