Back to project page Media-Pack.
The source code is released under:
Apache License
If you think the Android project Media-Pack listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
// // INTEL CORPORATION PROPRIETARY INFORMATION // This software is supplied under the terms of a license agreement or // nondisclosure agreement with Intel Corporation and may not be copied // or disclosed except in accordance with the terms of that agreement. // Copyright (c) 2013-2014 Intel Corporation. All Rights Reserved. ////from w ww.j a v a 2s . c o m package com.intel.inde.mp.samples; public class FPSCounter { private long mTimeNow; private long mTimePrev; private long mTimeElapsed; private int mFrames; private int mFPS; private int mEveryXFrames; public FPSCounter(int xFrames) { mFrames = 0; mEveryXFrames = xFrames; } public boolean update() { mFrames = (mFrames + 1) % mEveryXFrames; if(mFrames == 0) { mTimeNow = System.currentTimeMillis(); mTimeElapsed = (mTimeNow - mTimePrev) / mEveryXFrames; mTimePrev = mTimeNow; mFPS = (int)(1000.0f / (float)mTimeElapsed); return true; } return false; } public int fps() { return mFPS; } }