GUIDEV_AA.c
上传用户:zbk8730
上传日期:2017-08-10
资源大小:12168k
文件大小:6k
源码类别:

uCOS

开发平台:

C/C++

  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        : GUIDevAA.C
  16. Purpose     : Memory device drawing with Antialiasing
  17. ----------------------------------------------------------------------
  18. Version-Date---Author-Explanation
  19. ----------------------------------------------------------------------
  20. 1.02    000804 RS     LCD_CopyFromLCDAA added
  21. 1.00a   000804 RS     Fix for odd X-sizes
  22. 1.00    000728 RS     First release
  23. ----------------------------------------------------------------------
  24. Known problems or limitations with current version
  25. ----------------------------------------------------------------------
  26. None.
  27. ---------------------------END-OF-HEADER------------------------------
  28. */
  29. #include "GUI_Private.h"
  30. #include <string.h>
  31. #if GUI_SUPPORT_MEMDEV
  32. /*
  33.         *********************************************************
  34.         *                                                       *
  35.         *              Check config                             *
  36.         *                                                       *
  37.         *********************************************************
  38. */
  39. /*
  40.         *********************************************************
  41.         *                                                       *
  42.         *                Macros                                 *
  43.         *                                                       *
  44.         *********************************************************
  45. */
  46. #define SETPIXEL(x,y,colorindex) _SetPixel(x,y,colorindex);
  47. #define BKCOLORINDEX GUI_Context.pDevData->aColorIndex[0]
  48. #define   COLORINDEX GUI_Context.pDevData->aColorIndex[1]
  49. /*
  50.       *************************************************
  51.       *                                               *
  52.       *             CopyToLCDAA                       *
  53.       *                                               *
  54.       *************************************************
  55. */
  56. void GUI_MEMDEV_CopyToLCDAA(GUI_MEMDEV_Handle hMem) {
  57.   /* Make sure memory handle is valid */
  58.   if (hMem) {
  59.     int x,y;
  60.     static const tLCDDEV_APIList* pDevicePrev;
  61.     GUI_MEMDEV* pDev = (GUI_MEMDEV*)GUI_ALLOC_LOCK(hMem);  /* Convert to pointer */
  62.     LCD_PIXELINDEX* pData0 = (LCD_PIXELINDEX*)(pDev+1);
  63.     int LineOff = pDev->XSize;
  64.     int x0 = pDev->x0;
  65.     int y0 = pDev->y0;
  66.     int XMax = pDev->XSize/2;
  67.     int YMax = pDev->YSize/2;
  68.     pDevicePrev = GUI_Context.pDeviceAPI; /* Remember list ptr (for restore) */
  69.     GUI_Context.pDeviceAPI = &LCD_L0_APIList;
  70.     LCD_SetClipRectMax();
  71.     for (y=0; y< YMax; y++) {
  72.       LCD_PIXELINDEX* pData = pData0;
  73.       for (x=0; x< XMax; x++) {
  74.         LCD_PIXELINDEX PixelIndex;
  75.         int ColorSep[3];
  76.         U32 Color = LCD_Index2Color(*pData);
  77.         ColorSep[0] = Color&255;
  78.         ColorSep[1] = (Color>>8)  &255;
  79.         ColorSep[2] = (Color>>16) &255;
  80.         Color = LCD_Index2Color(*(pData+1));
  81.         ColorSep[0] += Color&255;
  82.         ColorSep[1] += (Color>>8)  &255;
  83.         ColorSep[2] += (Color>>16) &255;
  84.         Color = LCD_Index2Color(*(pData+LineOff));
  85.         ColorSep[0] += Color&255;
  86.         ColorSep[1] += (Color>>8)  &255;
  87.         ColorSep[2] += (Color>>16) &255;
  88.         Color = LCD_Index2Color(*(pData+LineOff+1));
  89.         ColorSep[0] += Color&255;
  90.         ColorSep[1] += (Color>>8)  &255;
  91.         ColorSep[2] += (Color>>16) &255;
  92.         Color  = (ColorSep[0]+2)>>2;
  93.         Color |= ((ColorSep[1]+2)>>2)<<8;
  94.         Color |= ((U32)((ColorSep[2]+2)>>2))<<16;
  95.         PixelIndex = LCD_Color2Index(Color);
  96.         LCD_SetPixelIndex(x+x0, y+y0, PixelIndex);
  97.         pData+=2;
  98.       }
  99.       pData0 += 2*LineOff;
  100.     }
  101.     GUI_Context.pDeviceAPI = pDevicePrev; /* Restore API list ptr */
  102.   }
  103. }
  104. /*
  105.       *************************************************
  106.       *                                               *
  107.       *             CopyFromLCDAA                     *
  108.       *                                               *
  109.       *************************************************
  110. */
  111. void GUI_MEMDEV_CopyFromLCDAA(GUI_MEMDEV_Handle hMem) {
  112.   /* Make sure memory handle is valid */
  113.   if (!hMem) {
  114.     hMem = GUI_Context.hDevData;
  115.   }
  116.   if (hMem) {
  117.     int x,y;
  118.     GUI_MEMDEV* pDevData = (GUI_MEMDEV*) GUI_ALLOC_LOCK(hMem);  /* Convert to pointer */
  119.     GUI_USAGE* pUsage = 0;
  120.     int x0 = pDevData->x0;
  121.     int y0 = pDevData->y0;
  122.     int XMax = pDevData->XSize/2;
  123.     int YMax = pDevData->YSize/2;
  124.     LCD_PIXELINDEX* pData = (LCD_PIXELINDEX*)(pDevData+1);
  125.     int LineOff = pDevData->BytesPerLine;
  126.     if (pDevData->hUsage) 
  127.       pUsage = GUI_USAGE_h2p(pDevData->hUsage);
  128.     for (y=0; y< YMax; y++) {
  129.       if (pUsage) {
  130.         GUI_USAGE_AddHLine(pUsage, 0, y*2, pDevData->XSize);
  131.         GUI_USAGE_AddHLine(pUsage, 0, y*2+1, pDevData->XSize);
  132.       }
  133.       for (x=0; x< XMax; x++) {
  134.         *pData = *(pData+1) = *(pData+LineOff) = *(pData+LineOff+1) = LCD_GetPixelIndex(x+x0,y+y0);
  135.         pData+=2;
  136.       }
  137.       pData += LineOff + (pDevData->XSize&1);
  138.     }
  139.   }
  140.   GUI_ALLOC_UNLOCK(hMem);
  141. }
  142. #else
  143. void GUIDEV_AA(void) {} /* avoid empty object files */
  144. #endif /* GUI_MEMDEV_SUPPORT */