1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-05 03:20:39 -08:00
emacs/java/org/gnu/emacs/EmacsFillRectangle.java
Po Lu b84fa71f89 Port visible bell to Android
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform): Ignore
GC_INVERT.

* java/org/gnu/emacs/EmacsFillRectangle.java
(EmacsFillRectangle) <invertFilter>: New variable.
(perform): If the transfer mode is invert, copy the source
to itself with invertFilter as the color filter.

* java/org/gnu/emacs/EmacsGC.java (EmacsGC) <xorAlu, srcInAlu>:
Delete now-redundant ALUs.
(markDirty): Cease updating the paint's transfermode.

* java/org/gnu/emacs/EmacsSafThread.java (openDocument1): Fix
typo in documentation.

* src/android.c (android_blit_xor): Delete unused function.
(android_copy_area): Remove calls to unused blit functions.

* src/androidgui.h (enum android_gc_function): Rename XOR to
INVERT.

* src/androidterm.c (android_flash): Replace with GXinvert.
2024-05-02 11:31:37 +08:00

91 lines
2.5 KiB
Java

/* Communication module for Android terminals. -*- c-file-style: "GNU" -*-
Copyright (C) 2023-2024 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 android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.Log;
public final class EmacsFillRectangle
{
/* Color filter that inverts colors from the source. */
private static final ColorFilter invertFilter;
static
{
invertFilter = new ColorMatrixColorFilter (new float[] {
-1f, 0f, 0f, 0f, 255f,
0f, -1f, 0f, 0f, 255f,
0f, 0f, -1f, 0f, 255f,
0f, 0f, 0f, 1f, 0f,
});
};
public static void
perform (EmacsDrawable drawable, EmacsGC gc,
int x, int y, int width, int height)
{
Paint paint;
Rect rect;
Canvas canvas;
Bitmap invertBitmap;
canvas = drawable.lockCanvas (gc);
/* Clip masks are not respected or implemented when specified with
this request. */
if (canvas == null || gc.clip_mask != null)
return;
rect = new Rect (x, y, x + width, y + height);
if (gc.function != EmacsGC.GC_INVERT)
{
paint = gc.gcPaint;
paint.setStyle (Paint.Style.FILL);
if (gc.fill_style != EmacsGC.GC_FILL_OPAQUE_STIPPLED)
canvas.drawRect (rect, paint);
else
gc.blitOpaqueStipple (canvas, rect);
}
else
{
paint = new Paint ();
/* Simply invert the destination, which is only implemented for
this request. As Android doesn't permit copying a bitmap to
itself, a copy of the source must be procured beforehand. */
invertBitmap = Bitmap.createBitmap (drawable.getBitmap (),
x, y, width, height);
paint.setColorFilter (invertFilter);
canvas.drawBitmap (invertBitmap, null, rect, paint);
paint.setColorFilter (null);
invertBitmap.recycle ();
}
drawable.damageRect (rect);
}
};