/********************************************************************* * * _FlushLine */ static void _FlushLine(void) { int i; int iEnd = _x1_InUse-_x0; int IMax = GUI_Context.AA_Factor * GUI_Context.AA_Factor; for (i =_x0_InUse-_x0; i<=iEnd; i++) { int Intens = *(pabAABuffer+i); if (Intens) { /* Check we can use line draw */ if (Intens == IMax) { int j; for (j=i; j<iEnd; ) { if (*(pabAABuffer+j+1) != IMax) { break; } j++; } /* Draw the full pixel(s) */ if (j!=i) { pLCD_HLPrev->pfDrawHLine(_x0+i, _y, _x0+j); i = j; /*xxx*/ } else { LCD_HL_DrawPixel (_x0+i,_y); } } else { LCD_SetPixelAA(_x0+i,_y, (15*Intens+IMax/2)/IMax); } } } _CleanLine(); }
/********************************************************************* * * Draw */ static void Draw(int x0, int y0, int XSize, int YSize, int BytesPerLine, const U8*pData) { int x, y; tSetPixelAA* pfSetPixelAA; pfSetPixelAA = (GUI_Context.TextMode & GUI_TM_TRANS) ? LCD_SetPixelAA : LCD_SetPixelAA_NoTrans; for (y=0; y<YSize; y++) { const U8* pData0 = pData; const U8* pData1 = pData+BytesPerLine; for (x=0; x<XSize; x++) { int PixelCnt=0; int Mask0 = Bit2Mask0[x&3]; int Mask1 = Bit2Mask1[x&3]; if ((*pData0) & Mask0) PixelCnt++; if ((*pData0) & Mask1) PixelCnt++; if ((*pData1) & Mask0) PixelCnt++; if ((*pData1) & Mask1) PixelCnt++; if ((x&3) ==3) { pData0++; pData1++; } switch (PixelCnt) { case 4: LCD_HL_DrawPixel(x0+x,y0+y); break; case 3: (*pfSetPixelAA) (x0+x,y0+y, 12); break; case 2: (*pfSetPixelAA) (x0+x,y0+y, 8); break; case 1: (*pfSetPixelAA) (x0+x,y0+y, 4); break; } } pData+=2*BytesPerLine; } }
/********************************************************************* * * GL_DrawPoint */ void GL_DrawPoint(int x, int y) { if (GUI_Context.PenSize == 1) { LCD_HL_DrawPixel(x, y); } else { GL_FillCircle(x, y, (GUI_Context.PenSize - 1) / 2); } }
/********************************************************************* * * GUI_DrawPixel */ void GUI_DrawPixel(int x, int y) { #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x,y); r.x0 = r.x1 = x; r.y0 = r.y1 = y; WM_ITERATE_START(&r); { #endif LCD_HL_DrawPixel(x,y); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
static void _DrawArc(int x0, int y0, int rx, int ry, int Angle0, int Angle1, int xMul, int yMul) { float afx[4]; float afy[4]; float ri = rx-(GUI_Context.PenSize+1.5)/2; float ro = rx+(GUI_Context.PenSize+1.5)/2; float fAngle0 = Angle0*3.1415926/180; float fAngle1 = Angle1*3.1415926/180; float sin0 = sin(fAngle0); float sin1 = sin(fAngle1); float cos0 = cos(fAngle0); float cos1 = cos(fAngle1); U32 ri2 = ri*ri; U32 ro2 = ro*ro; int y, yMax, yMin; afy[0] = ri*sin0; afy[1] = ro*sin0; afy[2] = ri*sin1; afy[3] = ro*sin1; afx[0] = ri*cos0; afx[1] = ro*cos0; afx[2] = ri*cos1; afx[3] = ro*cos1; yMin = ceil(afy[0]); yMax = floor(afy[3]); /* Use Clipping rect to reduce calculation (if possible) */ if (GUI_Context.pClipRect_HL) { if (yMul ==1) { if (yMax > (GUI_Context.pClipRect_HL->y1 -y0)) yMax = (GUI_Context.pClipRect_HL->y1 -y0); if (yMin < (GUI_Context.pClipRect_HL->y0 -y0)) yMin = (GUI_Context.pClipRect_HL->y0 -y0); } if (yMul == -1) { if (yMin > (GUI_Context.pClipRect_HL->y1 -y0)) yMin = (GUI_Context.pClipRect_HL->y1 -y0); if (yMax < (GUI_Context.pClipRect_HL->y0 -y0)) yMax = (GUI_Context.pClipRect_HL->y0 -y0); } } /* Start drawing lines ... */ { int xMinDisp, xMaxDisp, xMin=0,xMax=0; for (y=yMax; y>=yMin; y--) { CalcX(&xMin, y, ri2); CalcX(&xMax, y, ro2); if ((float)y< afy[1]) { xMaxDisp = CalcInterSectLin(y,afy[0], afy[1], afx[0], afx[1]); } else { xMaxDisp = xMax; } if ((float)y > afy[2]) { xMinDisp = CalcInterSectLin(y,afy[2], afy[3], afx[2], afx[3]); } else { xMinDisp = xMin; } if (xMul>0) LCD_HL_DrawHLine(xMinDisp+x0, yMul*y+y0, xMaxDisp+x0); else LCD_HL_DrawHLine(-xMaxDisp+x0, yMul*y+y0, -xMinDisp+x0); } } #if 0 /* Test code */ { int i; GUI_SetColor( GUI_WHITE ); for (i=0; i<4; i++) LCD_HL_DrawPixel(afx[i]+x0, afy[i]+y0); } #endif GUI_USE_PARA(ry); }