2
puts the yuv images onto a surface
3
Copyright (C) 2000 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
14
#include "renderMachine.h"
19
RenderMachine::RenderMachine() {
22
surface=new X11Surface();
25
surface=new SDLSurface();
31
startTime=new TimeStamp();
32
endTime=new TimeStamp();
34
initialMode = _IMAGE_DESK;
38
RenderMachine::~RenderMachine() {
54
void RenderMachine::waitRestTime() {
55
endTime->gettimeofday();
56
startTime->minus(endTime,endTime);
64
int RenderMachine::openWindow(int width,
65
int height,const char *title) {
67
if (surface->open(width,height,title)) {
68
pictureArray=new PictureArray(width, height);
70
return switchToMode(initialMode);
76
void RenderMachine::closeWindow() {
78
if (surface->isOpen()==false) {
81
if (pictureArray != NULL) {
89
important method. This is our only way to switch from
90
fullscreen back to the desktop screen.
91
This method is called if the video end (normal or by user request)
92
We dont have a callback, thus after the image stops, we would
95
void RenderMachine::flushWindow() {
97
// we always switch back to desk mode.
98
if (IS_FULL(surface->getImageMode())) {
99
switchToMode(surface->getImageMode() ^ _IMAGE_DESK ^ _IMAGE_FULL);
108
void RenderMachine::putImage(YUVPicture* pic,
112
cout << "pic is null"<<endl;
115
startTime->gettimeofday();
116
startTime->addOffset(waitTime);
119
surface->dither(pic);
122
if (surface->checkEvent(&nextMode) == true) {
123
switchToMode(nextMode);
125
surface->putImage(pic);
130
int RenderMachine::switchToMode(int mode) {
131
if (surface->getImageMode() != mode) {
132
surface->closeImage();
133
if (mode != _IMAGE_NONE) {
134
surface->openImage(mode);
138
cout << "no imageMode, no open, that's life"<<endl;
147
PictureArray* RenderMachine::lockPictureArray() {
152
void RenderMachine::unlockPictureArray(PictureArray* pictureArray) {
154
// chance to switch mode
158
if (surface->getImageMode() != _IMAGE_NONE) {
159
YUVPicture* pic=pictureArray->getYUVPictureCallback();
161
TimeStamp* waitTime=pic->getWaitTime();
162
TimeStamp* earlyTime=pic->getEarlyTime();
163
putImage(pic,waitTime,earlyTime);
166
cout << "no mode selected"<<endl;
171
void RenderMachine::config(const char* key,
172
const char* value,void* user_data) {
173
if (strcmp(key,"getDepth")==0) {
174
int* val=(int*)user_data;
175
*val=surface->getDepth();
177
if (surface != NULL) {
178
int mode = surface->getImageMode();
179
if (strcmp(key,"toggleFullscreen")==0) {
180
if (surface->findImage(mode ^ _IMAGE_FULL) != NULL) {
181
if (surface->isOpen())
182
switchToMode(mode ^ _IMAGE_FULL);
184
initialMode = _IMAGE_FULL;
187
if (strcmp(key,"toggleDouble")==0) {
188
if (surface->findImage(mode ^ _IMAGE_DOUBLE) != NULL) {
189
if (surface->isOpen())
190
switchToMode(mode ^ _IMAGE_DOUBLE);
192
initialMode = _IMAGE_DOUBLE;
197
surface->config(key,value,user_data);