ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

surface.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRAPHICS_SURFACE_H
00024 #define GRAPHICS_SURFACE_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/list.h"
00028 
00029 namespace Common {
00030 struct Rect;
00031 struct Point;
00032 }
00033 
00034 #include "graphics/pixelformat.h"
00035 
00036 namespace Graphics {
00037 
00042 struct Surface {
00043     /*
00044      * IMPORTANT implementation specific detail:
00045      *
00046      * ARM code relies on the layout of the first 3 of these fields. Do not
00047      * change them.
00048      */
00049 
00053     uint16 w;
00054 
00058     uint16 h;
00059 
00065     uint16 pitch;
00066 
00067 protected:
00071     void *pixels;
00072 
00073 public:
00077     PixelFormat format;
00078 
00082     Surface() : w(0), h(0), pitch(0), pixels(0), format() {
00083     }
00084 
00090     inline const void *getPixels() const {
00091         return pixels;
00092     }
00093 
00099     inline void *getPixels() {
00100         return pixels;
00101     }
00102 
00110     void setPixels(void *newPixels) { pixels = newPixels; }
00111 
00119     inline const void *getBasePtr(int x, int y) const {
00120         return (const byte *)(pixels) + y * pitch + x * format.bytesPerPixel;
00121     }
00122 
00130     inline void *getBasePtr(int x, int y) {
00131         return static_cast<byte *>(pixels) + y * pitch + x * format.bytesPerPixel;
00132     }
00133 
00144     void create(uint16 width, uint16 height, const PixelFormat &format);
00145 
00154     void free();
00155 
00168     void init(uint16 width, uint16 height, uint16 pitch, void *pixels, const PixelFormat &format);
00169 
00181     void copyFrom(const Surface &surf);
00182 
00197     Surface getSubArea(const Common::Rect &area);
00198 
00212     const Surface getSubArea(const Common::Rect &area) const;
00213 
00225     void copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height);
00235     void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect);
00236 
00250     void convertToInPlace(const PixelFormat &dstFormat, const byte *palette = 0);
00251 
00261     Graphics::Surface *convertTo(const PixelFormat &dstFormat, const byte *palette = 0) const;
00262 
00273     void drawLine(int x0, int y0, int x1, int y1, uint32 color);
00274 
00288     void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, uint32 color);
00289 
00299     void hLine(int x, int y, int x2, uint32 color);
00300 
00310     void vLine(int x, int y, int y2, uint32 color);
00311 
00318     void fillRect(Common::Rect r, uint32 color);
00319 
00326     void frameRect(const Common::Rect &r, uint32 color);
00327 
00328     // See comment in graphics/surface.cpp about it
00329     void move(int dx, int dy, int height);
00330 };
00331 
00337 struct SurfaceDeleter {
00338     void operator()(Surface *ptr) {
00339         if (ptr) {
00340             ptr->free();
00341         }
00342         delete ptr;
00343     }
00344 };
00345 
00356 class FloodFill {
00357 public:
00365     FloodFill(Surface *surface, uint32 oldColor, uint32 fillColor, bool maskMode = false);
00366     ~FloodFill();
00367 
00374     void addSeed(int x, int y);
00375 
00383     void fill();
00384 
00393     void fillMask();
00394 
00400     Surface *getMask() { return _mask; }
00401 
00402 private:
00403     Common::List<Common::Point *> _queue;
00404     Surface *_surface;
00405     Surface *_mask;
00406     uint32 _oldColor, _fillColor;
00407     byte *_visited;
00408     int _w, _h;
00409 
00410     bool _maskMode;
00411 };
00412 
00413 } // End of namespace Graphics
00414 
00415 
00416 #endif


Generated on Sat May 18 2019 05:01:21 for ResidualVM by doxygen 1.7.1
curved edge   curved edge