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 isTransparentAt(int x, int y) override;
49  bool isTransparentAtLite(int x, int y) override;
50 
51  bool startPixelOp() override;
52  bool endPixelOp() override;
53 
54  bool displayTransRotate(int x, int y, uint32 angle, int32 hotspotX, int32 hotspotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha = Graphics::kDefaultRgbaMod, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
55  bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = Graphics::kDefaultRgbaMod, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
56  bool displayTrans(int x, int y, 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;
57  bool display(int x, int y, Rect32 rect, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
58  bool displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY) override;
59  bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
60  /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
61  static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin);
62  static long DLL_CALLCONV TellProc(fi_handle handle);*/
63  int getWidth() override {
64  if (!_loaded) {
65  finishLoad();
66  }
67  if (_surface) {
68  return _surface->w;
69  }
70  return _width;
71  }
72  int getHeight() override {
73  if (!_loaded) {
74  finishLoad();
75  }
76  if (_surface) {
77  return _surface->h;
78  }
79  return _height;
80  }
81  bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) override {
82  if (!_loaded) {
83  finishLoad();
84  }
85  if (_surface) {
86  uint32 pixel = getPixelAt(_surface, x, y);
87  _surface->format.colorToARGB(pixel, *a, *r, *g, *b);
88  return STATUS_OK;
89  }
90  return STATUS_FAILED;
91  }
92 
93  Graphics::AlphaType getAlphaType() const { return _alphaType; }
94 private:
95  Graphics::Surface *_surface;
96  bool _loaded;
97  bool finishLoad();
98  bool drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, Graphics::TransformStruct transformStruct);
99  void genAlphaMask(Graphics::Surface *surface);
100  uint32 getPixelAt(Graphics::Surface *surface, int x, int y);
101 
102  uint32 _rotation;
103  Graphics::AlphaType _alphaType;
104  void *_lockPixels;
105  int _lockPitch;
106  byte *_alphaMask;
107 };
108 
109 } // End of namespace Wintermute
110 
111 #endif
Definition: base_game.h:75
Definition: str.h:59
Definition: surface.h:67
int16 h
Definition: surface.h:76
Definition: base_surface_osystem.h:40
Definition: rect32.h:60
Definition: base_surface.h:38
int16 w
Definition: surface.h:71
PixelFormat format
Definition: surface.h:95
Definition: transform_struct.h:75
Definition: achievements_tables.h:27
void colorToARGB(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) const
Definition: pixelformat.h:254