diff options
| author | Po Lu <luangruo@yahoo.com> | 2023-06-11 14:35:13 +0800 |
|---|---|---|
| committer | Po Lu <luangruo@yahoo.com> | 2023-06-11 14:35:13 +0800 |
| commit | 24f25fc2f8823b1999fa66e4b21601ee4000f321 (patch) | |
| tree | 73ffc3c062c2c8899b86d2973a5c985a83044084 /java/org/gnu/emacs/EmacsSurfaceView.java | |
| parent | 5abc977bbb2d38f3c607f1575e02aa7a6c483db0 (diff) | |
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.
Diffstat (limited to 'java/org/gnu/emacs/EmacsSurfaceView.java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsSurfaceView.java | 29 |
1 files changed, 25 insertions, 4 deletions
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> 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<Bitmap> (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); } }; |
