ScummVM API documentation
video_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 * 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#ifndef TITANIC_VIDEO_SURFACE_H
23#define TITANIC_VIDEO_SURFACE_H
24
25#include "common/scummsys.h"
26#include "common/array.h"
27#include "graphics/managed_surface.h"
28#include "titanic/support/font.h"
29#include "titanic/support/direct_draw.h"
30#include "titanic/support/movie.h"
31#include "titanic/support/movie_range_info.h"
32#include "titanic/support/rect.h"
33#include "titanic/support/transparency_surface.h"
34#include "titanic/core/list.h"
35#include "titanic/core/resource_key.h"
36
37namespace Titanic {
38
39class CScreenManager;
40class CJPEGDecode;
41class CTargaDecode;
42
43class CVideoSurface : public ListItem {
44 friend class CJPEGDecode;
45 friend class CTargaDecode;
46private:
47 static byte _palette1[32][32];
48 static byte _palette2[32][32];
49
53 static void setupPalette(byte palette[32][32], byte val);
54public:
58 static void setup() {
59 setupPalette(_palette1, 0xff);
60 }
61private:
65 void clipBounds(Rect &srcRect, Rect &destRect, CVideoSurface *srcSurface,
66 const Rect *subRect = nullptr, const Point *destPos = nullptr);
67
71 void blitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src);
72
76 void flippedBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src);
77
78 void transBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src, bool flipFlag);
79protected:
80 static int _videoSurfaceCounter;
81protected:
82 CScreenManager *_screenManager;
83 Graphics::ManagedSurface *_rawSurface;
84 bool _pendingLoad;
85 Graphics::ManagedSurface *_transparencySurface;
86 DisposeAfterUse::Flag _freeTransparencySurface;
87 int _videoSurfaceNum;
88 bool _hasFrame;
89 int _lockCount;
90public:
91 CMovie *_movie;
92 DirectDrawSurface *_ddSurface;
93 bool _fastBlitFlag;
94 bool _flipVertically;
95 CResourceKey _resourceKey;
96 TransparencyMode _transparencyMode;
97public:
98 CVideoSurface(CScreenManager *screenManager);
99 ~CVideoSurface() override;
100
104 void setSurface(CScreenManager *screenManager, DirectDrawSurface *surface);
105
109 void load(SimpleFile *file) override {
110 ListItem::load(file);
111 }
112
116 virtual void loadResource(const CResourceKey &key) = 0;
117
121 virtual void loadTarga(const CResourceKey &key) = 0;
122
126 virtual void loadJPEG(const CResourceKey &key) = 0;
127
131 virtual void loadTarga(const CString &name) = 0;
132
138 virtual void loadMovie(const CResourceKey &key, bool destroyFlag = false) = 0;
139
143 virtual bool lock() = 0;
144
148 virtual void unlock() = 0;
149
153 virtual bool hasSurface() = 0;
154
158 virtual int getWidth() = 0;
159
163 virtual int getHeight() = 0;
164
168 virtual int getPitch() = 0;
169
173 virtual int getBpp() = 0;
174
178 virtual void recreate(int width, int height, int bpp = 16) = 0;
179
183 virtual void resize(int width, int height, int bpp = 16) = 0;
184
188 virtual void detachSurface() = 0;
189
193 virtual int getPixelDepth() = 0;
194
198 virtual uint16 getPixel(const Common::Point &pt) = 0;
199
200
204 virtual void setPixel(const Point &pt, uint pixel) = 0;
205
209 virtual void shiftColors() = 0;
210
214 virtual void clear() = 0;
215
220 virtual void playMovie(uint flags, CGameObject *obj) = 0;
221
226 virtual void playMovie(uint startFrame, uint endFrame, uint flags, CGameObject *obj) = 0;
227
232 virtual void playMovie(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj) = 0;
233
237 virtual void stopMovie() = 0;
238
242 virtual void setMovieFrame(uint frameNumber) = 0;
243
247 virtual void addMovieEvent(int eventId, CGameObject *obj) = 0;
248
252 virtual void setMovieFrameRate(double rate) = 0;
253
257 virtual const CMovieRangeInfoList *getMovieRangeInfo() const = 0;
258
262 virtual void flipVertically(bool needsLock = true) = 0;
263
267 virtual bool loadIfReady() = 0;
268
272 virtual bool load() = 0;
273
278 virtual void transPixelate() = 0;
279
283 virtual bool hasFrame();
284
289
293 virtual int freeSurface() { return 0; }
294
298 virtual uint16 *getBasePtr(int x, int y) = 0;
299
303 void blitFrom(const Point &destPos, CVideoSurface *src, const Rect *srcRect = nullptr);
304
308 void blitFrom(const Point &destPos, const Graphics::Surface *src);
309
313 void setTransparencySurface(Graphics::ManagedSurface *surface) { _transparencySurface = surface; }
314
319 return _transparencySurface ? &_transparencySurface->rawSurface() : nullptr;
320 }
321
326 uint16 *getPixels() { return (uint16 *)_rawSurface->getPixels(); }
327
332 Graphics::ManagedSurface *getRawSurface() { return _rawSurface; }
333
338
349 void copyPixel(uint16 *destP, const uint16 *srcP, byte alpha,
350 const Graphics::PixelFormat &srcFormat, bool isAlpha);
351};
352
354 friend class OSMovie;
355public:
356 OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface);
357 OSVideoSurface(CScreenManager *screenManager, const CResourceKey &key, bool flag = false);
358 ~OSVideoSurface() override;
359
363 void loadResource(const CResourceKey &key) override;
364
368 void loadTarga(const CResourceKey &key) override;
369
373 void loadJPEG(const CResourceKey &key) override;
374
378 void loadTarga(const CString &name) override;
379
385 void loadMovie(const CResourceKey &key, bool destroyFlag = false) override;
386
390 bool lock() override;
391
395 void unlock() override;
396
400 bool hasSurface() override;
401
405 int getWidth() override;
406
410 int getHeight() override;
411
415 int getPitch() override;
416
420 int getBpp() override;
421
425 void recreate(int width, int height, int bpp = 16) override;
426
430 void resize(int width, int height, int bpp = 16) override;
431
435 void detachSurface() override;
436
440 int getPixelDepth() override;
441
445 uint16 getPixel(const Point &pt) override;
446
450 void setPixel(const Point &pt, uint pixel) override;
451
455 void shiftColors() override;
456
460 void clear() override;
461
466 void playMovie(uint flags, CGameObject *obj) override;
467
472 void playMovie(uint startFrame, uint endFrame, uint flags, CGameObject *obj) override;
473
478 void playMovie(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj) override;
479
483 void stopMovie() override;
484
488 void setMovieFrame(uint frameNumber) override;
489
493 void addMovieEvent(int frameNumber, CGameObject *obj) override;
494
498 void setMovieFrameRate(double rate) override;
499
503 const CMovieRangeInfoList *getMovieRangeInfo() const override;
504
508 void flipVertically(bool needsLock = true) override;
509
513 bool loadIfReady() override;
514
518 bool load() override;
519
524 void transPixelate() override;
525
530
534 int freeSurface() override;
535
539 uint16 *getBasePtr(int x, int y) override;
540};
541
542} // End of namespace Titanic
543
544#endif /* TITANIC_VIDEO_SURFACE_H */
Definition: managed_surface.h:51
const Surface & rawSurface() const
Definition: managed_surface.h:195
void * getPixels()
Definition: managed_surface.h:271
Definition: game_object.h:79
Definition: image_decoders.h:33
Definition: movie.h:43
Definition: movie_range_info.h:76
Definition: resource_key.h:30
Definition: screen_manager.h:49
Definition: string.h:40
Definition: image_decoders.h:41
Definition: video_surface.h:43
virtual int getHeight()=0
virtual void loadMovie(const CResourceKey &key, bool destroyFlag=false)=0
const Graphics::Surface * getTransparencySurface() const
Definition: video_surface.h:318
virtual void loadJPEG(const CResourceKey &key)=0
Graphics::ManagedSurface * getRawSurface()
Definition: video_surface.h:332
virtual void playMovie(uint flags, CGameObject *obj)=0
static void setup()
Definition: video_surface.h:58
virtual void recreate(int width, int height, int bpp=16)=0
virtual void loadTarga(const CString &name)=0
virtual void playMovie(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj)=0
virtual void detachSurface()=0
virtual void stopMovie()=0
virtual int getPixelDepth()=0
virtual int getBpp()=0
virtual void resize(int width, int height, int bpp=16)=0
virtual bool lock()=0
virtual const CMovieRangeInfoList * getMovieRangeInfo() const =0
virtual void playMovie(uint startFrame, uint endFrame, uint flags, CGameObject *obj)=0
virtual uint16 getPixel(const Common::Point &pt)=0
virtual int getWidth()=0
virtual void setPixel(const Point &pt, uint pixel)=0
virtual void shiftColors()=0
virtual bool hasSurface()=0
virtual void clear()=0
virtual uint16 * getBasePtr(int x, int y)=0
uint16 * getPixels()
Definition: video_surface.h:326
virtual void loadResource(const CResourceKey &key)=0
virtual Graphics::ManagedSurface * dupMovieTransparency() const =0
virtual void setMovieFrame(uint frameNumber)=0
void setTransparencySurface(Graphics::ManagedSurface *surface)
Definition: video_surface.h:313
void blitFrom(const Point &destPos, const Graphics::Surface *src)
virtual void unlock()=0
virtual int freeSurface()
Definition: video_surface.h:293
virtual bool loadIfReady()=0
virtual bool hasFrame()
void blitFrom(const Point &destPos, CVideoSurface *src, const Rect *srcRect=nullptr)
void copyPixel(uint16 *destP, const uint16 *srcP, byte alpha, const Graphics::PixelFormat &srcFormat, bool isAlpha)
virtual void setMovieFrameRate(double rate)=0
virtual int getPitch()=0
virtual bool load()=0
virtual void transPixelate()=0
void setSurface(CScreenManager *screenManager, DirectDrawSurface *surface)
virtual void loadTarga(const CResourceKey &key)=0
void load(SimpleFile *file) override
Definition: video_surface.h:109
virtual void addMovieEvent(int eventId, CGameObject *obj)=0
Definition: direct_draw_surface.h:45
Definition: list.h:35
void load(SimpleFile *file) override
Definition: movie.h:165
Definition: video_surface.h:353
uint16 getPixel(const Point &pt) override
void stopMovie() override
void setMovieFrameRate(double rate) override
void clear() override
const CMovieRangeInfoList * getMovieRangeInfo() const override
void playMovie(uint startFrame, uint endFrame, uint flags, CGameObject *obj) override
void transPixelate() override
Graphics::ManagedSurface * dupMovieTransparency() const override
void loadResource(const CResourceKey &key) override
void shiftColors() override
bool loadIfReady() override
int getWidth() override
void setPixel(const Point &pt, uint pixel) override
int getHeight() override
int getPixelDepth() override
void loadJPEG(const CResourceKey &key) override
void detachSurface() override
void unlock() override
void playMovie(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj) override
void playMovie(uint flags, CGameObject *obj) override
int freeSurface() override
void recreate(int width, int height, int bpp=16) override
bool lock() override
void loadMovie(const CResourceKey &key, bool destroyFlag=false) override
uint16 * getBasePtr(int x, int y) override
int getPitch() override
bool hasSurface() override
bool load() override
void loadTarga(const CResourceKey &key) override
void loadTarga(const CString &name) override
void resize(int width, int height, int bpp=16) override
int getBpp() override
void setMovieFrame(uint frameNumber) override
void addMovieEvent(int frameNumber, CGameObject *obj) override
Definition: rect.h:35
Definition: simple_file.h:49
bool isAlpha(int c)
Definition: rect.h:144
Definition: pixelformat.h:138
Definition: surface.h:67