diff options
author | Johannes Schickel | 2011-05-01 16:54:45 +0200 |
---|---|---|
committer | Johannes Schickel | 2011-05-01 16:54:45 +0200 |
commit | 71bdb86e028db9556611f88b3686ce93312a8131 (patch) | |
tree | 3c24233044a8e72bd8ecd73b981f50c725d5d282 /graphics/surface.h | |
parent | 89b63e3adb4692c9659f8b133727ccc1e2af75b4 (diff) | |
parent | 8ff527ac4ef4237e63c0802a22eb0f942089e6c4 (diff) | |
download | scummvm-rg350-71bdb86e028db9556611f88b3686ce93312a8131.tar.gz scummvm-rg350-71bdb86e028db9556611f88b3686ce93312a8131.tar.bz2 scummvm-rg350-71bdb86e028db9556611f88b3686ce93312a8131.zip |
Merge pull request #16 "Add a PixelFormat to Graphics::Surface.".
For further discussion check here:
https://github.com/scummvm/scummvm/pull/16
Conflicts:
graphics/png.cpp
Diffstat (limited to 'graphics/surface.h')
-rw-r--r-- | graphics/surface.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/graphics/surface.h b/graphics/surface.h index 92c7b7e899..1b54690aa9 100644 --- a/graphics/surface.h +++ b/graphics/surface.h @@ -31,6 +31,8 @@ namespace Common { struct Rect; } +#include "graphics/pixelformat.h" + namespace Graphics { /** @@ -68,14 +70,14 @@ struct Surface { void *pixels; /** - * How many bytes a single pixel occupies. + * The pixel format of the surface. */ - uint8 bytesPerPixel; + PixelFormat format; /** * Construct a simple Surface object. */ - Surface() : w(0), h(0), pitch(0), pixels(0), bytesPerPixel(0) { + Surface() : w(0), h(0), pitch(0), pixels(0), format() { } /** @@ -86,7 +88,7 @@ struct Surface { * @return Pointer to the pixel. */ inline const void *getBasePtr(int x, int y) const { - return (const byte *)(pixels) + y * pitch + x * bytesPerPixel; + return (const byte *)(pixels) + y * pitch + x * format.bytesPerPixel; } /** @@ -97,7 +99,7 @@ struct Surface { * @return Pointer to the pixel. */ inline void *getBasePtr(int x, int y) { - return static_cast<byte *>(pixels) + y * pitch + x * bytesPerPixel; + return static_cast<byte *>(pixels) + y * pitch + x * format.bytesPerPixel; } /** @@ -108,9 +110,9 @@ struct Surface { * * @param width Width of the surface object. * @param height Height of the surface object. - * @param bytePP The number of bytes a single pixel uses. + * @param format The pixel format the surface should use. */ - void create(uint16 width, uint16 height, uint8 bytesPP); + void create(uint16 width, uint16 height, const PixelFormat &format); /** * Release the memory used by the pixels memory of this surface. This is the |