ScummVM API documentation
movie.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 MEDIASTATION_MOVIE_H
23 #define MEDIASTATION_MOVIE_H
24 
25 #include "common/array.h"
26 
27 #include "mediastation/asset.h"
28 #include "mediastation/audio.h"
29 #include "mediastation/datafile.h"
30 #include "mediastation/bitmap.h"
31 #include "mediastation/mediascript/scriptconstants.h"
32 
33 namespace MediaStation {
34 
35 enum MovieBlitType {
36  kInvalidMovieBlit = 0,
37  kUncompressedMovieBlit = 1,
38  kUncompressedDeltaMovieBlit = 2,
39  kCompressedDeltaMovieBlit = 3,
40 };
41 
43 public:
44  MovieFrameHeader(Chunk &chunk);
45 
46  uint _index = 0;
47  uint _keyframeEndInMilliseconds = 0;
48 };
49 
50 class MovieFrameImage : public Bitmap {
51 public:
52  MovieFrameImage(Chunk &chunk, MovieFrameHeader *header);
53  virtual ~MovieFrameImage() override;
54 
55  uint32 index() { return _bitmapHeader->_index; }
56 
57 private:
58  MovieFrameHeader *_bitmapHeader = nullptr;
59 };
60 
61 enum MovieSectionType {
62  kMovieRootSection = 0x06a8,
63  kMovieImageDataSection = 0x06a9,
64  kMovieFrameDataSection = 0x06aa
65 };
66 
67 struct MovieFrame {
68  MovieFrame(Chunk &chunk);
69  uint unk3 = 0;
70  uint unk4 = 0;
71  uint layerId = 0;
72  uint startInMilliseconds = 0;
73  uint endInMilliseconds = 0;
74  Common::Point leftTop;
75  Common::Point diffBetweenKeyframeAndFrame;
76  MovieBlitType blitType = kInvalidMovieBlit;
77  int16 zIndex = 0;
78  uint keyframeIndex = 0;
79  bool keepAfterEnd = false;
80  uint index = 0;
81  MovieFrameImage *image = nullptr;
82  MovieFrameImage *keyframeImage = nullptr;
83 };
84 
85 class Movie : public SpatialEntity {
86 public:
87  Movie() : _framesOnScreen(Movie::compareFramesByZIndex), SpatialEntity(kAssetTypeMovie) {}
88  virtual ~Movie() override;
89 
90  virtual void readChunk(Chunk &chunk) override;
91  virtual void readSubfile(Subfile &subfile, Chunk &chunk) override;
92 
93  virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
94  virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
95  virtual void process() override;
96 
97  virtual void draw(const Common::Array<Common::Rect> &dirtyRegion) override;
98 
99  virtual bool isVisible() const override { return _isVisible; }
100 
101  uint32 _audioChunkReference = 0;
102  uint32 _animationChunkReference = 0;
103 
104 private:
105  AudioSequence _audioSequence;
106  uint _audioChunkCount = 0;
107  uint _fullTime = 0;
108 
109  uint _loadType = 0;
110  bool _isPlaying = false;
111  bool _hasStill = false;
112 
115 
116  Common::Array<MovieFrame *> _framesNotYetShown;
118 
119  // Script method implementations.
120  void timePlay();
121  void timeStop();
122 
123  void setVisibility(bool visibility);
124  void updateFrameState();
125  void invalidateRect(const Common::Rect &rect);
126  void decompressIntoAuxImage(MovieFrame *frame);
127 
128  void readImageData(Chunk &chunk);
129  void readFrameData(Chunk &chunk);
130 
131  Common::Rect getFrameBoundingBox(MovieFrame *frame);
132  static int compareFramesByZIndex(const MovieFrame *a, const MovieFrame *b);
133 };
134 
135 } // End of namespace MediaStation
136 
137 #endif
Definition: asset.h:167
Definition: asset.h:32
Definition: datafile.h:103
Definition: bitmap.h:41
Definition: rect.h:524
Definition: movie.h:85
Definition: movie.h:42
Definition: bitmap.h:50
Definition: audio.h:33
Definition: rect.h:144
Definition: array.h:561
Definition: movie.h:67
Definition: datafile.h:129
Definition: movie.h:50
Definition: scriptvalue.h:36