1 #ifndef __RENDER_DIRTY_H
2 #define __RENDER_DIRTY_H
3
4 #include "JA2Types.h"
5
6 #include <string_theory/string>
7
8
9 #define NO_BGND_RECT NULL
10
11 enum BackgroundFlags
12 {
13 BGND_FLAG_NONE = 0,
14 BGND_FLAG_PERMANENT = 0x80000000,
15 BGND_FLAG_SINGLE = 0x40000000,
16 BGND_FLAG_SAVE_Z = 0x20000000,
17 BGND_FLAG_SAVERECT = 0x08000000,
18 BGND_FLAG_ANIMATED = 0x00000001
19 };
20 ENUM_BITSET(BackgroundFlags)
21
22
23 // Callback for topmost blitters
24 typedef void (*OVERLAY_CALLBACK)(VIDEO_OVERLAY*);
25
26 // Struct for topmost blitters
27 struct VIDEO_OVERLAY
28 {
29 VIDEO_OVERLAY* prev;
30 VIDEO_OVERLAY* next;
31 BOOLEAN fAllocated;
32 BOOLEAN fDisabled;
33 BOOLEAN fActivelySaving;
34 BOOLEAN fDeletionPending;
35 BACKGROUND_SAVE* background;
36 UINT16* pSaveArea;
37 SGPFont uiFontID;
38 INT16 sX;
39 INT16 sY;
40 UINT8 ubFontBack;
41 UINT8 ubFontFore;
42 ST::utf32_buffer codepoints;
43 SGPVSurface* uiDestBuff;
44 OVERLAY_CALLBACK BltCallback;
45 };
46
47
48 // GLOBAL VARIABLES
49 extern SGPRect gDirtyClipRect;
50
51
52 // DIRTY QUEUE
53 void AddBaseDirtyRect(INT32 iLeft, INT32 iTop, INT32 iRight, INT32 iBottom);
54 void ExecuteBaseDirtyRectQueue(void);
55
56
57 // BACKGROUND RECT BUFFERING STUFF
58 void InitializeBackgroundRects(void);
59 void ShutdownBackgroundRects(void);
60 BACKGROUND_SAVE* RegisterBackgroundRect(BackgroundFlags, INT16 x, INT16 y, INT16 w, INT16 h);
61 void FreeBackgroundRect(BACKGROUND_SAVE*);
62 void FreeBackgroundRectPending(BACKGROUND_SAVE*);
63 void FreeBackgroundRectType(BackgroundFlags);
64 void RestoreBackgroundRects(void);
65 void SaveBackgroundRects(void);
66 void InvalidateBackgroundRects(void);
67 void UpdateSaveBuffer(void);
68 void RestoreExternBackgroundRect(INT16 sLeft, INT16 sTop, INT16 sWidth, INT16 sHeight);
69 void RegisterBackgroundRectSingleFilled(INT16 x, INT16 y, INT16 w, INT16 h);
70 void EmptyBackgroundRects(void);
71 void RestoreExternBackgroundRectGivenID(const BACKGROUND_SAVE*);
72
73
74 void GDirtyPrint(INT16 x, INT16 y, const ST::utf32_buffer& codepoints);
GDirtyPrint(INT16 x,INT16 y,const ST::string & str)75 inline void GDirtyPrint(INT16 x, INT16 y, const ST::string& str)
76 {
77 GDirtyPrint(x, y, str.to_utf32());
78 }
79
80 void GPrintInvalidate(INT16 x, INT16 y, const ST::utf32_buffer& codepoints);
GPrintInvalidate(INT16 x,INT16 y,const ST::string & str)81 inline void GPrintInvalidate(INT16 x, INT16 y, const ST::string& str)
82 {
83 GPrintInvalidate(x, y, str.to_utf32());
84 }
85
86
87 // VIDEO OVERLAY STUFF
88 VIDEO_OVERLAY* RegisterVideoOverlay(OVERLAY_CALLBACK callback, INT16 x, INT16 y, INT16 w, INT16 h);
89 VIDEO_OVERLAY* RegisterVideoOverlay(OVERLAY_CALLBACK callback, INT16 x, INT16 y, SGPFont font, UINT8 foreground, UINT8 background, const ST::utf32_buffer& codepoints);
RegisterVideoOverlay(OVERLAY_CALLBACK callback,INT16 x,INT16 y,SGPFont font,UINT8 foreground,UINT8 background,const ST::string & str)90 inline VIDEO_OVERLAY* RegisterVideoOverlay(OVERLAY_CALLBACK callback, INT16 x, INT16 y, SGPFont font, UINT8 foreground, UINT8 background, const ST::string& str)
91 {
92 return RegisterVideoOverlay(callback, x, y, font, foreground, background, str.to_utf32());
93 }
94 void ExecuteVideoOverlays(void);
95 void SaveVideoOverlaysArea(SGPVSurface* src);
96
97 // Delete Topmost blitters saved areas
98 void DeleteVideoOverlaysArea(void);
99
100 void AllocateVideoOverlaysArea(void);
101 void ExecuteVideoOverlaysToAlternateBuffer(SGPVSurface* buffer);
102 void RemoveVideoOverlay(VIDEO_OVERLAY*);
103 void RestoreShiftedVideoOverlays(INT16 sShiftX, INT16 sShiftY);
104 void EnableVideoOverlay(BOOLEAN fEnable, VIDEO_OVERLAY*);
105 void SetVideoOverlayText(VIDEO_OVERLAY* v, const ST::utf32_buffer& codepoints);
SetVideoOverlayText(VIDEO_OVERLAY * v,const ST::string & str)106 inline void SetVideoOverlayText(VIDEO_OVERLAY* v, const ST::string& str)
107 {
108 SetVideoOverlayText(v, str.to_utf32());
109 }
110 void SetVideoOverlayPos(VIDEO_OVERLAY*, INT16 X, INT16 Y);
111
112 void BlitBufferToBuffer(SGPVSurface* src, SGPVSurface* dst, UINT16 usSrcX, UINT16 usSrcY, UINT16 usWidth, UINT16 usHeight);
113
114 #endif
115