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 
38 namespace Wintermute {
39 class BaseImage;
41 public:
43  ~BaseSurfaceOSystem() override;
44 
45  bool create(const Common::String &filename, 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 Common::String &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  if (_width == 0) {
64  finishLoad();
65  }
66  return _width;
67  }
68  int getHeight() override {
69  if (_height == 0) {
70  finishLoad();
71  }
72  return _height;
73  }
74  bool putPixel(int x, int y, byte r, byte g, byte b, byte a) override {
75  if (!_pixelOpReady) {
76  return STATUS_FAILED;
77  }
78  if (_surface) {
79  _surface->setPixel(x, y, _surface->format.ARGBToColor(a, r, g, b));
80  _surfaceModified = true;
81  return STATUS_OK;
82  }
83  return STATUS_FAILED;
84  }
85  bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) const override {
86  if (!_pixelOpReady) {
87  return STATUS_FAILED;
88  }
89  if (_surface) {
90  _surface->format.colorToARGB(_surface->getPixel(x, y), *a, *r, *g, *b);
91  return STATUS_OK;
92  }
93  return STATUS_FAILED;
94  }
95 
96  Graphics::AlphaType getAlphaType() const { return _alphaType; }
97 private:
98  Graphics::Surface *_surface;
99  bool finishLoad();
100  bool drawSprite(int x, int y, Common::Rect32 *rect, Common::Rect32 *newRect, Graphics::TransformStruct transformStruct);
101  void writeAlpha(Graphics::Surface *surface, const Graphics::Surface *mask);
102 
103  bool _pixelOpReady;
104  bool _surfaceModified;
105  float _rotation;
106  Graphics::AlphaType _alphaType;
107  Graphics::Surface *_alphaMask;
108  Graphics::AlphaType _alphaMaskType;
109 };
110 
111 } // End of namespace Wintermute
112 
113 #endif
Definition: base_game.h:75
Definition: rect.h:526
Definition: str.h:59
Definition: surface.h:67
Definition: base_surface_osystem.h:40
Definition: base_surface.h:37
void setPixel(int x, int y, int pixel)
Definition: surface.h:183
PixelFormat format
Definition: surface.h:95
uint32 ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) const
Definition: pixelformat.h:278
Definition: transform_struct.h:75
uint32 getPixel(int x, int y) const
Definition: surface.h:162
Definition: achievements_tables.h:27
void colorToARGB(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) const
Definition: pixelformat.h:309