1 /* ScummVM - Graphic Adventure Engine
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.
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.
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.
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.
25 #ifndef GRAPHICS_SURFACE_H
26 #define GRAPHICS_SURFACE_H
28 #include "common/scummsys.h"
29 #include "common/rect.h"
34 * An arbitrary graphics surface, which can be the target (or source) of blit
35 * operations, font rendering, etc.
39 * ARM code relies on the layout of the first 3 of these fields. Do
47 Surface() : w(0), h(0), pitch(0), pixels(0), bytesPerPixel(0) {}
49 inline const void *getBasePtr(int x
, int y
) const {
50 return (const byte
*)(pixels
) + y
* pitch
+ x
* bytesPerPixel
;
53 inline void *getBasePtr(int x
, int y
) {
54 return static_cast<byte
*>(pixels
) + y
* pitch
+ x
* bytesPerPixel
;
58 * Allocate pixels memory for this surface and for the specified dimension.
60 void create(uint16 width
, uint16 height
, uint8 bytesPP
);
63 * Release the memory used by the pixels memory of this surface. This is the
64 * counterpart to create().
69 * Copies data from another Surface, this calls *free* on the current surface, to assure
72 void copyFrom(const Surface
&surf
);
74 void drawLine(int x0
, int y0
, int x1
, int y1
, uint32 color
);
75 void hLine(int x
, int y
, int x2
, uint32 color
);
76 void vLine(int x
, int y
, int y2
, uint32 color
);
77 void fillRect(Common::Rect r
, uint32 color
);
78 void frameRect(const Common::Rect
&r
, uint32 color
);
79 // See comment in graphics/surface.cpp about it
80 void move(int dx
, int dy
, int height
);
84 * For safe deletion of surface with SharedPtr.
85 * The deleter assures Surface::free is called on
88 struct SharedPtrSurfaceDeleter
{
89 void operator()(Surface
*ptr
) {
96 } // End of namespace Graphics