This source file includes following definitions.
- perform
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.gnu.emacs;
21
22 import android.graphics.Bitmap;
23 import android.graphics.Canvas;
24 import android.graphics.Paint;
25 import android.graphics.Rect;
26 import android.graphics.RectF;
27
28 import android.util.Log;
29
30 public final class EmacsDrawRectangle
31 {
32 public static void
33 perform (EmacsDrawable drawable, EmacsGC gc,
34 int x, int y, int width, int height)
35 {
36 Paint maskPaint, paint;
37 Canvas maskCanvas;
38 Bitmap maskBitmap;
39 Rect maskRect, dstRect;
40 Canvas canvas;
41 Bitmap clipBitmap;
42
43
44 if (gc.fill_style == EmacsGC.GC_FILL_OPAQUE_STIPPLED)
45 return;
46
47 canvas = drawable.lockCanvas (gc);
48
49 if (canvas == null)
50 return;
51
52 paint = gc.gcPaint;
53 paint.setStyle (Paint.Style.STROKE);
54
55 if (gc.clip_mask == null)
56
57
58 canvas.drawRect (new RectF (x + 0.5f, y + 0.5f,
59 x + width + 0.5f,
60 y + height + 0.5f),
61 paint);
62 else
63 {
64
65
66
67 clipBitmap = gc.clip_mask.bitmap;
68 dstRect = new Rect (x, y, x + width, y + height);
69 maskRect = new Rect (gc.clip_x_origin,
70 gc.clip_y_origin,
71 (gc.clip_x_origin
72 + clipBitmap.getWidth ()),
73 (gc.clip_y_origin
74 + clipBitmap.getHeight ()));
75
76 if (!maskRect.setIntersect (dstRect, maskRect))
77
78
79 return;
80
81
82
83
84 maskBitmap
85 = Bitmap.createBitmap (maskRect.width (), maskRect.height (),
86 Bitmap.Config.ARGB_8888);
87
88
89 maskCanvas = new Canvas (maskBitmap);
90 maskRect.offset (-gc.clip_x_origin,
91 -gc.clip_y_origin);
92 maskCanvas.drawBitmap (gc.clip_mask.bitmap,
93 maskRect, new Rect (0, 0,
94 maskRect.width (),
95 maskRect.height ()),
96 paint);
97 maskRect.offset (gc.clip_x_origin,
98 gc.clip_y_origin);
99
100
101
102 maskPaint = new Paint ();
103 maskPaint.setXfermode (EmacsGC.srcInAlu);
104 maskPaint.setStyle (Paint.Style.STROKE);
105
106
107 maskCanvas.drawRect (maskRect, maskPaint);
108
109
110 paint.setXfermode (null);
111 canvas.drawBitmap (maskBitmap, null, maskRect, paint);
112
113
114 maskBitmap.recycle ();
115 }
116
117 drawable.damageRect (new Rect (x, y, x + width + 1,
118 y + height + 1));
119 }
120 }