xoreos  0.0.5
fader.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/util.h"
26 
28 
29 #include "src/video/fader.h"
30 
31 #include "src/events/events.h"
32 
33 namespace Video {
34 
35 Fader::Fader(uint32 width, uint32 height, int n) {
36  addTrack(new FaderVideoTrack(width, height, n));
37  initVideo();
38 }
39 
41  assert(_surface);
42  static_cast<FaderVideoTrack &>(track).drawFrame(*_surface);
43  _needCopy = true;
44 }
45 
46 Fader::FaderVideoTrack::FaderVideoTrack(uint32 width, uint32 height, int n) : _width(width), _height(height), _curFrame(-1), _c(0), _n(n) {
47 }
48 
50  // Fade from black to green
51  byte *data = surface.getData();
52  for (uint32 i = 0; i < _height; i++) {
53  byte *rowData = data;
54 
55  for (uint32 j = 0; j < _width; j++, rowData += 4) {
56  rowData[0] = 0;
57  rowData[1] = _c;
58  rowData[2] = 0;
59  rowData[3] = 255;
60  }
61 
62  data += surface.getWidth() * 4;
63  }
64 
65  // Keep a red square in the middle
66  int xPos = (_width / 2) - 2;
67  int yPos = (_height / 2) - 2;
68  int dPos = (yPos * surface.getWidth() + xPos) * 4;
69  for (int i = 0; i < 4; i++) {
70  for (int j = 0; j < 4; j++) {
71  surface.getData()[dPos + j * 4 + 0] = 0;
72  surface.getData()[dPos + j * 4 + 1] = 0;
73  surface.getData()[dPos + j * 4 + 2] = 255;
74  surface.getData()[dPos + j * 4 + 3] = 255;
75  }
76  dPos += surface.getWidth() * 4;
77  }
78 
79  _c += 2;
80  _curFrame++;
81 }
82 
83 } // End of namespace Video
Common::ScopedPtr< Graphics::Surface > _surface
The video&#39;s surface.
Definition: decoder.h:393
byte * getData()
Definition: surface.cpp:61
void addTrack(Track *track, bool isExternal=false)
Define a track to be used by this class.
Definition: decoder.cpp:152
bool _needCopy
Is new frame content available that needs to by copied?
Definition: decoder.h:391
Testing implementation for the VideoDecoder interface.
void initVideo()
Create a surface for video of these dimensions.
Definition: decoder.cpp:71
int getWidth() const
Definition: surface.cpp:53
Fader(uint32 width, uint32 height, int n)
Definition: fader.cpp:35
Utility templates and functions.
The global events manager.
An abstract representation of a video track.
Definition: decoder.h:226
An image surface, in BGRA format.
uint32 _height
Definition: h263.cpp:54
void decodeNextTrackFrame(VideoTrack &track)
Decode enough data for the next frame.
Definition: fader.cpp:40
uint32_t uint32
Definition: types.h:204
void drawFrame(Graphics::Surface &surface)
Definition: fader.cpp:49
uint32 _width
Definition: h263.cpp:53
uint8 byte
Definition: types.h:209
FaderVideoTrack(uint32 width, uint32 height, int n)
Definition: fader.cpp:46