看了几天SurfaceFlinger源码,发现在Android源码环境下可以用C++来进行绘图操作,特将代码记下,以供后来参考
testsurface.cpp
#include <cutils/memory.h>
#include <unistd.h>
#include <utils/Log.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include <ui/DisplayInfo.h>
#include <ui/Rect.h>
#include <ui/Region.h>
#include <SkGraphics.h>
#include <SkBitmap.h>
#include <SkCanvas.h>
#include <SkDevice.h>
#include <SkStream.h>
#include <images/SkImageDecoder.h>
#include <hardware/hwcomposer_defs.h>
using namespace android;
static SkBitmap::Config convertPixelFormat(PixelFormat format) {
/* note: if PIXEL_FORMAT_RGBX_8888 means that all alpha bytes are 0xFF, then
we can map to SkBitmap::kARGB_8888_Config, and opti

本文记录了作者在深入研究SurfaceFlinger源码后,发现Android系统允许使用C++进行绘图操作。通过分享testsurface.cpp代码,为后续开发者提供参考。
最低0.47元/天 解锁文章
1455





