1.在frameworks/native/services/surfaceflinger/SurfaceFlinger.h class SurfaceFlinger : public BnSurfaceComposer, private IBinder::DeathRecipient,private HWComposer::EventHandler{ void debugShowFPS(); //add mat4 mPreviousColorMatrix; }; 2.在frameworks/native/services/surfaceflinger/SurfaceFlinger_hwc1.cpp oid SurfaceFlinger::debugShowFPS(){ /* uint32_t flipCount = getDefaultDisplayDevice()->getPageFlipCount(); flipCount: SurfaceFlinger合成帧次数,即向屏幕提交多少帧数据. 在t1 时刻获取 mPageFlipCount 的数值 v1,在在 t2时刻获取 mPageFlipCount 的数值 v2,FPS 的计算公式: FPS = (v2 - v1) / (t2 - t1); */ static int mFrameCount; //就是flipCount的值,static全局变量 static int mLastFrameCount = 0; static nsecs_t mLastFpsTime = 0; static float mFps = 0; char value[16]; mFrameCount++; nsecs_t now = systemTime(); nsecs_t diff = now - mLastFpsTime; ALOGE(“xxx———> %s(), %d, startTime = %tu",__FUNCTION__,__LINE__,mLastFpsTime/(1000*1000));//ms ALOGE(“xxx———> %s(), %d, endTime = %tu",__FUNCTION__,__LINE__,now/(1000*1000));//ms ALOGE(“xxx———> %s(), %d, diff = %tu",__FUNCTION__,__LINE__,diff/(1000*1000));//ms ALOGE(“xxx———> %s(), %d, mFrameCount = %d",__FUNCTION__,__LINE__,mFrameCount);// //if(diff > ms2ns(250)) {//250ms显示一次 if(diff > ms2ns(1000)) {//1s显示一次 ALOGE("zgj------> %s(), %d, mCount ================ %d",__FUNCTION__,__LINE__,mFrameCount - mLastFrameCount);//mCount:SurfaceFlinger1s合成的帧率 mFps = ((mFrameCount - mLastFrameCount) * float(s2ns(1))) / diff; mLastFpsTime = now; mLastFrameCount = mFrameCount; property_get("debug.showfps.flags", value, "0"); if (value[0] == '1') { ALOGE(“xxx———> %s(), %d, fps ======================> %.2f",__FUNCTION__,__LINE__,mFps); } } } 3.编译 # mm 注意:此时需要拷贝system/lib64/libsurfaceflinger.so,然后push到设备的/system/lib64下,重启或杀死surfaceflinger即可. 4.启动打印 # adb shell setprop debug.showfps.flags 1
Android7.1在SurfaceFlinger实时显示帧率
猜你喜欢
转载自blog.csdn.net/u010164190/article/details/80227593
今日推荐
周排行