1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-13 06:50:39 -08:00

Optimize stipples on Android

* java/org/gnu/emacs/EmacsGC.java (EmacsGC) <tileObject>:
Change type to EmacsTileObject.
(markDirty): Create an EmacsTileObject rather than a
BitmapDrawable.

* java/org/gnu/emacs/EmacsTileObject.java: New file,
significantly leaner than BitmapDrawable.
This commit is contained in:
Po Lu 2024-05-06 12:09:21 +08:00
parent f920959ac9
commit 2f36fc1b4f
2 changed files with 105 additions and 11 deletions

View file

@ -29,8 +29,6 @@ import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
/* X like graphics context structures. Keep the enums in synch with
@ -58,7 +56,7 @@ public final class EmacsGC extends EmacsHandleObject
public Paint gcPaint;
/* Drawable object for rendering the stiple bitmap. */
public BitmapDrawable tileObject;
public EmacsTileObject tileObject;
/* ID incremented every time the clipping rectangles of any GC
changes. */
@ -132,11 +130,9 @@ public final class EmacsGC extends EmacsHandleObject
/* Allocate a new tile object if none is already present or it
cannot be reconfigured. */
if ((tileObject == null)
|| (Build.VERSION.SDK_INT < Build.VERSION_CODES.S))
if (tileObject == null)
{
tileObject = new BitmapDrawable (EmacsService.resources,
stippleBitmap);
tileObject = new EmacsTileObject (stippleBitmap);
tileObject.setTileModeXY (TileMode.REPEAT, TileMode.REPEAT);
}
else
@ -144,11 +140,8 @@ public final class EmacsGC extends EmacsHandleObject
bitmap. */
tileObject.setBitmap (stippleBitmap);
}
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
&& tileObject != null)
tileObject.setBitmap (null);
else if (tileObject != null)
tileObject = null;
tileObject.setBitmap (null);
}
/* Prepare the tile object to draw a stippled image onto a section of