• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revisionb5be90f0c9f1fd45725f7703216f5fb51d16fd69 (tree)
Time2018-07-27 16:40:25
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[Draw][OpenGL][OSD] Prepare to direct update vram.

Change Summary

Incremental Difference

--- a/source/src/qt/CMakeLists.txt
+++ b/source/src/qt/CMakeLists.txt
@@ -1,5 +1,5 @@
11 message("* qt/osd")
2-SET(THIS_LIB_VERSION 2.13.0)
2+SET(THIS_LIB_VERSION 2.13.1)
33
44 set(s_qt_osd_headers
55 osd_base.h
--- a/source/src/qt/gui/CMakeLists.txt
+++ b/source/src/qt/gui/CMakeLists.txt
@@ -1,6 +1,6 @@
11 message("* qt/gui")
22
3-set(THIS_LIB_VERSION 2.15.1)
3+set(THIS_LIB_VERSION 2.15.2)
44 #include(cotire)
55 #include(PrecompiledHeader)
66
--- a/source/src/qt/gui/draw_thread.cpp
+++ b/source/src/qt/gui/draw_thread.cpp
@@ -46,6 +46,11 @@ DrawThreadClass::DrawThreadClass(OSD *o, CSP_Logger *logger,QObject *parent) : Q
4646
4747 connect(this, SIGNAL(sig_update_osd()), glv, SLOT(update_osd()), Qt::QueuedConnection);
4848 connect(this, SIGNAL(sig_push_frames_to_avio(int, int, int)), glv->extfunc, SLOT(paintGL_OffScreen(int, int, int)));
49+ connect(this, SIGNAL(sig_map_texture()), glv, SLOT(do_map_vram_texture()));
50+ connect(this, SIGNAL(sig_unmap_texture()), glv, SLOT(do_unmap_vram_texture()));
51+ connect(glv, SIGNAL(sig_map_texture_reply(bool, void *, int, int)), this, SLOT(do_recv_texture_map_status(bool, void *, int, int)));
52+ connect(glv, SIGNAL(sig_unmap_texture_reply()), this, SLOT(do_recv_texture_unmap_status()));
53+
4954 //connect(this, SIGNAL(sig_call_draw_screen()), p_osd, SLOT(draw_screen()));
5055 //connect(this, SIGNAL(sig_call_no_draw_screen()), p_osd, SLOT(no_draw_screen()));
5156 use_separate_thread_draw = true;
@@ -60,6 +65,12 @@ DrawThreadClass::DrawThreadClass(OSD *o, CSP_Logger *logger,QObject *parent) : Q
6065 wait_refresh = emu_frame_rate;
6166 bDrawReq = true;
6267 renderSemaphore = new QSemaphore(0);
68+ textureMappingSemaphore = new QSemaphore(0);
69+ mapping_status = false;
70+ mapping_pointer = NULL;
71+ mapping_width = 0;
72+ mapping_height = 0;
73+ mapped_drawn = false;
6374 }
6475
6576 DrawThreadClass::~DrawThreadClass()
@@ -68,6 +79,10 @@ DrawThreadClass::~DrawThreadClass()
6879 while(renderSemaphore->available() <= 0) renderSemaphore->release(1);
6980 delete renderSemaphore;
7081 }
82+ if(textureMappingSemaphore != NULL) {
83+ while(textureMappingSemaphore->available() <= 0) textureMappingSemaphore->release(1);
84+ delete textureMappingSemaphore;
85+ }
7186
7287 }
7388
@@ -86,12 +101,15 @@ void DrawThreadClass::do_set_frames_per_second(double fps)
86101
87102 void DrawThreadClass::doDrawMain(bool flag)
88103 {
104+ req_map_screen_texture();
89105 p_osd->do_decode_movie(1);
90106 if(flag) {
91107 draw_frames = p_osd->draw_screen();
92108 } else {
93109 draw_frames = p_osd->no_draw_screen();
94110 }
111+ req_unmap_screen_texture();
112+
95113 emit sig_draw_frames(draw_frames);
96114 }
97115 void DrawThreadClass::doDraw(bool flag)
@@ -116,7 +134,9 @@ void DrawThreadClass::doExit(void)
116134
117135 void DrawThreadClass::do_draw_one_turn(bool _req_draw)
118136 {
119- if((_req_draw) && (draw_screen_buffer != NULL)) {
137+ if((mapped_drawn) && (_req_draw)) {
138+ emit sig_update_screen(NULL);
139+ } else if((_req_draw) && (draw_screen_buffer != NULL)) {
120140 emit sig_update_screen(draw_screen_buffer);
121141 } else {
122142 if(ncount == 0) emit sig_update_osd();
@@ -128,6 +148,7 @@ void DrawThreadClass::do_draw_one_turn(bool _req_draw)
128148 rec_frame_width, rec_frame_height);
129149 rec_frame_count = -1;
130150 }
151+ mapped_drawn = false;
131152 }
132153
133154 void DrawThreadClass::doWork(const QString &param)
@@ -182,3 +203,47 @@ void DrawThreadClass::do_req_encueue_video(int count, int width, int height)
182203 rec_frame_count = count;
183204 }
184205
206+void DrawThreadClass::req_map_screen_texture()
207+{
208+ mapping_status = false;
209+ mapping_pointer = NULL;
210+ mapping_width = 0;
211+ mapping_height = 0;
212+ if(glv->is_ready_to_map_vram_texture()) {
213+ emit sig_map_texture();
214+ textureMappingSemaphore->acquire();
215+ }
216+}
217+
218+void DrawThreadClass::req_unmap_screen_texture()
219+{
220+ if(mapping_status) {
221+ if(glv->is_ready_to_map_vram_texture()) {
222+ emit sig_unmap_texture();
223+ textureMappingSemaphore->acquire();
224+ }
225+ }
226+}
227+
228+void DrawThreadClass::do_recv_texture_map_status(bool f, void *p, int width, int height)
229+{
230+ mapping_status = f;
231+ mapping_pointer = (scrntype_t *)p;
232+ mapping_width = width;
233+ mapping_height = height;
234+ p_osd->do_set_screen_map_texture_address(mapping_pointer, mapping_width, mapping_height);
235+ if(mapping_status) {
236+ mapped_drawn = true;
237+ }
238+ textureMappingSemaphore->release(1);
239+}
240+
241+void DrawThreadClass::do_recv_texture_unmap_status(void)
242+{
243+ mapping_status = false;
244+ mapping_pointer = NULL;
245+ mapping_width = 0;
246+ mapping_height = 0;
247+ p_osd->do_set_screen_map_texture_address(mapping_pointer, mapping_width, mapping_height);
248+ textureMappingSemaphore->release(1);
249+}
--- a/source/src/qt/gui/draw_thread.h
+++ b/source/src/qt/gui/draw_thread.h
@@ -52,11 +52,18 @@ class DLL_PREFIX DrawThreadClass : public QThread {
5252 CSP_Logger *csp_logger;
5353 int ncount;
5454 double emu_frame_rate;
55+
56+ bool mapping_status;
57+ scrntype_t *mapping_pointer;
58+ int mapping_width;
59+ int mapping_height;
60+ bool mapped_drawn;
5561 void doDrawMain(bool flag);
5662 public:
5763 DrawThreadClass(OSD *o, CSP_Logger *logger, QObject *parent = 0);
5864 ~DrawThreadClass();
5965 QSemaphore *renderSemaphore;
66+ QSemaphore *textureMappingSemaphore;
6067
6168 void run() { doWork("");}
6269 void SetEmu(EMU *p);
@@ -69,6 +76,11 @@ public slots:
6976 void do_req_encueue_video(int count, int width, int height);
7077 void do_draw_one_turn(bool _req_draw);
7178 void do_set_frames_per_second(double fps);
79+ void do_recv_texture_map_status(bool f, void *p, int width, int height);
80+ void do_recv_texture_unmap_status(void);
81+
82+ void req_map_screen_texture();
83+ void req_unmap_screen_texture();
7284 signals:
7385 int sig_draw_frames(int);
7486 int message_changed(QString);
@@ -78,6 +90,8 @@ signals:
7890 int sig_push_frames_to_avio(int, int, int);
7991 int sig_call_draw_screen();
8092 int sig_call_no_draw_screen();
93+ int sig_map_texture();
94+ int sig_unmap_texture();
8195 };
8296
8397 QT_END_NAMESPACE
--- a/source/src/qt/gui/gl/qt_glutil_gl_tmpl.h
+++ b/source/src/qt/gui/gl/qt_glutil_gl_tmpl.h
@@ -321,6 +321,14 @@ public:
321321 }
322322 }
323323 }
324+ virtual scrntype_t *get_screen_buffer(int y) { return NULL; }
325+ virtual void get_screen_geometry(int *w, int *h) {
326+ if(w != NULL) *w = 0;
327+ if(h != NULL) *h = 0;
328+ }
329+ virtual bool is_ready_to_map_vram_texture(void) { return false; }
330+ virtual bool map_vram_texture(void) { return false; }
331+ virtual bool unmap_vram_texture(void) { return false; }
324332 public slots:
325333 virtual void paintGL(void) { }
326334 virtual void resizeGL(int width, int height) { }
@@ -347,6 +355,7 @@ public slots:
347355 virtual void do_set_display_osd(bool onoff) { }
348356 virtual void do_display_osd_leds(int lednum, bool onoff) { }
349357 virtual void do_set_led_width(int bitwidth) { }
358+
350359 signals:
351360 int sig_push_image_to_movie(int, int, int, QImage *);
352361 };
--- a/source/src/qt/gui/gl4_3/qt_glutil_gl4_3.cpp
+++ b/source/src/qt/gui/gl4_3/qt_glutil_gl4_3.cpp
@@ -1255,9 +1255,9 @@ void GLDraw_4_3::setBrightness(GLfloat r, GLfloat g, GLfloat b)
12551255 } else {
12561256 uploadMainTexture(imgptr, false);
12571257 }
1258- crt_flag = true;
12591258 p_wid->doneCurrent();
12601259 }
1260+ crt_flag = true;
12611261 }
12621262
12631263 void GLDraw_4_3::set_texture_vertex(float wmul, float hmul)
--- a/source/src/qt/gui/qt_gldraw.cpp
+++ b/source/src/qt/gui/qt_gldraw.cpp
@@ -197,3 +197,39 @@ void GLDrawClass::do_stop_run_vm()
197197 {
198198 run_vm = false;
199199 }
200+
201+void GLDrawClass::do_map_vram_texture()
202+{
203+ bool stat = false;
204+ int w = 0;
205+ int h = 0;
206+ void *p = NULL;
207+ if(extfunc != NULL) {
208+ if(extfunc->is_ready_to_map_vram_texture()) {
209+ this->makeCurrent();
210+ stat = extfunc->map_vram_texture();
211+ if(stat) {
212+ extfunc->get_screen_geometry(&w, &h);
213+ p = extfunc->get_screen_buffer(0);
214+ }
215+ }
216+ }
217+ emit sig_map_texture_reply(stat, p, w, h);
218+}
219+
220+void GLDrawClass::do_unmap_vram_texture()
221+{
222+ if(extfunc != NULL) {
223+ if(extfunc->is_ready_to_map_vram_texture()) {
224+ extfunc->unmap_vram_texture();
225+ this->doneCurrent();
226+ }
227+ }
228+ emit sig_unmap_texture_reply();
229+}
230+
231+const bool GLDrawClass::is_ready_to_map_vram_texture(void)
232+{
233+ if(extfunc == NULL) return false;
234+ return extfunc->is_ready_to_map_vram_texture();
235+}
--- a/source/src/qt/gui/qt_gldraw.h
+++ b/source/src/qt/gui/qt_gldraw.h
@@ -97,12 +97,16 @@ public:
9797 uint32_t get_scan_from_index(int index);
9898 const char *get_key_vk_name(int index);
9999 quint32 getModState(void) { return modifier;}
100- quint32 modifier;
100+
101101 void InitFBO(void);
102102 void closeEvent(QCloseEvent *event);
103103 void drawUpdateTexture(bitmap_t *p);
104104 QString logGLString(bool getExtensions = false);
105105 bool emu_launched;
106+ quint32 modifier;
107+
108+ const bool is_ready_to_map_vram_texture(void);
109+
106110 public slots:
107111 void initKeyCode(void);
108112 void releaseKeyCode(void);
@@ -145,6 +149,8 @@ public slots:
145149 void do_update_icon(int icon_type, int localnum, QPixmap *p);
146150 void do_update_icon(int icon_type, int localnum, QString message, QColor bg, QColor fg, QColor fg2, QColor fg3, QColor lg, QColor tg, float pt);
147151
152+ void do_map_vram_texture();
153+ void do_unmap_vram_texture();
148154 signals:
149155 void update_screenChanged(int tick);
150156 void do_notify_move_mouse(int x, int y);
@@ -161,6 +167,9 @@ signals:
161167 int sig_set_display_osd(bool);
162168 int sig_display_osd_leds(int,bool);
163169 int sig_resize_osd(int);
170+
171+ int sig_map_texture_reply(bool, void *, int, int);
172+ int sig_unmap_texture_reply();
164173 };
165174
166175 #endif // End.
--- a/source/src/qt/osd_base.cpp
+++ b/source/src/qt/osd_base.cpp
@@ -51,6 +51,10 @@ OSD_BASE::OSD_BASE(USING_FLAGS *p, CSP_Logger *logger) : QThread(0)
5151 max_vm_nodes = 0;
5252 p_logger = logger;
5353
54+ mapped_screen_pointer = NULL;
55+ mapped_screen_width = 0;
56+ mapped_screen_height = 0;
57+ mapped_screen_status = false;
5458 SupportedFeatures.clear();
5559 }
5660
--- a/source/src/qt/osd_base.h
+++ b/source/src/qt/osd_base.h
@@ -207,6 +207,10 @@ protected:
207207 virtual void initialize_video();
208208 virtual void release_video();
209209
210+ scrntype_t *mapped_screen_pointer;
211+ int mapped_screen_width;
212+ int mapped_screen_height;
213+ bool mapped_screen_status;
210214 bitmap_t dshow_screen_buffer;
211215 int direct_show_width, direct_show_height;
212216 bool direct_show_mute[2];
@@ -487,6 +491,7 @@ public slots:
487491 int draw_screen();
488492 int no_draw_screen();
489493 void do_draw(bool flag);
494+ void do_set_screen_map_texture_address(scrntype_t *p, int width, int height);
490495
491496 signals:
492497 int sig_update_screen(bitmap_t *);
--- a/source/src/qt/osd_screen.cpp
+++ b/source/src/qt/osd_screen.cpp
@@ -79,6 +79,20 @@ void OSD_BASE::set_vm_screen_size(int screen_width, int screen_height, int windo
7979
8080 scrntype_t* OSD_BASE::get_vm_screen_buffer(int y)
8181 {
82+ if(mapped_screen_status) {
83+ if((mapped_screen_width > 0) && (mapped_screen_pointer != NULL)){
84+ if(y < mapped_screen_height) {
85+ int offset = y * mapped_screen_width;
86+ uint8_t *p = (uint8_t *)mapped_screen_pointer;
87+ p = p + offset;
88+ return (scrntype_t *)p;
89+ } else {
90+ return NULL;
91+ }
92+ } else {
93+ return NULL;
94+ }
95+ }
8296 return get_buffer(&vm_screen_buffer, y);
8397 }
8498
@@ -90,6 +104,21 @@ scrntype_t* OSD_BASE::get_buffer(bitmap_t *p, int y)
90104 return (scrntype_t *)p->pImage.scanLine(y);
91105 }
92106
107+void OSD_BASE::do_set_screen_map_texture_address(scrntype_t *p, int width, int height)
108+{
109+ if((p != NULL) && (width > 0) && (height > 0)) {
110+ mapped_screen_pointer = p;
111+ mapped_screen_width = width;
112+ mapped_screen_height = height;
113+ mapped_screen_status = true;
114+ } else {
115+ mapped_screen_pointer = NULL;
116+ mapped_screen_width = 0;
117+ mapped_screen_height = 0;
118+ mapped_screen_status = false;
119+ }
120+}
121+
93122 int OSD_BASE::draw_screen()
94123 {
95124 // draw screen
Show on old repository browser