Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
55
The next image shows the draw boxes for these 3 rendering steps:
Figure 21. Version 1
6.8.6.2
Version 2
In the previous implementation the store buffer is read twice, first when blending the needle, then again when
blending the hub on top of it. To avoid this additional memory access, we can blend both sources in one step onto
the store buffer. The problem: by default the driver only processes the bounding box of the source buffer. In our
example, the hub must be blended over the needle so just a part of the needle would be visible. To avoid this issue
we can force the driver to process both the SRC and the DST frame buffer by using the mmlGdcPeSelectArea
function.
/* Here we blend hub over rotated needle to store */
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(&ctx, MML_GDC_PE_STORE, &sNeedle));
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]));
/* We have to render the combined bounding box of needle and hub in this case */
UTIL_SUCCESS(ret, mmlGdcPeSelectArea(&ctx, MML_GDC_PE_SRC | MML_GDC_PE_DST));
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));
/* Blend the hub over rotated needle */
UTIL_SUCCESS(ret, mmlGdcPeSetMatrix(&ctx, MML_GDC_PE_DST,
MML_GDC_PE_GEO_MATRIX_FORMAT_3X2, mat[BMP_NEEDLE]));
UTIL_SUCCESS(ret, mmlGdcPeBlt(&ctx, BGR_WIDTH * 0.5f, ROT_CENTER_Y));
}
This time only 2 rendering steps are required:
The fill instruction clears the whole buffer.
Blend the hub over the rotated needle. The driver will calculate and render the bounding box of the rotated
needle and the hub.