PuzzleSDK
TextureMemoryAlloc类 参考

#include <Texture2dTest.h>

+ 类 TextureMemoryAlloc 继承关系图:
+ TextureMemoryAlloc 的协作图:

Public 成员函数

 CREATE_FUNC (TextureMemoryAlloc)
 
virtual void onEnter () override
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
void updateImage (cocos2d::Ref *sender)
 
void changeBackgroundVisible (cocos2d::Ref *sender)
 
- Public 成员函数 继承自 TextureDemo
virtual ~TextureDemo ()
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

Private 属性

cocos2d::Sprite * _background
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 Texture2dTest.h488 行定义.

成员函数说明

◆ changeBackgroundVisible()

void TextureMemoryAlloc::changeBackgroundVisible ( cocos2d::Ref *  sender)

在文件 Texture2dTest.cpp1896 行定义.

1897{
1898 if (_background)
1899 {
1900 _background->setVisible(true);
1901 }
1902}
cocos2d::Sprite * _background

引用了 _background.

被这些函数引用 onEnter().

+ 这是这个函数的调用关系图:

◆ CREATE_FUNC()

TextureMemoryAlloc::CREATE_FUNC ( TextureMemoryAlloc  )

◆ onEnter()

void TextureMemoryAlloc::onEnter ( )
overridevirtual

重载 TextureDemo .

在文件 Texture2dTest.cpp1857 行定义.

1858{
1860 _background = nullptr;
1861
1862 MenuItemFont::setFontSize(24);
1863
1864 auto item1 = MenuItemFont::create("PNG", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1865 item1->setTag(0);
1866
1867 auto item2 = MenuItemFont::create("RGBA8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1868 item2->setTag(1);
1869
1870 auto item3 = MenuItemFont::create("RGB8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1871 item3->setTag(2);
1872
1873 auto item4 = MenuItemFont::create("RGBA4", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1874 item4->setTag(3);
1875
1876 auto item5 = MenuItemFont::create("A8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
1877 item5->setTag(4);
1878
1879 auto menu = Menu::create(item1, item2, item3, item4, item5, nullptr);
1880 menu->alignItemsHorizontally();
1881
1882 addChild(menu);
1883
1884 auto warmup = MenuItemFont::create("warm up texture", CC_CALLBACK_1(TextureMemoryAlloc::changeBackgroundVisible, this));
1885
1886 auto menu2 = Menu::create(warmup, nullptr);
1887
1888 menu2->alignItemsHorizontally();
1889
1890 addChild(menu2);
1891 auto s = Director::getInstance()->getWinSize();
1892
1893 menu2->setPosition(Vec2(s.width/2, s.height/4));
1894}
virtual void onEnter() override
void updateImage(cocos2d::Ref *sender)
void changeBackgroundVisible(cocos2d::Ref *sender)

引用了 _background, changeBackgroundVisible(), TextureDemo::onEnter() , 以及 updateImage().

+ 函数调用图:

◆ subtitle()

std::string TextureMemoryAlloc::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 Texture2dTest.cpp1948 行定义.

1949{
1950 return "Testing Texture Memory allocation. Use Instruments + VM Tracker";
1951}

◆ title()

std::string TextureMemoryAlloc::title ( ) const
overridevirtual

重载 TestCase .

在文件 Texture2dTest.cpp1943 行定义.

1944{
1945 return "Texture memory";
1946}

◆ updateImage()

void TextureMemoryAlloc::updateImage ( cocos2d::Ref *  sender)

在文件 Texture2dTest.cpp1904 行定义.

1905{
1906 if (_background)
1907 {
1908 _background->removeFromParentAndCleanup(true);
1909 }
1910
1911 Director::getInstance()->getTextureCache()->removeUnusedTextures();
1912
1913 int tag = ((Node*)sender)->getTag();
1914 std::string file;
1915 switch (tag)
1916 {
1917 case 0:
1918 file = "Images/test_image.png";
1919 break;
1920 case 1:
1921 file = "Images/test_image_rgba8888.pvr";
1922 break;
1923 case 2:
1924 file = "Images/test_image_rgb888.pvr";
1925 break;
1926 case 3:
1927 file = "Images/test_image_rgba4444.pvr";
1928 break;
1929 case 4:
1930 file = "Images/test_image_a8.pvr";
1931 break;
1932 }
1933
1934 _background = Sprite::create(file.c_str());
1935 addChild(_background, -10);
1936
1937 _background->setVisible(false);
1938
1939 auto s = Director::getInstance()->getWinSize();
1940 _background->setPosition(Vec2(s.width/2, s.height/2));
1941}

引用了 _background.

被这些函数引用 onEnter().

+ 这是这个函数的调用关系图:

类成员变量说明

◆ _background

cocos2d::Sprite* TextureMemoryAlloc::_background
private

在文件 Texture2dTest.h498 行定义.

被这些函数引用 changeBackgroundVisible(), onEnter() , 以及 updateImage().


该类的文档由以下文件生成: