Skip to content

Commit

Permalink
Set a minimum of 1x1 for Android text bitmap measurement.
Browse files Browse the repository at this point in the history
Should fix some crashes seen on Google Play
  • Loading branch information
hrydgard committed Aug 30, 2018
1 parent 773dba1 commit 8e6a1bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions android/src/org/ppsspp/ppsspp/TextRenderer.java
Expand Up @@ -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;
}

Expand All @@ -67,10 +73,6 @@ public static int[] renderText(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);
Expand Down
3 changes: 1 addition & 2 deletions ext/native/thin3d/thin3d_vulkan.cpp
Expand Up @@ -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_);
}

Expand Down

0 comments on commit 8e6a1bc

Please sign in to comment.