From 24f25fc2f8823b1999fa66e4b21601ee4000f321 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 11 Jun 2023 14:35:13 +0800 Subject: Update Android port * java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView): Document member variables. (onDraw): Use separate Paint object on the UI thread. * src/textconv.c (really_commit_text, really_set_composing_text) (really_delete_surrounding_text): Run modification hooks when deleting text. --- java/org/gnu/emacs/EmacsSurfaceView.java | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'java') diff --git a/java/org/gnu/emacs/EmacsSurfaceView.java b/java/org/gnu/emacs/EmacsSurfaceView.java index 0deb930c2c2..738b1a99eef 100644 --- a/java/org/gnu/emacs/EmacsSurfaceView.java +++ b/java/org/gnu/emacs/EmacsSurfaceView.java @@ -38,19 +38,40 @@ import java.lang.ref.WeakReference; public final class EmacsSurfaceView extends View { private static final String TAG = "EmacsSurfaceView"; + + /* The EmacsView representing the window that this surface is + displaying. */ private EmacsView view; + + /* The complete buffer contents at the time of the last draw. */ private Bitmap frontBuffer; + + /* Canvas representing the front buffer. */ private Canvas bitmapCanvas; + + /* Reference to the last bitmap copied to the front buffer. */ private WeakReference bitmap; - private Paint bitmapPaint; + + /* Paint objects used on the main and UI threads, respectively. */ + private static final Paint bitmapPaint, uiThreadPaint; + + static + { + /* Create two different Paint objects; one is used on the main + thread for buffer swaps, while the other is used from the UI + thread in `onDraw'. This is necessary because Paint objects + are not thread-safe, even if their uses are interlocked. */ + + bitmapPaint = new Paint (); + uiThreadPaint = new Paint (); + }; public - EmacsSurfaceView (final EmacsView view) + EmacsSurfaceView (EmacsView view) { super (view.getContext ()); this.view = view; - this.bitmapPaint = new Paint (); this.bitmap = new WeakReference (null); } @@ -161,6 +182,6 @@ public final class EmacsSurfaceView extends View now. */ if (frontBuffer != null) - canvas.drawBitmap (frontBuffer, 0f, 0f, bitmapPaint); + canvas.drawBitmap (frontBuffer, 0f, 0f, uiThreadPaint); } }; -- cgit v1.2.1