2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-11-05 01:14:22 +08:00
|
|
|
#ifndef __NewRendererTest_H_
|
|
|
|
#define __NewRendererTest_H_
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "../BaseTest.h"
|
|
|
|
|
2013-11-13 03:53:53 +08:00
|
|
|
#define kTagSpriteBatchNode 100
|
2013-11-16 03:29:11 +08:00
|
|
|
#define kTagClipperNode 101
|
|
|
|
#define kTagContentNode 102
|
2013-11-13 03:53:53 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(NewRendererTests);
|
2013-11-13 03:19:18 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class MultiSceneTest : public TestCase
|
2013-11-13 03:19:18 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-11-27 08:54:48 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2013-11-13 03:19:18 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class NewSpriteTest : public MultiSceneTest
|
2013-11-05 01:14:22 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-27 08:54:48 +08:00
|
|
|
CREATE_FUNC(NewSpriteTest);
|
2013-11-13 03:19:18 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-11-05 01:14:22 +08:00
|
|
|
|
|
|
|
void createSpriteTest();
|
|
|
|
void createNewSpriteTest();
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2013-11-05 01:14:22 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-27 08:54:48 +08:00
|
|
|
NewSpriteTest();
|
|
|
|
virtual ~NewSpriteTest();
|
2013-11-05 01:14:22 +08:00
|
|
|
};
|
|
|
|
|
2014-04-07 22:02:43 +08:00
|
|
|
class GroupCommandTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(GroupCommandTest);
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GroupCommandTest();
|
|
|
|
virtual ~GroupCommandTest();
|
|
|
|
};
|
|
|
|
|
2013-11-16 03:29:11 +08:00
|
|
|
class NewClippingNodeTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-05 01:14:22 +08:00
|
|
|
|
2013-11-27 08:54:48 +08:00
|
|
|
CREATE_FUNC(NewClippingNodeTest);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-11-15 08:39:03 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
|
|
|
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event *event);
|
2013-11-16 03:29:11 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-27 08:54:48 +08:00
|
|
|
NewClippingNodeTest();
|
|
|
|
virtual ~NewClippingNodeTest();
|
|
|
|
|
2013-11-16 03:29:11 +08:00
|
|
|
bool _scrolling;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Vec2 _lastPoint;
|
2013-11-16 03:29:11 +08:00
|
|
|
};
|
2013-11-15 08:39:03 +08:00
|
|
|
|
2013-11-20 05:57:39 +08:00
|
|
|
class NewDrawNodeTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-11-27 08:54:48 +08:00
|
|
|
CREATE_FUNC(NewDrawNodeTest)
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-11-20 05:57:39 +08:00
|
|
|
|
|
|
|
protected:
|
2013-11-27 08:54:48 +08:00
|
|
|
NewDrawNodeTest();
|
|
|
|
virtual ~NewDrawNodeTest();
|
2013-11-20 05:57:39 +08:00
|
|
|
};
|
|
|
|
|
2013-11-27 10:35:23 +08:00
|
|
|
class NewCullingTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
CREATE_FUNC(NewCullingTest)
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-11-27 10:35:23 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
NewCullingTest();
|
|
|
|
virtual ~NewCullingTest();
|
2015-04-09 08:37:30 +08:00
|
|
|
bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event *event);
|
|
|
|
void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event *event);
|
|
|
|
cocos2d::Vec2 _lastPos;
|
2013-11-27 10:35:23 +08:00
|
|
|
};
|
|
|
|
|
2019-08-05 14:25:58 +08:00
|
|
|
class SpriteCreation : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(SpriteCreation);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
void addSpritesCallback(Ref *);
|
|
|
|
void delSpritesCallback(Ref *);
|
|
|
|
|
|
|
|
void updateSpriteCountLabel(int x);
|
|
|
|
|
|
|
|
void doTest();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int totalSprites = 1000;
|
|
|
|
int suggestDelta = 100;
|
|
|
|
cocos2d::Label* _labelSpriteNum = nullptr;
|
|
|
|
cocos2d::Label* labelCreate = nullptr;
|
|
|
|
cocos2d::Label* labelDestory = nullptr;
|
|
|
|
SpriteCreation();
|
|
|
|
virtual ~SpriteCreation();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-01-15 09:03:54 +08:00
|
|
|
class VBOFullTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(VBOFullTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2019-08-05 14:25:58 +08:00
|
|
|
|
2014-01-15 09:03:54 +08:00
|
|
|
protected:
|
|
|
|
VBOFullTest();
|
|
|
|
virtual ~VBOFullTest();
|
|
|
|
};
|
|
|
|
|
2019-08-05 14:25:58 +08:00
|
|
|
|
2014-05-13 16:23:35 +08:00
|
|
|
class CaptureScreenTest : public MultiSceneTest
|
|
|
|
{
|
2014-05-26 16:32:13 +08:00
|
|
|
static const int childTag = 119;
|
2014-05-13 16:23:35 +08:00
|
|
|
public:
|
2014-05-13 17:17:15 +08:00
|
|
|
CREATE_FUNC(CaptureScreenTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-05-13 16:23:35 +08:00
|
|
|
|
|
|
|
protected:
|
2014-05-13 17:17:15 +08:00
|
|
|
CaptureScreenTest();
|
|
|
|
~CaptureScreenTest();
|
2014-05-13 16:23:35 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void onCaptured(cocos2d::Ref*);
|
2014-05-14 01:06:26 +08:00
|
|
|
void afterCaptured(bool succeed, const std::string& outputFile);
|
2014-05-13 16:23:35 +08:00
|
|
|
|
2014-05-14 01:06:26 +08:00
|
|
|
std::string _filename;
|
2014-05-13 16:23:35 +08:00
|
|
|
};
|
|
|
|
|
2016-05-07 22:10:53 +08:00
|
|
|
class CaptureNodeTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
static const int childTag = 120;
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(CaptureNodeTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CaptureNodeTest();
|
|
|
|
~CaptureNodeTest();
|
|
|
|
|
|
|
|
void onCaptured(cocos2d::Ref*);
|
|
|
|
|
|
|
|
std::string _filename;
|
|
|
|
};
|
|
|
|
|
2015-06-29 17:25:13 +08:00
|
|
|
class BugAutoCulling : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(BugAutoCulling);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
protected:
|
|
|
|
BugAutoCulling();
|
2016-02-09 03:25:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class RendererBatchQuadTri : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(RendererBatchQuadTri);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
protected:
|
|
|
|
RendererBatchQuadTri();
|
2015-06-29 17:25:13 +08:00
|
|
|
};
|
|
|
|
|
2019-05-14 09:00:27 +08:00
|
|
|
|
|
|
|
class RendererUniformBatch : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(RendererUniformBatch);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
protected:
|
|
|
|
RendererUniformBatch();
|
|
|
|
|
|
|
|
cocos2d::backend::ProgramState* createBlurProgramState();
|
|
|
|
cocos2d::backend::ProgramState* createSepiaProgramState();
|
|
|
|
};
|
|
|
|
|
|
|
|
class RendererUniformBatch2 : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(RendererUniformBatch2);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
protected:
|
|
|
|
RendererUniformBatch2();
|
|
|
|
|
|
|
|
cocos2d::backend::ProgramState* createBlurProgramState();
|
|
|
|
cocos2d::backend::ProgramState* createSepiaProgramState();
|
|
|
|
};
|
2016-08-08 05:51:02 +08:00
|
|
|
|
2019-03-12 10:37:52 +08:00
|
|
|
class NonBatchSprites : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NonBatchSprites);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2019-08-05 14:25:58 +08:00
|
|
|
virtual void update(float dt) override;
|
2019-03-12 10:37:52 +08:00
|
|
|
protected:
|
|
|
|
NonBatchSprites();
|
2019-08-05 14:25:58 +08:00
|
|
|
|
|
|
|
void createSprite();
|
|
|
|
|
2019-03-12 10:37:52 +08:00
|
|
|
virtual ~NonBatchSprites();
|
2019-08-05 14:25:58 +08:00
|
|
|
class Ticker {
|
|
|
|
public:
|
|
|
|
Ticker(int m):_max(m) {}
|
|
|
|
void hit() {_cnt += 1;}
|
|
|
|
void cancel() {_cnt = 0;}
|
|
|
|
bool ok() {return _cnt >= _max;}
|
|
|
|
private:
|
|
|
|
int _cnt = 0;
|
|
|
|
int _max = 0;
|
|
|
|
};
|
|
|
|
Node *_spritesAnchor = nullptr;
|
|
|
|
int _spriteIndex = 0;
|
|
|
|
float _maDt = 1.0f / 60.0f;
|
|
|
|
float _rmaDt = 1.0f/ 60.0f;
|
|
|
|
const float DEST_DT_30FPS = 1.0f / 30.0f;
|
|
|
|
cocos2d::Label * _totalSprites = nullptr;
|
|
|
|
Ticker _contSlow = Ticker(20);
|
|
|
|
Ticker _contFast = Ticker(2);
|
|
|
|
Ticker _around30fps = Ticker(60 * 3);
|
2019-03-12 10:37:52 +08:00
|
|
|
};
|
2013-11-05 01:14:22 +08:00
|
|
|
#endif //__NewRendererTest_H_
|