public final class EmacsSurfaceView extends View
{
private static final String TAG = "EmacsSurfaceView";
+
+ /* The EmacsView representing the window that this surface is
+ displaying. */
private EmacsView view;
+
+ /* The complete buffer contents at the time of the last draw. */
private Bitmap frontBuffer;
+
+ /* Canvas representing the front buffer. */
private Canvas bitmapCanvas;
+
+ /* Reference to the last bitmap copied to the front buffer. */
private WeakReference<Bitmap> bitmap;
- private Paint bitmapPaint;
+
+ /* Paint objects used on the main and UI threads, respectively. */
+ private static final Paint bitmapPaint, uiThreadPaint;
+
+ static
+ {
+ /* Create two different Paint objects; one is used on the main
+ thread for buffer swaps, while the other is used from the UI
+ thread in `onDraw'. This is necessary because Paint objects
+ are not thread-safe, even if their uses are interlocked. */
+
+ bitmapPaint = new Paint ();
+ uiThreadPaint = new Paint ();
+ };
public
- EmacsSurfaceView (final EmacsView view)
+ EmacsSurfaceView (EmacsView view)
{
super (view.getContext ());
this.view = view;
- this.bitmapPaint = new Paint ();
this.bitmap = new WeakReference<Bitmap> (null);
}
now. */
if (frontBuffer != null)
- canvas.drawBitmap (frontBuffer, 0f, 0f, bitmapPaint);
+ canvas.drawBitmap (frontBuffer, 0f, 0f, uiThreadPaint);
}
};
/* Now delete whatever needs to go. */
- del_range (start, end);
+ del_range_1 (start, end, true, false);
record_buffer_change (start, start, Qt);
/* Don't record changes if TEXT is empty. */
if (end != start)
{
- del_range (start, end);
+ del_range_1 (start, end, true, false);
set_point (start);
record_buffer_change (start, start, Qt);
}
its end. */
start = marker_position (f->conversion.compose_region_start);
end = marker_position (f->conversion.compose_region_end);
- del_range (start, end);
+ del_range_1 (start, end, true, false);
set_point (start);
if (start != end)
start = max (BEGV, lstart - left);
end = min (ZV, rstart + right);
- text = del_range_1 (start, end, false, true);
+ text = del_range_1 (start, end, true, true);
record_buffer_change (start, start, text);
}
else
start = rstart;
end = min (ZV, rstart + right);
- text = del_range_1 (start, end, false, true);
+ text = del_range_1 (start, end, true, true);
record_buffer_change (start, start, Qnil);
/* Now delete what must be deleted on the left. */
start = max (BEGV, lstart - left);
end = lstart;
- text = del_range_1 (start, end, false, true);
+ text = del_range_1 (start, end, true, true);
record_buffer_change (start, start, text);
}