SURFACE.H (5197B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/SURFACE.H 1 3/03/97 10:25a Joe_bostic $ */ 17 /*********************************************************************************************** 18 *** 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 *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : SURFACE.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : 09/08/96 * 28 * * 29 * Last Update : September 8, 1996 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 36 #ifndef SURFACE_H 37 #define SURFACE_H 38 39 #include "buff.h" 40 #include "rect.h" 41 42 /* 43 ** This class is used to represent an arbitrary rectangle in a graphic memory space. Typically, 44 ** this represents what could be called a graphic buffer or even a portion of a graphic buffer. 45 ** It can also represent a piece of artwork (such as a shape image) to be used to construct a 46 ** display image. This wide range of use is possible, because this class is a very minimal 47 ** representation of the graphic data. It holds only the information is absolutely needs and 48 ** has the minimum member functions possible. 49 */ 50 class Surface 51 { 52 public: 53 Surface(void) : Width(0), Height(0), Pitch(0) {} 54 Surface(int w, int h, Buffer const * buffer=NULL, int pitch=0); 55 Surface(Surface const & surface, int x, int y, int w, int h); 56 virtual ~Surface(void) {} 57 58 /* 59 ** Basic manipulation routines for copying entire surfaces or 60 ** a sub-region. 61 */ 62 void Copy_To(Rect const & fromrect, Surface & tosurface, Rect const & torect) const; 63 void Copy_To(Rect const & fromrect, Buffer & tobuffer) const; 64 65 /* 66 ** Convenience routines that make presumptions on what is desired so that a 67 ** minimum of parameters can be specified. These routine ultimately map to the 68 ** basic copy routines. 69 */ 70 void Copy_To(Buffer & buffer, int x=0, int y=0, int w=-1, int h=-1) const; 71 void Copy_From(Buffer const & buffer, int x=0, int y=0, int w=-1, int h=-1); 72 73 /* 74 ** Basic query functions. Support routines that will manipulate the underlying 75 ** image data will require access to this information. 76 */ 77 void * Get_Buffer(void) const {return(SurfaceData.Get_Buffer());} 78 int Get_Size(void) const {return(Bytes_Per_Line() * Height);} 79 int Get_Width(void) const {return(Width);} 80 int Get_Height(void) const {return(Height);} 81 int Get_Pitch(void) const {return(Pitch);} 82 83 protected: 84 int Bytes_Per_Line(void) const {return(Width+Pitch);} 85 86 /* 87 ** This is the pointer to the surface memory. Sometimes this could be allocated memory 88 ** managed by this class but more likely, it is memory that is merely referred to by 89 ** this class. 90 */ 91 Buffer SurfaceData; 92 93 /* 94 ** This is the width (columns) of the surface (in pixels). 95 */ 96 int Width; 97 98 /* 99 ** This ithe height (rows) of the surface (in pixels). 100 */ 101 int Height; 102 103 /* 104 ** This is the modulus of the surface underlying memory 'display surface' width 105 ** divided by this surface's width. For a surface that is full width, this value 106 ** will be 0. This value will be non-zero if this surface is referring to a 107 ** sub-region within another surface. 108 */ 109 int Pitch; 110 }; 111 112 113 #endif