1 #ifndef __UIDIRECTDRAWCANVAS_H__
2 #define __UIDIRECTDRAWCANVAS_H__
8 extern LPDIRECTDRAW7 gDirectDraw
;
10 class UIDirectDrawCanvas
: public UICanvas
14 static const char *TypeName
;
16 UIDirectDrawCanvas( UISize
);
17 virtual ~UIDirectDrawCanvas();
19 virtual bool IsA( const UITypeID
) const;
20 virtual UIBaseObject
*Clone( void ) const;
22 virtual bool Generate( void ) const = 0;
24 virtual void SetSize( const UISize
& );
26 bool Prepare( void ) const;
27 virtual void BltFrom( const UICanvas
* const src
, const UIPoint
&Source
, const UIPoint
&Destination
, const UISize
&Size
);
29 // Used by generator functions
30 virtual LPDIRECTDRAWSURFACE7
GetSurface( void ) const;
31 virtual void SetSurface( LPDIRECTDRAWSURFACE7
);
33 virtual void Refresh( void );
35 DWORD
FormatUIColorForDirectDrawSurface( const UIColor
& ) const;
36 DWORD
FormatRGBForDirectDrawSurface( const unsigned char r
, const unsigned char g
, const unsigned char b
, const unsigned char a
= 0xFF ) const;
38 void SetDirectDrawSurface16( unsigned char *p
, const unsigned char r
, const unsigned char g
, const unsigned char b
, const unsigned char a
= 0xFF ) const;
39 void SetDirectDrawSurface24( unsigned char *p
, const unsigned char r
, const unsigned char g
, const unsigned char b
, const unsigned char a
= 0xFF ) const;
40 void SetDirectDrawSurface32( unsigned char *p
, const unsigned char r
, const unsigned char g
, const unsigned char b
, const unsigned char a
= 0xFF ) const;
45 UIDirectDrawCanvas
& operator= (const UIDirectDrawCanvas
&);
46 UIDirectDrawCanvas (const UIDirectDrawCanvas
&);
50 virtual void DestoryAll( void );
52 LPDIRECTDRAWSURFACE7 mSurface
;
71 inline DWORD
UIDirectDrawCanvas::FormatUIColorForDirectDrawSurface( const UIColor
&color
) const
73 return (((DWORD
)(color
.r
>> mRedScale
) << mRedShift
) & mRedMask
) |
74 (((DWORD
)(color
.g
>> mGreenScale
) << mGreenShift
) & mGreenMask
) |
75 (((DWORD
)(color
.b
>> mBlueScale
) << mBlueShift
) & mBlueMask
) |
76 (((DWORD
)(color
.a
>> mAlphaScale
) << mAlphaShift
) & mAlphaMask
);
79 inline DWORD
UIDirectDrawCanvas::FormatRGBForDirectDrawSurface( const unsigned char r
, const unsigned char g
, const unsigned char b
, const unsigned char a
) const
81 return (((DWORD
)(r
>> mRedScale
) << mRedShift
) & mRedMask
) |
82 (((DWORD
)(g
>> mGreenScale
) << mGreenShift
) & mGreenMask
) |
83 (((DWORD
)(b
>> mBlueScale
) << mBlueShift
) & mBlueMask
) |
84 (((DWORD
)(a
>> mAlphaScale
) << mAlphaShift
) & mAlphaMask
);
87 inline void UIDirectDrawCanvas::SetDirectDrawSurface16( unsigned char *p
, const unsigned char r
, const unsigned char g
, const unsigned char b
, const unsigned char a
) const
89 *(WORD
*)(p
) = static_cast<unsigned short> ((((WORD
)((r
>> mRedScale
) << (WORD
)mRedShift
) & (WORD
)mRedMask
)) |
90 (((WORD
)((g
>> mGreenScale
) << (WORD
)mGreenShift
) & (WORD
)mGreenMask
)) |
91 (((WORD
)((b
>> mBlueScale
) << (WORD
)mBlueShift
) & (WORD
)mBlueMask
)) |
92 (((WORD
)((a
>> mAlphaScale
) << (WORD
)mAlphaShift
) & (WORD
)mAlphaMask
)));
95 inline void UIDirectDrawCanvas::SetDirectDrawSurface24( unsigned char *p
, const unsigned char r
, const unsigned char g
, const unsigned char b
, const unsigned char ) const
102 inline void UIDirectDrawCanvas::SetDirectDrawSurface32( unsigned char *p
, const unsigned char r
, const unsigned char g
, const unsigned char b
, const unsigned char a
) const
104 *(DWORD
*)(p
) = (((DWORD
)(r
>> mRedScale
) << mRedShift
) & mRedMask
) |
105 (((DWORD
)(g
>> mGreenScale
) << mGreenShift
) & mGreenMask
) |
106 (((DWORD
)(b
>> mBlueScale
) << mBlueShift
) & mBlueMask
) |
107 (((DWORD
)(a
>> mAlphaScale
) << mAlphaShift
) & mAlphaMask
);
110 typedef void (UIDirectDrawCanvas::*DDCSetPixelFunc
)( unsigned char *, const unsigned char, const unsigned char, const unsigned char, const unsigned char ) const;
112 #endif // __UIDIRECTDRAWCANVAS_H__