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 */ 22 23 #ifndef TITANIC_DIRECT_DRAW_SURFACE_H 24 #define TITANIC_DIRECT_DRAW_SURFACE_H 25 26 #include "common/scummsys.h" 27 #include "common/array.h" 28 #include "graphics/managed_surface.h" 29 #include "titanic/support/rect.h" 30 31 namespace Titanic { 32 33 class TitanicEngine; 34 35 struct DDSurfaceDesc { 36 int _w; 37 int _h; 38 int _bpp; 39 int _flags; 40 int _caps; 41 DDSurfaceDescDDSurfaceDesc42 DDSurfaceDesc(int w, int h, int bpp) : _w(w), _h(h), _bpp(bpp), 43 _flags(0x1006), _caps(64) {} 44 }; 45 46 class DirectDrawSurface { 47 private: 48 Graphics::ManagedSurface *_surface; 49 DisposeAfterUse::Flag _disposeAfterUse; 50 public: 51 DirectDrawSurface(); 52 ~DirectDrawSurface(); 53 54 /** 55 * Create a surface 56 */ 57 void create(int w, int h, int bpp); 58 59 /** 60 * Create a surface based on a passed surface 61 */ 62 void create(Graphics::ManagedSurface *surface); 63 64 /** 65 * Frees the surface 66 */ 67 void free(); 68 69 /** 70 * Return the size of the surface in ytes 71 */ getSize()72 int getSize() const { return _surface->pitch * _surface->h; } 73 74 /** 75 * Return the surface width 76 */ getWidth()77 int getWidth() const { return _surface->w; } 78 79 /** 80 * Return the surface width 81 */ getHeight()82 int getHeight() const { return _surface->h; } 83 84 /** 85 * Return the surface pitch 86 */ getPitch()87 int getPitch() const { return _surface->pitch; } 88 89 /** 90 * Return the surface's format 91 */ getFormat()92 const Graphics::PixelFormat &getFormat() { return _surface->format; } 93 94 /** 95 * Lock the surface for access 96 */ 97 Graphics::ManagedSurface *lock(const Rect *bounds, int flags); 98 99 /** 100 * Unlocks the surface at the end of direct accesses 101 */ 102 void unlock(); 103 104 /** 105 * Fills an area of the surfae with the specified color. If no bounds are passed, 106 * then the entire surface is filled 107 */ 108 void fill(const Rect *bounds, uint32 color); 109 110 /** 111 * Fill an area with a specific color 112 */ 113 void fillRect(Rect *rect, byte r, byte g, byte b); 114 115 /** 116 * Copy data from a source surfcae into this one 117 */ 118 void blit(const Rect &destRect, DirectDrawSurface *srcSurface, Rect &srcRect); 119 120 /** 121 * Copy data from a source surfcae into this one 122 */ 123 void blit(const Point &destPos, DirectDrawSurface *srcSurface, Rect *bounds); 124 }; 125 126 } // End of namespace Titanic 127 128 #endif /* TITANIC_DIRECT_DRAW_SURFACE_H */ 129