Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
39
Figure 14. Black&White image on constant color
6.5.6 A simple auto-generated pattern
Fill the source surface with a simple pattern and copy it to the store surface.
We reuse surfSrc, but we use MML_GDC_SURF_FORMAT_R8G8B8A8 for the surface color format because it is
much easier to write the data when each pixel is 4-byte aligned. mmlGdcPeBlt copies the pattern to the store
surface at position 35/45, so again the existing content of the store surface is overwritten in that area.
// re-use the source surface for the pattern
mmlGdcSmResetSurfaceObject(surfSrc);
UTIL_SUCCESS(ret, mmlGdcSmAssignBuffer(surfSrc, patternWidth, patternHeight,
MML_GDC_SURF_FORMAT_R8G8B8A8, (
void
*)patternAddr, 0));
// create the pattern directly to VRAM
CreatePattern((MM_U32)patternAddr, patternSize, patternWidth, patternHeight);
// add it to the context as ’source’
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(ctx, MML_GDC_PE_SRC, surfSrc));
UTIL_SUCCESS(ret, mmlGdcPeBlt(ctx, 35.0f, 45.0f));
Creating the pattern:
static
void
CreatePattern(MM_U32 addr, MM_U32 size, MM_U32 width, MM_U32 height)
{
MM_U32 x;
MM_U32 y;
MM_U32 red;
MM_U32 green;
MM_U32 blue;
MM_U32 alpha;
MM_GDC_LOCK(addr, size, MA_WRITE);
for
(x = 0; x < width; x++)
{