2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
http://www.cocos2d-x.org
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
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:
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
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 __NewRendererTest_H_
|
|
|
|
#define __NewRendererTest_H_
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "../BaseTest.h"
|
|
|
|
|
|
|
|
#define kTagSpriteBatchNode 100
|
2021-12-28 21:27:32 +08:00
|
|
|
#define kTagClipperNode 101
|
|
|
|
#define kTagContentNode 102
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
DEFINE_TEST_SUITE(NewRendererTests);
|
|
|
|
|
|
|
|
class MultiSceneTest : public TestCase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
};
|
|
|
|
|
|
|
|
class NewSpriteTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NewSpriteTest);
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
void createSpriteTest();
|
|
|
|
void createNewSpriteTest();
|
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
NewSpriteTest();
|
|
|
|
virtual ~NewSpriteTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
class GroupCommandTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(GroupCommandTest);
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
protected:
|
|
|
|
GroupCommandTest();
|
|
|
|
virtual ~GroupCommandTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
class NewClippingNodeTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NewClippingNodeTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2021-12-28 21:27:32 +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);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
NewClippingNodeTest();
|
|
|
|
virtual ~NewClippingNodeTest();
|
|
|
|
|
|
|
|
bool _scrolling;
|
|
|
|
cocos2d::Vec2 _lastPoint;
|
|
|
|
};
|
|
|
|
|
|
|
|
class NewDrawNodeTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NewDrawNodeTest)
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
NewDrawNodeTest();
|
|
|
|
virtual ~NewDrawNodeTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
class NewCullingTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NewCullingTest)
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
protected:
|
|
|
|
NewCullingTest();
|
|
|
|
virtual ~NewCullingTest();
|
2021-12-28 21:27:32 +08:00
|
|
|
bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
|
|
|
|
void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event);
|
2019-11-23 20:27:39 +08:00
|
|
|
cocos2d::Vec2 _lastPos;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SpriteCreation : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(SpriteCreation);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
2021-12-28 21:27:32 +08:00
|
|
|
void addSpritesCallback(Ref*);
|
|
|
|
void delSpritesCallback(Ref*);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
void updateSpriteCountLabel(int x);
|
|
|
|
|
|
|
|
void doTest();
|
|
|
|
|
|
|
|
protected:
|
2021-12-28 21:27:32 +08:00
|
|
|
int totalSprites = 1000;
|
|
|
|
int suggestDelta = 100;
|
|
|
|
cocos2d::Label* _labelSpriteNum = nullptr;
|
|
|
|
cocos2d::Label* labelCreate = nullptr;
|
|
|
|
cocos2d::Label* labelDestory = nullptr;
|
2019-11-23 20:27:39 +08:00
|
|
|
SpriteCreation();
|
|
|
|
virtual ~SpriteCreation();
|
|
|
|
};
|
|
|
|
|
|
|
|
class VBOFullTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(VBOFullTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
VBOFullTest();
|
|
|
|
virtual ~VBOFullTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
class CaptureScreenTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
static const int childTag = 119;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
public:
|
|
|
|
CREATE_FUNC(CaptureScreenTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CaptureScreenTest();
|
|
|
|
~CaptureScreenTest();
|
|
|
|
|
|
|
|
void onCaptured(cocos2d::Ref*);
|
2021-12-28 21:27:32 +08:00
|
|
|
void afterCaptured(bool succeed, std::string_view outputFile);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
std::string _filename;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CaptureNodeTest : public MultiSceneTest
|
|
|
|
{
|
|
|
|
static const int childTag = 120;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BugAutoCulling : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(BugAutoCulling);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
protected:
|
|
|
|
BugAutoCulling();
|
|
|
|
};
|
|
|
|
|
|
|
|
class RendererBatchQuadTri : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(RendererBatchQuadTri);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
protected:
|
|
|
|
RendererBatchQuadTri();
|
|
|
|
};
|
|
|
|
|
|
|
|
class RendererUniformBatch : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(RendererUniformBatch);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
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;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
protected:
|
|
|
|
RendererUniformBatch2();
|
|
|
|
|
|
|
|
cocos2d::backend::ProgramState* createBlurProgramState();
|
|
|
|
cocos2d::backend::ProgramState* createSepiaProgramState();
|
|
|
|
};
|
|
|
|
|
|
|
|
class NonBatchSprites : public MultiSceneTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NonBatchSprites);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
virtual void update(float dt) override;
|
2021-12-28 21:27:32 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
protected:
|
|
|
|
NonBatchSprites();
|
|
|
|
|
|
|
|
void createSprite();
|
|
|
|
|
|
|
|
virtual ~NonBatchSprites();
|
2021-12-28 21:27:32 +08:00
|
|
|
class Ticker
|
|
|
|
{
|
2019-11-23 20:27:39 +08:00
|
|
|
public:
|
2021-12-28 21:27:32 +08:00
|
|
|
Ticker(int m) : _max(m) {}
|
|
|
|
void hit() { _cnt += 1; }
|
|
|
|
void cancel() { _cnt = 0; }
|
|
|
|
bool ok() { return _cnt >= _max; }
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
private:
|
|
|
|
int _cnt = 0;
|
|
|
|
int _max = 0;
|
|
|
|
};
|
2021-12-28 21:27:32 +08:00
|
|
|
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-11-23 20:27:39 +08:00
|
|
|
};
|
2021-12-28 21:27:32 +08:00
|
|
|
#endif //__NewRendererTest_H_
|