diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsNative.java | 10 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsSurfaceView.java | 33 |
2 files changed, 39 insertions, 4 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java index e699dda9ad4..56c03ee38dc 100644 --- a/java/org/gnu/emacs/EmacsNative.java +++ b/java/org/gnu/emacs/EmacsNative.java | |||
| @@ -20,6 +20,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 20 | package org.gnu.emacs; | 20 | package org.gnu.emacs; |
| 21 | 21 | ||
| 22 | import android.content.res.AssetManager; | 22 | import android.content.res.AssetManager; |
| 23 | |||
| 24 | import android.graphics.Bitmap; | ||
| 25 | |||
| 23 | import android.view.inputmethod.ExtractedText; | 26 | import android.view.inputmethod.ExtractedText; |
| 24 | import android.view.inputmethod.ExtractedTextRequest; | 27 | import android.view.inputmethod.ExtractedTextRequest; |
| 25 | 28 | ||
| @@ -216,6 +219,13 @@ public final class EmacsNative | |||
| 216 | failure. */ | 219 | failure. */ |
| 217 | public static native int[] getSelection (short window); | 220 | public static native int[] getSelection (short window); |
| 218 | 221 | ||
| 222 | |||
| 223 | /* Graphics functions used as a replacement for potentially buggy | ||
| 224 | Android APIs. */ | ||
| 225 | |||
| 226 | public static native void blitRect (Bitmap src, Bitmap dest, int x1, | ||
| 227 | int y1, int x2, int y2); | ||
| 228 | |||
| 219 | static | 229 | static |
| 220 | { | 230 | { |
| 221 | /* Older versions of Android cannot link correctly with shared | 231 | /* Older versions of Android cannot link correctly with shared |
diff --git a/java/org/gnu/emacs/EmacsSurfaceView.java b/java/org/gnu/emacs/EmacsSurfaceView.java index e0411f7f8b3..0deb930c2c2 100644 --- a/java/org/gnu/emacs/EmacsSurfaceView.java +++ b/java/org/gnu/emacs/EmacsSurfaceView.java | |||
| @@ -57,11 +57,36 @@ public final class EmacsSurfaceView extends View | |||
| 57 | private void | 57 | private void |
| 58 | copyToFrontBuffer (Bitmap bitmap, Rect damageRect) | 58 | copyToFrontBuffer (Bitmap bitmap, Rect damageRect) |
| 59 | { | 59 | { |
| 60 | if (damageRect != null) | 60 | EmacsService.checkEmacsThread (); |
| 61 | bitmapCanvas.drawBitmap (bitmap, damageRect, damageRect, | 61 | |
| 62 | bitmapPaint); | 62 | if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O |
| 63 | && Build.VERSION.SDK_INT != Build.VERSION_CODES.O_MR1) | ||
| 64 | { | ||
| 65 | /* If `drawBitmap' can safely be used while a bitmap is locked | ||
| 66 | by another thread, continue here... */ | ||
| 67 | |||
| 68 | if (damageRect != null) | ||
| 69 | bitmapCanvas.drawBitmap (bitmap, damageRect, damageRect, | ||
| 70 | bitmapPaint); | ||
| 71 | else | ||
| 72 | bitmapCanvas.drawBitmap (bitmap, 0f, 0f, bitmapPaint); | ||
| 73 | } | ||
| 63 | else | 74 | else |
| 64 | bitmapCanvas.drawBitmap (bitmap, 0f, 0f, bitmapPaint); | 75 | { |
| 76 | /* But if it can not, as on Android 8.0 and 8.1, then use a | ||
| 77 | replacement function. */ | ||
| 78 | |||
| 79 | if (damageRect != null) | ||
| 80 | EmacsNative.blitRect (bitmap, frontBuffer, | ||
| 81 | damageRect.left, | ||
| 82 | damageRect.top, | ||
| 83 | damageRect.right, | ||
| 84 | damageRect.bottom); | ||
| 85 | else | ||
| 86 | EmacsNative.blitRect (bitmap, frontBuffer, 0, 0, | ||
| 87 | bitmap.getWidth (), | ||
| 88 | bitmap.getHeight ()); | ||
| 89 | } | ||
| 65 | } | 90 | } |
| 66 | 91 | ||
| 67 | private void | 92 | private void |