ScummVM API documentation
surface.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 * Additional copyright for this file:
8 * Copyright (C) 1995-1997 Presto Studios, Inc.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#ifndef PEGASUS_SURFACE_H
26#define PEGASUS_SURFACE_H
27
28#include "common/rect.h"
29#include "common/str.h"
30
31#include "pegasus/elements.h"
32#include "pegasus/types.h"
33
34namespace Common {
35 class MacResManager;
36}
37
38namespace Graphics {
39 struct Surface;
40}
41
42namespace Video {
43 class VideoDecoder;
44}
45
46namespace Pegasus {
47
48// Surface bounds are always normalized.
49
50class Surface {
51public:
52 Surface();
53 virtual ~Surface();
54
55 virtual void allocateSurface(const Common::Rect &);
56 virtual void deallocateSurface();
57 virtual void shareSurface(Surface *surface);
58 bool isSurfaceValid() const { return _surface != 0; }
59
60 Graphics::Surface *getSurface() const { return _surface; }
61 void getSurfaceBounds(Common::Rect &r) { r = _bounds; }
62
63 // None of the copyToCurrentPort* functions do any sanity checks.
64 // It's up to clients to make sure that the Surface is valid.
65 void copyToCurrentPort() const;
66 void copyToCurrentPortTransparent() const;
67 void copyToCurrentPort(const Common::Rect &) const;
68 void copyToCurrentPortTransparent(const Common::Rect &) const;
69 void copyToCurrentPort(const Common::Rect &, const Common::Rect &) const;
70 void copyToCurrentPortTransparent(const Common::Rect &, const Common::Rect &) const;
71 void copyToCurrentPortMasked(const Common::Rect &, const Common::Rect &, const Surface *) const;
72 void copyToCurrentPortTransparentGlow(const Common::Rect &, const Common::Rect &) const;
73 void scaleTransparentCopy(const Common::Rect &, const Common::Rect &) const;
74 void scaleTransparentCopyGlow(const Common::Rect &, const Common::Rect &) const;
75
76 virtual void getImageFromPICTFile(const Common::Path &fileName);
77 virtual void getImageFromPICTResource(Common::MacResManager *resFork, uint16 id);
78 virtual void getImageFromMovieFrame(Video::VideoDecoder *, TimeValue);
79
80protected:
81 bool _ownsSurface;
82 Graphics::Surface *_surface;
83 Common::Rect _bounds;
84
85private:
86 bool getImageFromPICTStream(Common::SeekableReadStream *stream);
87
88 uint32 getGlowColor(uint32 color) const;
89 bool isTransparent(uint32 color) const;
90};
91
92class PixelImage : public Surface {
93public:
94 PixelImage();
95 ~PixelImage() override {}
96
97 void drawImage(const Common::Rect &, const Common::Rect &);
98
99protected:
100 virtual void setTransparent(bool transparent) { _transparent = transparent; }
101
102 bool _transparent;
103};
104
105class Frame : public PixelImage {
106public:
107 Frame() {}
108 ~Frame() override {}
109
110 virtual void initFromPICTFile(const Common::Path &fileName, bool transparent = false);
111 virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
112 virtual void initFromMovieFrame(Video::VideoDecoder *, TimeValue, bool transparent = false);
113};
114
115class SpriteFrame : public Frame {
116friend class Sprite;
117public:
118 SpriteFrame() { _referenceCount = 0; }
119 ~SpriteFrame() override {}
120
121protected:
122 uint32 _referenceCount;
123};
124
125class Picture : public DisplayElement, public Frame {
126public:
127 Picture(const DisplayElementID id) : DisplayElement(id) {}
128 ~Picture() override {}
129
130 void initFromPICTFile(const Common::Path &fileName, bool transparent = false) override;
131 void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false) override;
132 void initFromMovieFrame(Video::VideoDecoder *, TimeValue, bool transparent = false) override;
133
134 void draw(const Common::Rect &) override;
135};
136
137} // End of namespace Pegasus
138
139#endif
Definition: macresman.h:126
Definition: path.h:52
Definition: stream.h:745
Definition: elements.h:43
Definition: surface.h:105
Definition: surface.h:125
Definition: surface.h:92
Definition: surface.h:115
Definition: elements.h:168
Definition: surface.h:50
Definition: video_decoder.h:53
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:536
Definition: surface.h:67