mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-11 07:03:33 +02:00
Draw "OSM" as a view. ES 3.0: Tell tilers to discard depth/stencil of the backbuffer.
Also, don't even bind the UI texture unless there's UI to draw (probably negligible optimization).
This commit is contained in:
+33
-25
@@ -5,12 +5,43 @@
|
||||
#include "base/timeutil.h"
|
||||
#include "gfx_es2/draw_buffer.h"
|
||||
|
||||
#include "ui/ui_context.h"
|
||||
|
||||
OnScreenMessages osm;
|
||||
|
||||
void OnScreenMessages::Draw(DrawBuffer &draw, const Bounds &bounds) {
|
||||
void OnScreenMessagesView::Draw(UIContext &dc) {
|
||||
// First, clean out old messages.
|
||||
std::lock_guard<std::recursive_mutex> guard(mutex_);
|
||||
osm.Lock();
|
||||
osm.Clean();
|
||||
|
||||
// Get height
|
||||
float w, h;
|
||||
dc.Draw()->MeasureText(UBUNTU24, "Wg", &w, &h);
|
||||
|
||||
float y = 10.0f;
|
||||
// Then draw them all.
|
||||
const std::list<OnScreenMessages::Message> &messages = osm.Messages();
|
||||
for (auto iter = messages.begin(); iter != messages.end(); ++iter) {
|
||||
float alpha = (iter->endTime - time_now_d()) * 4.0f;
|
||||
if (alpha > 1.0) alpha = 1.0f;
|
||||
if (alpha < 0.0) alpha = 0.0f;
|
||||
// Messages that are wider than the screen are left-aligned instead of centered.
|
||||
float tw, th;
|
||||
dc.Draw()->MeasureText(UBUNTU24, iter->text.c_str(), &tw, &th);
|
||||
float x = bounds_.centerX();
|
||||
int align = ALIGN_TOP | ALIGN_HCENTER;
|
||||
if (tw > bounds_.w) {
|
||||
align = ALIGN_TOP | ALIGN_LEFT;
|
||||
x = 2;
|
||||
}
|
||||
dc.Draw()->DrawTextShadow(UBUNTU24, iter->text.c_str(), x, y, colorAlpha(iter->color, alpha), align);
|
||||
y += h;
|
||||
}
|
||||
|
||||
osm.Unlock();
|
||||
}
|
||||
|
||||
void OnScreenMessages::Clean() {
|
||||
restart:
|
||||
double now = time_now_d();
|
||||
for (auto iter = messages_.begin(); iter != messages_.end(); iter++) {
|
||||
@@ -19,29 +50,6 @@ restart:
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
|
||||
// Get height
|
||||
float w, h;
|
||||
draw.MeasureText(UBUNTU24, "Wg", &w, &h);
|
||||
|
||||
float y = 10.0f;
|
||||
// Then draw them all.
|
||||
for (auto iter = messages_.begin(); iter != messages_.end(); ++iter) {
|
||||
float alpha = (iter->endTime - time_now_d()) * 4.0f;
|
||||
if (alpha > 1.0) alpha = 1.0f;
|
||||
if (alpha < 0.0) alpha = 0.0f;
|
||||
// Messages that are wider than the screen are left-aligned instead of centered.
|
||||
float tw, th;
|
||||
draw.MeasureText(UBUNTU24, iter->text.c_str(), &tw, &th);
|
||||
float x = bounds.centerX();
|
||||
int align = ALIGN_TOP | ALIGN_HCENTER;
|
||||
if (tw > bounds.w) {
|
||||
align = ALIGN_TOP | ALIGN_LEFT;
|
||||
x = 2;
|
||||
}
|
||||
draw.DrawTextShadow(UBUNTU24, iter->text.c_str(), x, y, colorAlpha(iter->color, alpha), align);
|
||||
y += h;
|
||||
}
|
||||
}
|
||||
|
||||
void OnScreenMessages::Show(const std::string &message, float duration_s, uint32_t color, int icon, bool checkUnique) {
|
||||
|
||||
Reference in New Issue
Block a user