ScummVM API documentation
base_surface_osystem.h
1/* ScummVM - Graphic Adventure Engine
2 *
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.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * This file is based on WME Lite.
24 * http://dead-code.org/redir.php?target=wmelite
25 * Copyright (c) 2011 Jan Nedoma
26 */
27
28#ifndef WINTERMUTE_BASE_SURFACESDL_H
29#define WINTERMUTE_BASE_SURFACESDL_H
30
31#include "graphics/surface.h"
32#include "graphics/transform_struct.h" // for Graphics::AlphaType
33
34#include "engines/wintermute/base/gfx/base_surface.h"
35
36#include "common/list.h"
37
38namespace Wintermute {
39class BaseImage;
41public:
43 ~BaseSurfaceOSystem() override;
44
45 bool create(const char *filename, bool texture2D, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) override;
46 bool create(int width, int height) override;
47
48 bool setAlphaImage(const char *filename) override;
49
50 bool invalidate() override;
51
52 bool isTransparentAtLite(int x, int y) const override;
53 bool startPixelOp() override;
54 bool endPixelOp() override;
55
56 bool displayTransRotate(int x, int y, float rotate, int32 hotspotX, int32 hotspotY, Common::Rect32 rect, float zoomX, float zoomY, uint32 alpha = Graphics::kDefaultRgbaMod, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
57 bool displayTransZoom(int x, int y, Common::Rect32 rect, float zoomX, float zoomY, uint32 alpha = Graphics::kDefaultRgbaMod, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
58 bool displayTrans(int x, int y, Common::Rect32 rect, uint32 alpha = Graphics::kDefaultRgbaMod, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
59 bool display(int x, int y, Common::Rect32 rect, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
60 bool displayTiled(int x, int y, Common::Rect32 rect, int numTimesX, int numTimesY) override;
61 bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
62 int getWidth() override {
63 return _width;
64 }
65 int getHeight() override {
66 return _height;
67 }
68 bool putPixel(int x, int y, byte r, byte g, byte b, byte a) override {
69 if (!_pixelOpReady) {
70 return STATUS_FAILED;
71 }
72 if (_surface) {
73 _surface->setPixel(x, y, _surface->format.ARGBToColor(a, r, g, b));
74 _surfaceModified = true;
75 return STATUS_OK;
76 }
77 return STATUS_FAILED;
78 }
79 bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) const override {
80 if (!_pixelOpReady) {
81 return STATUS_FAILED;
82 }
83 if (_surface) {
84 _surface->format.colorToARGB(_surface->getPixel(x, y), *a, *r, *g, *b);
85 return STATUS_OK;
86 }
87 return STATUS_FAILED;
88 }
89
90 Graphics::AlphaType getAlphaType() const { return _alphaType; }
91private:
92 Graphics::Surface *_surface;
93 bool loadImage();
94 bool drawSprite(int x, int y, Common::Rect32 *rect, Common::Rect32 *newRect, Graphics::TransformStruct transformStruct);
95 void writeAlpha(Graphics::Surface *surface, const Graphics::Surface *mask);
96
97 bool _pixelOpReady;
98 bool _surfaceModified;
99 float _rotation;
100 Graphics::AlphaType _alphaType;
101 Graphics::Surface *_alphaMask;
102 Graphics::AlphaType _alphaMaskType;
103};
104
105} // End of namespace Wintermute
106
107#endif
Definition: base_game.h:79
Definition: base_surface.h:37
Definition: base_surface_osystem.h:40
Definition: rect.h:538
uint32 ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) const
Definition: pixelformat.h:278
void colorToARGB(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) const
Definition: pixelformat.h:309
Definition: surface.h:67
uint32 getPixel(int x, int y) const
Definition: surface.h:164
void setPixel(int x, int y, int pixel)
Definition: surface.h:185
PixelFormat format
Definition: surface.h:95
Definition: transform_struct.h:75