Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
57
6.8.6.4
Version 4
The previous version must always update the whole layer frame although only a very small part (the old needle)
must be redrawn. The most efficient way would be to re-render only the new and the old needle parts.
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(&ctx, MML_GDC_PE_STORE, &sNeedle));
/* Blend hub over rotated needle to store. */
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(&ctx, MML_GDC_PE_DST, &sSrc[BMP_NEEDLE]));
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]));
/* Needle and store define the bounding box. */
UTIL_SUCCESS(ret, mmlGdcPeSelectArea(&ctx, MML_GDC_PE_DST | MML_GDC_PE_STORE));
while
(TRUE)
{
UTIL_SUCCESS(ret, mmlGdcPeSetMatrix(&ctx, MML_GDC_PE_DST,
MML_GDC_PE_GEO_MATRIX_FORMAT_3X2, mat[BMP_NEEDLE]));
/* Blend the hub over rotated needle */
UTIL_SUCCESS(ret, mmlGdcPeBlt(&ctx, (MM_FLOAT)BGR_WIDTH * 0.5f, (MM_FLOAT)ROT_CENTER_Y));
/* Determine draw box for the current frame ... */
UTIL_SUCCESS(ret, mmlGdcPeGetDrawBox(&ctx, &x, &y, &w, &h, MM_TRUE));
/* ... and assign it as active area to the target for the next frame. This box includes the current needle and must be
repainted in the next frame */
UTIL_SUCCESS(ret, mmlGdcPeActiveArea(&ctx, MML_GDC_PE_STORE, x, y, w, h));
}
Again we have only one rendering step, but this time the rendering box (red) is much smaller. It is the bounding box
from the previously rendered needle (green) and the new needle box (blue). The mmlGdcPeGetDrawBox returns the
drawing box of the last rendering step and this box is set as the ActiveArea for the store surface. Please note that
mmlGdcPeGetDrawBox does not include the drawing box of the store surface, otherwise the box would be
increased with each new frame.
Figure 24. Version4