Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
38
Figure 13. Constant color
6.5.5 A simple black-and-white image
Now a second surface surfSrc is needed for the source path. It has to be initialized with
mmlGdcSmResetSurfaceObject and filled with the image data; a simple 32 x 32 pixel black-and-white image. As it is
a 1 bpp image, MML_GDC_SURF_FORMAT_RGB1 is used for the color format.
The store surface keeps the same, but the new source surface has to be added to the context. mmlGdcPeBlt copies
the image to the store surface at position 20/20.
// initialization of surfSrc
mmlGdcSmResetSurfaceObject(surfSrc);
CopyToVram(black_and_white, (MM_U32)vImgAddr, imgSize);
// use the black-and-white format
UTIL_SUCCESS(ret, mmlGdcSmAssignBuffer(surfSrc, imgWidth, imgHeight,
MML_GDC_SURF_FORMAT_RGB1, vImgAddr, 0));
// add it to the context as ’source’
UTIL_SUCCESS(ret, mmlGdcPeBindSurface(ctx, MML_GDC_PE_SRC, surfSrc));
UTIL_SUCCESS(ret, mmlGdcPeBlt(ctx, 20.0f, 20.0f));
CopyToVram is a small helper function to copy the image data to its destination in the VRAM.
static
void
CopyToVram(
const
void
* data, MM_U32 addr, MM_U32 size)
{
void
*vaddr = (
void
*)addr;
MM_GDC_LOCK(vaddr, size, MA_WRITE);
memcpy(vaddr, data, size);
MM_GDC_UNLOCK(vaddr);
}