1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-02 21:52:04 -08:00

Update Android port

* doc/emacs/android.texi (Android Windowing): Remove yet another
limitation.
* java/debug.sh: Make this work on systems which prohibit
attaching to app processes from adbd.
* java/org/gnu/emacs/EmacsCopyArea.java (perform): Avoid
creating copies whenever possible.
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
Remove SurfaceView based implementation and use manual double
buffering with invalidate instead.
* java/org/gnu/emacs/EmacsView.java (EmacsView, handleDirtyBitmap)
(raise, lower, onDetachedFromWindow): Adjust accordingly.
* java/org/gnu/emacs/EmacsWindow.java (windowUpdated): Remove
function.
* src/sfntfont.c (sfntfont_open): Set font->max_width correctly.
This commit is contained in:
Po Lu 2023-02-10 18:57:51 +08:00
parent 60270d8ee3
commit a1941cd7a7
7 changed files with 120 additions and 209 deletions

View file

@ -103,14 +103,6 @@ public class EmacsView extends ViewGroup
displayed whenever possible. */
public boolean isCurrentlyTextEditor;
/* An empty rectangle. */
public static final Rect emptyRect;
static
{
emptyRect = new Rect ();
};
public
EmacsView (EmacsWindow window)
{
@ -127,14 +119,8 @@ public class EmacsView extends ViewGroup
/* Create the surface view. */
this.surfaceView = new EmacsSurfaceView (this);
this.surfaceView.setZOrderMediaOverlay (true);
addView (this.surfaceView);
/* Not sure exactly what this does but it makes things magically
work. Why is something as simple as XRaiseWindow so involved
on Android? */
setChildrenDrawingOrderEnabled (true);
/* Get rid of the default focus highlight. */
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O)
setDefaultFocusHighlightEnabled (false);
@ -191,8 +177,12 @@ public class EmacsView extends ViewGroup
bitmapDirty = false;
/* Explicitly free the old bitmap's memory. */
if (oldBitmap != null)
oldBitmap.recycle ();
{
oldBitmap.recycle ();
surfaceView.setBitmap (null, null);
}
/* Some Android versions still don't free the bitmap until the
next GC. */
@ -342,67 +332,27 @@ public class EmacsView extends ViewGroup
thread. */
public void
swapBuffers (boolean force)
swapBuffers ()
{
Canvas canvas;
Rect damageRect;
Bitmap bitmap;
/* Code must always take damageRegion, and then surfaceChangeLock,
never the other way around! */
damageRect = null;
synchronized (damageRegion)
{
if (!force && damageRegion.isEmpty ())
if (damageRegion.isEmpty ())
return;
bitmap = getBitmap ();
/* Emacs must take the following lock to ensure the access to the
canvas occurs with the surface created. Otherwise, Android
will throttle calls to lockCanvas. */
synchronized (surfaceView.surfaceChangeLock)
{
if (!force)
damageRect = damageRegion.getBounds ();
else
damageRect = emptyRect;
if (!surfaceView.isCreated ())
return;
if (bitmap == null)
return;
/* Lock the canvas with the specified damage. */
canvas = surfaceView.lockCanvas (damageRect);
/* Return if locking the canvas failed. */
if (canvas == null)
return;
/* Copy from the back buffer to the canvas. If damageRect was
made empty, then draw the entire back buffer. */
if (damageRect.isEmpty ())
canvas.drawBitmap (bitmap, 0f, 0f, paint);
else
canvas.drawBitmap (bitmap, damageRect, damageRect, paint);
/* Unlock the canvas and clear the damage. */
surfaceView.unlockCanvasAndPost (canvas);
damageRegion.setEmpty ();
}
/* Transfer the bitmap to the surface view, then invalidate
it. */
surfaceView.setBitmap (bitmap, damageRect);
}
}
public void
swapBuffers ()
{
swapBuffers (false);
}
@Override
public boolean
onKeyDown (int keyCode, KeyEvent event)
@ -486,16 +436,6 @@ public class EmacsView extends ViewGroup
return;
parent.bringChildToFront (this);
/* Yes, all of this is really necessary! */
parent.requestLayout ();
parent.invalidate ();
requestLayout ();
invalidate ();
/* The surface view must be destroyed and recreated. */
removeView (surfaceView);
addView (surfaceView, 0);
}
public void
@ -511,16 +451,6 @@ public class EmacsView extends ViewGroup
return;
parent.moveChildToBack (this);
/* Yes, all of this is really necessary! */
parent.requestLayout ();
parent.invalidate ();
requestLayout ();
invalidate ();
/* The surface view must be removed and attached again. */
removeView (surfaceView);
addView (surfaceView, 0);
}
@Override
@ -574,6 +504,7 @@ public class EmacsView extends ViewGroup
bitmap.recycle ();
bitmap = null;
canvas = null;
surfaceView.setBitmap (null, null);
/* Collect the bitmap storage; it could be large. */
Runtime.getRuntime ().gc ();