Permalink
Browse files

Merge pull request #11336 from hrydgard/android-text-crash-fix

Set a minimum of 1x1 for Android text bitmap measurement.
  • Loading branch information...
unknownbrackets committed Aug 30, 2018
2 parents 19dd285 + 8e6a1bc commit 557748d65b41e48e4be6f4c9c122fb3de38495e9
Showing with 7 additions and 6 deletions.
  1. +6 −4 android/src/org/ppsspp/ppsspp/TextRenderer.java
  2. +1 −2 ext/native/thin3d/thin3d_vulkan.cpp
@@ -54,6 +54,12 @@ private static Point measure(String string, double textSize) {
total.x = Math.max(sz.x, total.x);
}
total.y = (int) (p.descent() - p.ascent()) * lines.length + 2;
// Returning a 0 size can create problems when the caller
// uses the measurement to create a texture.
if (total.x < 1)
total.x = 1;
if (total.y < 1)
total.y = 1;
return total;
}
@@ -67,10 +73,6 @@ public static int measureText(String string, double textSize) {
int w = s.x;
int h = s.y;
if (w == 0)
w = 1;
if (h == 0)
h = 1;
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
@@ -1078,12 +1078,11 @@ InputLayout *VKContext::CreateInputLayout(const InputLayoutDesc &desc) {
}
Texture *VKContext::CreateTexture(const TextureDesc &desc) {
if (!push_) {
if (!push_ || !renderManager_.GetInitCmd()) {
// Too early! Fail.
ELOG("Can't create textures before the first frame has started.");
return nullptr;
}
_assert_(renderManager_.GetInitCmd());
return new VKTexture(vulkan_, renderManager_.GetInitCmd(), push_, desc, allocator_);
}

0 comments on commit 557748d

Please sign in to comment.