Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
xsurface.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : Command & Conquer *
24 * *
25 * $Archive:: /G/wwlib/xsurface.h $*
26 * *
27 * $Author:: Eric_c $*
28 * *
29 * $Modtime:: 4/02/99 12:01p $*
30 * *
31 * $Revision:: 2 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36#if _MSC_VER >= 1000
37#pragma once
38#endif // _MSC_VER >= 1000
39
40#ifndef XSURFACE_H
41#define XSURFACE_H
42
43#include "surface.h"
44
45/*
46** This is a concrete (mostly) derived class that handles a surface. This layer presumes that
47** pixels are compositied into a contiguous integral (usually a byte) linear array. The
48** implemented routines do not use hardware assist. They are prime candidates to be converted
49** to assembly language.
50*/
51class XSurface : public Surface
52{
53 public:
54 XSurface(int width=0, int height=0) : Surface(width, height), LockCount(0) {}
55 virtual ~XSurface(void) {}
56
57 /*
58 ** Copies regions from one surface to another.
59 */
60 virtual bool Blit_From(Rect const & dcliprect, Rect const & destrect, Surface const & source, Rect const & scliprect, Rect const & sourcerect, bool trans=false);
61 virtual bool Blit_From(Rect const & destrect, Surface const & source, Rect const & sourcerect, bool trans=false);
62 virtual bool Blit_From(Surface const & source, bool trans=false);
63
64 /*
65 ** Fills a region with a constant color.
66 */
67 virtual bool Fill_Rect(Rect const & rect, int color);
68 virtual bool Fill_Rect(Rect const & cliprect, Rect const & fillrect, int color);
69 virtual bool Fill(int color);
70
71 /*
72 ** Fetches and stores a pixel to the display (pixel is in surface format).
73 */
74 virtual bool Put_Pixel(Point2D const & point, int color);
75 virtual int Get_Pixel(Point2D const & point) const;
76
77 /*
78 ** Draws lines onto the surface.
79 */
80 virtual bool Draw_Line(Point2D const & startpoint, Point2D const & endpoint, int color);
81 virtual bool Draw_Line(Rect const & cliprect, Point2D const & startpoint, Point2D const & endpoint, int color);
82
83 /*
84 ** Draws rectangles onto the surface.
85 */
86 virtual bool Draw_Rect(Rect const & rect, int color);
87 virtual bool Draw_Rect(Rect const & cliprect, Rect const & rect, int color);
88
89 /*
90 ** Gets and frees a direct pointer to the video memory.
91 */
92 virtual void * Lock(Point2D = Point2D(0, 0)) const {LockCount++;return(NULL);}
93 virtual bool Unlock(void) const {LockCount--;return(true);}
94 virtual bool Is_Locked(void) const {return(LockCount != 0);}
95
96 /*
97 ** Queries information about the surface.
98 */
99 virtual int Bytes_Per_Pixel(void) const = 0;
100 virtual int Stride(void) const = 0;
101
102 /*
103 ** Hack function to serve the purpose that RTTI was invented for, but since
104 ** the Watcom compiler doesn't support RTTI, we must resort to using this
105 ** alternative.
106 */
107 virtual bool Is_Direct_Draw(void) const {return(false);}
108
109 /*
110 ** This routine is handy for preparing to perform some kind of manual blit
111 ** operation.
112 */
113 static bool Prep_For_Blit(Surface & dest, Rect & drect, Surface const & source, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer);
114 static bool Prep_For_Blit(Surface & dest, Rect const & dcliprect, Rect & drect, Surface const & source, Rect const & scliprect, Rect & srect, bool & overlapped, void * & dbuffer, void * & sbuffer);
115
116 /*
117 ** These are the exposed manual blit routines. They can be called directly if desired.
118 */
119 static bool Blit_Trans(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect);
120 static bool Blit_Plain(Surface & dest, Rect const & destrect, Surface const & source, Rect const & sourcerect);
121
122 protected:
123 /*
124 ** Records the number of locks on this surface.
125 */
126 mutable int LockCount;
127};
128
129bool Blit_Clip(Rect & drect, Rect const & dwindow, Rect & srect, Rect const & swindow);
130
131
132#endif
#define NULL
Definition BaseType.h:92
TPoint2D< int > Point2D
Definition Point.h:114
Surface(int width, int height)
Definition Surface.h:55
virtual bool Draw_Rect(Rect const &rect, int color)
Definition xsurface.cpp:233
virtual bool Draw_Line(Point2D const &startpoint, Point2D const &endpoint, int color)
Definition xsurface.cpp:84
virtual int Bytes_Per_Pixel(void) const =0
XSurface(int width=0, int height=0)
Definition xsurface.h:54
static bool Blit_Plain(Surface &dest, Rect const &destrect, Surface const &source, Rect const &sourcerect)
Definition xsurface.cpp:857
virtual bool Is_Locked(void) const
Definition xsurface.h:94
virtual int Stride(void) const =0
virtual ~XSurface(void)
Definition xsurface.h:55
virtual bool Unlock(void) const
Definition xsurface.h:93
virtual bool Blit_From(Rect const &dcliprect, Rect const &destrect, Surface const &source, Rect const &scliprect, Rect const &sourcerect, bool trans=false)
Definition xsurface.cpp:525
virtual void * Lock(Point2D=Point2D(0, 0)) const
Definition xsurface.h:92
virtual int Get_Pixel(Point2D const &point) const
Definition xsurface.cpp:289
static bool Blit_Trans(Surface &dest, Rect const &destrect, Surface const &source, Rect const &sourcerect)
Definition xsurface.cpp:887
virtual bool Put_Pixel(Point2D const &point, int color)
Definition xsurface.cpp:322
virtual bool Fill(int color)
Definition xsurface.cpp:434
int LockCount
Definition xsurface.h:126
static bool Prep_For_Blit(Surface &dest, Rect &drect, Surface const &source, Rect &srect, bool &overlapped, void *&dbuffer, void *&sbuffer)
Definition xsurface.cpp:699
virtual bool Is_Direct_Draw(void) const
Definition xsurface.h:107
virtual bool Fill_Rect(Rect const &rect, int color)
Definition xsurface.cpp:355
TRect< int > Rect
Definition trect.h:221
bool Blit_Clip(Rect &drect, Rect const &dwindow, Rect &srect, Rect const &swindow)
Definition xsurface.cpp:576