GBUFFER.H 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  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. /***************************************************************************
  15. ** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  16. ***************************************************************************
  17. * *
  18. * Project Name : Westwood 32 Bit Library *
  19. * *
  20. * File Name : GBUFFER.H *
  21. * *
  22. * Programmer : Phil W. Gorrow *
  23. * *
  24. * Start Date : May 26, 1994 *
  25. * *
  26. * Last Update : October 9, 1995 [] *
  27. * *
  28. ***************************************************************************
  29. * *
  30. * This module contains the definition for the graphic buffer class. The *
  31. * primary functionality of the graphic buffer class is handled by inline *
  32. * functions that make a call through function pointers to the correct *
  33. * routine. This has two benefits: *
  34. * *
  35. * *
  36. * 1) C++ name mangling is not a big deal since the function pointers *
  37. * point to functions in standard C format. *
  38. * 2) The function pointers can be changed when we set a different *
  39. * graphic mode. This allows us to have both supervga and mcga *
  40. * routines present in memory at once. *
  41. * *
  42. * In the basic library, these functions point to stub routines which just *
  43. * return. This makes a product that just uses a graphic buffer take the *
  44. * minimum amount of code space. For programs that require MCGA or VESA *
  45. * support, all that is necessary to do is link either the MCGA or VESA *
  46. * specific libraries in, previous to WWLIB32. The linker will then *
  47. * overide the the necessary stub functions automatically. *
  48. * *
  49. * In addition, there are helpful inline function calls for parameter *
  50. * ellimination. This header file gives the defintion for all *
  51. * GraphicViewPort and GraphicBuffer classes. *
  52. * *
  53. * Terminology: *
  54. * *
  55. * Buffer Class - A class which consists of a pointer to an allocated *
  56. * buffer and the size of the buffer that was allocated. *
  57. * *
  58. * Graphic ViewPort - The Graphic ViewPort defines a window into a *
  59. * Graphic Buffer. This means that although a Graphic Buffer *
  60. * represents linear memory, this may not be true with a Graphic *
  61. * Viewport. All low level functions that act directly on a graphic *
  62. * viewport are included within this class. This includes but is not *
  63. * limited to most of the functions which can act on a Video Viewport *
  64. * Video Buffer. *
  65. * *
  66. * Graphic Buffer - A Graphic Buffer is an instance of an allocated buffer *
  67. * used to represent a rectangular region of graphics memory. *
  68. * The HidBuff and BackBuff are excellent examples of a Graphic Buffer. *
  69. * *
  70. * Below is a tree which shows the relationship of the VideoBuffer and *
  71. * Buffer classes to the GraphicBuffer class: *
  72. * *
  73. * BUFFER.H GBUFFER.H BUFFER.H VBUFFER.H *
  74. * ---------- ---------- ---------- ---------- *
  75. * | Buffer | | Graphic | | Buffer | | Video | *
  76. * | Class | | ViewPort | | Class | | ViewPort | *
  77. * ---------- ---------- ---------- ---------- *
  78. * \ / \ / *
  79. * \ / \ / *
  80. * ---------- ---------- *
  81. * | Graphic | | Video | *
  82. * | Buffer | | Buffer | *
  83. * ---------- ---------- *
  84. * GBUFFER.H VBUFFER.H *
  85. *-------------------------------------------------------------------------*
  86. * Functions: *
  87. * GBC::GraphicBufferClass -- inline constructor for GraphicBufferClass *
  88. * GVPC::Remap -- Short form to remap an entire graphic view port *
  89. * GVPC::Get_XPos -- Returns x offset for a graphic viewport class *
  90. * GVPC::Get_Ypos -- Return y offset in a GraphicViewPortClass *
  91. * VVPC::Get_XPos -- Get the x pos of the VP on the Video *
  92. * VVPC::Get_YPos -- Get the y pos of the VP on the video *
  93. * GBC::Get_Graphic_Buffer -- Get the graphic buffer of the VP. *
  94. * GVPC::Draw_Line -- Stub function to draw line in Graphic Viewport Class*
  95. * GVPC::Fill_Rect -- Stub function to fill rectangle in a GVPC *
  96. * GVPC::Remap -- Stub function to remap a GVPC *
  97. * GVPC::Print -- stub func to print a text string *
  98. * GVPC::Print -- Stub function to print an integer *
  99. * GVPC::Print -- Stub function to print a short to a graphic viewport *
  100. * GVPC::Print -- stub function to print a long on a graphic view port *
  101. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  102. #ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
  103. #define _WIN32
  104. #endif // _WIN32
  105. #define WIN32_LEAN_AND_MEAN
  106. #include <ddraw.h>
  107. #ifndef GBUFFER_H
  108. #define GBUFFER_H
  109. /*=========================================================================*/
  110. /* If we have not already loaded the standard library header, than we can */
  111. /* load it. */
  112. /*=========================================================================*/
  113. #ifndef WWSTD_H
  114. #include "wwstd.h"
  115. #endif
  116. #ifndef DRAWBUFF_H
  117. #include "drawbuff.h"
  118. #endif
  119. //#ifndef BUFFER_H
  120. #include "buffer.h"
  121. //#endif
  122. #ifndef WINDOWS_H
  123. #include "ww_win.h"
  124. #endif
  125. #include <stdlib.h>
  126. #include "iconcach.h"
  127. #ifndef FUNCTION_H
  128. //#pragma off (unreferenced)
  129. #ifndef BITMAPCLASS
  130. #define BITMAPCLASS
  131. class BitmapClass
  132. {
  133. public:
  134. BitmapClass(int w, int h, unsigned char * data) :
  135. Width(w), Height(h), Data(data) {};
  136. int Width;
  137. int Height;
  138. unsigned char * Data;
  139. };
  140. class TPoint2D
  141. {
  142. public:
  143. TPoint2D(int xx, int yy) : x(xx), y(yy) {};
  144. TPoint2D(void) : x(0), y(0) {};
  145. int x;
  146. int y;
  147. };
  148. #endif
  149. //#pragma on (unreferenced)
  150. #endif
  151. //////////////////////////////////////////////////////////////////////////
  152. //
  153. // Defines for direct draw
  154. //
  155. //
  156. extern LPDIRECTDRAW DirectDrawObject; //pointer to direct draw object
  157. extern HWND MainWindow; //handle to programs main window
  158. /*
  159. ** Pointer to function to call if we detect a focus loss
  160. */
  161. extern void (*Gbuffer_Focus_Loss_Function)(void);
  162. enum GBC_Enum {
  163. GBC_NONE = 0,
  164. GBC_VIDEOMEM = 1,
  165. GBC_VISIBLE = 2,
  166. };
  167. #define NOT_LOCKED NULL
  168. /*=========================================================================*/
  169. /* Define the screen width and height to make portability to other modules */
  170. /* easier. */
  171. /*=========================================================================*/
  172. #define DEFAULT_SCREEN_WIDTH 356
  173. #define DEFAULT_SCREEN_HEIGHT 200
  174. /*=========================================================================*/
  175. /* Let the compiler know that a GraphicBufferClass exists so that it can */
  176. /* keep a pointer to it in a VideoViewPortClass. */
  177. /*=========================================================================*/
  178. class GraphicViewPortClass;
  179. class GraphicBufferClass;
  180. class VideoViewPortClass;
  181. class VideoBufferClass;
  182. GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass *ptr);
  183. GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass &ptr);
  184. /*=========================================================================*/
  185. /* GraphicViewPortClass - Holds viewport information on a viewport which */
  186. /* has been attached to a GraphicBuffer. A viewport is effectively a */
  187. /* rectangular subset of the full buffer which is used for clipping and */
  188. /* the like. */
  189. /* */
  190. /* char *Buffer - is the offset to view port buffer */
  191. /* int Width - is the width of view port */
  192. /* int Height - is the height of view port */
  193. /* int XAdd - is add value to go from the end of a line */
  194. /* to the beginning of the next line */
  195. /* int XPos; - x offset into its associated VideoBuffer */
  196. /* int YPos; - y offset into its associated VideoBuffer */
  197. /*=========================================================================*/
  198. class GraphicViewPortClass {
  199. public:
  200. /*===================================================================*/
  201. /* Define the base constructor and destructors for the class */
  202. /*===================================================================*/
  203. GraphicViewPortClass(GraphicBufferClass* graphic_buff, int x, int y, int w, int h);
  204. GraphicViewPortClass();
  205. ~GraphicViewPortClass();
  206. /*===================================================================*/
  207. /* define functions to get at the private data members */
  208. /*===================================================================*/
  209. long Get_Offset(void);
  210. int Get_Height(void);
  211. int Get_Width(void);
  212. int Get_XAdd(void);
  213. int Get_XPos(void);
  214. int Get_YPos(void);
  215. int Get_Pitch(void);
  216. inline BOOL Get_IsDirectDraw(void);
  217. GraphicBufferClass *Get_Graphic_Buffer(void);
  218. /*===================================================================*/
  219. /* Define a function which allows us to change a video viewport on */
  220. /* the fly. */
  221. /*===================================================================*/
  222. BOOL Change(int x, int y, int w, int h);
  223. /*===================================================================*/
  224. /* Define the set of common graphic functions that are supported by */
  225. /* both Graphic ViewPorts and VideoViewPorts. */
  226. /*===================================================================*/
  227. long Size_Of_Region(int w, int h);
  228. void Put_Pixel(int x, int y, unsigned char color);
  229. int Get_Pixel(int x, int y);
  230. void Clear(unsigned char color = 0);
  231. long To_Buffer(int x, int y, int w, int h, void *buff, long size);
  232. long To_Buffer(int x, int y, int w, int h, BufferClass *buff);
  233. long To_Buffer(BufferClass *buff);
  234. HRESULT Blit( GraphicViewPortClass& dest, int x_pixel, int y_pixel, int dx_pixel,
  235. int dy_pixel, int pixel_width, int pixel_height, BOOL trans = FALSE);
  236. HRESULT Blit( GraphicViewPortClass& dest, int dx, int dy, BOOL trans = FALSE);
  237. HRESULT Blit( GraphicViewPortClass& dest, BOOL trans = FALSE);
  238. HRESULT Blit( VideoViewPortClass& dest, int x_pixel, int y_pixel, int dx_pixel,
  239. int dy_pixel, int pixel_width, int pixel_height, BOOL trans = FALSE);
  240. HRESULT Blit( VideoViewPortClass& dest, int dx, int dy, BOOL trans = FALSE);
  241. HRESULT Blit( VideoViewPortClass& dest, BOOL trans = FALSE);
  242. BOOL Scale( GraphicViewPortClass &dest, int src_x, int src_y, int dst_x,
  243. int dst_y, int src_w, int src_h, int dst_w, int dst_h, BOOL trans = FALSE, char *remap = NULL);
  244. BOOL Scale( GraphicViewPortClass &dest, int src_x, int src_y, int dst_x,
  245. int dst_y, int src_w, int src_h, int dst_w, int dst_h, char *remap);
  246. BOOL Scale( GraphicViewPortClass &dest, BOOL trans = FALSE, char *remap = NULL);
  247. BOOL Scale( GraphicViewPortClass &dest, char *remap);
  248. BOOL Scale( VideoViewPortClass &dest, int src_x, int src_y, int dst_x,
  249. int dst_y, int src_w, int src_h, int dst_w, int dst_h, BOOL trans = FALSE, char *remap = NULL);
  250. BOOL Scale( VideoViewPortClass &dest, int src_x, int src_y, int dst_x,
  251. int dst_y, int src_w, int src_h, int dst_w, int dst_h, char *remap);
  252. BOOL Scale( VideoViewPortClass &dest, BOOL trans = FALSE, char *remap = NULL);
  253. BOOL Scale( VideoViewPortClass &dest, char *remap);
  254. unsigned long Print(char const *string, int x_pixel, int y_pixel, int fcolor, int bcolor);
  255. unsigned long Print(short num, int x_pixel, int y_pixel, int fcol, int bcol);
  256. unsigned long Print(int num, int x_pixel, int y_pixel, int fcol, int bcol);
  257. unsigned long Print(long num, int x_pixel, int y_pixel, int fcol, int bcol);
  258. /*===================================================================*/
  259. /* Define the list of graphic functions which work only with a */
  260. /* graphic buffer. */
  261. /*===================================================================*/
  262. VOID Draw_Line(int sx, int sy, int dx, int dy, unsigned char color);
  263. VOID Draw_Rect(int sx, int sy, int dx, int dy, unsigned char color);
  264. VOID Fill_Rect(int sx, int sy, int dx, int dy, unsigned char color);
  265. VOID Fill_Quad(VOID *span_buff, int x0, int y0, int x1, int y1,
  266. int x2, int y2, int x3, int y3, int color);
  267. VOID Remap(int sx, int sy, int width, int height, VOID *remap);
  268. VOID Remap(VOID *remap);
  269. void Draw_Stamp(void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap);
  270. void Draw_Stamp(void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap, int clip_window);
  271. // This doesnt seem to exist anywhere?? - Steve T 9/26/95 6:05PM
  272. // VOID Grey_Out_Region(int x, int y, int width, int height, int color);
  273. //
  274. // New members to lock and unlock the direct draw video memory
  275. //
  276. inline BOOL Lock ();
  277. inline BOOL Unlock();
  278. inline int Get_LockCount();
  279. // Member to blit using direct draw access to hardware blitter
  280. HRESULT DD_Linear_Blit_To_Linear ( GraphicViewPortClass &dest, int source_x, int source_y, int dest_x, int dest_y, int width , int height, BOOL mask );
  281. /*===================================================================*/
  282. /* Define functions to attach the viewport to a graphicbuffer */
  283. /*===================================================================*/
  284. VOID Attach(GraphicBufferClass *graphic_buff, int x, int y, int w, int h);
  285. void Attach(GraphicBufferClass *video_buff, int w, int h);
  286. protected:
  287. /*===================================================================*/
  288. /* Define the data used by a GraphicViewPortClass */
  289. /*===================================================================*/
  290. long Offset; // offset to graphic page
  291. int Width; // width of graphic page
  292. int Height; // height of graphic page
  293. int XAdd; // xadd for graphic page (0)
  294. int XPos; // x offset in relation to graphicbuff
  295. int YPos; // y offset in relation to graphicbuff
  296. long Pitch; //Distance from one line to the next
  297. GraphicBufferClass *GraphicBuff; // related graphic buff
  298. BOOL IsDirectDraw; //Flag to let us know if it is a direct draw surface
  299. int LockCount; // Count for stacking locks if non-zero the buffer
  300. }; // is a locked DD surface
  301. /*=========================================================================*/
  302. /* GraphicBufferClass - A GraphicBuffer refers to an actual instance of an */
  303. /* allocated buffer. The GraphicBuffer may be drawn to directly */
  304. /* becuase it inherits a ViewPort which represents its physcial size. */
  305. /* */
  306. /* BYTE *Buffer - is the offset to graphic buffer */
  307. /* int Width - is the width of graphic buffer */
  308. /* int Height - is the height of graphic buffer */
  309. /* int XAdd - is the xadd of graphic buffer */
  310. /* int XPos; - will be 0 because it is graphicbuff */
  311. /* int YPos; - will be 0 because it is graphicbuff */
  312. /* long Pitch - modulo of buffer for reading and writing */
  313. /* BOOL IsDirectDraw - flag if its a direct draw surface */
  314. /*=========================================================================*/
  315. class GraphicBufferClass : public GraphicViewPortClass, public BufferClass {
  316. public:
  317. GraphicBufferClass(int w, int h, GBC_Enum flags);
  318. GraphicBufferClass(int w, int h, void *buffer, long size);
  319. GraphicBufferClass(int w, int h, void *buffer = 0);
  320. GraphicBufferClass(void);
  321. ~GraphicBufferClass();
  322. void DD_Init(GBC_Enum flags);
  323. void Init(int w, int h, void *buffer, long size, GBC_Enum flags);
  324. void Un_Init(void);
  325. void GraphicBufferClass::Attach_DD_Surface (GraphicBufferClass * attach_buffer);
  326. BOOL Lock(void);
  327. BOOL Unlock(void);
  328. void Scale_Rotate(BitmapClass &bmp,TPoint2D const &pt,long scale,unsigned char angle);
  329. // Member to get a pointer to a direct draw surface
  330. LPDIRECTDRAWSURFACE Get_DD_Surface ( void );
  331. protected:
  332. LPDIRECTDRAWSURFACE VideoSurfacePtr; //Pointer to the related direct draw surface
  333. DDSURFACEDESC VideoSurfaceDescription;//Description of the said surface
  334. };
  335. inline int GraphicViewPortClass::Get_LockCount(void)
  336. {
  337. return (LockCount);
  338. }
  339. /***********************************************************************************************
  340. * GVPC::Get_IsDirectDraw -- provide read access to the IsDirectDraw flag *
  341. * *
  342. * *
  343. * *
  344. * INPUT: Nothing *
  345. * *
  346. * OUTPUT: IsDirectDraw *
  347. * *
  348. * WARNINGS: None *
  349. * *
  350. * HISTORY: *
  351. * 11/29/95 1:02PM ST : Created *
  352. *=============================================================================================*/
  353. inline BOOL GraphicViewPortClass::Get_IsDirectDraw(void)
  354. {
  355. return (IsDirectDraw);
  356. }
  357. /***********************************************************************************************
  358. * GBC::Get_DD_Surface -- returns a pointer to the buffer direct draw surface *
  359. * *
  360. * *
  361. * *
  362. * INPUT: Nothing *
  363. * *
  364. * OUTPUT: ptr to direct draw surface *
  365. * *
  366. * WARNINGS: None *
  367. * *
  368. * HISTORY: *
  369. * 9/29/95 9:43AM ST : Created *
  370. *=============================================================================================*/
  371. inline LPDIRECTDRAWSURFACE GraphicBufferClass::Get_DD_Surface ( void )
  372. {
  373. return ( VideoSurfacePtr );
  374. }
  375. /***********************************************************************************************
  376. * GVPC::Lock -- lock the graphics buffer for reading or writing *
  377. * *
  378. * *
  379. * *
  380. * INPUT: Nothing *
  381. * *
  382. * OUTPUT: TRUE if surface was successfully locked *
  383. * *
  384. * WARNINGS: None *
  385. * *
  386. * HISTORY: *
  387. * 09-19-95 12:33pm ST : Created *
  388. * 10/09/1995 : Moved actually functionality to GraphicBuffer *
  389. *=============================================================================================*/
  390. inline BOOL GraphicViewPortClass::Lock(void)
  391. {
  392. BOOL lock = GraphicBuff->Lock();
  393. if ( !lock ) return(FALSE);
  394. if (this != GraphicBuff) {
  395. Attach(GraphicBuff, XPos, YPos, Width, Height);
  396. }
  397. return(TRUE);
  398. }
  399. /***********************************************************************************************
  400. * GVPC::Unlock -- unlock the video buffer *
  401. * *
  402. * *
  403. * *
  404. * INPUT: Nothing *
  405. * *
  406. * OUTPUT: TRUE if surface was successfully unlocked *
  407. * *
  408. * WARNINGS: None *
  409. * *
  410. * HISTORY: *
  411. * 09-19-95 02:20pm ST : Created *
  412. * 10/09/1995 : Moved actually functionality to GraphicBuffer *
  413. *=============================================================================================*/
  414. inline BOOL GraphicViewPortClass::Unlock(void)
  415. {
  416. BOOL unlock = GraphicBuff->Unlock();
  417. if (!unlock) return(FALSE);
  418. if (this != GraphicBuff && IsDirectDraw && !GraphicBuff->LockCount) {
  419. Offset = 0;
  420. }
  421. return(TRUE);
  422. }
  423. /***************************************************************************
  424. * GVPC::GET_OFFSET -- Get offset for virtual view port class instance *
  425. * *
  426. * INPUT: none *
  427. * *
  428. * OUTPUT: long the offset for the virtual viewport instance *
  429. * *
  430. * HISTORY: *
  431. * 06/07/1994 PWG : Created. *
  432. *=========================================================================*/
  433. inline long GraphicViewPortClass::Get_Offset(void)
  434. {
  435. return(Offset);
  436. }
  437. /***************************************************************************
  438. * GVPC::GET_HEIGHT -- Gets the height of a virtual viewport instance *
  439. * *
  440. * INPUT: none *
  441. * *
  442. * OUTPUT: WORD the height of the virtual viewport instance *
  443. * *
  444. * HISTORY: *
  445. * 06/07/1994 PWG : Created. *
  446. *=========================================================================*/
  447. inline int GraphicViewPortClass::Get_Height(void)
  448. {
  449. return(Height);
  450. }
  451. /***************************************************************************
  452. * GVPC::GET_WIDTH -- Get the width of a virtual viewport instance *
  453. * *
  454. * INPUT: none *
  455. * *
  456. * OUTPUT: WORD the width of the virtual viewport instance *
  457. * *
  458. * HISTORY: *
  459. * 06/07/1994 PWG : Created. *
  460. *=========================================================================*/
  461. inline int GraphicViewPortClass::Get_Width(void)
  462. {
  463. return(Width);
  464. }
  465. /***************************************************************************
  466. * GVPC::GET_XADD -- Get the X add offset for virtual viewport instance *
  467. * *
  468. * INPUT: none *
  469. * *
  470. * OUTPUT: WORD the xadd for a virtual viewport instance *
  471. * *
  472. * HISTORY: *
  473. * 06/07/1994 PWG : Created. *
  474. *=========================================================================*/
  475. inline int GraphicViewPortClass::Get_XAdd(void)
  476. {
  477. return(XAdd);
  478. }
  479. /***************************************************************************
  480. * GVPC::GET_XPOS -- Get the x pos of the VP on the Video *
  481. * *
  482. * INPUT: none *
  483. * *
  484. * OUTPUT: WORD the x offset to VideoBufferClass *
  485. * *
  486. * HISTORY: *
  487. * 08/22/1994 SKB : Created. *
  488. *=========================================================================*/
  489. inline int GraphicViewPortClass::Get_XPos(void)
  490. {
  491. return(XPos);
  492. }
  493. /***************************************************************************
  494. * GVPC::GET_YPOS -- Get the y pos of the VP on the video *
  495. * *
  496. * INPUT: none *
  497. * *
  498. * OUTPUT: WORD the x offset to VideoBufferClass *
  499. * *
  500. * WARNINGS: *
  501. * *
  502. * HISTORY: *
  503. * 08/22/1994 SKB : Created. *
  504. *=========================================================================*/
  505. inline int GraphicViewPortClass::Get_YPos(void)
  506. {
  507. return(YPos);
  508. }
  509. /***************************************************************************
  510. * GVPC::GET_GRAPHIC_BUFFER -- Get the graphic buffer of the VP. *
  511. * *
  512. * INPUT: *
  513. * *
  514. * OUTPUT: *
  515. * *
  516. * HISTORY: *
  517. * 08/22/1994 SKB : Created. *
  518. *=========================================================================*/
  519. inline GraphicBufferClass *GraphicViewPortClass::Get_Graphic_Buffer(void)
  520. {
  521. return (GraphicBuff);
  522. }
  523. /***************************************************************************
  524. * GVPC::SIZE_OF_REGION -- stub to call curr graphic mode Size_Of_Region *
  525. * *
  526. * INPUT: *
  527. * *
  528. * OUTPUT: *
  529. * *
  530. * WARNINGS: *
  531. * *
  532. * HISTORY: *
  533. * 03/01/1995 BWG : Created. *
  534. *=========================================================================*/
  535. inline long GraphicViewPortClass::Size_Of_Region(int w, int h)
  536. {
  537. return Buffer_Size_Of_Region(this, w, h);
  538. }
  539. /***************************************************************************
  540. * GVPC::PUT_PIXEL -- stub to call curr graphic mode Put_Pixel *
  541. * *
  542. * INPUT: *
  543. * *
  544. * OUTPUT: *
  545. * *
  546. * WARNINGS: *
  547. * *
  548. * HISTORY: *
  549. * 01/06/1995 PWG : Created. *
  550. *=========================================================================*/
  551. inline void GraphicViewPortClass::Put_Pixel(int x, int y, unsigned char color)
  552. {
  553. if (Lock()){
  554. Buffer_Put_Pixel(this, x, y, color);
  555. }
  556. Unlock();
  557. }
  558. /***************************************************************************
  559. * GVPC::GET_PIXEL -- stub to call curr graphic mode Get_Pixel *
  560. * *
  561. * INPUT: *
  562. * *
  563. * OUTPUT: *
  564. * *
  565. * WARNINGS: *
  566. * *
  567. * HISTORY: *
  568. * 01/06/1995 PWG : Created. *
  569. *=========================================================================*/
  570. inline int GraphicViewPortClass::Get_Pixel(int x, int y)
  571. {
  572. int return_code=0;
  573. if (Lock()){
  574. return_code=(Buffer_Get_Pixel(this, x, y));
  575. }
  576. Unlock();
  577. return(return_code);
  578. }
  579. /***************************************************************************
  580. * GVPC::CLEAR -- stub to call curr graphic mode Clear *
  581. * *
  582. * INPUT: *
  583. * *
  584. * OUTPUT: *
  585. * *
  586. * WARNINGS: *
  587. * *
  588. * HISTORY: *
  589. * 01/06/1995 PWG : Created. *
  590. *=========================================================================*/
  591. inline void GraphicViewPortClass::Clear(unsigned char color)
  592. {
  593. if (Lock()){
  594. Buffer_Clear(this, color);
  595. }
  596. Unlock();
  597. }
  598. /***************************************************************************
  599. * GVPC::TO_BUFFER -- stub 1 to call curr graphic mode To_Buffer *
  600. * *
  601. * INPUT: *
  602. * *
  603. * OUTPUT: *
  604. * *
  605. * WARNINGS: *
  606. * *
  607. * HISTORY: *
  608. * 01/06/1995 PWG : Created. *
  609. *=========================================================================*/
  610. inline long GraphicViewPortClass::To_Buffer(int x, int y, int w, int h, void *buff, long size)
  611. {
  612. long return_code=0;
  613. if (Lock()){
  614. return_code = (Buffer_To_Buffer(this, x, y, w, h, buff, size));
  615. }
  616. Unlock();
  617. return ( return_code );
  618. }
  619. /***************************************************************************
  620. * GVPC::TO_BUFFER -- stub 2 to call curr graphic mode To_Buffer *
  621. * *
  622. * INPUT: *
  623. * *
  624. * OUTPUT: *
  625. * *
  626. * WARNINGS: *
  627. * *
  628. * HISTORY: *
  629. * 01/06/1995 PWG : Created. *
  630. *=========================================================================*/
  631. inline long GraphicViewPortClass::To_Buffer(int x, int y, int w, int h, BufferClass *buff)
  632. {
  633. long return_code=0;
  634. if (Lock()){
  635. return_code = (Buffer_To_Buffer(this, x, y, w, h, buff->Get_Buffer(), buff->Get_Size()));
  636. }
  637. Unlock();
  638. return ( return_code );
  639. }
  640. /***************************************************************************
  641. * GVPC::TO_BUFFER -- stub 3 to call curr graphic mode To_Buffer *
  642. * *
  643. * INPUT: *
  644. * *
  645. * OUTPUT: *
  646. * *
  647. * WARNINGS: *
  648. * *
  649. * HISTORY: *
  650. * 01/06/1995 PWG : Created. *
  651. *=========================================================================*/
  652. inline long GraphicViewPortClass::To_Buffer(BufferClass *buff)
  653. {
  654. long return_code=0;
  655. if (Lock()){
  656. return_code = (Buffer_To_Buffer(this, 0, 0, Width, Height, buff->Get_Buffer(), buff->Get_Size()));
  657. }
  658. Unlock();
  659. return ( return_code );
  660. }
  661. /***************************************************************************
  662. * GVPC::BLIT -- stub 1 to call curr graphic mode Blit to GVPC *
  663. * *
  664. * INPUT: *
  665. * *
  666. * OUTPUT: *
  667. * *
  668. * WARNINGS: *
  669. * *
  670. * HISTORY: *
  671. * 01/06/1995 PWG : Created. *
  672. *=========================================================================*/
  673. inline HRESULT GraphicViewPortClass::Blit( GraphicViewPortClass& dest, int x_pixel, int y_pixel, int dx_pixel,
  674. int dy_pixel, int pixel_width, int pixel_height, BOOL trans)
  675. {
  676. HRESULT return_code=0;
  677. if ( IsDirectDraw && dest.IsDirectDraw ){
  678. return(DD_Linear_Blit_To_Linear( dest, XPos+x_pixel, YPos+y_pixel
  679. , dest.Get_XPos()+dx_pixel, dest.Get_YPos()+dy_pixel
  680. , pixel_width, pixel_height, trans));
  681. } else {
  682. if (Lock()){
  683. if (dest.Lock()){
  684. return_code=(Linear_Blit_To_Linear(this, &dest, x_pixel, y_pixel
  685. , dx_pixel, dy_pixel
  686. , pixel_width, pixel_height, trans));
  687. }
  688. dest.Unlock();
  689. }
  690. Unlock();
  691. }
  692. return ( return_code );
  693. }
  694. /***************************************************************************
  695. * GVPC::BLIT -- Stub 2 to call curr graphic mode Blit to GVPC *
  696. * *
  697. * INPUT: *
  698. * *
  699. * OUTPUT: *
  700. * *
  701. * WARNINGS: *
  702. * *
  703. * HISTORY: *
  704. * 01/06/1995 PWG : Created. *
  705. *=========================================================================*/
  706. inline HRESULT GraphicViewPortClass::Blit( GraphicViewPortClass& dest, int dx, int dy, BOOL trans)
  707. {
  708. HRESULT return_code=0;
  709. if ( IsDirectDraw && dest.IsDirectDraw ){
  710. return(DD_Linear_Blit_To_Linear( dest, XPos, YPos
  711. , dest.Get_XPos()+dx, dest.Get_YPos()+dy
  712. , Width, Height, trans));
  713. } else {
  714. if (Lock()){
  715. if (dest.Lock()){
  716. return_code=(Linear_Blit_To_Linear(this, &dest, 0, 0
  717. , dx, dy
  718. , Width, Height, trans));
  719. }
  720. dest.Unlock();
  721. }
  722. Unlock();
  723. }
  724. return (return_code);
  725. }
  726. /***************************************************************************
  727. * GVPC::BLIT -- stub 3 to call curr graphic mode Blit to GVPC *
  728. * *
  729. * INPUT: *
  730. * *
  731. * OUTPUT: *
  732. * *
  733. * WARNINGS: *
  734. * *
  735. * HISTORY: *
  736. * 01/06/1995 PWG : Created. *
  737. *=========================================================================*/
  738. inline HRESULT GraphicViewPortClass::Blit( GraphicViewPortClass& dest, BOOL trans)
  739. {
  740. HRESULT return_code=0;
  741. if ( IsDirectDraw && dest.IsDirectDraw ){
  742. return(DD_Linear_Blit_To_Linear( dest, XPos, YPos
  743. , dest.Get_XPos(), dest.Get_YPos()
  744. , MAX( Width, dest.Get_Width())
  745. , MAX( Height, dest.Get_Height())
  746. , trans));
  747. } else {
  748. if (Lock()){
  749. if (dest.Lock()){
  750. return_code=(Linear_Blit_To_Linear(this, &dest, 0, 0
  751. , 0, 0
  752. , Width, Height, trans));
  753. }
  754. dest.Unlock();
  755. }
  756. Unlock();
  757. }
  758. return (return_code);
  759. }
  760. /***************************************************************************
  761. * GVPC::SCALE -- stub 1 to call curr graphic mode Scale to GVPC *
  762. * *
  763. * INPUT: *
  764. * *
  765. * OUTPUT: *
  766. * *
  767. * WARNINGS: *
  768. * *
  769. * HISTORY: *
  770. * 01/06/1995 PWG : Created. *
  771. *=========================================================================*/
  772. inline BOOL GraphicViewPortClass::Scale( GraphicViewPortClass &dest, int src_x, int src_y, int dst_x,
  773. int dst_y, int src_w, int src_h, int dst_w, int dst_h, BOOL trans, char *remap)
  774. {
  775. BOOL return_code=0;
  776. if (Lock()){
  777. if (dest.Lock()){
  778. return_code = (Linear_Scale_To_Linear(this, &dest, src_x, src_y, dst_x, dst_y, src_w, src_h, dst_w, dst_h, trans, remap));
  779. }
  780. dest.Unlock();
  781. }
  782. Unlock();
  783. return ( return_code );
  784. }
  785. /***************************************************************************
  786. * GVPC::SCALE -- stub 2 to call curr graphic mode Scale to GVPC *
  787. * *
  788. * INPUT: *
  789. * *
  790. * OUTPUT: *
  791. * *
  792. * WARNINGS: *
  793. * *
  794. * HISTORY: *
  795. * 01/06/1995 PWG : Created. *
  796. *=========================================================================*/
  797. inline BOOL GraphicViewPortClass::Scale( GraphicViewPortClass &dest, int src_x, int src_y, int dst_x,
  798. int dst_y, int src_w, int src_h, int dst_w, int dst_h, char *remap)
  799. {
  800. BOOL return_code=0;
  801. if (Lock()){
  802. if (dest.Lock()){
  803. return_code = (Linear_Scale_To_Linear(this, &dest, src_x, src_y, dst_x, dst_y, src_w, src_h, dst_w, dst_h, FALSE, remap));
  804. }
  805. dest.Unlock();
  806. }
  807. Unlock();
  808. return ( return_code );
  809. }
  810. /***************************************************************************
  811. * GVPC::SCALE -- stub 3 to call curr graphic mode Scale to GVPC *
  812. * *
  813. * INPUT: *
  814. * *
  815. * OUTPUT: *
  816. * *
  817. * WARNINGS: *
  818. * *
  819. * HISTORY: *
  820. * 01/06/1995 PWG : Created. *
  821. *=========================================================================*/
  822. inline BOOL GraphicViewPortClass::Scale( GraphicViewPortClass &dest, BOOL trans, char *remap)
  823. {
  824. BOOL return_code=0;
  825. if (Lock()){
  826. if (dest.Lock()){
  827. return_code = (Linear_Scale_To_Linear(this, &dest, 0, 0, 0, 0, Width, Height, dest.Get_Width(), dest.Get_Height(), trans, remap));
  828. }
  829. dest.Unlock();
  830. }
  831. Unlock();
  832. return ( return_code );
  833. }
  834. /***************************************************************************
  835. * GVPC::SCALE -- stub 4 to call curr graphic mode Scale to GVPC *
  836. * *
  837. * INPUT: *
  838. * *
  839. * OUTPUT: *
  840. * *
  841. * WARNINGS: *
  842. * *
  843. * HISTORY: *
  844. * 01/06/1995 PWG : Created. *
  845. *=========================================================================*/
  846. inline BOOL GraphicViewPortClass::Scale( GraphicViewPortClass &dest, char *remap)
  847. {
  848. BOOL return_code=0;
  849. if (Lock()){
  850. if (dest.Lock()){
  851. return_code = (Linear_Scale_To_Linear(this, &dest, 0, 0, 0, 0, Width, Height, dest.Get_Width(), dest.Get_Height(), FALSE, remap));
  852. }
  853. dest.Unlock();
  854. }
  855. Unlock();
  856. return ( return_code );
  857. }
  858. /***************************************************************************
  859. * GVPC::PRINT -- stub func to print a text string *
  860. * *
  861. * INPUT: *
  862. * *
  863. * OUTPUT: *
  864. * *
  865. * WARNINGS: *
  866. * *
  867. * HISTORY: *
  868. * 01/17/1995 PWG : Created. *
  869. *=========================================================================*/
  870. inline unsigned long GraphicViewPortClass::Print(char const *str, int x, int y, int fcol, int bcol)
  871. {
  872. unsigned long return_code=0;
  873. if (Lock()){
  874. return_code = (Buffer_Print(this, str, x, y, fcol, bcol));
  875. }
  876. Unlock();
  877. return ( return_code );
  878. }
  879. /***************************************************************************
  880. * GVPC::PRINT -- Stub function to print an integer *
  881. * *
  882. * INPUT: *
  883. * *
  884. * OUTPUT: *
  885. * *
  886. * WARNINGS: *
  887. * *
  888. * HISTORY: *
  889. *=========================================================================*/
  890. inline unsigned long GraphicViewPortClass::Print(int num, int x, int y, int fcol, int bcol)
  891. {
  892. char str[17];
  893. unsigned long return_code=0;
  894. if (Lock()){
  895. return_code = (Buffer_Print(this, itoa(num, str, 10), x, y, fcol, bcol));
  896. }
  897. Unlock();
  898. return ( return_code );
  899. }
  900. /***************************************************************************
  901. * GVPC::PRINT -- Stub function to print a short to a graphic viewport *
  902. * *
  903. * INPUT: *
  904. * *
  905. * OUTPUT: *
  906. * *
  907. * WARNINGS: *
  908. * *
  909. * HISTORY: *
  910. *=========================================================================*/
  911. inline unsigned long GraphicViewPortClass::Print(short num, int x, int y, int fcol, int bcol)
  912. {
  913. char str[17];
  914. unsigned long return_code=0;
  915. if (Lock()){
  916. return_code = (Buffer_Print(this, itoa(num, str, 10), x, y, fcol, bcol));
  917. }
  918. Unlock();
  919. return ( return_code );
  920. }
  921. /***************************************************************************
  922. * GVPC::PRINT -- stub function to print a long on a graphic view port *
  923. * *
  924. * INPUT: *
  925. * *
  926. * OUTPUT: *
  927. * *
  928. * WARNINGS: *
  929. * *
  930. * HISTORY: *
  931. *=========================================================================*/
  932. inline unsigned long GraphicViewPortClass::Print(long num, int x, int y, int fcol, int bcol)
  933. {
  934. char str[33];
  935. unsigned long return_code=0;
  936. if (Lock()){
  937. return_code = (Buffer_Print(this, ltoa(num, str,10), x, y, fcol, bcol));
  938. }
  939. Unlock();
  940. return ( return_code );
  941. }
  942. /***************************************************************************
  943. * GVPC::DRAW_STAMP -- stub function to draw a tile on a graphic view port *
  944. * *
  945. * INPUT: *
  946. * *
  947. * OUTPUT: *
  948. * *
  949. * WARNINGS: *
  950. * *
  951. * HISTORY: *
  952. *=========================================================================*/
  953. inline void GraphicViewPortClass::Draw_Stamp(void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap)
  954. {
  955. if (Lock()){
  956. Buffer_Draw_Stamp(this, icondata, icon, x_pixel, y_pixel, remap);
  957. }
  958. Unlock();
  959. }
  960. /***************************************************************************
  961. * GVPC::DRAW_STAMP -- stub function to draw a tile on a graphic view port *
  962. * This version clips the tile to a window *
  963. * *
  964. * INPUT: *
  965. * *
  966. * OUTPUT: *
  967. * *
  968. * WARNINGS: *
  969. * *
  970. * HISTORY: *
  971. * 07/31/1995 BWG : Created. *
  972. *=========================================================================*/
  973. extern BOOL IconCacheAllowed;
  974. inline void GraphicViewPortClass::Draw_Stamp(void const * icondata, int icon, int x_pixel, int y_pixel, void const * remap, int clip_window)
  975. {
  976. int cache_index=-1;
  977. int drewit = 0;
  978. if (IconCacheAllowed){
  979. if (IsDirectDraw){
  980. if (!remap){
  981. cache_index = Is_Icon_Cached(icondata,icon);
  982. }
  983. if (cache_index != -1){
  984. if (CachedIcons[cache_index].Get_Is_Cached() ){
  985. CachedIcons[cache_index].Draw_It (GraphicBuff->Get_DD_Surface() , x_pixel, y_pixel,
  986. WindowList[clip_window][WINDOWX] + XPos,
  987. WindowList[clip_window][WINDOWY] +YPos,
  988. WindowList[clip_window][WINDOWWIDTH],
  989. WindowList[clip_window][WINDOWHEIGHT]);
  990. CachedIconsDrawn++;
  991. drewit = 1;
  992. }
  993. }
  994. }
  995. }
  996. if (drewit == 0) {
  997. if (Lock()){
  998. UnCachedIconsDrawn++;
  999. Buffer_Draw_Stamp_Clip(this, icondata, icon, x_pixel, y_pixel, remap, WindowList[clip_window][WINDOWX], WindowList[clip_window][WINDOWY], WindowList[clip_window][WINDOWWIDTH], WindowList[clip_window][WINDOWHEIGHT]);
  1000. }
  1001. }
  1002. Unlock();
  1003. }
  1004. /***************************************************************************
  1005. * GVPC::DRAW_LINE -- Stub function to draw line in Graphic Viewport Class *
  1006. * *
  1007. * INPUT: *
  1008. * *
  1009. * OUTPUT: *
  1010. * *
  1011. * WARNINGS: *
  1012. * *
  1013. * HISTORY: *
  1014. * 01/16/1995 PWG : Created. *
  1015. *=========================================================================*/
  1016. inline VOID GraphicViewPortClass::Draw_Line(int sx, int sy, int dx, int dy, unsigned char color)
  1017. {
  1018. if (Lock()){
  1019. Buffer_Draw_Line(this, sx, sy, dx, dy, color);
  1020. }
  1021. Unlock();
  1022. }
  1023. /***************************************************************************
  1024. * GVPC::FILL_RECT -- Stub function to fill rectangle in a GVPC *
  1025. * *
  1026. * INPUT: *
  1027. * *
  1028. * OUTPUT: *
  1029. * *
  1030. * WARNINGS: *
  1031. * *
  1032. * HISTORY: *
  1033. * 01/16/1995 PWG : Created. *
  1034. *=========================================================================*/
  1035. inline VOID GraphicViewPortClass::Fill_Rect(int sx, int sy, int dx, int dy, unsigned char color)
  1036. {
  1037. if ( AllowHardwareBlitFills
  1038. && IsDirectDraw
  1039. && ( (dx-sx) * (dy-sy) >= (32*32) )
  1040. && GraphicBuff->Get_DD_Surface()->GetBltStatus(DDGBS_CANBLT) == DD_OK){
  1041. DDBLTFX blit_effects;
  1042. RECT dest_rectangle;
  1043. dest_rectangle.left =sx+XPos;
  1044. dest_rectangle.top =sy+YPos;
  1045. dest_rectangle.right =dx+XPos;
  1046. dest_rectangle.bottom=dy+YPos;
  1047. if (dest_rectangle.left<XPos){
  1048. dest_rectangle.left=XPos;
  1049. }
  1050. if (dest_rectangle.right >= Width + XPos){
  1051. dest_rectangle.right = Width +XPos -1;
  1052. }
  1053. if (dest_rectangle.top<YPos){
  1054. dest_rectangle.top=YPos;
  1055. }
  1056. if (dest_rectangle.bottom >= Height + YPos){
  1057. dest_rectangle.bottom = Height + YPos -1;
  1058. }
  1059. if (dest_rectangle.left >= dest_rectangle.right) return;
  1060. if (dest_rectangle.top >= dest_rectangle.bottom) return;
  1061. dest_rectangle.right++;
  1062. dest_rectangle.bottom++;
  1063. blit_effects.dwSize=sizeof(blit_effects);
  1064. blit_effects.dwFillColor = color;
  1065. GraphicBuff->Get_DD_Surface()->Blt(&dest_rectangle,
  1066. NULL,
  1067. NULL,
  1068. DDBLT_WAIT | DDBLT_ASYNC | DDBLT_COLORFILL,
  1069. &blit_effects);
  1070. } else {
  1071. if (Lock()){
  1072. Buffer_Fill_Rect(this, sx, sy, dx, dy, color);
  1073. Unlock();
  1074. }
  1075. }
  1076. }
  1077. /***************************************************************************
  1078. * GVPC::REMAP -- Stub function to remap a GVPC *
  1079. * *
  1080. * INPUT: *
  1081. * *
  1082. * OUTPUT: *
  1083. * *
  1084. * WARNINGS: *
  1085. * *
  1086. * HISTORY: *
  1087. * 01/16/1995 PWG : Created. *
  1088. *=========================================================================*/
  1089. inline VOID GraphicViewPortClass::Remap(int sx, int sy, int width, int height, VOID *remap)
  1090. {
  1091. if (Lock()){
  1092. Buffer_Remap(this, sx, sy, width, height, remap);
  1093. }
  1094. Unlock();
  1095. }
  1096. inline VOID GraphicViewPortClass::Fill_Quad(VOID *span_buff, int x0, int y0, int x1, int y1,
  1097. int x2, int y2, int x3, int y3, int color)
  1098. {
  1099. if (Lock()){
  1100. Buffer_Fill_Quad(this, span_buff, x0, y0, x1, y1, x2, y2, x3, y3, color);
  1101. }
  1102. Unlock();
  1103. }
  1104. /***************************************************************************
  1105. * GVPC::REMAP -- Short form to remap an entire graphic view port *
  1106. * *
  1107. * INPUT: BYTE * to the remap table to use *
  1108. * *
  1109. * OUTPUT: none *
  1110. * *
  1111. * HISTORY: *
  1112. * 07/01/1994 PWG : Created. *
  1113. *=========================================================================*/
  1114. inline VOID GraphicViewPortClass::Remap(VOID *remap)
  1115. {
  1116. if (Lock()){
  1117. Buffer_Remap(this, 0, 0, Width, Height, remap);
  1118. }
  1119. Unlock();
  1120. }
  1121. inline int GraphicViewPortClass::Get_Pitch(void)
  1122. {
  1123. return(Pitch);
  1124. }
  1125. /*=========================================================================*/
  1126. /* The following BufferClass functions are defined here because they act */
  1127. /* on graphic viewports. */
  1128. /*=========================================================================*/
  1129. /***************************************************************************
  1130. * BUFFER_TO_PAGE -- Generic 'c' callable form of Buffer_To_Page *
  1131. * *
  1132. * INPUT: *
  1133. * *
  1134. * OUTPUT: *
  1135. * *
  1136. * WARNINGS: *
  1137. * *
  1138. * HISTORY: *
  1139. * 01/12/1995 PWG : Created. *
  1140. *=========================================================================*/
  1141. inline long Buffer_To_Page(int x, int y, int w, int h, void *Buffer, GraphicViewPortClass &view)
  1142. {
  1143. long return_code=0;
  1144. if (view.Lock()){
  1145. return_code = (Buffer_To_Page(x, y, w, h, Buffer, &view));
  1146. }
  1147. view.Unlock();
  1148. return ( return_code );
  1149. }
  1150. /***************************************************************************
  1151. * BC::TO_PAGE -- Copys a buffer class to a page with definable w, h *
  1152. * *
  1153. * INPUT: int width - the width of copy region *
  1154. * int height - the height of copy region *
  1155. * GVPC& dest - virtual viewport to copy to *
  1156. * *
  1157. * OUTPUT: none *
  1158. * *
  1159. * WARNINGS: x and y position are the upper left corner of the dest *
  1160. * viewport *
  1161. * *
  1162. * HISTORY: *
  1163. * 07/01/1994 PWG : Created. *
  1164. *=========================================================================*/
  1165. inline long BufferClass::To_Page(int w, int h, GraphicViewPortClass &view)
  1166. {
  1167. long return_code=0;
  1168. if (view.Lock()){
  1169. return_code = (Buffer_To_Page(0, 0, w, h, Buffer, &view));
  1170. }
  1171. view.Unlock();
  1172. return ( return_code );
  1173. }
  1174. /***************************************************************************
  1175. * BC::TO_PAGE -- Copys a buffer class to a page with definable w, h *
  1176. * *
  1177. * INPUT: GVPC& dest - virtual viewport to copy to *
  1178. * *
  1179. * OUTPUT: none *
  1180. * *
  1181. * WARNINGS: x and y position are the upper left corner of the dest *
  1182. * viewport. width and height are assumed to be the *
  1183. * viewport's width and height. *
  1184. * *
  1185. * HISTORY: *
  1186. * 07/01/1994 PWG : Created. *
  1187. *=========================================================================*/
  1188. inline long BufferClass::To_Page(GraphicViewPortClass &view)
  1189. {
  1190. long return_code=0;
  1191. if (view.Lock()){
  1192. return_code = (Buffer_To_Page(0, 0, view.Get_Width(), view.Get_Height(), Buffer, &view));
  1193. }
  1194. view.Unlock();
  1195. return ( return_code );
  1196. }
  1197. /***************************************************************************
  1198. * BC::TO_PAGE -- Copys a buffer class to a page with definable x, y, w, h *
  1199. * *
  1200. * INPUT: int x - x pixel on viewport to copy from *
  1201. * int y - y pixel on viewport to copy from *
  1202. * int width - the width of copy region *
  1203. * int height - the height of copy region *
  1204. * GVPC& dest - virtual viewport to copy to *
  1205. * *
  1206. * OUTPUT: none *
  1207. * *
  1208. * HISTORY: *
  1209. * 07/01/1994 PWG : Created. *
  1210. *=========================================================================*/
  1211. inline long BufferClass::To_Page(int x, int y, int w, int h, GraphicViewPortClass &view)
  1212. {
  1213. long return_code=0;
  1214. if (view.Lock()){
  1215. return_code = (Buffer_To_Page(x, y, w, h, Buffer, &view));
  1216. }
  1217. view.Unlock();
  1218. return ( return_code );
  1219. }
  1220. #endif