xe::ui control for hosting a turbobadger UI.

This commit is contained in:
Ben Vanik
2015-07-01 15:58:04 -07:00
parent dec0d12cc9
commit 4ec0655751
19 changed files with 1069 additions and 13 deletions

View File

@@ -9,19 +9,33 @@
#include "xenia/debug/ui/application.h"
#include "xenia/base/assert.h"
#include "xenia/base/logging.h"
#include "xenia/base/platform.h"
#include "xenia/base/threading.h"
#include "xenia/debug/ui/main_window.h"
#include "xenia/profiling.h"
#include "third_party/turbobadger/src/tb/tb_msg.h"
#include "third_party/turbobadger/src/tb/tb_system.h"
namespace xe {
namespace debug {
namespace ui {
Application::Application() {}
Application* current_application_ = nullptr;
Application::~Application() = default;
Application* Application::current() {
assert_not_null(current_application_);
return current_application_;
}
Application::Application() { current_application_ = this; }
Application::~Application() {
assert_true(current_application_ == this);
current_application_ = nullptr;
}
std::unique_ptr<Application> Application::Create() {
std::unique_ptr<Application> app(new Application());
@@ -64,3 +78,33 @@ void Application::Quit() {
} // namespace ui
} // namespace debug
} // namespace xe
// This doesn't really belong here (it belongs in tb_system_[linux/windows].cpp.
// This is here since the proper implementations has not yet been done.
void tb::TBSystem::RescheduleTimer(uint64_t fire_time) {
if (fire_time == tb::TB_NOT_SOON) {
return;
}
uint64_t now = tb::TBSystem::GetTimeMS();
uint64_t delay_millis = fire_time >= now ? fire_time - now : 0;
xe::debug::ui::Application::current()->loop()->PostDelayed([]() {
uint64_t next_fire_time = tb::TBMessageHandler::GetNextMessageFireTime();
uint64_t now = tb::TBSystem::GetTimeMS();
if (now < next_fire_time) {
// We timed out *before* we were supposed to (the OS is not playing nice).
// Calling ProcessMessages now won't achieve a thing so force a reschedule
// of the platform timer again with the same time.
// ReschedulePlatformTimer(next_fire_time, true);
return;
}
tb::TBMessageHandler::ProcessMessages();
// If we still have things to do (because we didn't process all messages,
// or because there are new messages), we need to rescedule, so call
// RescheduleTimer.
tb::TBSystem::RescheduleTimer(
tb::TBMessageHandler::GetNextMessageFireTime());
}, delay_millis);
}