mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-16 11:03:45 +01:00
Merge branch 'vfpu-dot' into TemporaryHackishBranch
This commit is contained in:
commit
d08d155edc
19 files changed
+1892
-198
No files matched your search
+2
-1
@@ -21,6 +21,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
extern const char *PPSSPP_GIT_VERSION;
|
||||
@@ -75,7 +76,7 @@ public:
|
||||
bool bIgnoreWindowsKey;
|
||||
bool bRestartRequired;
|
||||
#endif
|
||||
#if defined(USING_WIN_UI) || defined(USING_QT_UI)
|
||||
#if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP)
|
||||
std::string sFont;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1239,7 +1239,8 @@ namespace MIPSComp {
|
||||
fp.FMUL(fpr.V(dregs[a * 4 + b]), fpr.V(sregs[b * 4]), fpr.V(tregs[a * 4]));
|
||||
for (int c = 1; c < n; c++) {
|
||||
fpr.MapDirtyInInV(dregs[a * 4 + b], sregs[b * 4 + c], tregs[a * 4 + c], false);
|
||||
fp.FMADD(fpr.V(dregs[a * 4 + b]), fpr.V(sregs[b * 4 + c]), fpr.V(tregs[a * 4 + c]), fpr.V(dregs[a * 4 + b]));
|
||||
fp.FMUL(S0, fpr.V(sregs[b * 4 + c]), fpr.V(tregs[a * 4 + c]));
|
||||
fp.FADD(fpr.V(dregs[a * 4 + b]), fpr.V(dregs[a * 4 + b]), S0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+66
-48
@@ -463,20 +463,21 @@ namespace MIPSInt
|
||||
|
||||
for (int a = 0; a < n; a++) {
|
||||
for (int b = 0; b < n; b++) {
|
||||
float sum = 0.0f;
|
||||
union { float f; uint32_t u; } sum = { 0.0f };
|
||||
if (a == n - 1 && b == n - 1) {
|
||||
// S and T prefixes work on the final (or maybe first, in reverse?) dot.
|
||||
ApplySwizzleS(&s[b * 4], V_Quad);
|
||||
ApplySwizzleT(&t[a * 4], V_Quad);
|
||||
for (int c = 0; c < 4; c++) {
|
||||
sum += s[b * 4 + c] * t[a * 4 + c];
|
||||
}
|
||||
} else {
|
||||
for (int c = 0; c < n; c++) {
|
||||
sum += s[b * 4 + c] * t[a * 4 + c];
|
||||
}
|
||||
}
|
||||
d[a * 4 + b] = sum;
|
||||
|
||||
sum.f = vfpu_dot(&s[b * 4], &t[a * 4]);
|
||||
if (my_isnan(sum.f)) {
|
||||
sum.u = 0x7f800001;
|
||||
} else if ((sum.u & 0x7F800000) == 0) {
|
||||
sum.u &= 0xFF800000;
|
||||
}
|
||||
|
||||
d[a * 4 + b] = sum.f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1116,7 +1117,7 @@ namespace MIPSInt
|
||||
|
||||
void Int_VDot(MIPSOpcode op) {
|
||||
float s[4]{}, t[4]{};
|
||||
float d;
|
||||
union { float f; uint32_t u; } d;
|
||||
int vd = _VD;
|
||||
int vs = _VS;
|
||||
int vt = _VT;
|
||||
@@ -1125,12 +1126,16 @@ namespace MIPSInt
|
||||
ApplySwizzleS(s, V_Quad);
|
||||
ReadVector(t, sz, vt);
|
||||
ApplySwizzleT(t, V_Quad);
|
||||
d = 0.0f;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
d += s[i] * t[i];
|
||||
|
||||
d.f = vfpu_dot(s, t);
|
||||
if (my_isnan(d.f)) {
|
||||
d.u = 0x7f800001;
|
||||
} else if ((d.u & 0x7F800000) == 0) {
|
||||
d.u &= 0xFF800000;
|
||||
}
|
||||
ApplyPrefixD(&d, V_Single);
|
||||
WriteVector(&d, V_Single, vd);
|
||||
|
||||
ApplyPrefixD(&d.f, V_Single);
|
||||
WriteVector(&d.f, V_Single, vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
@@ -1165,10 +1170,7 @@ namespace MIPSInt
|
||||
}
|
||||
ApplyPrefixST(s, VFPURewritePrefix(VFPU_CTRL_SPREFIX, sprefixRemove, sprefixAdd), V_Quad);
|
||||
|
||||
float sum = 0.0f;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
sum += s[i] * t[i];
|
||||
}
|
||||
float sum = vfpu_dot(s, t);
|
||||
d = my_isnan(sum) ? fabsf(sum) : sum;
|
||||
ApplyPrefixD(&d, V_Single);
|
||||
WriteVector(&d, V_Single, vd);
|
||||
@@ -1404,10 +1406,7 @@ namespace MIPSInt
|
||||
u32 tprefixAdd = VFPU_MAKE_CONSTANTS(VFPUConst::ONE, VFPUConst::ONE, VFPUConst::ONE, VFPUConst::ONE);
|
||||
ApplyPrefixST(t, VFPURewritePrefix(VFPU_CTRL_TPREFIX, tprefixRemove, tprefixAdd), V_Quad);
|
||||
|
||||
d = 0.0f;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
d += s[i] * t[i];
|
||||
}
|
||||
d = vfpu_dot(s, t);
|
||||
ApplyPrefixD(&d, V_Single);
|
||||
WriteVector(&d, V_Single, vd);
|
||||
PC += 4;
|
||||
@@ -1438,10 +1437,7 @@ namespace MIPSInt
|
||||
tprefixAdd = 0;
|
||||
ApplyPrefixST(t, VFPURewritePrefix(VFPU_CTRL_TPREFIX, tprefixRemove, tprefixAdd), V_Quad);
|
||||
|
||||
d = 0.0f;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
d += s[i] * t[i];
|
||||
}
|
||||
d = vfpu_dot(s, t);
|
||||
ApplyPrefixD(&d, V_Single);
|
||||
WriteVector(&d, V_Single, vd);
|
||||
PC += 4;
|
||||
@@ -1558,7 +1554,8 @@ namespace MIPSInt
|
||||
}
|
||||
|
||||
void Int_Vtfm(MIPSOpcode op) {
|
||||
float s[16]{}, t[4]{}, d[4];
|
||||
float s[16]{}, t[4]{};
|
||||
FloatBits d;
|
||||
int vd = _VD;
|
||||
int vs = _VS;
|
||||
int vt = _VT;
|
||||
@@ -1572,13 +1569,24 @@ namespace MIPSInt
|
||||
ReadMatrix(s, msz, vs);
|
||||
ReadVector(t, sz, vt);
|
||||
|
||||
for (int i = 0; i < ins; i++) {
|
||||
d[i] = s[i * 4] * t[0];
|
||||
for (int k = 1; k < tn; k++) {
|
||||
d[i] += s[i * 4 + k] * t[k];
|
||||
float t2[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i < tn) {
|
||||
t2[i] = t[i];
|
||||
} else if (i == ins) {
|
||||
t2[i] = 1.0f;
|
||||
} else {
|
||||
t2[i] = 0.0f;
|
||||
}
|
||||
if (ins >= n) {
|
||||
d[i] += s[i * 4 + ins];
|
||||
}
|
||||
|
||||
for (int i = 0; i < ins; i++) {
|
||||
d.f[i] = vfpu_dot(&s[i * 4], t2);
|
||||
|
||||
if (my_isnan(d.f[i])) {
|
||||
d.u[i] = 0x7f800001;
|
||||
} else if ((d.u[i] & 0x7F800000) == 0) {
|
||||
d.u[i] &= 0xFF800000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1599,17 +1607,20 @@ namespace MIPSInt
|
||||
ApplyPrefixST(t, VFPURewritePrefix(VFPU_CTRL_TPREFIX, tprefixRemove, tprefixAdd), V_Quad);
|
||||
|
||||
// Really this is the operation all rows probably use (with constant wiring.)
|
||||
d[ins] = s[ins * 4] * t[0];
|
||||
for (int k = 1; k < 4; k++) {
|
||||
d[ins] += s[ins * 4 + k] * t[k];
|
||||
d.f[ins] = vfpu_dot(&s[ins * 4], t);
|
||||
|
||||
if (my_isnan(d.f[ins])) {
|
||||
d.u[ins] = 0x7f800001;
|
||||
} else if ((d.u[ins] & 0x7F800000) == 0) {
|
||||
d.u[ins] &= 0xFF800000;
|
||||
}
|
||||
|
||||
// D prefix applies to the last element only.
|
||||
u32 lastmask = (currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] & (1 << 8)) << ins;
|
||||
u32 lastsat = (currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] & 3) << (ins + ins);
|
||||
currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] = lastmask | lastsat;
|
||||
ApplyPrefixD(d, sz);
|
||||
WriteVector(d, sz, vd);
|
||||
ApplyPrefixD(d.f, sz);
|
||||
WriteVector(d.f, sz, vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
@@ -1956,7 +1967,8 @@ namespace MIPSInt
|
||||
}
|
||||
|
||||
void Int_VecDo3(MIPSOpcode op) {
|
||||
float s[4], t[4], d[4];
|
||||
float s[4], t[4];
|
||||
FloatBits d;
|
||||
int vd = _VD;
|
||||
int vs = _VS;
|
||||
int vt = _VT;
|
||||
@@ -2000,10 +2012,16 @@ namespace MIPSInt
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
switch (optype) {
|
||||
case 0: d[i] = s[i] + t[i]; break; //vadd
|
||||
case 1: d[i] = s[i] - t[i]; break; //vsub
|
||||
case 7: d[i] = s[i] / t[i]; break; //vdiv
|
||||
case 8: d[i] = s[i] * t[i]; break; //vmul
|
||||
case 0: d.f[i] = s[i] + t[i]; break; //vadd
|
||||
case 1: d.f[i] = s[i] - t[i]; break; //vsub
|
||||
case 7: d.f[i] = s[i] / t[i]; break; //vdiv
|
||||
case 8: d.f[i] = s[i] * t[i]; break; //vmul
|
||||
}
|
||||
|
||||
if (my_isnan(d.f[i])) {
|
||||
d.u[i] = 0x7f800001;
|
||||
} else if ((d.u[i] & 0x7F800000) == 0) {
|
||||
d.u[i] &= 0xFF800000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2012,12 +2030,12 @@ namespace MIPSInt
|
||||
u32 lastmask = (currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] & (1 << 8)) << (n - 1);
|
||||
u32 lastsat = (currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] & 3) << (n + n - 2);
|
||||
currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] = lastmask | lastsat;
|
||||
ApplyPrefixD(d, sz);
|
||||
ApplyPrefixD(d.f, sz);
|
||||
} else {
|
||||
RetainInvalidSwizzleST(d, sz);
|
||||
ApplyPrefixD(d, sz);
|
||||
RetainInvalidSwizzleST(d.f, sz);
|
||||
ApplyPrefixD(d.f, sz);
|
||||
}
|
||||
WriteVector(d, sz, vd);
|
||||
WriteVector(d.f, sz, vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
|
||||
@@ -607,3 +607,97 @@ float Float16ToFloat32(unsigned short l)
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
static uint32_t get_uexp(uint32_t x) {
|
||||
return (x >> 23) & 0xFF;
|
||||
}
|
||||
|
||||
static int32_t get_mant(uint32_t x) {
|
||||
// Note: this returns the hidden 1.
|
||||
return (x & 0x007FFFFF) | 0x00800000;
|
||||
}
|
||||
|
||||
static int32_t get_sign(uint32_t x) {
|
||||
return x & 0x80000000;
|
||||
}
|
||||
|
||||
float vfpu_dot(float a[4], float b[4]) {
|
||||
static const int EXTRA_BITS = 2;
|
||||
union float2int {
|
||||
uint32_t i;
|
||||
float f;
|
||||
} intermed[4];
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
intermed[i].f = a[i] * b[i];
|
||||
}
|
||||
|
||||
uint32_t exps[4];
|
||||
int32_t mants[4];
|
||||
uint32_t max_exp = 0;
|
||||
uint32_t last_inf = 0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
exps[i] = get_uexp(intermed[i].i);
|
||||
// Preserve extra bits of precision in the mantissa during the add.
|
||||
mants[i] = get_mant(intermed[i].i) << EXTRA_BITS;
|
||||
if (exps[i] > max_exp) {
|
||||
max_exp = exps[i];
|
||||
}
|
||||
if (exps[i] == 255) {
|
||||
bool diff_sign = last_inf && get_sign(last_inf) != get_sign(intermed[i].i);
|
||||
bool mant_nan = mants[i] != (0x00800000 << EXTRA_BITS);
|
||||
if (diff_sign || mant_nan) {
|
||||
intermed[0].i = 0x7F800001;
|
||||
return intermed[0].f;
|
||||
}
|
||||
last_inf = intermed[i].i;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t mant_sum = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int exp = max_exp - exps[i];
|
||||
if (exp >= 32) {
|
||||
mants[i] = 0;
|
||||
} else {
|
||||
mants[i] >>= max_exp - exps[i];
|
||||
}
|
||||
if (get_sign(intermed[i].i)) {
|
||||
mants[i] = -mants[i];
|
||||
}
|
||||
mant_sum += mants[i];
|
||||
}
|
||||
|
||||
uint32_t sign_sum = 0;
|
||||
if (mant_sum < 0) {
|
||||
sign_sum = 0x80000000;
|
||||
mant_sum = -mant_sum;
|
||||
}
|
||||
// Chop off the extra bits.
|
||||
mant_sum >>= EXTRA_BITS;
|
||||
|
||||
if (mant_sum == 0 || max_exp == 0) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
while (mant_sum < 0x00800000) {
|
||||
mant_sum <<= 1;
|
||||
max_exp -= 1;
|
||||
}
|
||||
while (mant_sum >= 0x01000000) {
|
||||
mant_sum >>= 1;
|
||||
max_exp += 1;
|
||||
}
|
||||
_dbg_assert_(JIT, (mant_sum & 0x00800000) != 0);
|
||||
|
||||
if (max_exp >= 255) {
|
||||
max_exp = 255;
|
||||
mant_sum = 0;
|
||||
} else if (max_exp == 0) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
intermed[0].i = sign_sum | (max_exp << 23) | (mant_sum & 0x007FFFFF);
|
||||
return intermed[0].f;
|
||||
}
|
||||
@@ -97,6 +97,8 @@ inline float vfpu_clamp(float v, float min, float max) {
|
||||
return v >= max ? max : (v <= min ? min : v);
|
||||
}
|
||||
|
||||
float vfpu_dot(float a[4], float b[4]);
|
||||
|
||||
#define VFPU_FLOAT16_EXP_MAX 0x1f
|
||||
#define VFPU_SH_FLOAT16_SIGN 15
|
||||
#define VFPU_MASK_FLOAT16_SIGN 0x1
|
||||
|
||||
@@ -108,10 +108,12 @@ EGLConfig EGL_FindConfig(int *contextVersion) {
|
||||
};
|
||||
|
||||
// We don't want HDR modes with more than 8 bits per component.
|
||||
auto readConfigMax = [&](EGLint attr, EGLint m) -> EGLint {
|
||||
// But let's assume some color is better than no color at all.
|
||||
auto readConfigMax = [&](EGLint attr, EGLint m, EGLint def = 1) -> EGLint {
|
||||
EGLint val = readConfig(attr);
|
||||
return val > m ? 1 : val; // why not 0?
|
||||
return val > m ? def : val;
|
||||
};
|
||||
|
||||
int colorScore = readConfigMax(EGL_RED_SIZE, 8) + readConfigMax(EGL_BLUE_SIZE, 8) + readConfigMax(EGL_GREEN_SIZE, 8);
|
||||
int alphaScore = readConfigMax(EGL_ALPHA_SIZE, 8);
|
||||
int depthScore = readConfig(EGL_DEPTH_SIZE);
|
||||
@@ -122,11 +124,13 @@ EGLConfig EGL_FindConfig(int *contextVersion) {
|
||||
int transparentScore = readConfig(EGL_TRANSPARENT_TYPE) == EGL_NONE ? 50 : 0;
|
||||
|
||||
EGLint caveat = readConfig(EGL_CONFIG_CAVEAT);
|
||||
int caveatScore = caveat == EGL_NONE ? 100 : (caveat == EGL_NON_CONFORMANT_CONFIG ? 50 : 0);
|
||||
// Let's assume that non-conformant configs aren't so awful.
|
||||
int caveatScore = caveat == EGL_NONE ? 100 : (caveat == EGL_NON_CONFORMANT_CONFIG ? 95 : 0);
|
||||
|
||||
#ifndef USING_FBDEV
|
||||
EGLint surfaceType = readConfig(EGL_SURFACE_TYPE);
|
||||
int surfaceScore = (surfaceType & EGL_WINDOW_BIT) ? 100 : 0;
|
||||
// Only try a non-Window config in the worst case when there are only non-Window configs.
|
||||
int surfaceScore = (surfaceType & EGL_WINDOW_BIT) ? 1000 : 0;
|
||||
#endif
|
||||
|
||||
EGLint renderable = readConfig(EGL_RENDERABLE_TYPE);
|
||||
|
||||
+8
-2
@@ -108,6 +108,9 @@
|
||||
#if defined(USING_QT_UI)
|
||||
#include <QFontDatabase>
|
||||
#endif
|
||||
#if PPSSPP_PLATFORM(UWP)
|
||||
#include <dwrite_3.h>
|
||||
#endif
|
||||
|
||||
// The new UI framework, for initialization
|
||||
|
||||
@@ -646,7 +649,10 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
// Note to translators: do not translate this/add this to PPSSPP-lang's files.
|
||||
// It's intended to be custom for every user.
|
||||
// Only add it to your own personal copies of PPSSPP.
|
||||
#if defined(USING_WIN_UI) && !PPSSPP_PLATFORM(UWP)
|
||||
#if PPSSPP_PLATFORM(UWP)
|
||||
// Roboto font is loaded in TextDrawerUWP.
|
||||
g_Config.sFont = des->T("Font", "Roboto");
|
||||
#elif defined(USING_WIN_UI) && !PPSSPP_PLATFORM(UWP)
|
||||
// TODO: Could allow a setting to specify a font file to load?
|
||||
// TODO: Make this a constant if we can sanely load the font on other systems?
|
||||
AddFontResourceEx(L"assets/Roboto-Condensed.ttf", FR_PRIVATE, NULL);
|
||||
@@ -729,7 +735,7 @@ static UI::Style MakeStyle(uint32_t fg, uint32_t bg) {
|
||||
}
|
||||
|
||||
static void UIThemeInit() {
|
||||
#if (defined(USING_WIN_UI) && !PPSSPP_PLATFORM(UWP)) || defined(USING_QT_UI)
|
||||
#if defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP) || defined(USING_QT_UI)
|
||||
ui_theme.uiFont = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 22);
|
||||
ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 15);
|
||||
ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 12);
|
||||
|
||||
+16
-4
@@ -217,9 +217,10 @@ void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^
|
||||
// Run() won't start until the CoreWindow is activated.
|
||||
CoreWindow::GetForCurrentThread()->Activate();
|
||||
// On mobile, we force-enter fullscreen mode.
|
||||
if (m_isPhone) {
|
||||
if (m_isPhone) g_Config.bFullScreen = true;
|
||||
|
||||
if (g_Config.bFullScreen)
|
||||
Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->TryEnterFullScreenMode();
|
||||
}
|
||||
}
|
||||
|
||||
void App::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args) {
|
||||
@@ -228,9 +229,10 @@ void App::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args) {
|
||||
// aware that a deferral may not be held indefinitely. After about five seconds,
|
||||
// the app will be forced to exit.
|
||||
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
|
||||
auto app = this;
|
||||
|
||||
create_task([this, deferral]() {
|
||||
m_deviceResources->Trim();
|
||||
create_task([app, deferral]() {
|
||||
app->m_deviceResources->Trim();
|
||||
deferral->Complete();
|
||||
});
|
||||
}
|
||||
@@ -246,6 +248,9 @@ void App::OnResuming(Platform::Object^ sender, Platform::Object^ args) {
|
||||
// Window event handlers.
|
||||
|
||||
void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args) {
|
||||
auto view = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
|
||||
g_Config.bFullScreen = view->IsFullScreenMode;
|
||||
|
||||
int width = sender->Bounds.Width;
|
||||
int height = sender->Bounds.Height;
|
||||
float scale = m_deviceResources->GetDpi() / 96.0f;
|
||||
@@ -263,6 +268,13 @@ void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ ar
|
||||
}
|
||||
|
||||
void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) {
|
||||
|
||||
if (args->Visible == false) {
|
||||
// MainScreen::OnExit and even App::OnWindowClosed
|
||||
// doesn't seem to be called when closing the window
|
||||
// Try to save the config here
|
||||
g_Config.Save("App::OnVisibilityChanged");
|
||||
}
|
||||
m_windowVisible = args->Visible;
|
||||
}
|
||||
|
||||
|
||||
@@ -419,6 +419,7 @@
|
||||
<ClInclude Include="..\..\ext\native\file\path.h" />
|
||||
<ClInclude Include="..\..\ext\native\file\vfs.h" />
|
||||
<ClInclude Include="..\..\ext\native\file\zip_read.h" />
|
||||
<ClInclude Include="..\..\ext\native\gfx_es2\draw_text_uwp.h" />
|
||||
<ClInclude Include="..\..\ext\native\json\json_reader.h" />
|
||||
<ClInclude Include="..\..\ext\native\json\json_writer.h" />
|
||||
<ClInclude Include="..\..\ext\native\gfx\texture_atlas.h" />
|
||||
@@ -1462,6 +1463,7 @@
|
||||
<ClCompile Include="..\..\ext\native\file\ini_file.cpp" />
|
||||
<ClCompile Include="..\..\ext\native\file\path.cpp" />
|
||||
<ClCompile Include="..\..\ext\native\file\zip_read.cpp" />
|
||||
<ClCompile Include="..\..\ext\native\gfx_es2\draw_text_uwp.cpp" />
|
||||
<ClCompile Include="..\..\ext\native\json\json_reader.cpp" />
|
||||
<ClCompile Include="..\..\ext\native\json\json_writer.cpp" />
|
||||
<ClCompile Include="..\..\ext\native\gfx\texture_atlas.cpp" />
|
||||
@@ -1642,4 +1644,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -474,6 +474,9 @@
|
||||
<ClCompile Include="..\..\ext\native\data\base64.cpp">
|
||||
<Filter>data</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\native\gfx_es2\draw_text_uwp.cpp">
|
||||
<Filter>gfx</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
@@ -747,5 +750,8 @@
|
||||
<ClInclude Include="..\..\ext\native\data\base64.h">
|
||||
<Filter>data</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\native\gfx_es2\draw_text_uwp.h">
|
||||
<Filter>gfx</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+10
-2
@@ -42,6 +42,7 @@ using namespace Concurrency;
|
||||
// UGLY!
|
||||
PPSSPP_UWPMain *g_main;
|
||||
extern WindowsAudioBackend *winAudioBackend;
|
||||
std::string langRegion;
|
||||
// TODO: Use Microsoft::WRL::ComPtr<> for D3D11 objects?
|
||||
// TODO: See https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/WindowsAudioSession for WASAPI with UWP
|
||||
// TODO: Low latency input: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/LowLatencyInput/cpp
|
||||
@@ -76,7 +77,6 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
|
||||
|
||||
wchar_t lcCountry[256];
|
||||
|
||||
std::string langRegion;
|
||||
if (0 != GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, lcCountry, 256)) {
|
||||
langRegion = ConvertWStringToUTF8(lcCountry);
|
||||
for (size_t i = 0; i < langRegion.size(); i++) {
|
||||
@@ -345,7 +345,7 @@ std::string System_GetProperty(SystemProperty prop) {
|
||||
case SYSPROP_NAME:
|
||||
return "Windows 10 Universal";
|
||||
case SYSPROP_LANGREGION:
|
||||
return "en_US"; // TODO UWP
|
||||
return langRegion;
|
||||
case SYSPROP_CLIPBOARD_TEXT:
|
||||
/* TODO: Need to either change this API or do this on a thread in an ugly fashion.
|
||||
DataPackageView ^view = Clipboard::GetContent();
|
||||
@@ -429,6 +429,14 @@ void System_SendMessage(const char *command, const char *parameter) {
|
||||
g_main->LoadStorageFile(file);
|
||||
}
|
||||
});
|
||||
} else if (!strcmp(command, "toggle_fullscreen")) {
|
||||
auto view = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
|
||||
if (strcmp(parameter, "0") == 0) {
|
||||
view->ExitFullScreenMode();
|
||||
}
|
||||
else if (strcmp(parameter, "1") == 0){
|
||||
view->TryEnterFullScreenMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+800
-55
File diff suppressed because it is too large.
Load diff
+251
-79
@@ -38,6 +38,18 @@
|
||||
<Filter Include="Content">
|
||||
<UniqueIdentifier>{ef87b390-608f-4c6d-a0ad-88963875ed11}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Content\lang">
|
||||
<UniqueIdentifier>{0c1cdb21-de65-4a10-962e-46b9bb0ff717}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Content\shaders">
|
||||
<UniqueIdentifier>{a861f712-3285-448d-b7a0-f6d39ac4c4b9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Content\flash0">
|
||||
<UniqueIdentifier>{d51ae335-1279-4484-bfbf-2caa2efba6d9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Content\flash0\font">
|
||||
<UniqueIdentifier>{d2294c79-82bd-470f-b984-f838f0fbcd25}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="App.cpp" />
|
||||
@@ -110,89 +122,249 @@
|
||||
<Filter>Content</Filter>
|
||||
</None>
|
||||
<None Include="PPSSPP_UWP_TemporaryKey.pfx" />
|
||||
<None Include="Content\flash0\font\jpn0.pgf" />
|
||||
<None Include="Content\flash0\font\kr0.pgf" />
|
||||
<None Include="Content\flash0\font\ltn0.pgf" />
|
||||
<None Include="Content\flash0\font\ltn1.pgf" />
|
||||
<None Include="Content\flash0\font\ltn2.pgf" />
|
||||
<None Include="Content\flash0\font\ltn3.pgf" />
|
||||
<None Include="Content\flash0\font\ltn4.pgf" />
|
||||
<None Include="Content\flash0\font\ltn5.pgf" />
|
||||
<None Include="Content\flash0\font\ltn6.pgf" />
|
||||
<None Include="Content\flash0\font\ltn7.pgf" />
|
||||
<None Include="Content\flash0\font\ltn8.pgf" />
|
||||
<None Include="Content\flash0\font\ltn9.pgf" />
|
||||
<None Include="Content\flash0\font\ltn10.pgf" />
|
||||
<None Include="Content\flash0\font\ltn11.pgf" />
|
||||
<None Include="Content\flash0\font\ltn12.pgf" />
|
||||
<None Include="Content\flash0\font\ltn13.pgf" />
|
||||
<None Include="Content\flash0\font\ltn14.pgf" />
|
||||
<None Include="Content\flash0\font\ltn15.pgf" />
|
||||
<None Include="Content\lang\pt_PT.ini" />
|
||||
<None Include="Content\lang\pt_BR.ini" />
|
||||
<None Include="Content\lang\pl_PL.ini" />
|
||||
<None Include="Content\lang\no_NO.ini" />
|
||||
<None Include="Content\lang\nl_NL.ini" />
|
||||
<None Include="Content\lang\ms_MY.ini" />
|
||||
<None Include="Content\lang\lt-LT.ini" />
|
||||
<None Include="Content\lang\lo_LA.ini" />
|
||||
<None Include="Content\lang\ko_KR.ini" />
|
||||
<None Include="Content\lang\jv_ID.ini" />
|
||||
<None Include="Content\lang\ja_JP.ini" />
|
||||
<None Include="Content\lang\it_IT.ini" />
|
||||
<None Include="Content\lang\id_ID.ini" />
|
||||
<None Include="Content\lang\hu_HU.ini" />
|
||||
<None Include="Content\lang\he_IL_invert.ini" />
|
||||
<None Include="Content\lang\he_IL.ini" />
|
||||
<None Include="Content\lang\gr_EL.ini" />
|
||||
<None Include="Content\lang\gl_ES.ini" />
|
||||
<None Include="Content\lang\fr_FR.ini" />
|
||||
<None Include="Content\lang\fi_FI.ini" />
|
||||
<None Include="Content\lang\fa_IR.ini" />
|
||||
<None Include="Content\lang\es_LA.ini" />
|
||||
<None Include="Content\lang\es_ES.ini" />
|
||||
<None Include="Content\lang\en_US.ini" />
|
||||
<None Include="Content\lang\dr_ID.ini" />
|
||||
<None Include="Content\lang\de_DE.ini" />
|
||||
<None Include="Content\lang\da_DK.ini" />
|
||||
<None Include="Content\lang\cz_CZ.ini" />
|
||||
<None Include="Content\lang\ca_ES.ini" />
|
||||
<None Include="Content\lang\bg_BG.ini" />
|
||||
<None Include="Content\lang\az_AZ.ini" />
|
||||
<None Include="Content\lang\ar_AE.ini" />
|
||||
<None Include="Content\lang\ro_RO.ini" />
|
||||
<None Include="Content\lang\ru_RU.ini" />
|
||||
<None Include="Content\lang\sv_SE.ini" />
|
||||
<None Include="Content\lang\tg_PH.ini" />
|
||||
<None Include="Content\lang\th_TH.ini" />
|
||||
<None Include="Content\lang\tr_TR.ini" />
|
||||
<None Include="Content\lang\uk_UA.ini" />
|
||||
<None Include="Content\lang\vi_VN.ini" />
|
||||
<None Include="Content\lang\zh_CN.ini" />
|
||||
<None Include="Content\lang\zh_TW.ini" />
|
||||
<None Include="Content\shaders\4xhqglsl.fsh" />
|
||||
<None Include="Content\shaders\5xBR.fsh" />
|
||||
<None Include="Content\shaders\5xBR-lv2.fsh" />
|
||||
<None Include="Content\shaders\aacolor.fsh" />
|
||||
<None Include="Content\shaders\bloom.fsh" />
|
||||
<None Include="Content\shaders\cartoon.fsh" />
|
||||
<None Include="Content\shaders\crt.fsh" />
|
||||
<None Include="Content\shaders\defaultshaders.ini" />
|
||||
<None Include="Content\shaders\fxaa.fsh" />
|
||||
<None Include="Content\shaders\GaussianDownscale.fsh" />
|
||||
<None Include="Content\shaders\grayscale.fsh" />
|
||||
<None Include="Content\shaders\inversecolors.fsh" />
|
||||
<None Include="Content\shaders\natural.fsh" />
|
||||
<None Include="Content\shaders\naturalA.fsh" />
|
||||
<None Include="Content\shaders\scanlines.fsh" />
|
||||
<None Include="Content\shaders\sharpen.fsh" />
|
||||
<None Include="Content\shaders\upscale_spline36.fsh" />
|
||||
<None Include="Content\shaders\videoAA.fsh" />
|
||||
<None Include="Content\shaders\vignette.fsh" />
|
||||
<None Include="Content\lang\ar_AE.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\az_AZ.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\bg_BG.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\ca_ES.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\cz_CZ.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\da_DK.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\de_DE.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\dr_ID.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\en_US.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\es_ES.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\es_LA.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\fa_IR.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\fi_FI.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\fr_FR.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\gl_ES.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\gr_EL.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\he_IL.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\hu_HU.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\id_ID.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\it_IT.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\ja_JP.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\jv_ID.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\ko_KR.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\lo_LA.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\lt-LT.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\ms_MY.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\nl_NL.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\no_NO.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\pl_PL.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\pt_BR.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\pt_PT.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\ro_RO.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\ru_RU.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\sv_SE.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\tg_PH.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\th_TH.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\tr_TR.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\uk_UA.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\vi_VN.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\zh_CN.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\lang\zh_TW.ini">
|
||||
<Filter>Content\lang</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\4xhqglsl.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\5xBR.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\5xBR-lv2.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\aacolor.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\bloom.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\cartoon.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\crt.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\defaultshaders.ini">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\fxaa.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\GaussianDownscale.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\grayscale.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\inversecolors.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\jpn0.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\kr0.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn0.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn1.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn2.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn3.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn4.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn5.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn6.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn7.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn8.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn9.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn10.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn11.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn12.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn13.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn14.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\flash0\font\ltn15.pgf">
|
||||
<Filter>Content\flash0\font</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\natural.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\naturalA.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\scanlines.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\sharpen.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\upscale_spline36.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\vignette.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
<None Include="Content\shaders\videoAA.fsh">
|
||||
<Filter>Content\shaders</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="Content\gamecontrollerdb.txt">
|
||||
<Filter>Content</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Font Include="Content\Roboto-Condensed.ttf">
|
||||
<Filter>Content</Filter>
|
||||
</Font>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+1
-1
Submodule assets/lang updated: a1993a6dd7...9d93983574.
@@ -7,6 +7,7 @@
|
||||
#include "util/text/utf8.h"
|
||||
#include "gfx_es2/draw_text.h"
|
||||
#include "gfx_es2/draw_text_win.h"
|
||||
#include "gfx_es2/draw_text_uwp.h"
|
||||
#include "gfx_es2/draw_text_qt.h"
|
||||
#include "gfx_es2/draw_text_android.h"
|
||||
|
||||
@@ -45,6 +46,8 @@ TextDrawer *TextDrawer::Create(Draw::DrawContext *draw) {
|
||||
TextDrawer *drawer = nullptr;
|
||||
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
|
||||
drawer = new TextDrawerWin32(draw);
|
||||
#elif PPSSPP_PLATFORM(UWP)
|
||||
drawer = new TextDrawerUWP(draw);
|
||||
#elif defined(USING_QT_UI)
|
||||
drawer = new TextDrawerQt(draw);
|
||||
#elif PPSSPP_PLATFORM(ANDROID)
|
||||
|
||||
@@ -0,0 +1,538 @@
|
||||
#include "base/display.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/stringutil.h"
|
||||
#include "thin3d/thin3d.h"
|
||||
#include "util/hash/hash.h"
|
||||
#include "util/text/wrap_text.h"
|
||||
#include "util/text/utf8.h"
|
||||
#include "gfx_es2/draw_text.h"
|
||||
#include "gfx_es2/draw_text_uwp.h"
|
||||
|
||||
|
||||
#if PPSSPP_PLATFORM(UWP)
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <dxgi1_3.h>
|
||||
#include <d2d1_3.h>
|
||||
#include <dwrite_3.h>
|
||||
|
||||
enum {
|
||||
MAX_TEXT_WIDTH = 4096,
|
||||
MAX_TEXT_HEIGHT = 512
|
||||
};
|
||||
|
||||
class TextDrawerFontContext {
|
||||
public:
|
||||
~TextDrawerFontContext() {
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void Create() {
|
||||
if (textFmt) {
|
||||
Destroy();
|
||||
}
|
||||
|
||||
if (factory == nullptr) return;
|
||||
|
||||
HRESULT hr = factory->CreateTextFormat(
|
||||
fname.c_str(),
|
||||
fontCollection,
|
||||
weight,
|
||||
DWRITE_FONT_STYLE_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL,
|
||||
MulDiv(height, (int)(96.0f * (1.0f / dpiScale)), 72),
|
||||
L"",
|
||||
&textFmt
|
||||
);
|
||||
}
|
||||
void Destroy() {
|
||||
textFmt->Release();
|
||||
textFmt = nullptr;
|
||||
}
|
||||
|
||||
IDWriteFactory4* factory = nullptr;
|
||||
IDWriteFontCollection1* fontCollection = nullptr;
|
||||
IDWriteTextFormat* textFmt = nullptr;
|
||||
std::wstring fname;
|
||||
int height;
|
||||
DWRITE_FONT_WEIGHT weight;
|
||||
float dpiScale;
|
||||
};
|
||||
|
||||
struct TextDrawerContext {
|
||||
ID2D1Bitmap1* bitmap;
|
||||
ID2D1Bitmap1* mirror_bmp;
|
||||
};
|
||||
|
||||
TextDrawerUWP::TextDrawerUWP(Draw::DrawContext *draw) : TextDrawer(draw), ctx_(nullptr) {
|
||||
HRESULT hr;
|
||||
// It's fine to assume we are using D3D11 in UWP
|
||||
ID3D11Device* d3ddevice = (ID3D11Device *)draw->GetNativeObject(Draw::NativeObject::DEVICE);
|
||||
|
||||
IDXGIDevice* dxgiDevice;
|
||||
hr = d3ddevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
|
||||
if (FAILED(hr)) FLOG("ID3DDevice QueryInterface IDXGIDevice failed");
|
||||
|
||||
// Initialize the Direct2D Factory.
|
||||
D2D1_FACTORY_OPTIONS options = {};
|
||||
D2D1CreateFactory(
|
||||
D2D1_FACTORY_TYPE_SINGLE_THREADED,
|
||||
__uuidof(ID2D1Factory5),
|
||||
&options,
|
||||
(void**)&m_d2dFactory
|
||||
);
|
||||
|
||||
// Initialize the DirectWrite Factory.
|
||||
DWriteCreateFactory(
|
||||
DWRITE_FACTORY_TYPE_SHARED,
|
||||
__uuidof(IDWriteFactory5),
|
||||
(IUnknown**)&m_dwriteFactory
|
||||
);
|
||||
|
||||
// Create D2D Device and DeviceContext.
|
||||
// TODO: We have one sitting right in DX::DeviceResource, there might be a way to use that instead.
|
||||
hr = m_d2dFactory->CreateDevice(dxgiDevice, &m_d2dDevice);
|
||||
if (FAILED(hr)) FLOG("D2D CreateDevice failed");
|
||||
hr = m_d2dDevice->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &m_d2dContext);
|
||||
if (FAILED(hr)) FLOG("D2D CreateDeviceContext failed");
|
||||
|
||||
// Load the Roboto font
|
||||
hr = m_dwriteFactory->CreateFontFileReference(L"Content/Roboto-Condensed.ttf", nullptr, &m_fontFile);
|
||||
if (FAILED(hr)) ELOG("CreateFontFileReference failed");
|
||||
hr = m_dwriteFactory->CreateFontSetBuilder(&m_fontSetBuilder);
|
||||
if (FAILED(hr)) ELOG("CreateFontSetBuilder failed");
|
||||
hr = m_fontSetBuilder->AddFontFile(m_fontFile);
|
||||
hr = m_fontSetBuilder->CreateFontSet(&m_fontSet);
|
||||
hr = m_dwriteFactory->CreateFontCollectionFromFontSet(m_fontSet, &m_fontCollection);
|
||||
|
||||
ctx_ = new TextDrawerContext();
|
||||
|
||||
D2D1_BITMAP_PROPERTIES1 properties;
|
||||
properties.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
properties.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
|
||||
properties.dpiX = 96.0f;
|
||||
properties.dpiY = 96.0f;
|
||||
properties.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_TARGET;
|
||||
properties.colorContext = nullptr;
|
||||
|
||||
// Create main drawing bitmap
|
||||
m_d2dContext->CreateBitmap(
|
||||
D2D1::SizeU(MAX_TEXT_WIDTH, MAX_TEXT_HEIGHT),
|
||||
nullptr,
|
||||
0,
|
||||
&properties,
|
||||
&ctx_->bitmap
|
||||
);
|
||||
m_d2dContext->SetTarget(ctx_->bitmap);
|
||||
|
||||
// Create mirror bitmap for mapping
|
||||
properties.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_CPU_READ;
|
||||
m_d2dContext->CreateBitmap(
|
||||
D2D1::SizeU(MAX_TEXT_WIDTH, MAX_TEXT_HEIGHT),
|
||||
nullptr,
|
||||
0,
|
||||
&properties,
|
||||
&ctx_->mirror_bmp
|
||||
);
|
||||
|
||||
m_d2dContext->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White, 1.0f), &m_d2dWhiteBrush);
|
||||
|
||||
}
|
||||
|
||||
TextDrawerUWP::~TextDrawerUWP() {
|
||||
ClearCache();
|
||||
|
||||
fontMap_.clear();
|
||||
|
||||
ctx_->bitmap->Release();
|
||||
ctx_->mirror_bmp->Release();
|
||||
|
||||
m_d2dWhiteBrush->Release();
|
||||
m_d2dContext->Release();
|
||||
m_d2dDevice->Release();
|
||||
m_d2dFactory->Release();
|
||||
|
||||
m_fontCollection->Release();
|
||||
m_fontSet->Release();
|
||||
m_fontFile->Release();
|
||||
m_fontSetBuilder->Release();
|
||||
m_dwriteFactory->Release();
|
||||
delete ctx_;
|
||||
}
|
||||
|
||||
uint32_t TextDrawerUWP::SetFont(const char *fontName, int size, int flags) {
|
||||
uint32_t fontHash = fontName ? hash::Adler32((const uint8_t *)fontName, strlen(fontName)) : 0;
|
||||
fontHash ^= size;
|
||||
fontHash ^= flags << 10;
|
||||
|
||||
auto iter = fontMap_.find(fontHash);
|
||||
if (iter != fontMap_.end()) {
|
||||
fontHash_ = fontHash;
|
||||
return fontHash;
|
||||
}
|
||||
|
||||
std::wstring fname;
|
||||
if (fontName)
|
||||
fname = ConvertUTF8ToWString(fontName);
|
||||
else
|
||||
fname = L"Tahoma";
|
||||
|
||||
TextDrawerFontContext *font = new TextDrawerFontContext();
|
||||
font->weight = DWRITE_FONT_WEIGHT_LIGHT;
|
||||
font->height = size;
|
||||
font->fname = fname;
|
||||
font->dpiScale = dpiScale_;
|
||||
font->factory = m_dwriteFactory;
|
||||
font->fontCollection = m_fontCollection;
|
||||
font->Create();
|
||||
|
||||
fontMap_[fontHash] = std::unique_ptr<TextDrawerFontContext>(font);
|
||||
fontHash_ = fontHash;
|
||||
return fontHash;
|
||||
}
|
||||
|
||||
void TextDrawerUWP::SetFont(uint32_t fontHandle) {
|
||||
auto iter = fontMap_.find(fontHandle);
|
||||
if (iter != fontMap_.end()) {
|
||||
fontHash_ = fontHandle;
|
||||
}
|
||||
}
|
||||
|
||||
void TextDrawerUWP::MeasureString(const char *str, size_t len, float *w, float *h) {
|
||||
CacheKey key{ std::string(str, len), fontHash_ };
|
||||
|
||||
TextMeasureEntry *entry;
|
||||
auto iter = sizeCache_.find(key);
|
||||
if (iter != sizeCache_.end()) {
|
||||
entry = iter->second.get();
|
||||
} else {
|
||||
IDWriteTextFormat* format = nullptr;
|
||||
auto iter = fontMap_.find(fontHash_);
|
||||
if (iter != fontMap_.end()) {
|
||||
format = iter->second->textFmt;
|
||||
}
|
||||
if (!format) return;
|
||||
|
||||
std::wstring wstr = ConvertUTF8ToWString(ReplaceAll(ReplaceAll(std::string(str, len), "\n", "\r\n"), "&&", "&"));
|
||||
|
||||
format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
|
||||
|
||||
IDWriteTextLayout* layout;
|
||||
m_dwriteFactory->CreateTextLayout(
|
||||
(LPWSTR)wstr.c_str(),
|
||||
(int)wstr.size(),
|
||||
format,
|
||||
MAX_TEXT_WIDTH,
|
||||
MAX_TEXT_HEIGHT,
|
||||
&layout
|
||||
);
|
||||
|
||||
DWRITE_TEXT_METRICS metrics;
|
||||
layout->GetMetrics(&metrics);
|
||||
layout->Release();
|
||||
|
||||
entry = new TextMeasureEntry();
|
||||
entry->width = metrics.width + 1;
|
||||
entry->height = metrics.height + 1;
|
||||
sizeCache_[key] = std::unique_ptr<TextMeasureEntry>(entry);
|
||||
}
|
||||
|
||||
entry->lastUsedFrame = frameCount_;
|
||||
*w = entry->width * fontScaleX_ * dpiScale_;
|
||||
*h = entry->height * fontScaleY_ * dpiScale_;
|
||||
}
|
||||
|
||||
void TextDrawerUWP::MeasureStringRect(const char *str, size_t len, const Bounds &bounds, float *w, float *h, int align) {
|
||||
|
||||
IDWriteTextFormat* format = nullptr;
|
||||
auto iter = fontMap_.find(fontHash_);
|
||||
if (iter != fontMap_.end()) {
|
||||
format = iter->second->textFmt;
|
||||
}
|
||||
if (!format) return;
|
||||
|
||||
std::string toMeasure = std::string(str, len);
|
||||
if (align & FLAG_WRAP_TEXT) {
|
||||
bool rotated = (align & (ROTATE_90DEG_LEFT | ROTATE_90DEG_RIGHT)) != 0;
|
||||
WrapString(toMeasure, toMeasure.c_str(), rotated ? bounds.h : bounds.w);
|
||||
}
|
||||
|
||||
std::vector<std::string> lines;
|
||||
SplitString(toMeasure, '\n', lines);
|
||||
float total_w = 0.0f;
|
||||
float total_h = 0.0f;
|
||||
for (size_t i = 0; i < lines.size(); i++) {
|
||||
CacheKey key{ lines[i], fontHash_ };
|
||||
|
||||
TextMeasureEntry *entry;
|
||||
auto iter = sizeCache_.find(key);
|
||||
if (iter != sizeCache_.end()) {
|
||||
entry = iter->second.get();
|
||||
} else {
|
||||
std::wstring wstr = ConvertUTF8ToWString(lines[i].length() == 0 ? " " : ReplaceAll(lines[i], "&&", "&"));
|
||||
|
||||
if (align & ALIGN_HCENTER)
|
||||
format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
|
||||
else if (align & ALIGN_LEFT)
|
||||
format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
|
||||
else if (align & ALIGN_RIGHT)
|
||||
format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING);
|
||||
|
||||
IDWriteTextLayout* layout;
|
||||
m_dwriteFactory->CreateTextLayout(
|
||||
(LPWSTR)wstr.c_str(),
|
||||
(int)wstr.size(),
|
||||
format,
|
||||
MAX_TEXT_WIDTH,
|
||||
MAX_TEXT_HEIGHT,
|
||||
&layout
|
||||
);
|
||||
|
||||
DWRITE_TEXT_METRICS metrics;
|
||||
layout->GetMetrics(&metrics);
|
||||
layout->Release();
|
||||
|
||||
entry = new TextMeasureEntry();
|
||||
entry->width = metrics.width + 1;
|
||||
entry->height = metrics.height + 1;
|
||||
sizeCache_[key] = std::unique_ptr<TextMeasureEntry>(entry);
|
||||
}
|
||||
entry->lastUsedFrame = frameCount_;
|
||||
|
||||
if (total_w < entry->width * fontScaleX_) {
|
||||
total_w = entry->width * fontScaleX_;
|
||||
}
|
||||
total_h += entry->height * fontScaleY_;
|
||||
}
|
||||
*w = total_w * dpiScale_;
|
||||
*h = total_h * dpiScale_;
|
||||
}
|
||||
|
||||
void TextDrawerUWP::DrawString(DrawBuffer &target, const char *str, float x, float y, uint32_t color, int align) {
|
||||
using namespace Draw;
|
||||
if (!strlen(str))
|
||||
return;
|
||||
|
||||
CacheKey key{ std::string(str), fontHash_ };
|
||||
|
||||
target.Flush(true);
|
||||
|
||||
TextStringEntry *entry;
|
||||
|
||||
auto iter = cache_.find(key);
|
||||
if (iter != cache_.end()) {
|
||||
entry = iter->second.get();
|
||||
entry->lastUsedFrame = frameCount_;
|
||||
}
|
||||
else {
|
||||
// Render the string to our bitmap and save to a GL texture.
|
||||
std::wstring wstr = ConvertUTF8ToWString(ReplaceAll(ReplaceAll(str, "\n", "\r\n"), "&&", "&"));
|
||||
SIZE size;
|
||||
|
||||
IDWriteTextFormat* format = nullptr;
|
||||
auto iter = fontMap_.find(fontHash_);
|
||||
if (iter != fontMap_.end()) {
|
||||
format = iter->second->textFmt;
|
||||
}
|
||||
if (!format) return;
|
||||
|
||||
if (align & ALIGN_HCENTER)
|
||||
format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
|
||||
else if (align & ALIGN_LEFT)
|
||||
format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
|
||||
else if (align & ALIGN_RIGHT)
|
||||
format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING);
|
||||
|
||||
IDWriteTextLayout* layout;
|
||||
m_dwriteFactory->CreateTextLayout(
|
||||
(LPWSTR)wstr.c_str(),
|
||||
(int)wstr.size(),
|
||||
format,
|
||||
MAX_TEXT_WIDTH,
|
||||
MAX_TEXT_HEIGHT,
|
||||
&layout
|
||||
);
|
||||
|
||||
DWRITE_TEXT_METRICS metrics;
|
||||
layout->GetMetrics(&metrics);
|
||||
|
||||
// Set the max size the same as current size, avoiding alignment issues
|
||||
layout->SetMaxHeight(metrics.height);
|
||||
layout->SetMaxWidth(metrics.width);
|
||||
|
||||
size.cx = metrics.width + 1;
|
||||
size.cy = metrics.height + 1;
|
||||
|
||||
// Prevent zero-sized textures, which can occur. Not worth to avoid
|
||||
// creating the texture altogether in this case. One example is a string
|
||||
// containing only '\r\n', see issue #10764.
|
||||
if (size.cx == 0)
|
||||
size.cx = 1;
|
||||
if (size.cy == 0)
|
||||
size.cy = 1;
|
||||
|
||||
entry = new TextStringEntry();
|
||||
entry->width = size.cx;
|
||||
entry->height = size.cy;
|
||||
entry->bmWidth = (size.cx + 3) & ~3;
|
||||
entry->bmHeight = (size.cy + 3) & ~3;
|
||||
entry->lastUsedFrame = frameCount_;
|
||||
|
||||
m_d2dContext->BeginDraw();
|
||||
m_d2dContext->Clear();
|
||||
m_d2dContext->DrawTextLayout(D2D1::Point2F(0.0f, 0.0f), layout, m_d2dWhiteBrush);
|
||||
m_d2dContext->EndDraw();
|
||||
|
||||
layout->Release();
|
||||
|
||||
D2D1_POINT_2U dstP = D2D1::Point2U(0, 0);
|
||||
D2D1_RECT_U srcR = D2D1::RectU(0, 0, entry->bmWidth, entry->bmHeight);
|
||||
D2D1_MAPPED_RECT map;
|
||||
ctx_->mirror_bmp->CopyFromBitmap(&dstP, ctx_->bitmap, &srcR);
|
||||
ctx_->mirror_bmp->Map(D2D1_MAP_OPTIONS_READ, &map);
|
||||
|
||||
DataFormat texFormat;
|
||||
// For our purposes these are equivalent, so just choose the supported one. D3D can emulate them.
|
||||
if (draw_->GetDataFormatSupport(Draw::DataFormat::A4R4G4B4_UNORM_PACK16) & FMT_TEXTURE)
|
||||
texFormat = Draw::DataFormat::A4R4G4B4_UNORM_PACK16;
|
||||
else if (draw_->GetDataFormatSupport(Draw::DataFormat::B4G4R4A4_UNORM_PACK16) & FMT_TEXTURE)
|
||||
texFormat = Draw::DataFormat::B4G4R4A4_UNORM_PACK16;
|
||||
else
|
||||
texFormat = Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
|
||||
// Convert the bitmap to a Thin3D compatible array of 16-bit pixels. Can't use a single channel format
|
||||
// because we need white. Well, we could using swizzle, but not all our backends support that.
|
||||
TextureDesc desc{};
|
||||
uint32_t *bitmapData32 = nullptr;
|
||||
uint16_t *bitmapData16 = nullptr;
|
||||
if (texFormat == Draw::DataFormat::R8G8B8A8_UNORM || texFormat == Draw::DataFormat::B8G8R8A8_UNORM) {
|
||||
bitmapData32 = new uint32_t[entry->bmWidth * entry->bmHeight];
|
||||
for (int y = 0; y < entry->bmHeight; y++) {
|
||||
for (int x = 0; x < entry->bmWidth; x++) {
|
||||
uint8_t bAlpha = (uint8_t)(map.bits[map.pitch * y + x * 4] & 0xff);
|
||||
bitmapData32[entry->bmWidth * y + x] = (bAlpha << 24) | 0x00ffffff;
|
||||
}
|
||||
}
|
||||
desc.initData.push_back((uint8_t *)bitmapData32);
|
||||
} else if (texFormat == Draw::DataFormat::B4G4R4A4_UNORM_PACK16) {
|
||||
bitmapData16 = new uint16_t[entry->bmWidth * entry->bmHeight];
|
||||
for (int y = 0; y < entry->bmHeight; y++) {
|
||||
for (int x = 0; x < entry->bmWidth; x++) {
|
||||
uint8_t bAlpha = (uint8_t)((map.bits[map.pitch * y + x * 4] & 0xff) >> 4);
|
||||
bitmapData16[entry->bmWidth * y + x] = (bAlpha) | 0xfff0;
|
||||
}
|
||||
}
|
||||
desc.initData.push_back((uint8_t *)bitmapData16);
|
||||
} else if (texFormat == Draw::DataFormat::A4R4G4B4_UNORM_PACK16) {
|
||||
bitmapData16 = new uint16_t[entry->bmWidth * entry->bmHeight];
|
||||
for (int y = 0; y < entry->bmHeight; y++) {
|
||||
for (int x = 0; x < entry->bmWidth; x++) {
|
||||
uint8_t bAlpha = (uint8_t)((map.bits[map.pitch * y + x * 4] & 0xff) >> 4);
|
||||
bitmapData16[entry->bmWidth * y + x] = (bAlpha << 12) | 0x0fff;
|
||||
}
|
||||
}
|
||||
desc.initData.push_back((uint8_t *)bitmapData16);
|
||||
}
|
||||
|
||||
ctx_->mirror_bmp->Unmap();
|
||||
|
||||
desc.type = TextureType::LINEAR2D;
|
||||
desc.format = texFormat;
|
||||
desc.width = entry->bmWidth;
|
||||
desc.height = entry->bmHeight;
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = 1;
|
||||
desc.tag = "TextDrawer";
|
||||
entry->texture = draw_->CreateTexture(desc);
|
||||
if (bitmapData16)
|
||||
delete[] bitmapData16;
|
||||
if (bitmapData32)
|
||||
delete[] bitmapData32;
|
||||
cache_[key] = std::unique_ptr<TextStringEntry>(entry);
|
||||
}
|
||||
|
||||
draw_->BindTexture(0, entry->texture);
|
||||
|
||||
// Okay, the texture is bound, let's draw.
|
||||
float w = entry->width * fontScaleX_ * dpiScale_;
|
||||
float h = entry->height * fontScaleY_ * dpiScale_;
|
||||
float u = entry->width / (float)entry->bmWidth;
|
||||
float v = entry->height / (float)entry->bmHeight;
|
||||
DrawBuffer::DoAlign(align, &x, &y, &w, &h);
|
||||
target.DrawTexRect(x, y, x + w, y + h, 0.0f, 0.0f, u, v, color);
|
||||
target.Flush(true);
|
||||
|
||||
}
|
||||
|
||||
void TextDrawerUWP::RecreateFonts() {
|
||||
for (auto& iter : fontMap_) {
|
||||
iter.second->dpiScale = dpiScale_;
|
||||
iter.second->Create();
|
||||
}
|
||||
}
|
||||
|
||||
void TextDrawerUWP::ClearCache() {
|
||||
for (auto &iter : cache_) {
|
||||
if (iter.second->texture)
|
||||
iter.second->texture->Release();
|
||||
}
|
||||
cache_.clear();
|
||||
sizeCache_.clear();
|
||||
}
|
||||
|
||||
void TextDrawerUWP::DrawStringRect(DrawBuffer &target, const char *str, const Bounds &bounds, uint32_t color, int align) {
|
||||
float x = bounds.x;
|
||||
float y = bounds.y;
|
||||
if (align & ALIGN_HCENTER) {
|
||||
x = bounds.centerX();
|
||||
} else if (align & ALIGN_RIGHT) {
|
||||
x = bounds.x2();
|
||||
}
|
||||
if (align & ALIGN_VCENTER) {
|
||||
y = bounds.centerY();
|
||||
} else if (align & ALIGN_BOTTOM) {
|
||||
y = bounds.y2();
|
||||
}
|
||||
|
||||
std::string toDraw = str;
|
||||
if (align & FLAG_WRAP_TEXT) {
|
||||
bool rotated = (align & (ROTATE_90DEG_LEFT | ROTATE_90DEG_RIGHT)) != 0;
|
||||
WrapString(toDraw, str, rotated ? bounds.h : bounds.w);
|
||||
}
|
||||
|
||||
DrawString(target, toDraw.c_str(), x, y, color, align);
|
||||
}
|
||||
|
||||
void TextDrawerUWP::OncePerFrame() {
|
||||
frameCount_++;
|
||||
// If DPI changed (small-mode, future proper monitor DPI support), drop everything.
|
||||
float newDpiScale = CalculateDPIScale();
|
||||
if (newDpiScale != dpiScale_) {
|
||||
dpiScale_ = newDpiScale;
|
||||
ClearCache();
|
||||
RecreateFonts();
|
||||
}
|
||||
|
||||
// Drop old strings. Use a prime number to reduce clashing with other rhythms
|
||||
if (frameCount_ % 23 == 0) {
|
||||
for (auto iter = cache_.begin(); iter != cache_.end();) {
|
||||
if (frameCount_ - iter->second->lastUsedFrame > 100) {
|
||||
if (iter->second->texture)
|
||||
iter->second->texture->Release();
|
||||
cache_.erase(iter++);
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto iter = sizeCache_.begin(); iter != sizeCache_.end(); ) {
|
||||
if (frameCount_ - iter->second->lastUsedFrame > 100) {
|
||||
sizeCache_.erase(iter++);
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#include <map>
|
||||
#include "gfx_es2/draw_text.h"
|
||||
|
||||
#if PPSSPP_PLATFORM(UWP)
|
||||
|
||||
#include <d2d1_3.h>
|
||||
#include <dwrite_3.h>
|
||||
|
||||
struct TextDrawerContext;
|
||||
// Internal struct but all details in .cpp file (pimpl to avoid pulling in excessive headers here)
|
||||
class TextDrawerFontContext;
|
||||
|
||||
class TextDrawerUWP : public TextDrawer {
|
||||
public:
|
||||
TextDrawerUWP(Draw::DrawContext *draw);
|
||||
~TextDrawerUWP();
|
||||
|
||||
uint32_t SetFont(const char *fontName, int size, int flags) override;
|
||||
void SetFont(uint32_t fontHandle) override; // Shortcut once you've set the font once.
|
||||
void MeasureString(const char *str, size_t len, float *w, float *h) override;
|
||||
void MeasureStringRect(const char *str, size_t len, const Bounds &bounds, float *w, float *h, int align = ALIGN_TOPLEFT) override;
|
||||
void DrawString(DrawBuffer &target, const char *str, float x, float y, uint32_t color, int align = ALIGN_TOPLEFT) override;
|
||||
void DrawStringRect(DrawBuffer &target, const char *str, const Bounds &bounds, uint32_t color, int align) override;
|
||||
// Use for housekeeping like throwing out old strings.
|
||||
void OncePerFrame() override;
|
||||
|
||||
protected:
|
||||
void ClearCache() override;
|
||||
void RecreateFonts(); // On DPI change
|
||||
|
||||
TextDrawerContext *ctx_;
|
||||
std::map<uint32_t, std::unique_ptr<TextDrawerFontContext>> fontMap_;
|
||||
|
||||
uint32_t fontHash_;
|
||||
std::map<CacheKey, std::unique_ptr<TextStringEntry>> cache_;
|
||||
std::map<CacheKey, std::unique_ptr<TextMeasureEntry>> sizeCache_;
|
||||
|
||||
|
||||
// Direct2D drawing components.
|
||||
ID2D1Factory5* m_d2dFactory;
|
||||
ID2D1Device4* m_d2dDevice;
|
||||
ID2D1DeviceContext4* m_d2dContext;
|
||||
ID2D1SolidColorBrush* m_d2dWhiteBrush;
|
||||
|
||||
// DirectWrite drawing components.
|
||||
IDWriteFactory5* m_dwriteFactory;
|
||||
IDWriteFontFile* m_fontFile;
|
||||
IDWriteFontSet* m_fontSet;
|
||||
IDWriteFontSetBuilder1* m_fontSetBuilder;
|
||||
IDWriteFontCollection1* m_fontCollection;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -85,6 +85,29 @@ else ifneq (,$(findstring rpi,$(platform)))
|
||||
PLATFORM_EXT := unix
|
||||
TARGET_ARCH = arm
|
||||
LDFLAGS += -lrt -ldl
|
||||
|
||||
# ARM64
|
||||
else ifneq (,$(findstring arm64,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro.so
|
||||
TARGET_ARCH = arm64
|
||||
fpic := -fPIC
|
||||
LDFLAGS += -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
FFMPEGINCFLAGS += -I$(FFMPEGDIR)/linux/aarch64/include
|
||||
FFMPEGLIBDIR := $(FFMPEGDIR)/linux/aarch64/lib
|
||||
FFMPEGLDFLAGS += -L$(FFMPEGLIBDIR) -lavformat -lavcodec -lavutil -lswresample -lswscale
|
||||
INCFLAGS += -I.
|
||||
HAVE_NEON=1
|
||||
ifneq (,$(findstring gles,$(platform)))
|
||||
GLES := 1
|
||||
GL_LIB := -lGLESv2 -lEGL
|
||||
LDFLAGS += -lGLESv2 -lEGL
|
||||
else
|
||||
GL_LIB := -lGL
|
||||
endif
|
||||
CPUFLAGS += -D__arm64__ -DARM64_ASM -D__NEON_OPT
|
||||
PLATCFLAGS += -DARM64
|
||||
LDFLAGS += -lrt -ldl
|
||||
PLATFORM_EXT := unix
|
||||
|
||||
# i.MX6
|
||||
else ifneq (,$(findstring imx6,$(platform)))
|
||||
|
||||
@@ -243,6 +243,7 @@ SOURCES_CXX += \
|
||||
$(EXTDIR)/glslang/SPIRV/GlslangToSpv.cpp \
|
||||
$(EXTDIR)/glslang/SPIRV/Logger.cpp \
|
||||
$(EXTDIR)/glslang/SPIRV/SpvBuilder.cpp \
|
||||
$(EXTDIR)/glslang/SPIRV/SpvPostProcess.cpp \
|
||||
$(EXTDIR)/SPIRV-Cross/spirv_cfg.cpp \
|
||||
$(EXTDIR)/SPIRV-Cross/spirv_cross.cpp \
|
||||
$(EXTDIR)/SPIRV-Cross/spirv_cross_util.cpp \
|
||||
|
||||
Reference in new issue
Block a user