Shrinking UI elements in the debugger.

This commit is contained in:
Ben Vanik
2015-09-06 20:49:20 -07:00
parent e5fbf840d2
commit a1a996c1e6
9 changed files with 46 additions and 5 deletions

View File

@@ -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;

View File

@@ -414,6 +414,10 @@ std::unique_ptr<el::graphics::Renderer> 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) {

View File

@@ -40,6 +40,7 @@ class GLContext : public GraphicsContext {
std::unique_ptr<ProfilerDisplay> CreateProfilerDisplay() override;
std::unique_ptr<el::graphics::Renderer> CreateElementalRenderer() override;
bool is_current() override;
bool MakeCurrent() override;
void ClearCurrent() override;

View File

@@ -30,6 +30,7 @@ class GraphicsContext {
virtual std::unique_ptr<ProfilerDisplay> CreateProfilerDisplay() = 0;
virtual std::unique_ptr<el::graphics::Renderer> 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

View File

@@ -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();