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
27 import android.util.Log;
28
29 public final class EmacsFillRectangle
30 {
31 public static void
32 perform (EmacsDrawable drawable, EmacsGC gc,
33 int x, int y, int width, int height)
34 {
35 Paint maskPaint, paint;
36 Canvas maskCanvas;
37 Bitmap maskBitmap;
38 Rect rect;
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 rect = new Rect (x, y, x + width, y + height);
54
55 paint.setStyle (Paint.Style.FILL);
56
57 if (gc.clip_mask == null)
58 canvas.drawRect (rect, paint);
59 else
60 {
61
62
63
64
65 clipBitmap = gc.clip_mask.bitmap;
66 dstRect = new Rect (x, y, x + width, y + height);
67 maskRect = new Rect (gc.clip_x_origin,
68 gc.clip_y_origin,
69 (gc.clip_x_origin
70 + clipBitmap.getWidth ()),
71 (gc.clip_y_origin
72 + clipBitmap.getHeight ()));
73
74 if (!maskRect.setIntersect (dstRect, maskRect))
75
76
77 return;
78
79
80
81
82 maskBitmap
83 = Bitmap.createBitmap (maskRect.width (), maskRect.height (),
84 Bitmap.Config.ARGB_8888);
85
86
87 maskCanvas = new Canvas (maskBitmap);
88 maskRect.offset (-gc.clip_x_origin,
89 -gc.clip_y_origin);
90 maskCanvas.drawBitmap (gc.clip_mask.bitmap,
91 maskRect, new Rect (0, 0,
92 maskRect.width (),
93 maskRect.height ()),
94 paint);
95 maskRect.offset (gc.clip_x_origin,
96 gc.clip_y_origin);
97
98
99
100 maskPaint = new Paint ();
101 maskPaint.setXfermode (EmacsGC.srcInAlu);
102
103
104 maskCanvas.drawRect (maskRect, maskPaint);
105
106
107 paint.setXfermode (null);
108 canvas.drawBitmap (maskBitmap, null, maskRect, paint);
109
110
111 maskBitmap.recycle ();
112 }
113
114 drawable.damageRect (rect);
115 }
116 }