/*********************************************************************
*
*       LCD_X_Config
*
* Purpose:
*   Called during the initialization process in order to set up the
*   display driver configuration.
*   
*/
void LCD_X_Config(void) {
  int i, BitsPerPixel;
  U32 Addr;

  //
  // Video RAM start address.
  //
  // This address is only required for display drivers with memory
  // mapped video RAM like the LIN_xxx driver. It does not need to
  // be adapted for display controllers with a simple bus interface.
  //
  Addr = 0x12345678;
  //
  // Display driver configuration
  //
  for (i = 0; i < GUI_COUNTOF(_aConfigPara); i++) {
    //
    // Set display driver and color conversion for 1st layer
    //
    GUI_DEVICE_CreateAndLink(_aConfigPara[i].pDisplayDriver, _aConfigPara[i].pColorConv, 0, i);
    //
    // Display driver configuration
    //
    LCD_SetPosEx     (i, _aConfigPara[i].xPos,   _aConfigPara[i].yPos);
    LCD_SetSizeEx    (i, _aConfigPara[i].xSize,  _aConfigPara[i].ySize);
    LCD_SetVSizeEx   (i, _aConfigPara[i].vxSize, _aConfigPara[i].vySize);
    LCD_SetVRAMAddrEx(i, (void *)Addr);
    LCD_SetVisEx     (i, 1);
    //
    // Set user palette data (only required if no fixed palette is used)
    //
    if (_aConfigPara[i].pPalette) {
      LCD_SetLUTEx(i, _aConfigPara[i].pPalette);
    }
    //
    // Calculate video RAM address for the following layer
    //
    BitsPerPixel = LCD_GetBitsPerPixelEx(i);
    Addr += ((_aConfigPara[i].vxSize * BitsPerPixel) * _aConfigPara[i].vySize) / 8;
  }
}
/*********************************************************************
*
*       _LCDBench
*/
static void _LCDBench(void) {
  GUI_POINT   Point;
  float       aPixelrateBitmap[5] = {0, 0, 0, 0, 0};
  float       PixelrateBigFont;
  float       PixelrateF6x8;
  float       FillratePPS;
  char      * s;
  char        ac[80];
  int         BitsPerPixel;
  int         xSizeString;
  int         ySizeFont;
  int         NumColors;
  int         MirrorX;
  int         MirrorY;
  int         SwapXY;
  int         xSize;
  int         ySize;

  BitsPerPixel = LCD_GetBitsPerPixelEx(0);
  xSize        = LCD_GetXSizeEx(0);
  ySize        = LCD_GetYSizeEx(0);
  MirrorX      = LCD_GetMirrorXEx(0);
  MirrorY      = LCD_GetMirrorYEx(0);
  SwapXY       = LCD_GetSwapXYEx(0);
  NumColors    = (1 << BitsPerPixel);
  _InitXbppDDP();
  //
  // Say hi !
  //
  GUI_X_Log("\nLCD driver benchmark. All values are  \xb5""s/pixel");
  GUI_X_Log("\nLower values are better.");
  GUI_SetBkColor(GUI_RED);
  GUI_SetColor(GUI_WHITE);
  GUI_Clear();
  GUI_SetFont(&GUI_FontComic18B_1);
  GUI_DispStringHCenterAt("LCD driver", xSize / 2, ySize / 3 - 10);
  GUI_DispStringHCenterAt("Benchmark" , xSize / 2, ySize / 3 + 20);
  GUI_Delay(1000);
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  GUI_SetLBorder(1);
  //
  // Log color depth, controller, orientation and cache
  //
  sprintf(ac, "\nColor depth: %d", BitsPerPixel);
  GUI_X_Log(ac);
  sprintf(ac, "\nOrientation: LCD_MIRROR_X = %d, LCD_MIRROR_Y = %d, LCD_SWAP_XY = %d", MirrorX, MirrorY, SwapXY);
  GUI_X_Log(ac);
  //
  // Measure filling
  //
  Point.x             = xSize;
  Point.y             = ySize;
  FillratePPS         = _Measure(&_ExecFill, &Point)  * (float)(2 * ((U32)xSize - 4) * ((U32)ySize - 4));
  sprintf(ac, "\nFill: %f", (float)1E6 / FillratePPS);
  GUI_X_Log(ac);
  //
  // Measure small font
  //
  GUI_SetFont(&GUI_Font6x8);
  s                   = _acSmall;
  xSizeString         = GUI_GetStringDistX(s);
  ySizeFont           = GUI_GetFontSizeY();
  PixelrateF6x8       = _Measure(&_ExecSmallFont, s)  * (float)2 * xSizeString * ySizeFont * 8;
  sprintf(ac, "\nF6x8: %f", (float)1E6 / PixelrateF6x8);
  GUI_X_Log(ac);
  //
  // Measure big font
  //
  GUI_SetFont(&GUI_FontComic18B_ASCII);
  s                   = _acBig;
  xSizeString         = GUI_GetStringDistX(s);
  ySizeFont           = GUI_GetFontSizeY();
  PixelrateBigFont    = _Measure(&_ExecBigFont, s)    * (float)2 * xSizeString * ySizeFont * 2;
  sprintf(ac, "\nFBig: %f", (float)1E6 / PixelrateBigFont);
  GUI_X_Log(ac);
  //
  // Measure 1bpp bitmap
  //
  aPixelrateBitmap[0] = _Measure(&_Exec1bpp, NULL)    * (float)2 * _bm_1bpp_58x8.XSize * 8;
  sprintf(ac, "\n1bpp: %f", (float)1E6 / aPixelrateBitmap[0]);
  GUI_X_Log(ac);
  //
  // Measure 2bpp bitmap
  //
  aPixelrateBitmap[1] = _Measure(&_Exec2bpp, NULL)    * (float)2 * _bm_2bpp_32x11.XSize * 11;
  sprintf(ac, "\n2bpp: %f", (float)1E6 / aPixelrateBitmap[1]);
  GUI_X_Log(ac);
  //
  // Measure 4bpp bitmap
  //
  aPixelrateBitmap[2] = _Measure(&_Exec4bpp, NULL)    * (float)2 * _bm_4bpp_32x11.XSize * 11;
  sprintf(ac, "\n4bpp: %f", (float)1E6 / aPixelrateBitmap[2]);
  GUI_X_Log(ac);
  //
  // Measure 8bpp bitmap
  //
  aPixelrateBitmap[3] = _Measure(&_Exec8bpp, NULL)    * (float)2 * _bm_8bpp_32x11.XSize * 11;
  sprintf(ac, "\n8bpp: %f", (float)1E6 / aPixelrateBitmap[3]);
  GUI_X_Log(ac);
  //
  // Measure device dependent bitmap
  //
  aPixelrateBitmap[4] = _Measure(&_ExecXbppDDP, NULL) * (float)2 * XSIZE_XBPP * YSIZE_XBPP;
  sprintf(ac, "\nXDDP: %f", (float)1E6 / aPixelrateBitmap[4]);
  GUI_X_Log(ac);
  //
  // Show results on display
  //
  GUI_Clear();
  if (xSize < 320) {
    GUI_SetFont(&GUI_Font6x8);
  } else {
    GUI_SetFont(&GUI_Font8x16);
  }
  GUI_GotoXY(0, 0);
  GUI_DispDecMin(BitsPerPixel);
  GUI_DispString(" bpp, ");
  GUI_DispDecMin(NumColors);
  GUI_DispString(" colors\n\nMIRROR_X ");
  GUI_DispDecMin(MirrorX);
  GUI_DispString(", MIRROR_Y ");
  GUI_DispDecMin(MirrorY);
  GUI_DispString(", SWAPXY ");
  GUI_DispDecMin(SwapXY);
  GUI_SetLBorder(1);
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispChar('\n');
  _DispFillrate("\nFill: ", FillratePPS,         " Fill");
  _DispFillrate("\nF6x8: ", PixelrateF6x8,       " F6x8");
  _DispFillrate("\nFBig: ", PixelrateBigFont,    " FComic18");
  _DispFillrate("\n1bpp: ", aPixelrateBitmap[0], " Bitmap 1bpp");
  _DispFillrate("\n2bpp: ", aPixelrateBitmap[1], " Bitmap 2bpp");
  _DispFillrate("\n4bpp: ", aPixelrateBitmap[2], " Bitmap 4bpp");
  _DispFillrate("\n8bpp: ", aPixelrateBitmap[3], " Bitmap 8bpp");
  _DispFillrate("\nXDDP: ", aPixelrateBitmap[4], " 8/16bppDDP");
}
Beispiel #3
0
/*********************************************************************
*
*       GUI_MEMDEV_CompareWithLCD
*/
int GUI_MEMDEV_CompareWithLCD(GUI_MEMDEV_Handle hMem, int*px, int*py, int *pExp, int*pAct) {
  int Ret = 0;
  /* Make sure memory handle is valid */
  if (!hMem) {
    hMem = GUI_Context.hDevData;
  }
  if (!hMem) {
    return 1;
  }
  GUI_LOCK();
  {
    GUI_MEMDEV * pDevData = (GUI_MEMDEV*) GUI_ALLOC_h2p(hMem);  /* Convert to pointer */
    int y    = pDevData->y0;
    int x0   = pDevData->x0;
    int XMax = pDevData->XSize + x0;
    int YMax = pDevData->YSize + y;
    int Max;
    int MagX = LCD_GetXMag();
    int MagY = LCD_GetYMag();
    /* Calculate limits */
    if (y < 0) {
			y = 0;
    }
    if (x0 < 0) {
			x0 = 0;
    }
    Max = LCD_GET_YSIZE();
		if (YMax > Max) {
			YMax = Max;
    }
    Max = LCD_GET_XSIZE();
		if (XMax > Max) {
			XMax = Max;
    }
    for (; y < YMax; y++) {
      int x = x0;
      U8 * pData = (U8 *)GUI_MEMDEV__XY2PTR(x, y);
      for (x = x0; x < XMax; x++) {
        int Exp = *pData++;
        int Act = LCD_L0_GetPixelIndex(x * MagX, y * MagY);
        #if (GUI_NUM_LAYERS > 1)
        if (LCD_GetBitsPerPixelEx(GUI_Context.SelLayer) > 8)
        #else
        if (LCD_GetBitsPerPixel() > 8)
        #endif
        {
          Exp |= (*pData++) << 8;
        }
        if (Act != Exp) {
          *px    = x;
          *py    = y;
          *pAct  = Act;
          *pExp  = Exp;
          Ret = 1;
          goto Skip;
        }
      }
    }
  }
Skip:
  GUI_UNLOCK();
  return Ret;
}
Beispiel #4
0
/*********************************************************************
*
*       _Serialize
*/
static void _Serialize(int x0, int y0, int xSize, int ySize, HANDLE hFile) {
  int i;
  int x, y;
  int BPP            = LCD_GetBitsPerPixelEx(GUI_Context.SelLayer);/**/
  int NumColors      = (BPP > 8) ? 0 : (1 << BPP);
  int Cnt            = 0;
  int DataNew;
  int Data = -1;
  char aIsUsed[256] = {0};
  char aIndex2Index[256];
  GUI_LOCK();
  /* Analyze which indices are really used */
  if (NumColors) {
    NumColors = 0;
    for (y = 0; y < ySize; y++) {
      for (x = 0; x < xSize; x++) {
        aIsUsed[LCD_GetPixelIndex(x0 + x, y0 + y)] = 1;
      }
    }
    for (i = 0; i < 256; i++) {
      if (aIsUsed[i]) {
        aIndex2Index[i] = NumColors++;
      }
    }
  }
  /* Write header */
  _WriteByteToFile('S', hFile);
  _WriteByteToFile('B', hFile);
  _WriteU16ToFile((U16)xSize, hFile);
  _WriteU16ToFile((U16)ySize, hFile);
  _WriteU16ToFile((U16)NumColors, hFile);
  /* Write index colors */
  for (i = 0; i < 256; i++) {
    if (aIsUsed[i]) {
      GUI_COLOR Color = GUI_Index2Color(i);
      _WriteRGBToFile(Color, hFile);
    }
  }
  /* Write pixels */
  for (y = 0; y < ySize; y++) {
    for (x = 0; x < xSize; x++) {
      if (NumColors) {
        DataNew = aIndex2Index[LCD_GetPixelIndex(x0 + x, y0 + y)];
      } else {
        DataNew = LCD_GetPixelColor(x0 + x, y0 + y);
      }
      /* Write data record if necessary */
      if ((Cnt == 0xFFFF) | (Data != DataNew)) {
        if (Cnt) {
          _WriteU16ToFile(Cnt, hFile);
          _WritePixel(Data, NumColors, hFile);
        }
        Data = DataNew;
        Cnt = 0;
      }
      Cnt++;
    }
  }
  /* Write last record */
  _WriteU16ToFile(Cnt, hFile);
  _WritePixel(DataNew, NumColors, hFile);
  GUI_UNLOCK();
}