Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
46
6.6.4 Map Layer
The map will be assigned to the wMap window:
UTIL_SUCCESS(ret, mmlGdcDispWinSetSurface(wMap, MML_GDC_DISP_BUFF_TARGET_COLOR_BUFF,
sMap));
Besides this we want to see a moving map. That means we have to move the layer in our animation loop. The driver
ensures that only pixels inside the screen of this surface are read from memory.
GetPosition(frameCount, &x, &y, &winker);
/* To get a moving map we have to recalculate a new matrix for the map layer. */
utMat3x2LoadIdentity(mat_geo);
/* Move it in a way that the requested center point fits the current position */
utMat3x2Translate(mat_geo, (MM_FLOAT)(CENTER_X - x), (MM_FLOAT)(CENTER_Y - y));
/* Assign the matrix to the window */
UTIL_SUCCESS(ret, mmlGdcDispWinSetMatrix(wMap, MML_GDC_DISP_BUFF_TARGET_COLOR_BUFF,
mat_geo));
UTIL_SUCCESS(ret, mmlGdcDispWinCommit(wMap));
6.6.5 Frame Layer
The frame layer is the simplest layer for this example because it is not included in an animation:
UTIL_SUCCESS(ret, mmlGdcDispWinSetSurface(wFrame, MML_GDC_DISP_BUFF_TARGET_COLOR_BUFF,
sFrame));
UTIL_SUCCESS(ret, mmlGdcDispWinSetBlendMode(wFrame, MML_GDC_DISP_BLEND_SOURCE_ALPHA |
MML_GDC_DISP_BLEND_SOURCE_MULTIPLY_ALPHA));
UTIL_SUCCESS(ret, mmlGdcDispWinSetAttribute(wFrame, MML_GDC_DISP_WIN_ATTR_COLOR,
0x80FFFFFF));
UTIL_SUCCESS(ret, mmlGdcDispWinCommit(wFrame));
The related properties required for the compression were already assigned to the surface in the utSurfLoadBitmap
function. In this case the RLA compression is used because it shrinks the size for this bitmap to 12.0% of the original
size.
6.6.6 Position Layer
The position layer demonstrates the fading capabilities of the hardware. To fade a layer with pixel based alpha
information, the following calculation inside the hardware is required:
Alpha = Alpha pix * Alpha fade
For the calculation of the Alpha value we have to assign the related properties to the wPosition window:
UTIL_SUCCESS(ret, mmlGdcDispWinSetSurface(wPosition, MML_GDC_DISP_BUFF_TARGET_COLOR_BUFF,
sPosition));
/* We want to fade this layer: multiply pixel-alpha * const alpha. */
UTIL_SUCCESS(ret, mmlGdcDispWinSetBlendMode(wPosition, MML_GDC_DISP_BLEND_GLOBAL_ALPHA |
MML_GDC_DISP_BLEND_SOURCE_ALPHA | MML_GDC_DISP_BLEND_SOURCE_MULTIPLY_ALPHA));
UTIL_SUCCESS(ret, mmlGdcDispWinSetAttribute(wPosition, MML_GDC_DISP_WIN_ATTR_COLOR,
0xFF0000FF));
To realize the blink effect we have to modify the color:
UTIL_SUCCESS(ret, mmlGdcDispWinSetAttribute(wPosition, MML_GDC_DISP_WIN_ATTR_COLOR, blink));