issue #2412:remove platform.cpp/.h

This commit is contained in:
minggo 2013-07-19 13:42:45 +08:00
parent d37161a143
commit 7704ab9161
19 changed files with 18 additions and 140 deletions

View File

@ -1 +1 @@
1ab0fd6fdad74af8ce054c089d8571a05a7a04d8
d4930675bbb21e1d9e49d7df7515af349e2ffdb7

View File

@ -82,7 +82,6 @@ platform/CCImageCommonWebp.cpp \
platform/CCSAXParser.cpp \
platform/CCThread.cpp \
platform/CCFileUtils.cpp \
platform/platform.cpp \
platform/CCEGLViewProtocol.cpp \
platform/android/CCDevice.cpp \
platform/android/CCEGLView.cpp \

View File

@ -24,11 +24,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
// cocos2d includes
#include "CCDirector.h"
// standard includes
#include <string>
// cocos2d includes
#include "CCDirector.h"
#include "ccFPSImages.h"
#include "draw_nodes/CCDrawingPrimitives.h"
#include "CCConfiguration.h"
@ -43,7 +44,6 @@ THE SOFTWARE.
#include "textures/CCTextureCache.h"
#include "sprite_nodes/CCSpriteFrameCache.h"
#include "cocoa/CCAutoreleasePool.h"
#include "platform/platform.h"
#include "platform/CCFileUtils.h"
#include "CCApplication.h"
#include "label_nodes/CCLabelBMFont.h"
@ -134,7 +134,7 @@ bool Director::init(void)
_drawsLabel = NULL;
_totalFrames = _frames = 0;
_FPS = new char[10];
_lastUpdate = new struct cc_timeval();
_lastUpdate = new struct timeval;
// paused ?
_paused = false;
@ -311,9 +311,9 @@ void Director::drawScene(void)
void Director::calculateDeltaTime(void)
{
struct cc_timeval now;
struct timeval now;
if (Time::gettimeofdayCocos2d(&now, NULL) != 0)
if (gettimeofday(&now, NULL) != 0)
{
CCLOG("error in gettimeofday");
_deltaTime = 0;
@ -794,7 +794,7 @@ void Director::resume(void)
setAnimationInterval(_oldAnimationInterval);
if (Time::gettimeofdayCocos2d(_lastUpdate, NULL) != 0)
if (gettimeofday(_lastUpdate, NULL) != 0)
{
CCLOG("cocos2d: Director: Error in gettimeofday");
}
@ -841,8 +841,8 @@ void Director::showStats(void)
void Director::calculateMPF()
{
struct cc_timeval now;
Time::gettimeofdayCocos2d(&now, NULL);
struct timeval now;
gettimeofday(&now, NULL);
_secondsPerFrame = (now.tv_sec - _lastUpdate->tv_sec) + (now.tv_usec - _lastUpdate->tv_usec) / 1000000.0f;
}
@ -1050,7 +1050,7 @@ Accelerometer* Director::getAccelerometer()
// so we now only support DisplayLinkDirector
void DisplayLinkDirector::startAnimation(void)
{
if (Time::gettimeofdayCocos2d(_lastUpdate, NULL) != 0)
if (gettimeofday(_lastUpdate, NULL) != 0)
{
CCLOG("cocos2d: DisplayLinkDirector: Error on gettimeofday");
}

View File

@ -28,6 +28,7 @@ THE SOFTWARE.
#define __CCDIRECTOR_H__
#include "platform/CCPlatformMacros.h"
#include "cocoa/CCObject.h"
#include "ccTypes.h"
#include "cocoa/CCGeometry.h"
@ -405,7 +406,7 @@ protected:
Array* _scenesStack;
/* last time the main loop was updated */
struct cc_timeval *_lastUpdate;
struct timeval *_lastUpdate;
/* whether or not the next delta time will be zero */
bool _nextDeltaTimeZero;

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
#include "CCGrabber.h"
#include "ccMacros.h"
#include "textures/CCTexture2D.h"
#include "platform/platform.h"
NS_CC_BEGIN

View File

@ -130,7 +130,6 @@ THE SOFTWARE.
#include "platform/CCImage.h"
#include "platform/CCSAXParser.h"
#include "platform/CCThread.h"
#include "platform/platform.h"
#include "platform/CCPlatformConfig.h"
#include "platform/CCPlatformMacros.h"

View File

@ -32,7 +32,6 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
#include "CCLabelBMFont.h"
#include "cocoa/CCString.h"
#include "platform/platform.h"
#include "cocoa/CCDictionary.h"
#include "CCConfiguration.h"
#include "draw_nodes/CCDrawingPrimitives.h"

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
#include "CCConfiguration.h"
#include "misc_nodes/CCRenderTexture.h"
#include "CCDirector.h"
#include "platform/platform.h"
#include "platform/CCImage.h"
#include "shaders/CCGLProgram.h"
#include "shaders/ccGLStateCache.h"

View File

@ -49,7 +49,6 @@ THE SOFTWARE.
#include "support/base64.h"
#include "platform/CCFileUtils.h"
#include "platform/CCImage.h"
#include "platform/platform.h"
#include "support/zip_support/ZipUtils.h"
#include "CCDirector.h"
#include "support/CCProfiling.h"

View File

@ -1,51 +0,0 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform.h"
#include "CCStdC.h"
NS_CC_BEGIN
int Time::gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp)
{
CC_UNUSED_PARAM(tzp);
if (tp)
{
gettimeofday((struct timeval *)tp, 0);
}
return 0;
}
double Time::timersubCocos2d(struct cc_timeval *start, struct cc_timeval *end)
{
if (! start || ! end)
{
return 0;
}
return ((end->tv_sec*1000.0+end->tv_usec/1000.0) - (start->tv_sec*1000.0+start->tv_usec/1000.0));
}
NS_CC_END

View File

@ -1,60 +0,0 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#include "CCThread.h"
#include "CCPlatformMacros.h"
NS_CC_BEGIN
/**
* @addtogroup platform
* @{
*/
struct CC_DLL cc_timeval
{
#ifdef __native_client__
time_t tv_sec; // seconds
#else
long tv_sec; // seconds
#endif
int tv_usec; // microSeconds
};
class CC_DLL Time
{
public:
static int gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp);
static double timersubCocos2d(struct cc_timeval *start, struct cc_timeval *end);
};
// end of platform group
/// @}
NS_CC_END
#endif // __PLATFORM_H__

View File

@ -63,7 +63,6 @@ SOURCES = ../actions/CCAction.cpp \
../particle_nodes/CCParticleBatchNode.cpp \
../platform/CCSAXParser.cpp \
../platform/CCThread.cpp \
../platform/platform.cpp \
../platform/CCImageCommonWebp.cpp \
../platform/CCEGLViewProtocol.cpp \
../platform/CCFileUtils.cpp \

View File

@ -57,7 +57,6 @@ SOURCES = ../actions/CCAction.cpp \
../particle_nodes/CCParticleBatchNode.cpp \
../platform/CCSAXParser.cpp \
../platform/CCThread.cpp \
../platform/platform.cpp \
../platform/CCImageCommonWebp.cpp \
../platform/CCEGLViewProtocol.cpp \
../platform/CCFileUtils.cpp \

View File

@ -141,7 +141,7 @@ void ProfilingBeginTimingBlock(const char *timerName)
timer = p->createAndAddTimerWithName(timerName);
}
gettimeofday((struct timeval *)&timer->_startTime, NULL);
gettimeofday(&timer->_startTime, NULL);
timer->numberOfCalls++;
}
@ -156,7 +156,8 @@ void ProfilingEndTimingBlock(const char *timerName)
struct timeval currentTime;
gettimeofday(&currentTime, NULL);
double duration = Time::timersubCocos2d((struct cc_timeval *)&timer->_startTime, (struct cc_timeval *)&currentTime);
double duration = (currentTime.tv_sec*1000.0 + currentTime.tv_usec/1000.0) -
(timer->_startTime.tv_sec*1000.0 + timer->_startTime.tv_usec/1000.0);
// milliseconds
timer->_averageTime = (timer->_averageTime + duration) / 2.0f;

View File

@ -27,7 +27,6 @@ THE SOFTWARE.
#include "ccConfig.h"
#include "cocoa/CCObject.h"
#include "platform/platform.h"
#include "cocoa/CCDictionary.h"
#include <string>
@ -76,14 +75,14 @@ public:
bool initWithName(const char* timerName);
~ProfilingTimer(void);
const char* description(void) const;
inline struct cc_timeval * getStartTime(void) { return &_startTime; };
inline struct timeval * getStartTime(void) { return &_startTime; };
inline void setAverageTime(double value) { _averageTime = value; }
inline double getAverageTime(void) { return _averageTime; }
/** resets the timer properties */
void reset();
std::string _nameStr;
struct cc_timeval _startTime;
struct timeval _startTime;
double _averageTime;
double minTime;
double maxTime;

View File

@ -34,7 +34,6 @@ THE SOFTWARE.
#include "ccConfig.h"
#include "ccMacros.h"
#include "CCConfiguration.h"
#include "platform/platform.h"
#include "platform/CCImage.h"
#include "CCGL.h"
#include "support/ccUtils.h"

View File

@ -33,7 +33,6 @@ THE SOFTWARE.
#include "CCTexture2D.h"
#include "ccMacros.h"
#include "CCDirector.h"
#include "platform/platform.h"
#include "platform/CCFileUtils.h"
#include "platform/CCThread.h"
#include "support/ccUtils.h"

View File

@ -33,7 +33,6 @@ THE SOFTWARE.
#include "platform/CCFileUtils.h"
#include "support/zip_support/ZipUtils.h"
#include "support/base64.h"
#include "platform/platform.h"
using namespace std;
/*

View File

@ -4,7 +4,6 @@
#include "cocos2d.h"
#include "../testBasic.h"
#include "platform/platform.h"
class TextureCacheTest : public Layer
{