22#ifndef GRAPHICS_MANAGED_SURFACE_H
23#define GRAPHICS_MANAGED_SURFACE_H
25#include "graphics/pixelformat.h"
26#include "graphics/surface.h"
27#include "graphics/transform_struct.h"
28#include "common/types.h"
29#include "graphics/blit.h"
31#define MS_RGB(R,G,B) (uint32)(((R) << 24) | ((G) << 16) | ((B) << 8) | 0xff)
32#define MS_ARGB(A,R,G,B) (uint32)(((R) << 24) | ((G) << 16) | ((B) << 8) | (A))
62 DisposeAfterUse::Flag _disposeAfterUse;
80 uint _transparentColor;
81 bool _transparentColorSet;
93 bool transparentColorSet, uint transparentColor,
94 byte flip,
bool alpha,
byte aMod);
101 const Palette *srcPalette,
byte flip,
bool alpha,
byte aMod);
113 const Common::Rect &destRect, uint32 transColor,
bool flipped, uint32 srcAlpha,
120 const Common::Rect &destRect,
const int flipping,
const uint colorMod,
121 const TSpriteBlendMode blend,
const AlphaType alphaType);
130 return _innerSurface.
clip(srcBounds, destBounds, src_w, src_h, flip);
151 WARN_DEPRECATED(
"Use copyFrom(), a move constructor or supply bounds")
186 operator const
Surface &()
const {
return _innerSurface; }
196 Surface *surfacePtr() {
return &_innerSurface; }
203 WARN_DEPRECATED(
"Use copyFrom() or a move constructor instead")
230 return _innerSurface.
getPixel(x, y);
241 return _innerSurface.
setPixel(x, y, pixel);
283 virtual void create(int16 width, int16 height);
336 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff,
337 const Palette *srcPalette =
nullptr);
343 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff,
344 const Palette *srcPalette =
nullptr);
351 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff,
352 const Palette *srcPalette =
nullptr);
358 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff);
364 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff);
371 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff);
377 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff,
378 const Palette *srcPalette =
nullptr);
384 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff,
385 const Palette *srcPalette =
nullptr);
392 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff,
393 const Palette *srcPalette =
nullptr);
399 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff);
405 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff);
412 byte flip =
FLIP_NONE,
bool alpha =
false,
byte aMod = 0xff);
468 uint32 srcAlpha = 0xff,
const Palette *srcPalette =
nullptr);
481 uint32 transColor = 0,
bool flipped =
false, uint32 srcAlpha = 0xff,
const Palette *srcPalette =
nullptr);
495 uint32 transColor = 0,
bool flipped =
false, uint32 srcAlpha = 0xff,
const Palette *srcPalette =
nullptr);
521 uint32 transColor = 0,
bool flipped =
false, uint32 srcAlpha = 0xff,
522 const Palette *srcPalette =
nullptr);
533 uint32 srcAlpha = 0xff);
545 uint32 transColor = 0,
bool flipped =
false, uint32 srcAlpha = 0xff);
558 uint32 transColor = 0,
bool flipped =
false, uint32 srcAlpha = 0xff);
572 uint32 transColor = 0,
bool flipped =
false, uint32 srcAlpha = 0xff);
580 destPos.
y + srcRect.
height()), src._palette);
607 const uint colorMod = MS_ARGB(255, 255, 255, 255),
608 const TSpriteBlendMode blend = BLEND_NORMAL,
609 const AlphaType alphaType = ALPHA_FULL);
627 const uint colorMod = MS_ARGB(255, 255, 255, 255),
628 const TSpriteBlendMode blend = BLEND_NORMAL,
629 const AlphaType alphaType = ALPHA_FULL);
649 const uint colorMod = MS_ARGB(255, 255, 255, 255),
650 const TSpriteBlendMode blend = BLEND_NORMAL,
651 const AlphaType alphaType = ALPHA_FULL);
672 const uint colorMod = MS_ARGB(255, 255, 255, 255),
673 const TSpriteBlendMode blend = BLEND_NORMAL,
674 const AlphaType alphaType = ALPHA_FULL);
691 const uint colorMod = MS_ARGB(255, 255, 255, 255),
692 const TSpriteBlendMode blend = BLEND_NORMAL,
693 const AlphaType alphaType = ALPHA_FULL);
711 const uint colorMod = MS_ARGB(255, 255, 255, 255),
712 const TSpriteBlendMode blend = BLEND_NORMAL,
713 const AlphaType alphaType = ALPHA_FULL);
733 const uint colorMod = MS_ARGB(255, 255, 255, 255),
734 const TSpriteBlendMode blend = BLEND_NORMAL,
735 const AlphaType alphaType = ALPHA_FULL);
756 const uint colorMod = MS_ARGB(255, 255, 255, 255),
757 const TSpriteBlendMode blend = BLEND_NORMAL,
758 const AlphaType alphaType = ALPHA_FULL);
775 const int posX = 0,
const int posY = 0,
778 const uint colorMod = MS_ARGB(255, 255, 255, 255),
779 const int width = -1,
const int height = -1,
780 const TSpriteBlendMode blend = BLEND_NORMAL,
781 const AlphaType alphaType = ALPHA_FULL);
783 const int posX = 0,
const int posY = 0,
786 const uint colorMod = MS_ARGB(255, 255, 255, 255),
787 const int width = -1,
const int height = -1,
788 const TSpriteBlendMode blend = BLEND_NORMAL,
789 const AlphaType alphaType = ALPHA_FULL);
815 void copyRectToSurface(
const void *buffer,
int srcPitch,
int destX,
int destY,
int width,
int height) {
898 void drawLine(
int x0,
int y0,
int x1,
int y1, uint32 color) {
899 _innerSurface.
drawLine(x0, y0, x1, y1, color);
906 void drawThickLine(
int x0,
int y0,
int x1,
int y1,
int penX,
int penY, uint32 color) {
907 _innerSurface.
drawThickLine(x0, y0, x1, y1, penX, penY, color);
930 void drawEllipse(
int x0,
int y0,
int x1,
int y1, uint32 color,
bool filled) {
931 _innerSurface.
drawEllipse(x0, y0, x1, y1, color, filled);
938 void hLine(
int x,
int y,
int x2, uint32 color) {
939 _innerSurface.
hLine(x, y, x2, color);
946 void vLine(
int x,
int y,
int y2, uint32 color) {
947 _innerSurface.
vLine(x, y, y2, color);
1025 _transparentColor = color;
1026 _transparentColorSet =
true;
1033 _transparentColorSet =
false;
1040 return _transparentColorSet;
static PixelFormat getSupportedPixelFormat()
Definition: blit.h:411
Definition: managed_surface.h:51
void blendFillRect(const Common::Rect r, const uint colorMod, const TSpriteBlendMode blend)
void convertFrom(const ManagedSurface &surf, const PixelFormat &fmt)
bool clip(Common::Rect &srcBounds, Common::Rect &destBounds, uint src_w=0, uint src_h=0, byte flip=FLIP_NONE) const
Definition: managed_surface.h:129
const Surface & rawSurface() const
Definition: managed_surface.h:195
const Common::Rect getBounds() const
Definition: managed_surface.h:328
const void * getPixels() const
Definition: managed_surface.h:273
void maskBlitFrom(const ManagedSurface &src, const ManagedSurface &mask, const Common::Point &destPos, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff)
void simpleBlitFrom(const Surface &src, const Common::Point &destPos, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff, const Palette *srcPalette=nullptr)
void copyFrom(const ManagedSurface &surf)
const void * getBasePtr(int x, int y) const
Definition: managed_surface.h:252
void blendBlitFrom(const ManagedSurface &src, const int flipping=FLIP_NONE, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
virtual void create(ManagedSurface &surf, const Common::Rect &bounds)
void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, uint32 transColor=0, bool flipped=false, uint32 srcAlpha=0xff, const Palette *srcPalette=nullptr)
void maskBlitFrom(const ManagedSurface &src, const ManagedSurface &mask, const Common::Rect &srcRect, const Common::Point &destPos, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff)
virtual void create(int16 width, int16 height)
void simpleBlitFrom(const ManagedSurface &src, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff)
void fillRect(const Common::Rect &r, uint32 color)
Definition: managed_surface.h:954
void blendBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, const int flipping=FLIP_NONE, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
DisposeAfterUse::Flag disposeAfterUse() const
Definition: managed_surface.h:219
void blendBlitFrom(const ManagedSurface &src, const Common::Point &destPos, const int flipping=FLIP_NONE, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
void blitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, const Palette *srcPalette=nullptr)
void maskBlitFrom(const Surface &src, const Surface &mask, const Common::Point &destPos, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff, const Palette *srcPalette=nullptr)
void blendBlitFromInner(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, const int flipping, const uint colorMod, const TSpriteBlendMode blend, const AlphaType alphaType)
void * getBasePtr(int x, int y)
Definition: managed_surface.h:264
int16 & w
Definition: managed_surface.h:134
void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, uint32 color)
Definition: managed_surface.h:906
int16 & h
Definition: managed_surface.h:135
void clearTransparentColor()
Definition: managed_surface.h:1032
virtual void clearDirtyRects()
Definition: managed_surface.h:311
void clear(uint32 color=0)
void transBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect, const Common::Rect &destRect, uint32 transColor=0, bool flipped=false, uint32 srcAlpha=0xff)
void simpleBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect, const Common::Point &destPos, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff)
void transBlitFrom(const ManagedSurface &src, uint32 transColor=0, bool flipped=false, uint32 srcAlpha=0xff)
void blitFrom(const Surface &src, const Palette *srcPalette=nullptr)
virtual void addDirtyRect(const Common::Rect &r)
bool hasTransparentColor() const
Definition: managed_surface.h:1039
void copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height)
Definition: managed_surface.h:815
void blendBlitFrom(const Surface &src, const Common::Point &destPos, const int flipping=FLIP_NONE, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
void transBlitFrom(const ManagedSurface &src, const Common::Point &destPos, uint32 transColor=0, bool flipped=false, uint32 srcAlpha=0xff)
void transBlitFromInner(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, uint32 transColor, bool flipped, uint32 srcAlpha, const Palette *srcPalette, const Palette *dstPalette)
void setPalette(const byte *colors, uint start, uint num)
void rawBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect, const Common::Point &destPos)
Definition: managed_surface.h:577
void vLine(int x, int y, int y2, uint32 color)
Definition: managed_surface.h:946
void convertToInPlace(const PixelFormat &dstFormat, const byte *palette, uint16 paletteCount)
Definition: managed_surface.h:1012
ManagedSurface * rotoscale(const TransformStruct &transform, bool filtering=false) const
Rotoscale function; this returns a transformed version of this surface after rotation and scaling....
void transBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect, const Common::Point &destPos, uint32 transColor=0, bool flipped=false, uint32 srcAlpha=0xff)
void blendBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect, const Common::Point &destPos, const int flipping=FLIP_NONE, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
void convertFrom(const Surface &surf, const PixelFormat &fmt)
bool empty() const
Definition: managed_surface.h:214
void blitFrom(const Surface &src, const Common::Point &destPos, const Palette *srcPalette=nullptr)
void simpleBlitFrom(const ManagedSurface &src, const Common::Point &destPos, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff)
virtual void setPixels(void *newPixels)
int32 & pitch
Definition: managed_surface.h:136
uint32 getPixel(int x, int y) const
Definition: managed_surface.h:229
const Surface getSubArea(const Common::Rect &area) const
Definition: managed_surface.h:986
void simpleBlitFrom(const Surface &src, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff, const Palette *srcPalette=nullptr)
Common::Rect blendBlitTo(ManagedSurface &target, const int posX=0, const int posY=0, const int flipping=FLIP_NONE, const Common::Rect *srcRect=nullptr, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const int width=-1, const int height=-1, const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
Renders this surface onto target.
uint getTransparentColor() const
Definition: managed_surface.h:1019
void maskBlitFrom(const Surface &src, const Surface &mask, const Common::Rect &srcRect, const Common::Point &destPos, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff, const Palette *srcPalette=nullptr)
void maskBlitFrom(const ManagedSurface &src, const ManagedSurface &mask, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff)
void simpleBlitFromInner(const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos, const Palette *srcPalette, bool transparentColorSet, uint transparentColor, byte flip, bool alpha, byte aMod)
void blendBlitFrom(const Surface &src, const int flipping=FLIP_NONE, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
void blendBlitFrom(const ManagedSurface &src, const Common::Rect &srcRect, const Common::Rect &destRect, const int flipping=FLIP_NONE, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
void frameRect(const Common::Rect &r, uint32 color)
Definition: managed_surface.h:962
void transBlitFrom(const Surface &src, uint32 transColor=0, bool flipped=false, uint32 srcAlpha=0xff, const Palette *srcPalette=nullptr)
void blitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos, const Palette *srcPalette=nullptr)
void blitFrom(const ManagedSurface &src, const Common::Rect &srcRect, const Common::Point &destPos)
static bool isBlendBlitPixelFormatSupported(const PixelFormat &src, const PixelFormat &dst)
Definition: managed_surface.h:588
void copyRectToSurfaceWithKey(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect &subRect, uint32 key)
Definition: managed_surface.h:845
void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, const Palette *srcPalette)
void simpleBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff, const Palette *srcPalette=nullptr)
PixelFormat & format
Definition: managed_surface.h:137
void blitFrom(const ManagedSurface &src, const Common::Point &destPos)
void blitFrom(const ManagedSurface &src)
void transBlitFrom(const Surface &src, const Common::Point &destPos, uint32 transColor=0, bool flipped=false, uint32 srcAlpha=0xff, const Palette *srcPalette=nullptr)
void grabPalette(byte *colors, uint start, uint num) const
Surface getSubArea(const Common::Rect &area)
Definition: managed_surface.h:978
void drawLine(int x0, int y0, int x1, int y1, uint32 color)
Definition: managed_surface.h:898
void copyRectToSurfaceWithKey(const void *buffer, int srcPitch, int destX, int destY, int width, int height, uint32 key)
Definition: managed_surface.h:835
ManagedSurface * scale(int16 newWidth, int16 newHeight, bool filtering=false, byte flip=0) const
void blendBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos, const int flipping=FLIP_NONE, const uint colorMod=(uint32)(((255)<< 24)|((255)<< 16)|((255)<< 8)|(255)), const TSpriteBlendMode blend=BLEND_NORMAL, const AlphaType alphaType=ALPHA_FULL)
const Common::Point getOffsetFromOwner() const
Definition: managed_surface.h:323
void maskBlitFromInner(const Surface &src, const Surface &mask, const Common::Rect &srcRect, const Common::Point &destPos, const Palette *srcPalette, byte flip, bool alpha, byte aMod)
void drawRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled)
Definition: managed_surface.h:914
void hLine(int x, int y, int x2, uint32 color)
Definition: managed_surface.h:938
void blitFromInner(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, const Palette *srcPalette)
void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos, uint32 transColor=0, bool flipped=false, uint32 srcAlpha=0xff, const Palette *srcPalette=nullptr)
void * getPixels()
Definition: managed_surface.h:271
void setTransparentColor(uint32 color)
Definition: managed_surface.h:1024
void setPixel(int x, int y, uint32 pixel)
Definition: managed_surface.h:240
void blitFrom(const ManagedSurface &src, const Common::Rect &srcRect, const Common::Rect &destRect)
AlphaType detectAlpha() const
Definition: managed_surface.h:970
void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect &subRect)
Definition: managed_surface.h:825
virtual void create(int16 width, int16 height, const PixelFormat &pixelFormat)
void convertToInPlace(const PixelFormat &dstFormat)
void copyFrom(const Surface &surf)
void drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool filled)
Definition: managed_surface.h:930
void drawPolygonScan(const int *polyX, const int *polyY, int npoints, const Common::Rect &bbox, uint32 color)
Definition: managed_surface.h:922
void maskBlitFrom(const Surface &src, const Surface &mask, byte flip=FLIP_NONE, bool alpha=false, byte aMod=0xff, const Palette *srcPalette=nullptr)
Simple class for handling a palette data.
Definition: palette.h:61
Definition: atari-screen.h:42
T MIN(T a, T b)
Definition: util.h:63
T MAX(T a, T b)
Definition: util.h:66
Definition: algorithm.h:29
Definition: formatinfo.h:28
@ FLIP_NONE
The image will not be flipped.
Definition: transform_struct.h:49
T height() const
Definition: rect.h:218
T width() const
Definition: rect.h:217
uint32 getPixel(int x, int y) const
Definition: surface.h:164
void copyRectToSurfaceWithKey(const void *buffer, int srcPitch, int destX, int destY, int width, int height, uint32 key)
AlphaType detectAlpha() const
void fillRect(Common::Rect r, uint32 color)
const void * getBasePtr(int x, int y) const
Definition: surface.h:140
void convertToInPlace(const PixelFormat &dstFormat)
Definition: surface.h:361
void frameRect(const Common::Rect &r, uint32 color)
void hLine(int x, int y, int x2, uint32 color)
void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, uint32 color)
Surface getSubArea(const Common::Rect &area)
void copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height)
void drawRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled)
void setPixel(int x, int y, int pixel)
Definition: surface.h:185
bool clip(Common::Rect &srcBounds, Common::Rect &destBounds, uint src_w=0, uint src_h=0, byte flip=FLIP_NONE) const
void drawLine(int x0, int y0, int x1, int y1, uint32 color)
void drawEllipse(int x0, int y0, int x1, int y1, uint32 color, bool filled)
void vLine(int x, int y, int y2, uint32 color)
const void * getPixels() const
Definition: surface.h:110
void drawPolygonScan(const int *polyX, const int *polyY, int npoints, const Common::Rect &bbox, uint32 color)