Merge branch 'qt' of https://github.com/jgilje/86Box into qt
This commit is contained in:
@@ -119,6 +119,7 @@ endif()
|
|||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
target_link_libraries(ui PRIVATE X11::X11)
|
target_link_libraries(ui PRIVATE X11::X11)
|
||||||
|
|
||||||
find_package(ECM NO_MODULE)
|
find_package(ECM NO_MODULE)
|
||||||
if (ECM_FOUND)
|
if (ECM_FOUND)
|
||||||
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <atomic>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
@@ -9,7 +8,7 @@ struct event_cpp11_t
|
|||||||
{
|
{
|
||||||
std::condition_variable cond;
|
std::condition_variable cond;
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
std::atomic_bool state = false;
|
bool state = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -89,7 +88,7 @@ thread_wait_event(event_t *handle, int timeout)
|
|||||||
auto lock = std::unique_lock<std::mutex>(event->mutex);
|
auto lock = std::unique_lock<std::mutex>(event->mutex);
|
||||||
|
|
||||||
if (timeout < 0) {
|
if (timeout < 0) {
|
||||||
event->cond.wait(lock, [=] { return event->state.load(); });
|
event->cond.wait(lock, [event] { return event->state; });
|
||||||
} else {
|
} else {
|
||||||
auto to = std::chrono::system_clock::now() + std::chrono::milliseconds(timeout);
|
auto to = std::chrono::system_clock::now() + std::chrono::milliseconds(timeout);
|
||||||
std::cv_status status;
|
std::cv_status status;
|
||||||
@@ -109,7 +108,10 @@ void
|
|||||||
thread_set_event(event_t *handle)
|
thread_set_event(event_t *handle)
|
||||||
{
|
{
|
||||||
auto event = reinterpret_cast<event_cpp11_t*>(handle);
|
auto event = reinterpret_cast<event_cpp11_t*>(handle);
|
||||||
event->state = true;
|
{
|
||||||
|
auto lock = std::unique_lock<std::mutex>(event->mutex);
|
||||||
|
event->state = true;
|
||||||
|
}
|
||||||
event->cond.notify_all();
|
event->cond.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +119,7 @@ void
|
|||||||
thread_reset_event(event_t *handle)
|
thread_reset_event(event_t *handle)
|
||||||
{
|
{
|
||||||
auto event = reinterpret_cast<event_cpp11_t*>(handle);
|
auto event = reinterpret_cast<event_cpp11_t*>(handle);
|
||||||
|
auto lock = std::unique_lock<std::mutex>(event->mutex);
|
||||||
event->state = false;
|
event->state = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void GLESWidget::paintGL()
|
|||||||
{
|
{
|
||||||
std::scoped_lock lock(image_mx);
|
std::scoped_lock lock(image_mx);
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.drawImage(QRect(0, 0, width(), height()), m_image.convertToFormat(QImage::Format_RGBX8888), QRect(sx, sy, sw, sh));
|
painter.drawImage(QRect(0, 0, width(), height()), m_image, QRect(sx, sy, sw, sh));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLESWidget::mouseReleaseEvent(QMouseEvent *event)
|
void GLESWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||||
@@ -141,12 +141,9 @@ void GLESWidget::qt_real_blit(int x, int y, int w, int h)
|
|||||||
sy = y;
|
sy = y;
|
||||||
sw = this->w = w;
|
sw = this->w = w;
|
||||||
sh = this->h = h;
|
sh = this->h = h;
|
||||||
static auto imagebits = m_image.bits();
|
auto imagebits = m_image.bits();
|
||||||
for (int y1 = y; y1 < (y + h - 1); y1++)
|
video_copy(imagebits + y * ((2048 + 64) * 4) + x * 4, &(buffer32->line[y][x]), h * (2048 + 64) * sizeof(uint32_t));
|
||||||
{
|
|
||||||
auto scanline = imagebits + (y1 * (2048 + 64) * 4);
|
|
||||||
video_copy(scanline + (x * 4), &(buffer32->line[y1][x]), w * 4);
|
|
||||||
}
|
|
||||||
if (screenshots)
|
if (screenshots)
|
||||||
{
|
{
|
||||||
video_screenshot((uint32_t *)imagebits, 0, 0, 2048 + 64);
|
video_screenshot((uint32_t *)imagebits, 0, 0, 2048 + 64);
|
||||||
|
|||||||
Reference in New Issue
Block a user