diff --git a/src/xenia/debug/ui/debugger_resources.rc b/src/xenia/debug/ui/debugger_resources.rc index c8e765beb..fc922d058 100644 --- a/src/xenia/debug/ui/debugger_resources.rc +++ b/src/xenia/debug/ui/debugger_resources.rc @@ -3,3 +3,4 @@ #include "third_party\\elemental-forms\\resources.rc" //IDR_xe_debug_ui_resources_skin_bg_tile_png RCDATA ".\\resources\\skin\\bg_tile.png" +IDR_xe_debug_ui_resources_smaller_skin_skin_tb_txt RCDATA ".\\resources\\smaller_skin\\skin.tb.txt" diff --git a/src/xenia/debug/ui/main_window.cc b/src/xenia/debug/ui/main_window.cc index adc06f971..b1e41611b 100644 --- a/src/xenia/debug/ui/main_window.cc +++ b/src/xenia/debug/ui/main_window.cc @@ -10,6 +10,7 @@ #include "xenia/debug/ui/main_window.h" #include "el/animation_manager.h" +#include "el/io/file_manager.h" #include "el/util/debug.h" #include "xenia/base/clock.h" #include "xenia/base/logging.h" @@ -17,6 +18,10 @@ #include "xenia/base/threading.h" #include "xenia/ui/gl/gl_context.h" +#if XE_PLATFORM_WIN32 +#include "el/io/win32_res_file_system_win.h" +#endif // XE_PLATFORM_WIN32 + namespace xe { namespace debug { namespace ui { @@ -40,6 +45,13 @@ bool MainWindow::Initialize() { window_->set_context(xe::ui::gl::GLContext::Create(window_.get())); window_->MakeReady(); +#if XE_PLATFORM_WIN32 + el::io::FileManager::RegisterFileSystem( + std::make_unique( + "IDR_xe_debug_ui_resources_")); +#endif // XE_PLATFORM_WIN32 + window_->LoadSkin("smaller_skin/skin.tb.txt"); + window_->on_closed.AddListener(std::bind(&MainWindow::OnClose, this)); window_->on_key_down.AddListener([this](xe::ui::KeyEvent* e) { diff --git a/src/xenia/debug/ui/resources/smaller_skin/skin.tb.txt b/src/xenia/debug/ui/resources/smaller_skin/skin.tb.txt new file mode 100644 index 000000000..df2986260 --- /dev/null +++ b/src/xenia/debug/ui/resources/smaller_skin/skin.tb.txt @@ -0,0 +1,11 @@ +elements + Button + padding 3 4 + Button.flat + padding 3 4 + ButtonInGroup + padding 3 4 + Box + padding 5 + ListItem + padding 1 4 diff --git a/src/xenia/kernel/xthread.cc b/src/xenia/kernel/xthread.cc index d8ff5863d..131f3881a 100644 --- a/src/xenia/kernel/xthread.cc +++ b/src/xenia/kernel/xthread.cc @@ -652,7 +652,7 @@ X_STATUS XThread::Suspend(uint32_t* out_suspend_count) { ++guest_object()->suspend_count; // If we are suspending ourselves, we can't hold the lock. - if (XThread::GetCurrentThread() == this) { + if (XThread::IsInThread() && XThread::GetCurrentThread() == this) { global_lock.unlock(); } diff --git a/src/xenia/ui/gl/gl4_elemental_renderer.cc b/src/xenia/ui/gl/gl4_elemental_renderer.cc index 8eb7f5ae9..aa15dbb5f 100644 --- a/src/xenia/ui/gl/gl4_elemental_renderer.cc +++ b/src/xenia/ui/gl/gl4_elemental_renderer.cc @@ -40,6 +40,8 @@ GL4ElementalRenderer::GL4Bitmap::~GL4Bitmap() { bool GL4ElementalRenderer::GL4Bitmap::Init(int width, int height, uint32_t* data) { + GraphicsContextLock lock(context_); + assert(width == el::util::GetNearestPowerOfTwo(width)); assert(height == el::util::GetNearestPowerOfTwo(height)); width_ = width; diff --git a/src/xenia/ui/gl/gl_context.cc b/src/xenia/ui/gl/gl_context.cc index ab045e4fd..46cc888c0 100644 --- a/src/xenia/ui/gl/gl_context.cc +++ b/src/xenia/ui/gl/gl_context.cc @@ -414,6 +414,10 @@ std::unique_ptr GLContext::CreateElementalRenderer() { return GL4ElementalRenderer::Create(this); } +bool GLContext::is_current() { + return tls_glew_context_ == glew_context_.get(); +} + bool GLContext::MakeCurrent() { SCOPE_profile_cpu_f("gpu"); if (FLAGS_thread_safe_gl) { diff --git a/src/xenia/ui/gl/gl_context.h b/src/xenia/ui/gl/gl_context.h index dd1108ea4..eb09aa36f 100644 --- a/src/xenia/ui/gl/gl_context.h +++ b/src/xenia/ui/gl/gl_context.h @@ -40,6 +40,7 @@ class GLContext : public GraphicsContext { std::unique_ptr CreateProfilerDisplay() override; std::unique_ptr CreateElementalRenderer() override; + bool is_current() override; bool MakeCurrent() override; void ClearCurrent() override; diff --git a/src/xenia/ui/graphics_context.h b/src/xenia/ui/graphics_context.h index 4f1ceef89..1997d19dc 100644 --- a/src/xenia/ui/graphics_context.h +++ b/src/xenia/ui/graphics_context.h @@ -30,6 +30,7 @@ class GraphicsContext { virtual std::unique_ptr CreateProfilerDisplay() = 0; virtual std::unique_ptr CreateElementalRenderer() = 0; + virtual bool is_current() = 0; virtual bool MakeCurrent() = 0; virtual void ClearCurrent() = 0; @@ -44,12 +45,20 @@ class GraphicsContext { struct GraphicsContextLock { explicit GraphicsContextLock(GraphicsContext* context) : context_(context) { - context_->MakeCurrent(); + was_current_ = context_->is_current(); + if (!was_current_) { + context_->MakeCurrent(); + } + } + ~GraphicsContextLock() { + if (!was_current_) { + context_->ClearCurrent(); + } } - ~GraphicsContextLock() { context_->ClearCurrent(); } private: - GraphicsContext* context_; + bool was_current_ = false; + GraphicsContext* context_ = nullptr; }; } // namespace ui diff --git a/src/xenia/ui/window.h b/src/xenia/ui/window.h index e4961c8e2..85215a7ab 100644 --- a/src/xenia/ui/window.h +++ b/src/xenia/ui/window.h @@ -116,7 +116,8 @@ class Window { protected: Window(Loop* loop, const std::wstring& title); - bool InitializeElemental(Loop* loop, el::graphics::Renderer* renderer); + virtual bool InitializeElemental(Loop* loop, + el::graphics::Renderer* renderer); virtual bool OnCreate(); virtual void OnMainMenuChange();