Speech bubbles can point down right.
[scummvm-innocent.git] / graphics / surface.h
blob20ab816236de5ab546c331b89b3772aac5d50cc7
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.
21 * $URL$
22 * $Id$
25 #ifndef GRAPHICS_SURFACE_H
26 #define GRAPHICS_SURFACE_H
28 #include "common/scummsys.h"
29 #include "common/rect.h"
31 namespace Graphics {
33 /**
34 * An arbitrary graphics surface, which can be the target (or source) of blit
35 * operations, font rendering, etc.
37 struct Surface {
38 /**
39 * ARM code relies on the layout of the first 3 of these fields. Do
40 * not change them.
42 uint16 w;
43 uint16 h;
44 uint16 pitch;
45 void *pixels;
46 uint8 bytesPerPixel;
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;
57 /**
58 * Allocate pixels memory for this surface and for the specified dimension.
60 void create(uint16 width, uint16 height, uint8 bytesPP);
62 /**
63 * Release the memory used by the pixels memory of this surface. This is the
64 * counterpart to create().
66 void free();
68 /**
69 * Copies data from another Surface, this calls *free* on the current surface, to assure
70 * it being clean.
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);
83 /**
84 * For safe deletion of surface with SharedPtr.
85 * The deleter assures Surface::free is called on
86 * deletion.
88 struct SharedPtrSurfaceDeleter {
89 void operator()(Surface *ptr) {
90 ptr->free();
91 delete ptr;
96 } // End of namespace Graphics
99 #endif