summaryrefslogtreecommitdiff
path: root/java/org/gnu/emacs/EmacsService.java
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-01-08 15:39:02 +0800
committerPo Lu <luangruo@yahoo.com>2023-01-08 15:39:02 +0800
commit695e26079eb60d10ffe25bb8ae91ebc6131fb27d (patch)
treebc18692c1e4c0f5aa3e6707850f4c2023bc75e81 /java/org/gnu/emacs/EmacsService.java
parente816e570393a964383e8b42330f5582c4c0a54f2 (diff)
Update Java part of Android port
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea, perform) (paintTo): * java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine): * java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint): * java/org/gnu/emacs/EmacsDrawRectangle.java (EmacsDrawRectangle) (paintTo): * java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable): * java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon): * java/org/gnu/emacs/EmacsFillRectangle.java (EmacsFillRectangle): * java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver): * java/org/gnu/emacs/EmacsGC.java (EmacsGC): * java/org/gnu/emacs/EmacsNative.java (EmacsNative): * java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap): * java/org/gnu/emacs/EmacsSdk23FontDriver.java (EmacsSdk23FontDriver): * java/org/gnu/emacs/EmacsSdk7FontDriver.java (EmacsSdk7FontDriver, textExtents1, textExtents, draw): * java/org/gnu/emacs/EmacsService.java (EmacsService, copyArea): * java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView): * java/org/gnu/emacs/EmacsView.java (EmacsView, onLayout) (onFocusChanged): * java/org/gnu/emacs/EmacsWindow.java (EmacsWindow, run) (resizeWindow, lockCanvas, getBitmap, onKeyDown, onKeyUp) (onActivityDetached): Move rendering to main thread. Make drawing operations completely static.
Diffstat (limited to 'java/org/gnu/emacs/EmacsService.java')
-rw-r--r--java/org/gnu/emacs/EmacsService.java122
1 files changed, 11 insertions, 111 deletions
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index 41a45b0bd85..4444b7f1c56 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
package org.gnu.emacs;
-import java.lang.Runnable;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
@@ -59,7 +58,6 @@ public class EmacsService extends Service
private EmacsThread thread;
private Handler handler;
- private EmacsPaintQueue paintQueue;
/* Display metrics used by font backends. */
public DisplayMetrics metrics;
@@ -191,126 +189,42 @@ public class EmacsService extends Service
return view.thing;
}
- /* X drawing operations. These are quite primitive operations. The
- drawing queue is kept on the Emacs thread, but is periodically
- flushed to the application thread, upon buffers swaps and once it
- gets too big. */
-
-
-
- private void
- ensurePaintQueue ()
- {
- if (paintQueue == null)
- paintQueue = new EmacsPaintQueue ();
- }
-
- public void
- flushPaintQueue ()
- {
- final EmacsPaintQueue queue;
-
- if (paintQueue == null)
- return;
-
- if (paintQueue.numRequests < 1)
- /* No requests to flush. */
- return;
-
- queue = paintQueue;
-
- handler.post (new Runnable () {
- @Override
- public void
- run ()
- {
- queue.run ();
- }
- });
-
- /* Clear the paint queue. */
- paintQueue = null;
- }
-
- private void
- checkFlush ()
- {
- if (paintQueue != null
- && paintQueue.numRequests > MAX_PENDING_REQUESTS)
- flushPaintQueue ();
- }
-
public void
fillRectangle (EmacsDrawable drawable, EmacsGC gc,
int x, int y, int width, int height)
{
- EmacsPaintReq req;
-
- ensurePaintQueue ();
-
- req = new EmacsFillRectangle (drawable, x, y,
- width, height,
- gc.immutableGC ());
- paintQueue.appendPaintOperation (req);
- checkFlush ();
+ EmacsFillRectangle.perform (drawable, gc, x, y,
+ width, height);
}
public void
fillPolygon (EmacsDrawable drawable, EmacsGC gc,
Point points[])
{
- EmacsPaintReq req;
-
- ensurePaintQueue ();
-
- req = new EmacsFillPolygon (drawable, points,
- gc.immutableGC ());
- paintQueue.appendPaintOperation (req);
- checkFlush ();
+ EmacsFillPolygon.perform (drawable, gc, points);
}
public void
drawRectangle (EmacsDrawable drawable, EmacsGC gc,
int x, int y, int width, int height)
{
- EmacsPaintReq req;
-
- ensurePaintQueue ();
-
- req = new EmacsDrawRectangle (drawable, x, y,
- width, height,
- gc.immutableGC ());
- paintQueue.appendPaintOperation (req);
- checkFlush ();
+ EmacsDrawRectangle.perform (drawable, gc, x, y,
+ width, height);
}
public void
drawLine (EmacsDrawable drawable, EmacsGC gc,
int x, int y, int x2, int y2)
{
- EmacsPaintReq req;
-
- ensurePaintQueue ();
-
- req = new EmacsDrawLine (drawable, x, y,
- x2, y2,
- gc.immutableGC ());
- paintQueue.appendPaintOperation (req);
- checkFlush ();
+ EmacsDrawLine.perform (drawable, gc, x, y,
+ x2, y2);
}
public void
drawPoint (EmacsDrawable drawable, EmacsGC gc,
int x, int y)
{
- EmacsPaintReq req;
-
- ensurePaintQueue ();
-
- req = new EmacsDrawPoint (drawable, x, y,
- gc.immutableGC ());
- paintQueue.appendPaintOperation (req);
- checkFlush ();
+ EmacsDrawPoint.perform (drawable, gc, x, y);
}
public void
@@ -319,15 +233,9 @@ public class EmacsService extends Service
int srcX, int srcY, int width, int height, int destX,
int destY)
{
- EmacsPaintReq req;
-
- ensurePaintQueue ();
-
- req = new EmacsCopyArea (srcDrawable, dstDrawable,
- srcX, srcY, width, height, destX,
- destY, gc.immutableGC ());
- paintQueue.appendPaintOperation (req);
- checkFlush ();
+ EmacsCopyArea.perform (srcDrawable, gc, dstDrawable,
+ srcX, srcY, width, height, destX,
+ destY);
}
public void
@@ -342,12 +250,4 @@ public class EmacsService extends Service
{
window.clearArea (x, y, width, height);
}
-
- public void
- appendPaintOperation (EmacsPaintReq op)
- {
- ensurePaintQueue ();
- paintQueue.appendPaintOperation (op);
- checkFlush ();
- }
};