SURFACE.H 5.1 KB

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