Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
52
/* draw the scale on background surface. You may use a fixed bitmap too. */
UTIL_SUCCESS(ret, DrawBgr(&s_sBgr, s_sSrc, s_mat));
/* display the background surface on background layer */
UTIL_SUCCESS(ret, mmlGdcDispWinSetSurface(s_winBgr, MML_GDC_DISP_BUFF_TARGET_COLOR_BUFF,
&s_sBgr));
UTIL_SUCCESS(ret, mmlGdcDispWinCommit(s_winBgr));
Now we create a layer for the hub and needle. We need a buffer with an alpha channel because the layer blending
should only pass the needle and hub. All other parts must have an alpha = 0 value so that they are not visible.
/* Create a window for needle layer */
windowProp.layerId = MML_GDC_DISP_LAYER_1;
UTIL_SUCCESS(ret, mmlGdcDispWinCreate(s_display, &windowProp, &s_winNeedle));
UTIL_SUCCESS(ret, mmlGdcDispWinSetBlendMode(s_winNeedle,
MML_GDC_DISP_BLEND_SOURCE_ALPHA));
UTIL_SUCCESS(ret, mmlGdcPeResetContext(&s_ctx));
/* Create a target surface for the needle.This is the focus layer for this demonstration. */
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(&s_sNeedle));
UTIL_SUCCESS(ret, utSurfCreateBuffer(&s_sNeedle, BGR_WIDTH, BGR_HEIGHT,
MML_GDC_SURF_FORMAT_R6G6B6));
6.8.5 Matrix operations to scale, rotate and translate images
All geometry changes such as translation, rotation, sharing, scaling and mirroring in the blit path are based on matrix
settings. The application can calculate such matrices on its own or by using the utility functions from the driver. The
x, y offset in the mmlGdcPeBlt function can be used for simple translations.
The default behavior is that all matrices are reset to identity matrices. That means a
mmlGdcPeBlt(&ctx, 10, 20)
would copy the source buffer to the target buffer with an offset x = 10 and y = 20. Depending on the
MML_GDC_PE_ATTR_ZERO_POINT settings the y offset is counted from the upper or lower left store surface
coordinate.
An equivalent operation with a matrix would be the following if sSrc is the source surface.
Mat3x2LoadIdentity(mat);
Mat3x2Translate(mat, 10, 20);
mmlGdcPeSetMatrix(ctx, MML_GDC_PE_SRC, mat);
mmlGdcPeBlt(0, 0);
However there are differences if several source buffers are involved. If the offset x, y is represented by a matrix.
Moffs =
�
1 0
0 1
�
The following relationship to the store surface is be valid for the SRC and MASK surface (represented by ’Ms’):
�
Xstore
Ystore
�
= Moffs × Ms ×
�
Xs
Ys
�
The path for the DST calculation is a little bit different (Mdst is the DST matrix):
�
Xstore
Ystore
�
= Mdst ×
�
Xdst
Ydst
�