Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
53
This means the offsets are valid for all blit paths except the DST and the individual matrix for each source buffer is
used for this path only.
This behavior can be used to simplify any operations. For instance, you can set a mirror matrix to the store and
without any other changes you can mirror all blit operations for this target.
In the speedometer example, we calculate matrices for the rotation center of the images and use the blit offset to
move it to the correct position.
mmlGdcPeBlt(&ctx, BGR_WIDTH * 0.5f, ROT_CENTER_Y);
All source surfaces including hub get a similar matrix (except background) in Prepare Surfaces.
utMat3x2LoadIdentity(mat[0]);
/* we have 7 sources so we can simply handle it in an array. */
for
(i = 1; i < 7; i++)
{
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(&sSrc[i]));
UTIL_SUCCESS(ret, utSurfLoadBitmap(&sSrc[i], mysrc[i].name, MM_FALSE));
// prepare matrix array for surfaces
utMat3x2LoadIdentity(mat[i]);
// align the rotation centers of surfaces
utMat3x2Translate(mat[i], -(MM_FLOAT)
utSurfWidth(&sSrc[i]) * 0.5f, -mysrc[i].fCenterY);
}
The rotation angle is changed frame by frame, so we have to calculate a new matrix each time for this surface. We
encapsulated it in the function GetRotMatrix:
static
MM_ERROR GetRotMatrix(MM_U32 SurfID, MML_GDC_SURFACE_CONTAINER *sSrc, MM_FLOAT fAngle,
Mat3x2 *mat)
{
MM_ERROR ret = MML_OK;
// move the surface to the rotation center
utMat3x2LoadIdentity(mat[SurfID]);
utMat3x2Translate(mat[SurfID], (MM_FLOAT)BGR_WIDTH * 0.5f, (MM_FLOAT)ROT_CENTER_Y);
utMat3x2Rot(mat[SurfID], fAngle);
utMat3x2Translate(mat[SurfID], -(MM_FLOAT)
utSurfWidth(&sSrc[SurfID]) * 0.5f, -mysrc[SurfID].fCenterY);
return
ret;
}