mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-25 06:50:46 -08:00
Work around more problems with Bitmaps
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New function `blitRect'. * java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView): Use it on Android 8.x. * src/android.c (blitRect): Implement new function.
This commit is contained in:
parent
9a35354593
commit
7fdde02f32
3 changed files with 137 additions and 4 deletions
|
|
@ -20,6 +20,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
package org.gnu.emacs;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import android.view.inputmethod.ExtractedText;
|
||||
import android.view.inputmethod.ExtractedTextRequest;
|
||||
|
||||
|
|
@ -216,6 +219,13 @@ public final class EmacsNative
|
|||
failure. */
|
||||
public static native int[] getSelection (short window);
|
||||
|
||||
|
||||
/* Graphics functions used as a replacement for potentially buggy
|
||||
Android APIs. */
|
||||
|
||||
public static native void blitRect (Bitmap src, Bitmap dest, int x1,
|
||||
int y1, int x2, int y2);
|
||||
|
||||
static
|
||||
{
|
||||
/* Older versions of Android cannot link correctly with shared
|
||||
|
|
|
|||
|
|
@ -57,11 +57,36 @@ public final class EmacsSurfaceView extends View
|
|||
private void
|
||||
copyToFrontBuffer (Bitmap bitmap, Rect damageRect)
|
||||
{
|
||||
if (damageRect != null)
|
||||
bitmapCanvas.drawBitmap (bitmap, damageRect, damageRect,
|
||||
bitmapPaint);
|
||||
EmacsService.checkEmacsThread ();
|
||||
|
||||
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O
|
||||
&& Build.VERSION.SDK_INT != Build.VERSION_CODES.O_MR1)
|
||||
{
|
||||
/* If `drawBitmap' can safely be used while a bitmap is locked
|
||||
by another thread, continue here... */
|
||||
|
||||
if (damageRect != null)
|
||||
bitmapCanvas.drawBitmap (bitmap, damageRect, damageRect,
|
||||
bitmapPaint);
|
||||
else
|
||||
bitmapCanvas.drawBitmap (bitmap, 0f, 0f, bitmapPaint);
|
||||
}
|
||||
else
|
||||
bitmapCanvas.drawBitmap (bitmap, 0f, 0f, bitmapPaint);
|
||||
{
|
||||
/* But if it can not, as on Android 8.0 and 8.1, then use a
|
||||
replacement function. */
|
||||
|
||||
if (damageRect != null)
|
||||
EmacsNative.blitRect (bitmap, frontBuffer,
|
||||
damageRect.left,
|
||||
damageRect.top,
|
||||
damageRect.right,
|
||||
damageRect.bottom);
|
||||
else
|
||||
EmacsNative.blitRect (bitmap, frontBuffer, 0, 0,
|
||||
bitmap.getWidth (),
|
||||
bitmap.getHeight ());
|
||||
}
|
||||
}
|
||||
|
||||
private void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue