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 "csp_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();
33 screen = QGuiApplication::primaryScreen();
35 draw_screen_buffer = NULL;
37 do_change_refresh_rate(screen->refreshRate());
38 connect(screen, SIGNAL(refreshRateChanged(qreal)), this, SLOT(do_change_refresh_rate(qreal)));
39 connect(this, SIGNAL(sig_update_screen(bitmap_t *)), glv, SLOT(update_screen(bitmap_t *)), Qt::QueuedConnection);
40 connect(this, SIGNAL(sig_push_frames_to_avio(int, int, int)), glv->extfunc, SLOT(paintGL_OffScreen(int, int, int)));
41 rec_frame_width = 640;
42 rec_frame_height = 480;
48 DrawThreadClass::~DrawThreadClass()
52 void DrawThreadClass::SetEmu(EMU *p)
59 void DrawThreadClass::doDraw(bool flag)
61 p_osd->do_decode_movie(1);
63 draw_frames = p_osd->draw_screen();
65 draw_frames = p_osd->no_draw_screen();
67 emit sig_draw_frames(draw_frames);
70 void DrawThreadClass::doExit(void)
72 //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL,
73 // "DrawThread : Exit.");
77 void DrawThreadClass::doWork(const QString ¶m)
83 if(draw_screen_buffer != NULL) {
85 emit sig_update_screen(draw_screen_buffer);
88 if(rec_frame_count > 0) {
89 emit sig_push_frames_to_avio(rec_frame_count,
90 rec_frame_width, rec_frame_height);
93 if(wait_count < 1.0f) {
95 wait_count = wait_count + wait_refresh - 1.0f;
97 wait_factor = (int)wait_count;
99 wait_count -= (qreal)wait_factor;
102 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL,
103 "DrawThread : Exit.");
107 void DrawThreadClass::do_change_refresh_rate(qreal rate)
110 wait_refresh = 1000.0f / (refresh_rate * 4.0);
111 wait_count = wait_refresh * 1.0;
114 void DrawThreadClass::do_update_screen(bitmap_t *p)
116 draw_screen_buffer = p;
120 void DrawThreadClass::do_req_encueue_video(int count, int width, int height)
122 rec_frame_width = width;
123 rec_frame_height = height;
124 rec_frame_count = count;