42 #define XY2PTR(x, y) (PIXEL *)(pContext->pData + y * pContext->BytesPerLine + x * pContext->pDrawingAPI->BytesPerPixel) 65 static void _Sort(
int * p0,
int * p1) {
85 static void _DrawBitLine1BPP(
GUI_DEVICE * pDevice,
unsigned x,
unsigned y,
U8 const * p,
int Diff,
int xsize,
const LCD_PIXELINDEX * pTrans) {
87 unsigned (* pfGetPixelIndex)(
GUI_DEVICE *, int, int);
93 Index0 = *(pTrans + 0);
94 Index1 = *(pTrans + 1);
96 pContext->
pfLog2Phys(pContext, x, y, &x_phys, &y_phys);
97 pData =
XY2PTR(x_phys, y_phys);
101 *pData = (PIXEL)(*p & (0x80 >> Diff)) ? Index1 : Index0;
111 if (*p & (0x80 >> Diff)) {
126 if (*p & (0x80 >> Diff)) {
127 Pixel = pfGetPixelIndex(pDevice, x, y);
146 static void _DrawBitLine2BPP(
GUI_DEVICE * pDevice,
int x,
int y,
U8 const * p,
int Diff,
int xsize,
const LCD_PIXELINDEX * pTrans) {
148 int CurrentPixel, Shift, Index;
157 pContext->
pfLog2Phys(pContext, x, y, &x_phys, &y_phys);
158 pData =
XY2PTR(x_phys, y_phys);
163 Shift = (3 - CurrentPixel) << 1;
164 Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
165 PixelIndex = *(pTrans + Index);
166 *pData = (PIXEL)PixelIndex;
168 if (++CurrentPixel == 4) {
175 Shift = (3 - CurrentPixel) << 1;
176 Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
177 *pData = (PIXEL)Index;
179 if (++CurrentPixel == 4) {
189 Shift = (3 - CurrentPixel) << 1;
190 Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
192 PixelIndex = *(pTrans + Index);
193 *pData = (PIXEL)PixelIndex;
196 if (++CurrentPixel == 4) {
203 Shift = (3 - CurrentPixel) << 1;
204 Index = (Pixels & (0xC0 >> (6 - Shift))) >> Shift;
206 *pData = (PIXEL)Index;
209 if (++CurrentPixel == 4) {
223 static void _DrawBitLine4BPP(
GUI_DEVICE * pDevice,
int x,
int y,
U8 const * p,
int Diff,
int xsize,
const LCD_PIXELINDEX * pTrans) {
225 int CurrentPixel, Shift, Index;
234 pContext->
pfLog2Phys(pContext, x, y, &x_phys, &y_phys);
235 pData =
XY2PTR(x_phys, y_phys);
240 Shift = (1 - CurrentPixel) << 2;
241 Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
242 PixelIndex = *(pTrans + Index);
243 *pData = (PIXEL)PixelIndex;
245 if (++CurrentPixel == 2) {
252 Shift = (1 - CurrentPixel) << 2;
253 Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
254 *pData = (PIXEL)Index;
256 if (++CurrentPixel == 2) {
266 Shift = (1 - CurrentPixel) << 2;
267 Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
269 PixelIndex = *(pTrans + Index);
270 *pData = (PIXEL)PixelIndex;
273 if (++CurrentPixel == 2) {
280 Shift = (1 - CurrentPixel) << 2;
281 Index = (Pixels & (0xF0 >> (4 - Shift))) >> Shift;
283 *pData = (PIXEL)Index;
286 if (++CurrentPixel == 2) {
307 pContext->
pfLog2Phys(pContext, x, y, &x_phys, &y_phys);
308 pData =
XY2PTR(x_phys, y_phys);
314 *pData = (PIXEL)*(pTrans + Pixel);
319 *pData = (PIXEL)*p++;
329 *pData = (PIXEL)*(pTrans + Pixel);
337 *pData = (PIXEL)Pixel;
350 static void _DrawBitLine16BPP(
GUI_DEVICE * pDevice,
int x,
int y,
U16 const * p,
int xsize) {
352 int x_phys, y_phys, PixelOffset;
356 pContext->
pfLog2Phys(pContext, x, y, &x_phys, &y_phys);
357 pData =
XY2PTR(x_phys, y_phys);
360 *pData = (PIXEL)*p++;
361 pData += PixelOffset;
369 static void _DrawBitLine32BPP(
GUI_DEVICE * pDevice,
int x,
int y,
U32 const * p,
int xsize) {
371 int x_phys, y_phys, PixelOffset;
375 pContext->
pfLog2Phys(pContext, x, y, &x_phys, &y_phys);
376 pData =
XY2PTR(x_phys, y_phys);
379 *pData = (PIXEL)*p++;
380 pData += PixelOffset;
394 static void _DrawBitmap_CX(
GUI_DEVICE * pDevice,
int x0,
int y0,
395 int xSize,
int ySize,
398 const U8 * pData,
int Diff,
400 int x0_phys, y0_phys, x1_phys, y1_phys;
406 switch (BitsPerPixel) {
408 for (i = 0; i < ySize; i++) {
409 _DrawBitLine1BPP(pDevice, x0, i + y0, pData, Diff, xSize, pTrans);
410 pData += BytesPerLine;
414 for (i = 0; i < ySize; i++) {
415 _DrawBitLine2BPP(pDevice, x0, i + y0, pData, Diff, xSize, pTrans);
416 pData += BytesPerLine;
420 for (i = 0; i < ySize; i++) {
421 _DrawBitLine4BPP(pDevice, x0, i + y0, pData, Diff, xSize, pTrans);
422 pData += BytesPerLine;
426 for (i = 0; i < ySize; i++) {
427 _DrawBitLine8BPP(pDevice, x0, i + y0, pData, xSize, pTrans);
428 pData += BytesPerLine;
432 for (i = 0; i < ySize; i++) {
433 _DrawBitLine16BPP(pDevice, x0, i + y0, (
U16 *)pData, xSize);
434 pData += BytesPerLine;
438 for (i = 0; i < ySize; i++) {
439 _DrawBitLine32BPP(pDevice, x0, i + y0, (
U32 *)pData, xSize);
440 pData += BytesPerLine;
445 pContext->
pfLog2Phys(pContext, x0 + Diff, y0, &x0_phys, &y0_phys);
446 pContext->
pfLog2Phys(pContext, x0 + Diff + xSize - 1, y0 + ySize - 1, &x1_phys, &y1_phys);
447 _Sort(&x0_phys, &x1_phys);
448 _Sort(&y0_phys, &y1_phys);
449 pDataBM =
XY2PTR(x0_phys, y0_phys);
450 pDevice = pDevice->
pNext;
453 x1_phys - x0_phys + 1,
454 y1_phys - y0_phys + 1,
464 static unsigned int _GetPixelIndex_CX(
GUI_DEVICE * pDevice,
int x,
int y) {
471 pContext->
pfLog2Phys(pContext, x, y, &x_phys, &y_phys);
472 pData =
XY2PTR(x_phys, y_phys);
481 static void _SetPixelIndex_CX(
GUI_DEVICE * pDevice,
int x,
int y,
int PixelIndex) {
487 pContext->
pfLog2Phys(pContext, x, y, &x_phys, &y_phys);
488 pData =
XY2PTR(x_phys, y_phys);
489 *pData = (PIXEL)PixelIndex;
490 pDevice = pDevice->
pNext;
498 static void _XorPixel_CX(
GUI_DEVICE * pDevice,
int x,
int y) {
499 PIXEL Pixel, IndexMask;
511 static void _DrawHLine_CX(
GUI_DEVICE * pDevice,
int x0,
int y,
int x1) {
519 static void _DrawVLine_CX(
GUI_DEVICE * pDevice,
int x,
int y0,
int y1) {
527 static void _FillRect_CX(
GUI_DEVICE * pDevice,
int x0,
int y0,
int x1,
int y1) {
531 PIXEL Pixel, IndexMask;
532 int x0_phys, y0_phys, x1_phys, y1_phys;
533 int NumPixels, NumLines;
537 pContext->
pfLog2Phys(pContext, x0, y0, &x0_phys, &y0_phys);
538 pContext->
pfLog2Phys(pContext, x1, y1, &x1_phys, &y1_phys);
539 _Sort(&x0_phys, &x1_phys);
540 _Sort(&y0_phys, &y1_phys);
541 pData = pLine =
XY2PTR(x0_phys, y0_phys);
542 NumLines = y1_phys - y0_phys + 1;
547 NumPixels = x1_phys - x0_phys + 1;
549 *pPixel++ ^= IndexMask;
550 }
while (--NumPixels);
551 pLine += pContext->
vxSize;
552 }
while (--NumLines);
555 if (
sizeof(Pixel) == 1) {
556 NumPixels = x1_phys - x0_phys + 1;
559 pLine += pContext->
vxSize;
560 }
while (--NumLines);
564 NumPixels = x1_phys - x0_phys + 1;
567 }
while (--NumPixels);
568 pLine += pContext->
vxSize;
569 }
while (--NumLines);
572 pDevice = pDevice->
pNext;
575 x1_phys - x0_phys + 1,
576 y1_phys - y0_phys + 1,
GUI_SADDR GUI_CONTEXT * GUI_pContext
#define LCD__GetColorIndex()
tLCDDEV_GetIndexMask * pfGetIndexMask
void(* pfSetPixelIndex)(GUI_DEVICE *pDevice, int x, int y, int ColorIndex)
const GUI_ORIENTATION_API * pDrawingAPI
void(* pfDrawBitmap)(GUI_DEVICE *pDevice, int x0, int y0, int xsize, int ysize, int BitsPerPixel, int BytesPerLine, const U8 *pData, int Diff, const LCD_PIXELINDEX *pTrans)
#define LCD_DRAWMODE_TRANS
void(* pfFillRect)(GUI_DEVICE *pDevice, int x0, int y0, int x1, int y1)
const LCD_API_COLOR_CONV * pColorConvAPI
const GUI_ORIENTATION_API API_NAME
void(* pfLog2Phys)(DRIVER_CONTEXT *pContext, int x, int y, int *px_phys, int *py_phys)
const GUI_DEVICE_API * pDeviceAPI
unsigned(* pfGetPixelIndex)(GUI_DEVICE *pDevice, int x, int y)