1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * Clipping rectangle defines
22  */
23 
24 #ifndef TINSEL_CLIPRECT_H     // prevent multiple includes
25 #define TINSEL_CLIPRECT_H
26 
27 #include "common/list.h"
28 #include "common/rect.h"
29 
30 namespace Tinsel {
31 
32 struct OBJECT;
33 
34 typedef Common::List<Common::Rect> RectList;
35 
36 /*----------------------------------------------------------------------*\
37 |*			Clip Rect Function Prototypes			*|
38 \*----------------------------------------------------------------------*/
39 
40 void ResetClipRect();	// Resets the clipping rectangle allocator
41 
42 void AddClipRect(		// Allocate a clipping rectangle from the free list
43 	const Common::Rect &pClip);		// clip rectangle dimensions to allocate
44 
45 const RectList &GetClipRects();
46 
47 bool IntersectRectangle(	// Creates the intersection of two rectangles
48 	Common::Rect &pDest,		// pointer to destination rectangle that is to receive the intersection
49 	const Common::Rect &pSrc1,		// pointer to a source rectangle
50 	const Common::Rect &pSrc2);		// pointer to a source rectangle
51 
52 bool UnionRectangle(		// Creates the union of two rectangles
53 	Common::Rect &pDest,		// destination rectangle that is to receive the new union
54 	const Common::Rect &pSrc1,		// a source rectangle
55 	const Common::Rect &pSrc2);		// a source rectangle
56 
57 void FindMovingObjects(		// Creates clipping rectangles for all the objects that have moved on the specified object list
58 	OBJECT **pObjList,	// playfield display list to draw
59 	Common::Point *pWin,		// playfield window top left position
60 	Common::Rect *pClip,		// playfield clipping rectangle
61 	bool bVelocity,		// when set, objects pos is updated with velocity
62 	bool bScrolled);	// when set, playfield has scrolled
63 
64 void MergeClipRect();	// Merges any clipping rectangles that overlap
65 
66 void UpdateClipRect(		// Redraws all objects within this clipping rectangle
67 	OBJECT **pObjList,	// object list to draw
68 	Common::Point *pWin,		// window top left position
69 	Common::Rect *pClip);		// pointer to clip rectangle
70 
71 } // End of namespace Tinsel
72 
73 #endif	// TINSEL_CLIPRECT_H
74