2 Skelton for retropc emulator
3 Author : Takeda.Toshiya
4 Port to Qt : K.Ohta <whatisthis.sowhat _at_ gmail.com>
7 History : 2015.11.10 Split from qt_main.cpp
8 [ win32 main ] -> [ Qt main ] -> [Drawing]
12 #include <QApplication>
14 #include <QGuiApplication>
22 #include "agar_logger.h"
23 #include "mainwidget_base.h"
24 #include "draw_thread.h"
25 #include "qt_glutil_gl2_0.h"
27 DrawThreadClass::DrawThreadClass(EMU *p, OSD *o, QObject *parent) : QThread(parent) {
28 MainWindow = (Ui_MainWindowBase *)parent;
29 glv = MainWindow->getGraphicsView();
32 screen = QGuiApplication::primaryScreen();
34 draw_screen_buffer = NULL;
36 do_change_refresh_rate(screen->refreshRate());
37 connect(screen, SIGNAL(refreshRateChanged(qreal)), this, SLOT(do_change_refresh_rate(qreal)));
38 connect(this, SIGNAL(sig_update_screen(bitmap_t *)), glv, SLOT(update_screen(bitmap_t *)));
39 connect(this, SIGNAL(sig_push_frames_to_avio(int, int, int)), glv->extfunc, SLOT(paintGL_OffScreen(int, int, int)));
40 rec_frame_width = 640;
41 rec_frame_height = 480;
47 DrawThreadClass::~DrawThreadClass()
51 void DrawThreadClass::SetEmu(EMU *p)
58 void DrawThreadClass::doDraw(bool flag)
60 p_osd->do_decode_movie(1);
62 draw_frames = p_osd->draw_screen();
64 draw_frames = p_osd->no_draw_screen();
66 emit sig_draw_frames(draw_frames);
69 void DrawThreadClass::doExit(void)
71 //AGAR_DebugLog(AGAR_LOG_DEBUG, "DrawThread : Exit.");
76 void DrawThreadClass::doWork(const QString ¶m)
81 if(draw_screen_buffer != NULL) {
83 emit sig_update_screen(draw_screen_buffer);
86 if(rec_frame_count > 0) {
87 emit sig_push_frames_to_avio(rec_frame_count,
88 rec_frame_width, rec_frame_height);
91 if(wait_count < 1.0f) {
93 wait_count = wait_count + wait_refresh - 1.0f;
95 wait_factor = (int)wait_count;
97 wait_count -= (qreal)wait_factor;
100 AGAR_DebugLog(AGAR_LOG_DEBUG, "DrawThread : Exit.");
104 void DrawThreadClass::do_change_refresh_rate(qreal rate)
107 wait_refresh = 1000.0f / (refresh_rate * 4.0);
108 wait_count = wait_refresh * 1.0;
111 void DrawThreadClass::do_update_screen(bitmap_t *p)
113 draw_screen_buffer = p;
117 void DrawThreadClass::do_req_encueue_video(int count, int width, int height)
119 rec_frame_width = width;
120 rec_frame_height = height;
121 rec_frame_count = count;