2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2004-03-21 21:20:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-03-21 21:20:25 +00:00
|
|
|
*
|
2006-02-11 10:10:44 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-03-21 21:20:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GRAPHICS_SURFACE_H
|
|
|
|
#define GRAPHICS_SURFACE_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2004-11-25 23:33:21 +00:00
|
|
|
#include "common/rect.h"
|
2004-03-21 21:20:25 +00:00
|
|
|
|
|
|
|
namespace Graphics {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An arbitrary graphics surface, which can be the target (or source) of blit
|
|
|
|
* operations, font rendering, etc.
|
|
|
|
*/
|
|
|
|
struct Surface {
|
2008-12-22 11:22:15 +00:00
|
|
|
/**
|
|
|
|
* ARM code relies on the layout of the first 3 of these fields. Do
|
|
|
|
* not change them.
|
|
|
|
*/
|
2004-03-21 21:20:25 +00:00
|
|
|
uint16 w;
|
|
|
|
uint16 h;
|
|
|
|
uint16 pitch;
|
2008-02-03 21:13:56 +00:00
|
|
|
void *pixels;
|
2004-03-21 21:20:25 +00:00
|
|
|
uint8 bytesPerPixel;
|
2008-02-09 23:31:04 +00:00
|
|
|
Surface() : w(0), h(0), pitch(0), pixels(0), bytesPerPixel(0) {}
|
2004-11-25 23:33:21 +00:00
|
|
|
|
2005-05-02 18:00:05 +00:00
|
|
|
inline const void *getBasePtr(int x, int y) const {
|
2009-01-05 20:12:25 +00:00
|
|
|
return (const byte *)(pixels) + y * pitch + x * bytesPerPixel;
|
2005-05-02 18:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void *getBasePtr(int x, int y) {
|
2009-01-01 23:54:09 +00:00
|
|
|
return static_cast<byte *>(pixels) + y * pitch + x * bytesPerPixel;
|
2004-11-25 23:33:21 +00:00
|
|
|
}
|
2005-05-08 12:33:55 +00:00
|
|
|
|
2005-05-08 21:24:33 +00:00
|
|
|
/**
|
|
|
|
* Allocate pixels memory for this surface and for the specified dimension.
|
|
|
|
*/
|
|
|
|
void create(uint16 width, uint16 height, uint8 bytesPP);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-08 21:24:33 +00:00
|
|
|
/**
|
|
|
|
* Release the memory used by the pixels memory of this surface. This is the
|
|
|
|
* counterpart to create().
|
|
|
|
*/
|
|
|
|
void free();
|
|
|
|
|
2008-09-16 14:10:55 +00:00
|
|
|
/**
|
|
|
|
* Copies data from another Surface, this calls *free* on the current surface, to assure
|
|
|
|
* it being clean.
|
|
|
|
*/
|
|
|
|
void copyFrom(const Surface &surf);
|
|
|
|
|
2005-05-08 12:33:55 +00:00
|
|
|
void drawLine(int x0, int y0, int x1, int y1, uint32 color);
|
2005-05-02 18:00:05 +00:00
|
|
|
void hLine(int x, int y, int x2, uint32 color);
|
|
|
|
void vLine(int x, int y, int y2, uint32 color);
|
2007-11-06 23:03:19 +00:00
|
|
|
void fillRect(Common::Rect r, uint32 color);
|
2005-05-02 18:00:05 +00:00
|
|
|
void frameRect(const Common::Rect &r, uint32 color);
|
2007-11-06 23:03:19 +00:00
|
|
|
// See comment in graphics/surface.cpp about it
|
2006-06-21 11:33:04 +00:00
|
|
|
void move(int dx, int dy, int height);
|
2004-03-21 21:20:25 +00:00
|
|
|
};
|
|
|
|
|
2008-09-16 14:10:55 +00:00
|
|
|
/**
|
|
|
|
* For safe deletion of surface with SharedPtr.
|
|
|
|
* The deleter assures Surface::free is called on
|
|
|
|
* deletion.
|
|
|
|
*/
|
|
|
|
struct SharedPtrSurfaceDeleter {
|
|
|
|
void operator()(Surface *ptr) {
|
|
|
|
ptr->free();
|
|
|
|
delete ptr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2004-03-21 21:20:25 +00:00
|
|
|
|
|
|
|
} // End of namespace Graphics
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|