/** * @brief Run speed test * @param None * @retval Pixels per second */ static int Run_SpeedTest(void) { int TimeStart, i; U32 PixelsPerSecond; unsigned aColorIndex[8]; int xSize, ySize, vySize; GUI_RECT Rect, ClipRect; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); vySize = LCD_GetVYSize(); #if GUI_SUPPORT_CURSOR GUI_CURSOR_Hide(); #endif if (vySize > ySize) { ClipRect.x0 = 0; ClipRect.y0 = 0; ClipRect.x1 = xSize; ClipRect.y1 = ySize; GUI_SetClipRect(&ClipRect); } Stop_Test = 0; for (i = 0; i< 8; i++) { aColorIndex[i] = GUI_Color2Index(_aColor[i]); } TimeStart = GUI_GetTime(); for (i = 0; ((GUI_GetTime() - TimeStart) < 5000) &&( Stop_Test == 0); i++) { GUI_SetColorIndex(aColorIndex[i&7]); /* Calculate random positions */ Rect.x0 = rand() % xSize - xSize / 2; Rect.y0 = rand() % ySize - ySize / 2; Rect.x1 = Rect.x0 + 20 + rand() % xSize; Rect.y1 = Rect.y0 + 20 + rand() % ySize; GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1); /* Clip rectangle to visible area and add the number of pixels (for speed computation) */ if (Rect.x1 >= xSize) { Rect.x1 = xSize - 1; } if (Rect.y1 >= ySize) { Rect.y1 = ySize - 1; } if (Rect.x0 < 0 ) { Rect.x0 = 0; } if (Rect.y1 < 0) { Rect.y1 = 0; } GUI_Exec(); /* Allow short breaks so we do not use all available CPU time ... */ } PixelsPerSecond = _GetPixelsPerSecond(); GUI_SetClipRect(NULL); return PixelsPerSecond; }
void GUIDEMO_Speed(void) { int t = GUI_GetTime(); int i = 0; int XSize = LCD_GET_XSIZE(); int YSize = LCD_GET_YSIZE(); I32 NumPixels=0; U16 aColorIndex[8]; GUIDEMO_ShowIntro("High speed", "Multi layer clipping" "\nHighly optimized drivers" ); for (i = 0; i< 8; i++) { aColorIndex[i] = GUI_Color2Index(_aColor[i]); } for (i = 0; (((t + 8000) - (int)GUI_GetTime()) > 0) && !GUIDEMO_CheckCancel(); i++) { GUI_RECT r; GUI_SetColorIndex(aColorIndex[i&7]); /* Calculate random positions */ r.x0 = rand() % XSize - XSize / 2; r.y0 = rand() % YSize - YSize / 2; r.x1 = r.x0 + rand() % XSize; r.y1 = r.y0 + rand() % YSize; GUI_FillRect(r.x0, r.y0, r.x1, r.y1); /* Clip rectangle to visible area and add the number of pixels (for speed computation) */ if (r.x1 >= XSize) r.x1 = XSize - 1; if (r.y1 >= YSize) r.y1 = YSize - 1; if (r.x0 < 0 ) r.x0 = 0; if (r.y1 < 0) r.y1 = 0; NumPixels += (r.x1 - r.x0) * (r.y1 - r.y0); /* Allow short breaks so we do not use all available CPU time ... */ } t = (GUI_GetTime() - t) / 100; GUI_Clear(); GUIDEMO_NotifyStartNext(); #if GUIDEMO_LARGE GUI_SetFont(&GUI_FontComic24B_ASCII); #else GUI_SetFont(&GUI_Font16B_ASCII); #endif GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Pixels/sec: ", 10, (LCD_GetYSize() - GUI_GetFontSizeY()) / 2); if (t == 0) t++; GUI_DispDecMin(10 * (NumPixels / t)); GUIDEMO_Wait(); }
/********************************************************************* * * GUIDEMO_Speed */ void GUIDEMO_Speed(void) { GUI_RECT ClipRect; GUI_RECT Rect; unsigned aColorIndex[8]; char cText[40] = { 0 }; U32 PixelsPerSecond; int TimeStart; int vySize; int xSize; int ySize; int i; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); vySize = LCD_GetVYSize(); if (vySize > ySize) { ClipRect.x0 = 0; ClipRect.y0 = 0; ClipRect.x1 = xSize; ClipRect.y1 = ySize; GUI_SetClipRect(&ClipRect); } GUIDEMO_ShowIntro("High speed", "Multi layer clipping\nHighly optimized drivers"); GUIDEMO_HideControlWin(); for (i = 0; i< 8; i++) { aColorIndex[i] = GUI_Color2Index(_aColor[i]); } TimeStart = GUIDEMO_GetTime(); for (i = 0; ((GUIDEMO_GetTime() - TimeStart) < 5000) && (GUIDEMO_CheckCancel() == 0); i++) { GUI_SetColorIndex(aColorIndex[i&7]); // // Calculate random positions // Rect.x0 = rand() % xSize - xSize / 2; Rect.y0 = rand() % ySize - ySize / 2; Rect.x1 = Rect.x0 + 20 + rand() % xSize; Rect.y1 = Rect.y0 + 20 + rand() % ySize; GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1); // // Clip rectangle to visible area and add the number of pixels (for speed computation) // if (Rect.x1 >= xSize) { Rect.x1 = xSize - 1; } if (Rect.y1 >= ySize) { Rect.y1 = ySize - 1; } if (Rect.x0 < 0 ) { Rect.x0 = 0; } if (Rect.y1 < 0) { Rect.y1 = 0; } GUI_Exec(); // // Allow short breaks so we do not use all available CPU time ... // } GUIDEMO_NotifyStartNext(); PixelsPerSecond = _GetPixelsPerSecond(); GUI_SetClipRect(NULL); GUIDEMO_DrawBk(); GUI_SetColor(GUI_WHITE); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontRounded22); GUI_DrawBitmap(&bmSeggerLogo70x35, 5, 5); GUIDEMO_AddStringToString(cText, "Pixels/sec: "); GUIDEMO_AddIntToString(cText, PixelsPerSecond); GUI_DispStringHCenterAt(cText, xSize / 2, (ySize - GUI_GetFontSizeY()) / 2); GUIDEMO_Delay(4000); }
/********************************************************************* * * _DrawBitmap */ static void _DrawBitmap(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag, tLCDDEV_Index2Color * pfIndex2Color) { const U32 * pData; int y, OldIndex, Mag, BytesPerLine, UseDrawBitmap = 0; U32 PrevColor; GUI_USE_PARA(pLogPal); OldIndex = LCD_GetColorIndex(); PrevColor = GUI_INVALID_COLOR; pData = (const U32 *)pPixel; Mag = (xMag | yMag); BytesPerLine = xsize * 4; /* Check if bitmaps color format fits to the current color conversion */ if (Mag == 1) { #if GUI_SUPPORT_MEMDEV if (!GUI_Context.hDevData) { #else { #endif if (LCD_GetpfIndex2ColorEx(GUI_Context.SelLayer) == pfIndex2Color) { UseDrawBitmap = 1; } } } if (UseDrawBitmap) { LCD_DrawBitmap(x0, y0, xsize, ysize, 1, 1, 24, BytesPerLine, pPixel, 0); } else { if (Mag == 1) { /* Perform clipping */ int x1, y1, Diff; y1 = y0 + ysize - 1; x1 = x0 + xsize - 1; /* Clip Y */ if (y0 < GUI_Context.ClipRect.y0) { Diff = GUI_Context.ClipRect.y0 - y0; y0 = GUI_Context.ClipRect.y0; #if GUI_SUPPORT_LARGE_BITMAPS /* Required only for 16 bit CPUs if some bitmaps are >64kByte */ pData += (U32)Diff * (U32)BytesPerLine / 4; #else pData += (unsigned)Diff * (unsigned)BytesPerLine / 4; #endif ysize -= Diff; } Diff = y1 - GUI_Context.ClipRect.y1; if (Diff > 0) { ysize -= Diff; } if (ysize <=0) { return; } /* Clip right side */ Diff = x1 - GUI_Context.ClipRect.x1; if (Diff > 0) { xsize -= Diff; } /* Clip left side */ if (x0 < GUI_Context.ClipRect.x0) { Diff = GUI_Context.ClipRect.x0 - x0; xsize -= Diff; pData += Diff; x0 += Diff; } if (xsize <=0) { return; } /* Simple, unmagnified output using LCD_L0_SetPixel() */ for (y = 0; y < ysize; y++) { int x; const U32 * p = pData; for (x = 0; x < xsize; x++) { U32 Color; Color = *p++; if (Color != PrevColor) { LCD_SetColor(pfIndex2Color(Color)); PrevColor = Color; } LCDDEV_L0_SetPixelIndex(x + x0, y + y0, LCD_COLORINDEX); } pData += BytesPerLine / 4; } } else { /* Magnified output using LCD_FillRect() */ int x,y; int yi; for (y = y0, yi = 0; yi < ysize; yi++, y += yMag, pPixel += BytesPerLine) { int yMax; yMax = y + yMag - 1; /* Draw if within clip area */ if ((yMax >= GUI_Context.ClipRect.y0) && (y <= GUI_Context.ClipRect.y1)) { int xi; const U32 GUI_UNI_PTR * p = pData; for (x = x0, xi = 0; xi < xsize; xi++, x += xMag) { U32 Color; Color = *p++; if (Color != PrevColor) { LCD_SetColor(pfIndex2Color(Color)); PrevColor = Color; } LCD_FillRect(x, y, x + xMag - 1, yMax); } } pData += BytesPerLine / 4; } } GUI_SetColorIndex(OldIndex); } } /********************************************************************* * * _DrawBitmap_565 */ static void _DrawBitmap_888(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag) { _DrawBitmap(x0, y0, xsize, ysize, pPixel, pLogPal, xMag, yMag, GUI_BitmapMethods888.pfIndex2Color); }