* doc/emacs/android.texi (Android Fonts): Document that TTC format fonts are now supported. * doc/emacs/emacs.texi (Top): Fix menus. * doc/lispref/commands.texi (Touchscreen Events) (Key Sequence Input): Document changes to touchscreen events. * etc/DEBUG: Describe how to debug 64 bit binaries on Android. * java/org/gnu/emacs/EmacsCopyArea.java (perform): Explicitly recycle copy bitmap. * java/org/gnu/emacs/EmacsDialog.java (EmacsDialog): New class. * java/org/gnu/emacs/EmacsDrawRectangle.java (perform): Use 5 point PolyLine like X, because Android behaves like Postscript on some devices and X elsewhere. * java/org/gnu/emacs/EmacsFillRectangle.java (perform): Explicitly recycle copy bitmap. * java/org/gnu/emacs/EmacsPixmap.java (destroyHandle): Explicitly recycle bitmap and GC if it is big. * java/org/gnu/emacs/EmacsView.java (EmacsView): Make `bitmapDirty' a boolean. (handleDirtyBitmap): Reimplement in terms of that boolean. Explicitly recycle old bitmap and GC. (onLayout): Fix lock up. (onDetachedFromWindow): Recycle bitmap and GC. * java/org/gnu/emacs/EmacsWindow.java (requestViewLayout): Update call to explicitlyDirtyBitmap. * src/android.c (android_run_select_thread, android_select): Really fix android_select. (android_build_jstring): New function. * src/android.h: Update prototypes. * src/androidmenu.c (android_process_events_for_menu): Totally unblock input before process_pending_signals. (android_menu_show): Remove redundant unblock_input and debugging code. (struct android_emacs_dialog, android_init_emacs_dialog) (android_dialog_show, android_popup_dialog, init_androidmenu): Implement popup dialogs on Android. * src/androidterm.c (android_update_tools) (handle_one_android_event, android_frame_up_to_date): Allow tapping tool bar items. (android_create_terminal): Add dialog hook. (android_wait_for_event): Adjust call to android_select. * src/androidterm.h (struct android_touch_point): New field `tool_bar_p'. * src/keyboard.c (read_key_sequence, head_table) (syms_of_keyboard): Prefix touchscreen events with posn. * src/keyboard.h (EVENT_HEAD): Handle touchscreen events. * src/process.c (wait_reading_process_output): Adjust call to android_select. * src/sfnt.c (sfnt_read_table_directory): If the first long turns out to be ttcf, return -1. (sfnt_read_ttc_header): New function. (main): Test TTC support. * src/sfnt.h (struct sfnt_ttc_header): New structure. (enum sfnt_ttc_tag): New enum. * src/sfntfont-android.c (struct sfntfont_android_scanline_buffer): New structure. (GET_SCANLINE_BUFFER): New macro. Try to avoid so much malloc upon accessing the scanline buffer. (sfntfont_android_put_glyphs): Do not use SAFE_ALLOCA to allocate the scaline buffer. (Fandroid_enumerate_fonts): Enumerate ttc fonts too. * src/sfntfont.c (struct sfnt_font_desc): New field `offset'. (sfnt_enum_font_1): Split out enumeration code from sfnt_enum_font. (sfnt_enum_font): Read TTC tables and enumerate each font therein. (sfntfont_open): Seek to the offset specified. * xcompile/Makefile.in (maintainer-clean): Fix depends here.
149 lines
3.3 KiB
Java
149 lines
3.3 KiB
Java
/* Communication module for Android terminals. -*- c-file-style: "GNU" -*-
|
|
|
|
Copyright (C) 2023 Free Software Foundation, Inc.
|
|
|
|
This file is part of GNU Emacs.
|
|
|
|
GNU Emacs is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or (at
|
|
your option) any later version.
|
|
|
|
GNU Emacs is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
package org.gnu.emacs;
|
|
|
|
import java.lang.IllegalArgumentException;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Rect;
|
|
|
|
import android.os.Build;
|
|
|
|
/* Drawable backed by bitmap. */
|
|
|
|
public class EmacsPixmap extends EmacsHandleObject
|
|
implements EmacsDrawable
|
|
{
|
|
/* The depth of the bitmap. This is not actually used, just defined
|
|
in order to be consistent with X. */
|
|
public int depth, width, height;
|
|
|
|
/* The bitmap itself. */
|
|
public Bitmap bitmap;
|
|
|
|
/* The canvas used to draw to BITMAP. */
|
|
public Canvas canvas;
|
|
|
|
public
|
|
EmacsPixmap (short handle, int colors[], int width,
|
|
int height, int depth)
|
|
{
|
|
super (handle);
|
|
|
|
if (depth != 1 && depth != 24)
|
|
throw new IllegalArgumentException ("Invalid depth specified"
|
|
+ " for pixmap: " + depth);
|
|
|
|
switch (depth)
|
|
{
|
|
case 1:
|
|
bitmap = Bitmap.createBitmap (colors, width, height,
|
|
Bitmap.Config.ALPHA_8);
|
|
break;
|
|
|
|
case 24:
|
|
bitmap = Bitmap.createBitmap (colors, width, height,
|
|
Bitmap.Config.ARGB_8888);
|
|
bitmap.setHasAlpha (false);
|
|
break;
|
|
}
|
|
|
|
this.width = width;
|
|
this.height = height;
|
|
this.depth = depth;
|
|
}
|
|
|
|
public
|
|
EmacsPixmap (short handle, int width, int height, int depth)
|
|
{
|
|
super (handle);
|
|
|
|
if (depth != 1 && depth != 24)
|
|
throw new IllegalArgumentException ("Invalid depth specified"
|
|
+ " for pixmap: " + depth);
|
|
|
|
switch (depth)
|
|
{
|
|
case 1:
|
|
bitmap = Bitmap.createBitmap (width, height,
|
|
Bitmap.Config.ALPHA_8,
|
|
false);
|
|
break;
|
|
|
|
case 24:
|
|
bitmap = Bitmap.createBitmap (width, height,
|
|
Bitmap.Config.ARGB_8888,
|
|
false);
|
|
break;
|
|
}
|
|
|
|
bitmap.eraseColor (0xff000000);
|
|
|
|
this.width = width;
|
|
this.height = height;
|
|
this.depth = depth;
|
|
}
|
|
|
|
@Override
|
|
public Canvas
|
|
lockCanvas ()
|
|
{
|
|
if (canvas == null)
|
|
canvas = new Canvas (bitmap);
|
|
|
|
return canvas;
|
|
}
|
|
|
|
@Override
|
|
public void
|
|
damageRect (Rect damageRect)
|
|
{
|
|
|
|
}
|
|
|
|
@Override
|
|
public Bitmap
|
|
getBitmap ()
|
|
{
|
|
return bitmap;
|
|
}
|
|
|
|
@Override
|
|
public void
|
|
destroyHandle ()
|
|
{
|
|
boolean needCollect;
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
|
|
needCollect = (bitmap.getByteCount ()
|
|
>= 1024 * 512);
|
|
else
|
|
needCollect = (bitmap.getAllocationByteCount ()
|
|
>= 1024 * 512);
|
|
|
|
bitmap.recycle ();
|
|
bitmap = null;
|
|
|
|
/* Collect the bitmap storage if the bitmap is big. */
|
|
if (needCollect)
|
|
Runtime.getRuntime ().gc ();
|
|
}
|
|
};
|