diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index ea2e4b2f0f..6986b39898 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -337,7 +337,9 @@ void Director::drawScene() if (_displayStats) { +#if !CC_STRIP_FPS showStats(); +#endif } _renderer->render(); @@ -356,7 +358,9 @@ void Director::drawScene() if (_displayStats) { +#if !CC_STRIP_FPS calculateMPF(); +#endif } } @@ -1257,6 +1261,8 @@ void Director::updateFrameRate() _frameRate = 1.0f / _deltaTime; } +#if !CC_STRIP_FPS + // display the FPS using a LabelAtlas // updates the FPS every frame void Director::showStats() @@ -1402,6 +1408,8 @@ void Director::createStatsLabel() _FPSLabel->setPosition(Vec2(0, height_spacing*0)+CC_DIRECTOR_STATS_POSITION); } +#endif // #if !CC_STRIP_FPS + void Director::setContentScaleFactor(float scaleFactor) { if (scaleFactor != _contentScaleFactor) diff --git a/cocos/base/CCDirector.h b/cocos/base/CCDirector.h index b046062da8..4512cabd9c 100644 --- a/cocos/base/CCDirector.h +++ b/cocos/base/CCDirector.h @@ -593,10 +593,12 @@ protected: void setNextScene(); void updateFrameRate(); +#if !CC_STRIP_FPS void showStats(); void createStatsLabel(); void calculateMPF(); void getFPSImageData(unsigned char** datapointer, ssize_t* length); +#endif /** calculates delta time since last time it was called */ void calculateDeltaTime(); diff --git a/cocos/base/ccConfig.h b/cocos/base/ccConfig.h index 9f17fc89e2..9a0c4a5625 100644 --- a/cocos/base/ccConfig.h +++ b/cocos/base/ccConfig.h @@ -398,4 +398,11 @@ THE SOFTWARE. # define CC_ENABLE_PREMULTIPLIED_ALPHA 1 #endif +/** @def CC_STRIP_FPS + * Whether to strip FPS related data and functions, such as cc_fps_images_png + */ +#ifndef CC_STRIP_FPS +#define CC_STRIP_FPS 0 +#endif + #endif // __CCCONFIG_H__ diff --git a/cocos/base/ccFPSImages.c b/cocos/base/ccFPSImages.c index a03acf3d2b..321422d87e 100644 --- a/cocos/base/ccFPSImages.c +++ b/cocos/base/ccFPSImages.c @@ -25,6 +25,8 @@ #include "base/ccFPSImages.h" +#if !CC_STRIP_FPS + unsigned char cc_fps_images_png[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x03, 0xe7, 0x00, 0x00, 0x00, 0x36, @@ -2376,3 +2378,5 @@ unsigned int cc_fps_images_len(void) { return sizeof(cc_fps_images_png); } + +#endif // #if !CC_STRIP_FPS diff --git a/cocos/base/ccFPSImages.h b/cocos/base/ccFPSImages.h index 42145b10a7..52abc056e2 100644 --- a/cocos/base/ccFPSImages.h +++ b/cocos/base/ccFPSImages.h @@ -23,20 +23,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __BASE_CCFPSIMAGES__H -#define __BASE_CCFPSIMAGES__H +#pragma once + +#include "base/ccConfig.h" + /// @cond DO_NOT_SHOW #ifdef __cplusplus extern "C" { #endif +#if !CC_STRIP_FPS extern unsigned char cc_fps_images_png[]; -unsigned int cc_fps_images_len(void); +unsigned int cc_fps_images_len(); +#endif #ifdef __cplusplus } #endif /// @endcond -#endif // __BASE_CCFPSIMAGES__H