1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-27 07:41:28 -08:00

Disable hardware acceleration on Android

It serves no purpose and causes tearing.  Uploading the bitmap
to the GPU takes about as long as it does to incrementally
update the surface in software.

* java/AndroidManifest.xml.in: Disable hardware acceleration.
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): Make
lastClosedMenu static.
* java/org/gnu/emacs/EmacsDialog.java (toAlertDialog): Enable
hardware acceleration within alert dialogs.
* java/org/gnu/emacs/EmacsSurfaceView.java (onDraw): Describe
why hardware acceleration is disabled.
* java/org/gnu/emacs/EmacsWindow.java (run): Remove redundant
call.
This commit is contained in:
Po Lu 2023-07-13 12:05:50 +08:00
parent 4e2fda28ed
commit 140755f2cf
5 changed files with 39 additions and 4 deletions

View file

@ -176,7 +176,25 @@ public final class EmacsSurfaceView extends View
onDraw (Canvas canvas)
{
/* Paint the view's bitmap; the bitmap might be recycled right
now. */
now.
Hardware acceleration is disabled in AndroidManifest.xml to
prevent Android from uploading the front buffer to the GPU from
a separate thread. This is important for two reasons: first,
the GPU command queue uses a massive amount of memory (dozens
of MiB) to upload bitmaps to the GPU, regardless of how much of
the bitmap has actually changed.
Secondly, asynchronous texturization leads to race conditions
when a buffer swap occurs before the front buffer is fully
uploaded to the GPU. Normally, only slight and tolerable
tearing should result from this behavior, but Android does not
properly interlock the ``generation ID'' used to avoid
texturizing unchanged bitmaps with the bitmap contents,
consequentially leading to textures in an incomplete state
remaining in use to the GPU if a buffer swap happens between
the image data being uploaded and the ``generation ID'' being
read. */
if (frontBuffer != null)
canvas.drawBitmap (frontBuffer, 0f, 0f, uiThreadPaint);