mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-15 11:21:19 -07:00
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.
This commit is contained in:
parent
d3e95fcae9
commit
b84fa71f89
7 changed files with 62 additions and 374 deletions
|
|
@ -21,6 +21,8 @@ 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;
|
||||
|
||||
|
|
@ -28,30 +30,42 @@ 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 maskPaint, paint;
|
||||
Canvas maskCanvas;
|
||||
Bitmap maskBitmap;
|
||||
Paint paint;
|
||||
Rect rect;
|
||||
Rect maskRect, dstRect;
|
||||
Canvas canvas;
|
||||
Bitmap clipBitmap;
|
||||
Bitmap invertBitmap;
|
||||
|
||||
canvas = drawable.lockCanvas (gc);
|
||||
|
||||
if (canvas == null)
|
||||
/* 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);
|
||||
|
||||
paint = gc.gcPaint;
|
||||
paint.setStyle (Paint.Style.FILL);
|
||||
|
||||
if (gc.clip_mask == null)
|
||||
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
|
||||
|
|
@ -59,57 +73,17 @@ public final class EmacsFillRectangle
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Drawing with a clip mask involves calculating the
|
||||
intersection of the clip mask with the dst rect, and
|
||||
extrapolating the corresponding part of the src rect. */
|
||||
paint = new Paint ();
|
||||
|
||||
clipBitmap = gc.clip_mask.bitmap;
|
||||
dstRect = new Rect (x, y, x + width, y + height);
|
||||
maskRect = new Rect (gc.clip_x_origin,
|
||||
gc.clip_y_origin,
|
||||
(gc.clip_x_origin
|
||||
+ clipBitmap.getWidth ()),
|
||||
(gc.clip_y_origin
|
||||
+ clipBitmap.getHeight ()));
|
||||
|
||||
if (!maskRect.setIntersect (dstRect, maskRect))
|
||||
/* There is no intersection between the clip mask and the
|
||||
dest rect. */
|
||||
return;
|
||||
|
||||
/* Finally, create a temporary bitmap that is the size of
|
||||
maskRect. */
|
||||
|
||||
maskBitmap
|
||||
= Bitmap.createBitmap (maskRect.width (), maskRect.height (),
|
||||
Bitmap.Config.ARGB_8888);
|
||||
|
||||
/* Draw the mask onto the maskBitmap. */
|
||||
maskCanvas = new Canvas (maskBitmap);
|
||||
maskRect.offset (-gc.clip_x_origin,
|
||||
-gc.clip_y_origin);
|
||||
maskCanvas.drawBitmap (gc.clip_mask.bitmap,
|
||||
maskRect, new Rect (0, 0,
|
||||
maskRect.width (),
|
||||
maskRect.height ()),
|
||||
paint);
|
||||
maskRect.offset (gc.clip_x_origin,
|
||||
gc.clip_y_origin);
|
||||
|
||||
/* Set the transfer mode to SRC_IN to preserve only the parts
|
||||
of the source that overlap with the mask. */
|
||||
maskPaint = new Paint ();
|
||||
maskPaint.setXfermode (EmacsGC.srcInAlu);
|
||||
|
||||
/* Draw the source. */
|
||||
maskCanvas.drawRect (maskRect, maskPaint);
|
||||
|
||||
/* Finally, draw the mask bitmap to the destination. */
|
||||
paint.setXfermode (null);
|
||||
canvas.drawBitmap (maskBitmap, null, maskRect, paint);
|
||||
|
||||
/* Recycle this unused bitmap. */
|
||||
maskBitmap.recycle ();
|
||||
/* 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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue