Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
54
6.8.6 Show different versions to restore and draw the needle layer
Figure 20. Previous layer frame
As mentioned, we want to discuss different possibilities. The scenario should be always the same: a previous frame
of the sNeedle surface was drawn and the new needle position must be drawn instead.
Version 1
Version 2
Version 3
Version 4
6.8.6.1
Version 1
A typical draw loop clears the buffer and draws the new objects on it. We perform 3 rendering steps:
The fill instruction clears the whole buffer.
Next the rotated needle is drawn.
Finally the hub is drawn.
// Set target to sNeedle surface and enable blending with MML_GDC_PE_DST
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(&ctx, MML_GDC_PE_STORE | MML_GDC_PE_DST, &sNeedle));
while
(TRUE)
{
// Clear the last frame
UTIL_SUCCESS(ret, mmlGdcPeColor(&ctx, 0, 0, 0, 0));
UTIL_SUCCESS(ret, mmlGdcPeFill(&ctx, 0, 0, BGR_WIDTH, BGR_HEIGHT));
// Draw the rotated needle
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(&ctx, MML_GDC_PE_SRC, &sSrc[BMP_NEEDLE]));
UTIL_SUCCESS(ret, mmlGdcPeSetMatrix(&ctx, MML_GDC_PE_SRC,
MML_GDC_PE_GEO_MATRIX_FORMAT_3X2, mat[BMP_NEEDLE]));
UTIL_SUCCESS(ret, mmlGdcPeBlt(&ctx, 0, 0));
// Draw the hub
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(&ctx, MML_GDC_PE_SRC, &sSrc[BMP_HUB]));
UTIL_SUCCESS(ret, mmlGdcPeSetMatrix(&ctx, MML_GDC_PE_SRC,
MML_GDC_PE_GEO_MATRIX_FORMAT_3X2, mat[BMP_HUB]));
UTIL_SUCCESS(ret, mmlGdcPeBlt(&ctx, BGR_WIDTH * 0.5f, ROT_CENTER_Y));
}