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)
62 emit sig_draw_timing(true);
63 draw_frames = p_osd->draw_screen();
67 emit sig_draw_frames(draw_frames);
70 void DrawThreadClass::doExit(void)
72 //AGAR_DebugLog(AGAR_LOG_DEBUG, "DrawThread : Exit.");
77 void DrawThreadClass::doWork(const QString ¶m)
82 if(draw_screen_buffer != NULL) {
84 emit sig_update_screen(draw_screen_buffer);
87 if(rec_frame_count > 0) {
88 emit sig_push_frames_to_avio(rec_frame_count,
89 rec_frame_width, rec_frame_height);
92 if(wait_count < 1.0f) {
94 wait_count = wait_count + wait_refresh - 1.0f;
96 wait_factor = (int)wait_count;
98 wait_count -= (qreal)wait_factor;
101 AGAR_DebugLog(AGAR_LOG_DEBUG, "DrawThread : Exit.");
105 void DrawThreadClass::do_change_refresh_rate(qreal rate)
108 wait_refresh = 1000.0f / (refresh_rate * 2.0);
109 wait_count = wait_refresh * 1.0;
112 void DrawThreadClass::do_update_screen(bitmap_t *p)
114 draw_screen_buffer = p;
118 void DrawThreadClass::do_req_encueue_video(int count, int width, int height)
120 rec_frame_width = width;
121 rec_frame_height = height;
122 rec_frame_count = count;