dsrc isn't necessary for this repo
[client-tools.git] / src / external / 3rd / application / UiBuilder / UIDirectDrawCanvas.h
blobee32651696c1575b91e302d59bf9c01966b415cf
1 #ifndef __UIDIRECTDRAWCANVAS_H__
2 #define __UIDIRECTDRAWCANVAS_H__
4 #include <ddraw.h>
6 #include "UICanvas.h"
8 extern LPDIRECTDRAW7 gDirectDraw;
10 class UIDirectDrawCanvas : public UICanvas
12 public:
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;
42 private:
45 UIDirectDrawCanvas & operator= (const UIDirectDrawCanvas &);
46 UIDirectDrawCanvas (const UIDirectDrawCanvas &);
48 protected:
50 virtual void DestoryAll( void );
52 LPDIRECTDRAWSURFACE7 mSurface;
54 DWORD mRedScale;
55 DWORD mRedShift;
56 DWORD mRedMask;
58 DWORD mGreenScale;
59 DWORD mGreenShift;
60 DWORD mGreenMask;
62 DWORD mBlueScale;
63 DWORD mBlueShift;
64 DWORD mBlueMask;
66 DWORD mAlphaScale;
67 DWORD mAlphaShift;
68 DWORD mAlphaMask;
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
97 *p = r;
98 *(p + 1) = g;
99 *(p + 2) = b;
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__