Hi!
I'm going back to the road of using skia to render text.
Based on the surfaceflingersink project, I add a text code to draw something with skia, and post to android surface:
------------------------------
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kRGB_565_Config, 320, 320);
bitmap.allocPixels();
SkCanvas canvas(new SkDevice(bitmap));
SkPaint paint;
paint.setARGB(255, 255, 0, 0);
paint.setStyle (SkPaint::kFill_Style);
SkRect r;
r.set(25, 25, 145, 145);
canvas.drawRect(r, paint);
if (++videodev->buf_index == MAX_FRAME_BUFFERS) videodev->buf_index = 0;
memcpy ( static_cast<unsigned char *>(videodev->frame_heap->base()) + videodev->frame_offset[videodev->buf_index], bitmap.getPixels(), bitmap.getSize());
videodev->isurface->postBuffer(videodev->frame_offset[videodev->buf_index]);
------------------------------------
Some strange blue dots appeared, not my expected red rectangle.
I add the code to save the bitmap ito png file:
------------------------------------
SkImageEncoder::EncodeFile("/media/snapshot.png", bitmap, SkImageEncoder::kPNG_Type, 100);
------------------------------------
The png file is correctly displayed.
Is bitmap.getPixels() the correct method to get the bitmap raw data?
Another question is, does the surface config affect the final output?
------------------------------------
videodev->surface = videoClient->createSurface (pid, 0, width, height, PIXEL_FORMAT_RGB_565, 0x00000200 | 0x00000000); //SurfaceComposer::ePushBuffers || ISurfaceComposer::eFXSurfaceNormal
------------------------------------
I've changed the config of surface and bitmap both to PIXEL_FORMAT_RGBA_8888 and kARGB_8888_Config, but the output is still wrong, only the bg color of png becomes white from black.