📄 guiaalib.lst
字号:
C51 COMPILER V8.05a GUIAALIB 04/11/2008 14:18:18 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE GUIAALIB
OBJECT MODULE PLACED IN GUIAALib.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\AntiAlias\GUIAALib.c LARGE BROWSE MDU_F120 DEBUG OBJECTEX
-TEND PRINT(.\GUIAALib.lst) OBJECT(GUIAALib.obj)
line level source
1 /*
2 *********************************************************************************************************
3 * uC/GUI
4 * Universal graphic software for embedded applications
5 *
6 * (c) Copyright 2002, Micrium Inc., Weston, FL
7 * (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
8 *
9 * 礐/GUI is protected by international copyright laws. Knowledge of the
10 * source code may not be used to write a similar product. This file may
11 * only be used in accordance with a license and should not be redistributed
12 * in any way. We appreciate your understanding and fairness.
13 *
14 ----------------------------------------------------------------------
15 File : GUIAALib.C
16 Purpose : Antialiasing library
17 ---------------------------END-OF-HEADER------------------------------
18 */
19
20 #include "gui\Core\GUI_Private.h"
21 #include "gui\Core\LCD_ConfDefaults.h" /* Required in order to know max. XSize so we do not was
-te memory */
22
23 #include <stdio.h>
24 #include <string.h>
25
26 /******************************************************************
27 *
28 * Config defaults ...
29 *
30 *******************************************************************
31 */
32 #ifndef GUI_AA_LINEBUFFER_SIZE
33 #define GUI_AA_LINEBUFFER_SIZE LCD_XSIZE
34 #endif
35
36 /*
37 *******************************************************************
38 *
39 * Statics
40 *
41 *******************************************************************
42 */
43
44 static U8 abAABuffer[GUI_AA_LINEBUFFER_SIZE]; /* This could be changed to dynamic memory ... */
45 static U8* pabAABuffer;
46 static int _x0, _x1, _y, _x0_InUse, _x1_InUse;
47 static GUI_RECT ClipRect_HL;
48
49 static tLCD_HL_APIList DrawAPICopy; /* Copy of device function ptr list */
50 static const tLCD_HL_APIList* pLCD_HLPrev; /* Copy of device function ptr list */
51
52
53 /*
C51 COMPILER V8.05a GUIAALIB 04/11/2008 14:18:18 PAGE 2
54 **********************************************
55 * *
56 * AA Clean Line Buffer *
57 * *
58 **********************************************
59
60 */
61
62 static void _CleanLine(void) {
63 1 memset(pabAABuffer,0, _x1 - _x0+1);
64 1 _y = -16383; /* Invalidate */
65 1 _x0_InUse = 16383;
66 1 _x1_InUse = -16383;
67 1 }
68
69 /*
70 **********************************************
71 * *
72 * AA Flush Line Buffer *
73 * *
74 **********************************************
75
76 */
77
78 static void _FlushLine(void) {
79 1 int i;
80 1 int iEnd = _x1_InUse-_x0;
81 1 int IMax = GUI_Context.AA_Factor * GUI_Context.AA_Factor;
82 1 for (i =_x0_InUse-_x0; i<=iEnd; i++) {
83 2 int Intens = *(pabAABuffer+i);
84 2 if (Intens) {
85 3 /* Check we can use line draw */
86 3 if (Intens == IMax) {
87 4 int j;
88 4 for (j=i; j<iEnd; ) {
89 5 if (*(pabAABuffer+j+1) != IMax) {
90 6 break;
91 6 }
92 5 j++;
93 5 }
94 4 /* Draw the full pixel(s) */
95 4 if (j!=i) {
96 5 pLCD_HLPrev->pfDrawHLine(_x0+i, _y, _x0+j);
97 5 i = j; /*xxx*/
98 5 } else {
99 5 LCD_HL_DrawPixel (_x0+i,_y);
100 5 }
101 4 } else {
102 4 LCD_SetPixelAA(_x0+i,_y, (15*Intens+IMax/2)/IMax);
103 4 }
104 3 }
105 2 }
106 1 _CleanLine();
107 1 }
108
109
110 /*
111 **********************************************
112 * *
113 * Local DrawHLine *
114 * *
115 **********************************************
C51 COMPILER V8.05a GUIAALIB 04/11/2008 14:18:18 PAGE 3
116
117 This is the redirected DrawHLine routine which is called
118 instead of the default output routine. Its job is to do
119 antialiasing and then perform the drawing operations.
120 */
121
122 static void _DrawHLine (int x0, int y, int x1) {
123 1 int x0Real, x1Real;
124 1 /* Make sure there is something to do */
125 1 if (x1<x0)
126 1 return;
127 1 /* Flush line if we are in an other pixel (real) line */
128 1 if (y/GUI_Context.AA_Factor != _y) {
129 2 _FlushLine();
130 2 _y = y/GUI_Context.AA_Factor;
131 2 }
132 1 x0Real = x0/GUI_Context.AA_Factor;
133 1 x1Real = x1/GUI_Context.AA_Factor;
134 1 /* Handle used area (speed optimization for drawing) */
135 1 if (x0Real < _x0_InUse)
136 1 _x0_InUse = x0Real;
137 1 if (x1Real > _x1_InUse)
138 1 _x1_InUse = x1Real;
139 1 /* Clip (should not be necessary ... Just to be on the safe side ! */
140 1 if (x0Real < _x0) {
141 2 x0 = _x0 * GUI_Context.AA_Factor;
142 2 }
143 1 if (x1Real > _x1) {
144 2 x1 = (_x1+1)*GUI_Context.AA_Factor-1;
145 2 }
146 1 /* Make sure there is still something to do (after clipping) */
147 1 if (x1<x0)
148 1 return;
149 1 /* Inc. hit counters in buffer */
150 1 {
151 2 int x0_Off = x0/GUI_Context.AA_Factor-_x0;
152 2 int x1_Off = x1/GUI_Context.AA_Factor-_x0;
153 2 int iRem = x1_Off-x0_Off+1;
154 2 U8 *pDest = pabAABuffer+x0_Off;
155 2 if (iRem ==1) {
156 3 *(pDest) += x1-x0+1;
157 3 } else {
158 3 /* First Pixel */
159 3 *pDest++ += ((x0_Off+_x0+1)*GUI_Context.AA_Factor-x0);
160 3 /* Middle Pixels */
161 3 for (;--iRem>1; ) {
162 4 *pDest++ +=GUI_Context.AA_Factor;
163 4 }
164 3 /* Last Pixel */
165 3 *pDest += (1+x1- (x1_Off+_x0) *GUI_Context.AA_Factor);
166 3 }
167 2 }
168 1 }
169
170 /*
171 *******************************************************************
172 *
173 * CalcClipRectHL
174 *
175 *******************************************************************
176 */
177 static void CalcClipRectHL(void) {
C51 COMPILER V8.05a GUIAALIB 04/11/2008 14:18:18 PAGE 4
178 1 ClipRect_HL.x0 = GUI_Context.ClipRect.x0 * GUI_Context.AA_Factor;
179 1 ClipRect_HL.y0 = GUI_Context.ClipRect.y0 * GUI_Context.AA_Factor;
180 1 ClipRect_HL.x1 = (GUI_Context.ClipRect.x1+1) * GUI_Context.AA_Factor -1;
181 1 ClipRect_HL.y1 = (GUI_Context.ClipRect.y1+1) * GUI_Context.AA_Factor -1;
182 1 }
183
184 /******************************************************************
185 *
186 * GUI_AA_Init
187 *
188 *******************************************************************
189 */
190
191 int GUI_AA_Init(int x0, int x1) {
192 1 int r =0;
193 1 /* Bounds checking:
194 1 Make sure x0, x1 are in legal range ...
195 1 (The important point is that they span no more than configured as
196 1 buffer size)
197 1 */
198 1 if (x0<0)
199 1 x0 =0;
200 1 if (x1-x0 > GUI_AA_LINEBUFFER_SIZE-1)
201 1 x1 = x0+GUI_AA_LINEBUFFER_SIZE-1;
202 1 /* Is there anything to do at all ??? */
203 1 if (x1 < x0) {
204 2 x1 = x0; /* Not really ... */
205 2 r =1;
206 2 }
207 1 DrawAPICopy = *GUI_Context.pLCD_HL; /* Copy API table */
208 1 pLCD_HLPrev = GUI_Context.pLCD_HL; /* Remember list ptr (for restore) */
209 1 DrawAPICopy.pfDrawHLine = _DrawHLine; /* modify function ptr. for hline */
210 1 GUI_Context.pLCD_HL = &DrawAPICopy; /* Use copy of fp-list */
211 1 pabAABuffer = abAABuffer;
212 1 _x0 = x0;
213 1 _x1 = x1;
214 1 _CleanLine();
215 1 CalcClipRectHL();
216 1 GUI_Context.pClipRect_HL = &ClipRect_HL;
217 1 return r;
218 1 }
219
220 /******************************************************************
221 *
222 * GUI_AA_Init
223 *
224 *******************************************************************
225 */
226
227 int GUI_AA_Init_HiRes(int x0, int x1) {
228 1 x0 /= GUI_Context.AA_Factor;
229 1 x1 /= GUI_Context.AA_Factor;
230 1 return GUI_AA_Init(x0, x1);
231 1 }
232
233 /*********************************************************************
234 *
235 * AA Selection of Factors for position and quality
236 *
237 **********************************************************************
238
239 */
C51 COMPILER V8.05a GUIAALIB 04/11/2008 14:18:18 PAGE 5
240
241
242 void GUI_AA_SetFactor(int Factor) {
243 1 GUI_Context.AA_Factor = Factor;
244 1 CalcClipRectHL(); /* High level clipping depends on quality factor */
245 1 }
246
247 int GUI_AA_GetFactor(void) {
248 1 return GUI_Context.AA_Factor;
249 1 }
250
251 void GUI_AA_DisableHiRes(void) {
252 1 GUI_Context.AA_HiResEnable = 0;
253 1 }
254
255 void GUI_AA_EnableHiRes(void) {
256 1 GUI_Context.AA_HiResEnable =1;
257 1 }
258
259 I16 GUI_AA_HiRes2Pixel(int HiRes) {
260 1 return GUI_Context.AA_Factor ? (HiRes / GUI_Context.AA_Factor) : HiRes;
261 1 }
262
263 /*
264 *******************************************************************
265 *
266 * GUI_AA_Exit
267 *
268 *******************************************************************
269 */
270 void GUI_AA_Exit(void) {
271 1 _FlushLine();
272 1 /* restore previous settings */
273 1 GUI_Context.pLCD_HL = pLCD_HLPrev;
274 1 GUI_Context.pClipRect_HL = &GUI_Context.ClipRect;
275 1 }
276
277 /*********************** EOF FILE *******************************/
278
279
280
281
282
283
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1721 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 268 35
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -