axmol/tests/cpp-tests/Classes/UnitTest/UnitTest.cpp

1727 lines
58 KiB
C++
Raw Normal View History

/****************************************************************************
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2022-05-14 04:38:37 +08:00
Copyright (c) 2021-2022 Bytedance Inc.
2021-12-28 16:06:23 +08:00
https://axis-project.github.io/
2021-12-28 16:06:23 +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 16:06:23 +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 16:06:23 +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.
****************************************************************************/
2014-01-03 20:14:03 +08:00
#include "UnitTest.h"
2016-06-30 01:24:23 +08:00
#include "ui/UIHelper.h"
#include "network/Uri.h"
2019-07-19 11:57:11 +08:00
#include "base/ccUtils.h"
2022-05-14 04:38:37 +08:00
#include "yasio/detail/byte_buffer.hpp"
2014-01-03 20:14:03 +08:00
USING_NS_CC;
using namespace cocos2d::network;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
2021-12-28 16:06:23 +08:00
# if defined(__arm64__)
# define USE_NEON64
# define INCLUDE_NEON64
# elif defined(__ARM_NEON__)
# define USE_NEON32
# define INCLUDE_NEON32
# else
# endif
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
2021-12-28 16:06:23 +08:00
# if defined(__arm64__) || defined(__aarch64__)
# define USE_NEON64
# define INCLUDE_NEON64
# elif defined(__ARM_NEON__)
# define INCLUDE_NEON32
# else
# endif
#else
#endif
2021-12-28 16:06:23 +08:00
#if defined(__SSE__)
# define USE_SSE
# define INCLUDE_SSE
#endif
2021-12-28 16:06:23 +08:00
#if (defined INCLUDE_NEON64) || (defined INCLUDE_NEON32) // FIXME: || (defined INCLUDE_SSE)
# define UNIT_TEST_FOR_OPTIMIZED_MATH_UTIL
#endif
#define EXPECT_EQ(a, b) assert((a) == (b))
#define EXPECT_NE(a, b) assert((a) != (b))
#define EXPECT_TRUE(a) assert(a)
#define EXPECT_FALSE(a) assert(!(a))
2014-01-03 20:14:03 +08:00
// For ' < o > ' multiply test scene.
UnitTests::UnitTests()
{
ADD_TEST_CASE(TemplateVectorTest);
ADD_TEST_CASE(TemplateMapTest);
ADD_TEST_CASE(ValueTest);
ADD_TEST_CASE(UTFConversionTest);
2016-06-30 01:24:23 +08:00
ADD_TEST_CASE(UIHelperSubStringTest);
2019-07-19 11:57:11 +08:00
ADD_TEST_CASE(ParseIntegerListTest);
ADD_TEST_CASE(ParseUriTest);
ADD_TEST_CASE(ResizableBufferAdapterTest);
#ifdef UNIT_TEST_FOR_OPTIMIZED_MATH_UTIL
ADD_TEST_CASE(MathUtilTest);
#endif
2014-01-03 20:14:03 +08:00
};
std::string UnitTestDemo::title() const
{
return "UnitTest";
}
//---------------------------------------------------------------
void TemplateVectorTest::onEnter()
{
UnitTestDemo::onEnter();
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
Vector<Node*> vec;
CCASSERT(vec.empty(), "vec should be empty.");
CCASSERT(vec.capacity() == 0, "vec.capacity should be 0.");
CCASSERT(vec.size() == 0, "vec.size should be 0.");
CCASSERT(vec.max_size() > 0, "vec.max_size should > 0.");
2014-01-03 20:14:03 +08:00
auto node1 = Node::create();
node1->setTag(1);
vec.pushBack(node1);
CCASSERT(node1->getReferenceCount() == 2, "node1->getReferenceCount should be 2.");
2014-01-03 20:14:03 +08:00
auto node2 = Node::create();
node2->setTag(2);
vec.pushBack(node2);
CCASSERT(vec.getIndex(node1) == 0, "node1 should at index 0 in vec.");
CCASSERT(vec.getIndex(node2) == 1, "node2 should at index 1 in vec.");
2014-01-03 20:14:03 +08:00
auto node3 = Node::create();
node3->setTag(3);
vec.insert(1, node3);
CCASSERT(vec.at(0)->getTag() == 1, "The element at 0, tag should be 1.");
CCASSERT(vec.at(1)->getTag() == 3, "The element at 1, tag should be 3.");
CCASSERT(vec.at(2)->getTag() == 2, "The element at 2, tag should be 2.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Test copy constructor
Vector<Node*> vec2(vec);
CCASSERT(vec2.size() == vec.size(), "vec2 and vec should have equal size.");
2014-01-03 20:14:03 +08:00
ssize_t size = vec.size();
for (ssize_t i = 0; i < size; ++i)
{
CCASSERT(vec2.at(i) == vec.at(i), "The element at the same index in vec2 and vec2 should be equal.");
CCASSERT(vec.at(i)->getReferenceCount() == 3, "The reference count of element in vec is 3. ");
CCASSERT(vec2.at(i)->getReferenceCount() == 3, "The reference count of element in vec2 is 3. ");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Test copy assignment operator
Vector<Node*> vec3;
vec3 = vec2;
CCASSERT(vec3.size() == vec2.size(), "vec3 and vec2 should have equal size.");
2014-01-03 20:14:03 +08:00
size = vec3.size();
for (ssize_t i = 0; i < size; ++i)
{
CCASSERT(vec3.at(i) == vec2.at(i), "The element at the same index in vec3 and vec2 should be equal.");
CCASSERT(vec3.at(i)->getReferenceCount() == 4, "The reference count of element in vec3 is 4. ");
CCASSERT(vec2.at(i)->getReferenceCount() == 4, "The reference count of element in vec2 is 4. ");
CCASSERT(vec.at(i)->getReferenceCount() == 4, "The reference count of element in vec is 4. ");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Test move constructor
2014-01-03 20:20:40 +08:00
2021-12-28 16:06:23 +08:00
auto createVector = []() {
2014-01-03 20:14:03 +08:00
Vector<Node*> ret;
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (int i = 0; i < 20; i++)
{
ret.pushBack(Node::create());
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
int j = 1000;
for (auto& child : ret)
{
child->setTag(j++);
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
return ret;
};
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
Vector<Node*> vec4(createVector());
for (const auto& child : vec4)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(child);
CCASSERT(child->getReferenceCount() == 2, "child's reference count should be 2.");
2014-01-03 20:14:03 +08:00
}
// Test init Vector<T> with capacity
Vector<Node*> vec5(10);
CCASSERT(vec5.capacity() == 10, "vec5's capacity should be 10.");
2014-01-03 20:14:03 +08:00
vec5.reserve(20);
CCASSERT(vec5.capacity() == 20, "vec5's capacity should be 20.");
2014-01-03 20:20:40 +08:00
CCASSERT(vec5.size() == 0, "vec5's size should be 0.");
CCASSERT(vec5.empty(), "vec5 is empty now.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
auto toRemovedNode = Node::create();
vec5.pushBack(toRemovedNode);
CCASSERT(toRemovedNode->getReferenceCount() == 2, "toRemovedNode's reference count is 2.");
2014-01-03 20:14:03 +08:00
// Test move assignment operator
vec5 = createVector();
CCASSERT(toRemovedNode->getReferenceCount() == 1, "toRemovedNode's reference count is 1.");
2014-01-03 20:14:03 +08:00
CCASSERT(vec5.size() == 20, "size should be 20");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (const auto& child : vec5)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(child);
CCASSERT(child->getReferenceCount() == 2, "child's reference count is 2.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Test Vector<T>::find
CCASSERT(vec.find(node3) == (vec.begin() + 1), "node3 is the 2nd element in vec.");
CCASSERT(std::find(std::begin(vec), std::end(vec), node2) == (vec.begin() + 2), "node2 is the 3rd element in vec.");
2014-01-03 20:20:40 +08:00
CCASSERT(vec.front()->getTag() == 1, "vec's front element's tag is 1.");
CCASSERT(vec.back()->getTag() == 2, "vec's back element's tag is 2.");
2014-01-03 20:20:40 +08:00
CCASSERT(vec.getRandomObject(), "vec getRandomObject should return true.");
CCASSERT(!vec.contains(Node::create()), "vec doesn't contain a empty Node instance.");
CCASSERT(vec.contains(node1), "vec contains node1.");
CCASSERT(vec.contains(node2), "vec contains node2.");
CCASSERT(vec.contains(node3), "vec contains node3.");
CCASSERT(vec.equals(vec2), "vec is equal to vec2.");
CCASSERT(vec.equals(vec3), "vec is equal to vec3.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Insert
vec5.insert(2, node1);
CCASSERT(vec5.at(2)->getTag() == 1, "vec5's 3rd element's tag is 1.");
CCASSERT(vec5.size() == 21, "vec5's size is 21.");
2014-01-03 20:14:03 +08:00
vec5.back()->setTag(100);
vec5.popBack();
CCASSERT(vec5.size() == 20, "vec5's size is 20.");
CCASSERT(vec5.back()->getTag() != 100, "the back element of vec5's tag is 100.");
2014-01-03 20:14:03 +08:00
// Erase and clear
Vector<Node*> vec6 = createVector();
Vector<Node*> vec7 = vec6; // Copy for check
2014-01-03 20:20:40 +08:00
CCASSERT(vec6.size() == 20, "vec6's size is 20.");
2014-01-03 20:14:03 +08:00
vec6.erase(vec6.begin() + 1); //
CCASSERT(vec6.size() == 19, "vec6's size is 19.");
CCASSERT((*(vec6.begin() + 1))->getTag() == 1002, "The 2rd element in vec6's tag is 1002.");
2014-01-03 20:14:03 +08:00
vec6.erase(vec6.begin() + 2, vec6.begin() + 10);
CCASSERT(vec6.size() == 11, "vec6's size is 11.");
CCASSERT(vec6.at(0)->getTag() == 1000, "vec6's first element's tag is 1000.");
CCASSERT(vec6.at(1)->getTag() == 1002, "vec6's second element's tag is 1002.");
CCASSERT(vec6.at(2)->getTag() == 1011, "vec6's third element's tag is 1011.");
CCASSERT(vec6.at(3)->getTag() == 1012, "vec6's fouth element's tag is 1012.");
2014-01-03 20:14:03 +08:00
vec6.erase(3);
CCASSERT(vec6.at(3)->getTag() == 1013, "vec6's 4th element's tag is 1013.");
2014-01-03 20:14:03 +08:00
vec6.eraseObject(vec6.at(2));
CCASSERT(vec6.at(2)->getTag() == 1013, "vec6's 3rd element's tag is 1013.");
2014-01-03 20:14:03 +08:00
vec6.clear();
2021-12-28 16:06:23 +08:00
auto objA = Node::create(); // retain count is 1
auto objB = Node::create();
auto objC = Node::create();
{
Vector<Node*> array1;
Vector<Node*> array2;
2021-12-28 16:06:23 +08:00
// push back objA 3 times
2021-12-28 16:06:23 +08:00
array1.pushBack(objA); // retain count is 2
array1.pushBack(objA); // retain count is 3
array1.pushBack(objA); // retain count is 4
array2.pushBack(objA); // retain count is 5
array2.pushBack(objB);
array2.pushBack(objC);
2021-12-28 16:06:23 +08:00
for (auto obj : array1)
{
array2.eraseObject(obj);
}
CCASSERT(objA->getReferenceCount() == 4, "objA's reference count is 4.");
}
CCASSERT(objA->getReferenceCount() == 1, "objA's reference count is 1.");
2021-12-28 16:06:23 +08:00
{
Vector<Node*> array1;
// push back objA 3 times
2021-12-28 16:06:23 +08:00
array1.pushBack(objA); // retain count is 2
array1.pushBack(objA); // retain count is 3
array1.pushBack(objA); // retain count is 4
CCASSERT(objA->getReferenceCount() == 4, "objA's reference count is 4.");
2021-12-28 16:06:23 +08:00
array1.eraseObject(objA, true); // Remove all occurrences in the Vector.
CCASSERT(objA->getReferenceCount() == 1, "objA's reference count is 1.");
2021-12-28 16:06:23 +08:00
array1.pushBack(objA); // retain count is 2
array1.pushBack(objA); // retain count is 3
array1.pushBack(objA); // retain count is 4
array1.eraseObject(objA, false);
2021-12-28 16:06:23 +08:00
CCASSERT(objA->getReferenceCount() == 3,
"objA's reference count is 3."); // Only remove the first occurrence in the Vector.
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Check the retain count in vec7
CCASSERT(vec7.size() == 20, "vec7's size is 20.");
2014-01-03 20:14:03 +08:00
for (const auto& child : vec7)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(child);
CCASSERT(child->getReferenceCount() == 2, "child's reference count is 2.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Sort
Vector<Node*> vecForSort = createVector();
2021-12-28 16:06:23 +08:00
std::sort(vecForSort.begin(), vecForSort.end(), [](Node* a, Node* b) { return a->getTag() >= b->getTag(); });
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (int i = 0; i < 20; ++i)
{
CCASSERT(vecForSort.at(i)->getTag() - 1000 == (19 - i), "vecForSort's element's tag is invalid.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Reverse
vecForSort.reverse();
for (int i = 0; i < 20; ++i)
{
CCASSERT(vecForSort.at(i)->getTag() - 1000 == i, "vecForSort's element's tag is invalid.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Swap
Vector<Node*> vecForSwap = createVector();
vecForSwap.swap(2, 4);
CCASSERT(vecForSwap.at(2)->getTag() == 1004, "vecForSwap's 3nd element's tag is 1004.");
CCASSERT(vecForSwap.at(4)->getTag() == 1002, "vecForSwap's 5rd element's tag is 1002.");
2014-01-03 20:14:03 +08:00
vecForSwap.swap(vecForSwap.at(2), vecForSwap.at(4));
CCASSERT(vecForSwap.at(2)->getTag() == 1002, "vecForSwap's 3rd element's tag is 1002.");
CCASSERT(vecForSwap.at(4)->getTag() == 1004, "vecForSwap's 5rd element's tag is 1004.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// shrinkToFit
Vector<Node*> vecForShrink = createVector();
vecForShrink.reserve(100);
CCASSERT(vecForShrink.capacity() == 100, "vecForShrink's capacity is 100.");
2014-01-03 20:14:03 +08:00
vecForShrink.pushBack(Node::create());
vecForShrink.shrinkToFit();
CCASSERT(vecForShrink.capacity() == 21, "vecForShrink's capacity is 21.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// get random object
// Set the seed by time
2016-07-11 11:17:28 +08:00
std::srand((unsigned)time(nullptr));
2014-01-03 20:14:03 +08:00
Vector<Node*> vecForRandom = createVector();
log("<--- begin ---->");
for (int i = 0; i < vecForRandom.size(); ++i)
{
log("Vector: random object tag = %d", vecForRandom.getRandomObject()->getTag());
}
log("<---- end ---->");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Self assignment
Vector<Node*> vecSelfAssign = createVector();
2021-12-28 16:06:23 +08:00
vecSelfAssign = vecSelfAssign;
CCASSERT(vecSelfAssign.size() == 20, "vecSelfAssign's size is 20.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (const auto& child : vecSelfAssign)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(child);
CCASSERT(child->getReferenceCount() == 2, "child's reference count is 2.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
vecSelfAssign = std::move(vecSelfAssign);
CCASSERT(vecSelfAssign.size() == 20, "vecSelfAssign's size is 20.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (const auto& child : vecSelfAssign)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(child);
CCASSERT(child->getReferenceCount() == 2, "child's reference count is 2.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// const at
Vector<Node*> vecConstAt = createVector();
constFunc(vecConstAt);
}
void TemplateVectorTest::constFunc(const Vector<Node*>& vec) const
{
log("vec[8] = %d", vec.at(8)->getTag());
}
std::string TemplateVectorTest::subtitle() const
{
return "Vector<T>, should not crash";
}
//---------------------------------------------------------------
void TemplateMapTest::onEnter()
{
UnitTestDemo::onEnter();
2014-01-03 20:20:40 +08:00
2021-12-28 16:06:23 +08:00
auto createMap = []() {
2021-12-28 17:20:17 +08:00
StringMap<Node*> ret;
2014-01-03 20:14:03 +08:00
for (int i = 0; i < 20; ++i)
{
auto node = Node::create();
node->setTag(1000 + i);
ret.insert(StringUtils::toString(i), node);
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
return ret;
};
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Default constructor
Map<std::string, Node*> map1;
CCASSERT(map1.empty(), "map1 is empty.");
CCASSERT(map1.size() == 0, "map1's size is 0.");
CCASSERT(map1.keys().empty(), "map1's keys are empty.");
CCASSERT(map1.keys(Node::create()).empty(), "map1's keys don't contain a empty Node.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Move constructor
2021-12-28 17:20:17 +08:00
auto map2 = createMap();
2014-01-03 20:14:03 +08:00
for (const auto& e : map2)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(e);
CCASSERT(e.second->getReferenceCount() == 2, "e.second element's reference count is 2.");
2014-01-03 20:14:03 +08:00
}
// Copy constructor
2021-12-28 17:20:17 +08:00
auto map3(map2);
2014-01-03 20:14:03 +08:00
for (const auto& e : map3)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(e);
CCASSERT(e.second->getReferenceCount() == 3, "e.second's reference count is 3.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Move assignment operator
2021-12-28 17:20:17 +08:00
StringMap<Node*> map4;
2014-01-03 20:14:03 +08:00
auto unusedNode = Node::create();
2021-12-28 16:06:23 +08:00
map4.insert("unused", unusedNode);
2014-01-03 20:14:03 +08:00
map4 = createMap();
CCASSERT(unusedNode->getReferenceCount() == 1, "unusedNode's reference count is 1.");
2014-01-03 20:14:03 +08:00
for (const auto& e : map4)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(e);
CCASSERT(e.second->getReferenceCount() == 2, "e.second's reference count is 2.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Copy assignment operator
2021-12-28 17:20:17 +08:00
StringMap<Node*> map5;
2014-01-03 20:14:03 +08:00
map5 = map4;
for (const auto& e : map5)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(e);
CCASSERT(e.second->getReferenceCount() == 3, "e.second's reference count is 3.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Check size
CCASSERT(map4.size() == map5.size(), "map4's size is equal to map5.size.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (const auto& e : map4)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(e);
CCASSERT(e.second == map5.find(e.first)->second, "e.second can't be found in map5.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// bucket_count, bucket_size(n), bucket
log("--------------");
log("bucket_count = %d", static_cast<int>(map4.bucketCount()));
log("size = %d", static_cast<int>(map4.size()));
for (int i = 0; i < map4.bucketCount(); ++i)
{
log("bucket_size(%d) = %d", i, static_cast<int>(map4.bucketSize(i)));
}
for (const auto& e : map4)
{
log("bucket(\"%s\"), bucket index = %d", e.first.c_str(), static_cast<int>(map4.bucket(e.first)));
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
log("----- all keys---------");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// keys and at
auto keys = map4.keys();
for (const auto& key : keys)
{
log("key = %s", key.c_str());
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
auto node10Key = map4.at("10");
map4.insert("100", node10Key);
map4.insert("101", node10Key);
map4.insert("102", node10Key);
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
log("------ keys for object --------");
auto keysForObject = map4.keys(node10Key);
for (const auto& key : keysForObject)
{
log("key = %s", key.c_str());
}
log("--------------");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// at in const function
constFunc(map4);
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// find
auto nodeToFind = map4.find("10");
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(nodeToFind);
CCASSERT(nodeToFind->second->getTag() == 1010, "nodeToFind's tag value is 1010.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// insert
Map<std::string, Node*> map6;
auto node1 = Node::create();
node1->setTag(101);
auto node2 = Node::create();
node2->setTag(102);
auto node3 = Node::create();
node3->setTag(103);
map6.insert("insert01", node1);
map6.insert("insert02", node2);
map6.insert("insert03", node3);
2014-01-03 20:20:40 +08:00
CCASSERT(node1->getReferenceCount() == 2, "node1's reference count is 2.");
CCASSERT(node2->getReferenceCount() == 2, "node2's reference count is 2.");
CCASSERT(node3->getReferenceCount() == 2, "node3's reference count is 2.");
CCASSERT(map6.at("insert01") == node1, "The element at insert01 is equal to node1.");
CCASSERT(map6.at("insert02") == node2, "The element at insert02 is equal to node2.");
CCASSERT(map6.at("insert03") == node3, "The element at insert03 is equal to node3.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// erase
2021-12-28 17:20:17 +08:00
StringMap<Node*> mapForErase = createMap();
2014-01-03 20:14:03 +08:00
mapForErase.erase(mapForErase.find("9"));
CCASSERT(mapForErase.find("9") == mapForErase.end(), "9 is already removed.");
CCASSERT(mapForErase.size() == 19, "mapForErase's size is 19.");
2014-01-03 20:14:03 +08:00
mapForErase.erase("7");
CCASSERT(mapForErase.find("7") == mapForErase.end(), "7 is already removed.");
CCASSERT(mapForErase.size() == 18, "mapForErase's size is 18.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
std::vector<std::string> itemsToRemove;
itemsToRemove.push_back("2");
itemsToRemove.push_back("3");
itemsToRemove.push_back("4");
mapForErase.erase(itemsToRemove);
CCASSERT(mapForErase.size() == 15, "mapForErase's size is 15.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// clear
2021-12-28 17:20:17 +08:00
StringMap<Node*> mapForClear = createMap();
2021-12-29 19:31:28 +08:00
auto mapForClearCopy = mapForClear;
2014-01-03 20:14:03 +08:00
mapForClear.clear();
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (const auto& e : mapForClearCopy)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(e);
CCASSERT(e.second->getReferenceCount() == 2, "e.second's reference count is 2.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// get random object
// Set the seed by time
2016-07-11 11:17:28 +08:00
std::srand((unsigned)time(nullptr));
2021-12-28 17:20:17 +08:00
StringMap<Node*> mapForRandom = createMap();
2014-01-03 20:14:03 +08:00
log("<--- begin ---->");
for (int i = 0; i < mapForRandom.size(); ++i)
{
log("Map: random object tag = %d", mapForRandom.getRandomObject()->getTag());
}
log("<---- end ---->");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
// Self assignment
2021-12-28 17:20:17 +08:00
StringMap<Node*> mapForSelfAssign = createMap();
2021-12-29 19:31:28 +08:00
mapForSelfAssign = mapForSelfAssign;
CCASSERT(mapForSelfAssign.size() == 20, "mapForSelfAssign's size is 20.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (const auto& e : mapForSelfAssign)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(e);
CCASSERT(e.second->getReferenceCount() == 2, "e.second's reference count is 2.");
2014-01-03 20:14:03 +08:00
}
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
mapForSelfAssign = std::move(mapForSelfAssign);
CCASSERT(mapForSelfAssign.size() == 20, "mapForSelfAssign's size is 20.");
2014-01-03 20:20:40 +08:00
2014-01-03 20:14:03 +08:00
for (const auto& e : mapForSelfAssign)
{
metal support for cocos2d-x (#19305) * remove deprecated files * remove some deprecated codes * remove more deprecated codes * remove ui deprecated codes * remove more deprecated codes * remove deprecated codes in ccmenuitem * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes in ui * remove more deprecated codes * remove more deprecated codes * remove more deprecated codes * remove vr related codes and ignore some modules * remove allocator * remove some config * 【Feature】add back-end project file * [Feature] add back-end file * add pipeline descriptor and shader cache * [Feature] support sprite for backend * [Feature] remove unneeded code * [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture * [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture * [Feature] remove macro define to .cpp file * [Feature] add log info * [Feature] add PipelineDescriptor for TriangleCommand * [Feature] add PipelineDescriptor object as member of TriangleCommand * [Feature] add getPipelineDescriptor method * add renderbackend * complete pipeline descriptor * [Feature] add viewport in RenderCommand * set viewport when rendrering * [Feature] occur error when using RendererBackend, to be fixed. * a workaround to fix black screen on macOS 10.14 (#19090) * add rendererbackend init function * fix typo * [Feature] modify testFile * [BugFix] modify shader path * [Feature] set default viewport * fix projection * [Feature] modify log info * [BugFix] change viewport data type to int * [BugFix] add BindGroup to PipelienDescriptor * [BugFix] change a_position to vec3 in sprite.vert * [BugFix] set vertexLayout according to V3F_C4B_T2F structure * [Feature] revert a_position to vec4 * [Feature] renderer should not use gl codes directly * [Feature] it's better not use default value parameter * fix depth test setting * rendererbackend -> renderer * clear color and depth at begin * add metal backend * metal support normalized attribute * simplify codes * update external * add render pass desctriptor in pipeline descriptor * fix warnings * fix crash and memeory leak * refactor Texture2D * put pipeline descriptor into render command * simplify codes * [Feature] update Sprite * fix crash when closing app * [Feature] update SpriteBatchNode and TextureAtlas * support render texture(not finish) * [Feature] remove unused code * make tests work on mac * fix download-deps path error * make tests work on iOS * [Feature] support ttf under normal label effect * refactor triangle command processing * let renderer handle more common commands * refactor backend * make render texture work * [Feature] refactor backend for GL * [Feature]Renaming to make it easy to understand * [Feature] change warp mode to CLAMP_TO_EDGE * fix ghost * simplify visit render queue logic * support progress timer without rial mode * support partcile system * Feature/update label (#149) * [BugFix] fix compile error * [Feature] support outline effect in ios * [Feature] add shader file * [BugFix] fix begin and end RenderPass * [Feature] update CustomCommand * [Feature] revert project.pbxproj * [Feature] simplify codes * [BugFix] pack AI88 to RGBA8888 only when outline enable * [Feature] support shadow effect in Label * [Feature] support BMFont * [Feature] support glow effect * [Feature] simplify shader files * LabelAtlas work * handle blend function correctly * support tile map * don't share buffer in metal * alloc buffer size as needed * support more tilemap * Merge branch 'minggo/metal-support' into feature/updateLabel * minggo/metal-support: support tile map handle blend function correctly LabelAtlas work Feature/update label (#149) support partcile system # Conflicts: # cocos/2d/CCLabel.cpp # cocos/2d/CCSprite.cpp # cocos/2d/CCSpriteBatchNode.cpp # cocos/renderer/CCQuadCommand.cpp # cocos/renderer/CCQuadCommand.h * render texture work without saving file * use global viewport * grid3d works * remove grabber * tiled3d works * [BugFix] fix label bug * [Feature] add updateSubData for buffer * [Feature] remove setVertexCount * support depth test * add callback command * [Feature] add UITest * [Feature] update UITest * [Feature] remove unneeded codes * fix custom command issue * fix layer color blend issue * [BugFix] fix iOS compile error * [Feature] remove unneeded codes * [Feature] fix updateVertexBuffer * layerradial works * add draw test back * fix batch issue * fix compiling error * [BugFix] support ETC1 * [BugFix] get the correct pipelineDescriptor * [BugFix] skip draw when backendTexture nullptr * clipping node support * [Feature] add shader files * fix stencil issue in metal * [Feature] update UILayoutTest * [BugFix] skip drawing when vertexCount is zero * refactor renderer * add set global z order for stencil manager commands * fix warnings caused by type * remove viewport in render command * [Feature] fix warnings caused by type * [BugFix] clear vertexCount and indexCount for CustomComand when needed * [Feature] update clear for CustomCommand * ios use metal * fix viewport issue * fix LayerColorGradient crash * [cmake] transport to android and windows (#160) * save point 1 * compile on windows * run on android * revert useless change * android set CC_ENABLE_CACHE_TEXTURE_DATA to 1 * add initGlew * fix android crash * add TODO new-renderer * review update * revert onGLFWWindowPosCallback * fix android compiling error * Impl progress radial (#162) * progresstimer add radial impl * default drawType to element * dec invoke times of createVertexBuffer (#163) * support depth/stencil format for gl backend * simplify progress timer codes * support motionstreak, effect is wrong * fix motionstreak issue * [Feature] update Scissor Test (#161) * [Feature] update Scissor Test * [Feature] update ScissorTest * [Feature] rename function * [Feature] get constant reference if needed * [Feature] show render status (#164) * improve performance * fix depth state * fill error that triangle vertex/index number bigger than buffer * fix compiline error in release mode * fix buffer conflict between CPU and GPU on iOS/macOS * Renderer refactor (#165) * use one vertes/index buffer with opengl * fix error on windows * custom command support index format config * CCLayer: compact vertex data structure * update comment * fix doc * support fast tilemap * pass index format instead * fix some wrong effect * fix render texture error * fix texture per-element size * fix texture format error * BlendFunc type refactor, GLenum -> backend::BlendFactor (#167) * BlendFunc use backend::BlendFactor as inner field * update comments * use int to replace GLenum * update xcode project fiel * rename to GLBlendConst * add ccConstants.h * update xcode project file * update copyright * remove primitive command * remove CCPrimitive.cpp/.h * remove deprecated files * remove unneeded files * remove multiple view support * remove multiple view support * remove the usage of frame buffer in camera * director don't use frame buffer * remove FrameBuffer * remove BatchCommand * add some api reference * add physics2d back * fix crash when close app on mac * improve render texture * fix rendertexture issue * fix rendertexture issue * simplify codes * CMake support for mac & ios (#169) * update cmake * fix compile error * update 3rd libs version * remove CCThread.h/.cpp * remove ccthread * use audio engine to implement simple audio engine * remove unneeded codes * remove deprecated codes * remove winrt macro * remove CC_USE_WIC * set partcile blend function in more elegant way * remove unneeded codes * remove unneeded codes * cmake works on windows * update project setting * improve performance * GLFloat -> float * sync v3 cmake improvements into metal-support (#172) * pick: modern cmake, compile definitions improvement (#19139) * modern cmake, use target_compile_definitions partly * simplify macro define, remove USE_* * modern cmake, macro define * add physics 2d macro define into ccConfig.h * remove USE_CHIPMUNK macro in build.gradle * remove CocosSelectModule.cmake * shrink useless define * simplify compile options config, re-add if necessary * update external for tmp CI test * un-quote target_compile_options value * add "-g" parameter only when debug mode * keep single build type when generator Xcode & VS projecy * update external for tmp CI tes * add static_cast<char>(-1), fix -Wc++11-narrowing * simplify win32 compile define * not modify code, only improve compile options # Conflicts: # .gitignore # cmake/Modules/CocosConfigDepend.cmake # cocos/CMakeLists.txt # external/config.json # tests/cpp-tests/CMakeLists.txt * modern cmake, improve cmake_compiler_flags (#19145) * cmake_compiler_flags * Fix typo * Fix typo2 * Remove chanages from Android.mk * correct lua template cmake build (#19149) * don't add -Wno-deprecated into jsb target * correct lua template cmake build * fix win32 lua template compile error * prevent cmake in-source-build friendly (#19151) * pick: Copy resources to "Resources/" on win32 like in linux configuration * add "/Z7" for cpp-tests on windows * [cmake] fix iOS xcode property setting failed (#19208) * fix iOS xcode property setting failed * use search_depend_libs_recursive at dlls collect * fix typo * [cmake] add find_host_library into iOS toolchain file (#19230) * pick: [lua android] use luajit & template cmake update (#19239) * increase cmake stability , remove tests/CMakeLists.txt (#19261) * cmake win32 Precompiled header (#19273) * Precompiled header * Fix * Precompiled header for cocos * Precompiled header jscocos2d * Fix for COCOS2D_DEBUG is always 1 on Android (#19291) Related #19289 * little build fix, tests cpp-tests works on mac * sync v3 build related codes into metal-support (#173) * strict initialization for std::array * remove proj.win32 project configs * modern cmake, cmake_cleanup_remove_unused_variables (#19146) * Switch travis CI to xenial (#19207) * Switch travis CI to xenial * Remove language: android * Set language: cpp * Fix java problem * Update sdkmanager * Fix sdkmanger * next sdkmanager fix * Remove xenial from android * revert to sdk-tools-{system}-3859397 * Remove linux cmake install * Update before-install.sh * Update .travis.yml * Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212) * Simplify install-deps-linux.sh * Cleanup * pick: install ninja * update cocos2d-console submodule * for metal-support alpha release, we only test cpp * add HelloCpp into project(Cocos2d-x) for tmp test * update extenal metal-support-4 * update uniform setting * [Feature] update BindGroup * [Feature] empty-test * [Feature] cpp-test * [Feature] fix GL compiler error * [Feature] fix GL crash * [Feature] empty-test * [Feature] cpp-tests * [feature] improve frameRate * [feature] fix opengl compile error * [feature] fix opengl compile error * [BugFix] fix compute maxLocation error * [Feature] update setting unifrom * [Feature] fix namespace * [Feature] remove unneeded code * [Bugfix] fix project file * [Feature] update review * [texture2d] impl texture format support (#175) * texture update * update * update texture * commit * compile on windows * ddd * rename * rename methods * no crash * save gl * save * save * rename * move out pixel format convert functions * metal crash * update * update android * support gles compressed texture format * support more compress format * add more conversion methods * ss * save * update conversion methods * add PVRTC format support * reformat * add marco linux * fix GL marcro * pvrtc supported only by ios 8.0+ * remove unused cmake * revert change * refactor Texture2D::initWithData * fix conversion log * refactor Texture2D::initWithData * remove some OpenGL constants for PVRTC * add todo * fix typo * AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174) * review cpp-tests, and fix part issues on start auto test * sync png format fix: Node:Particle3D abnormal texture effects #19204 * fix cpp-tests SpritePolygon crash, wrong png format (#19170) * fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it * [CCSpriteCache] allow re-add plist & add testcase (#19175) * allow re-add plist & add testcase * remove comments/rename method/update testcase * fix isSpriteFramesWithFileLoaded & add testcase * remove used variable * remove unused variable * fix double free issues when js/lua-tests exit on iOS (#19236) * disable part cases, AutoTest works without crash on mac * update cocos2dx files json, to test cocos new next * fix spritecache plist parsing issue (#19269) * [linux] Fix FileUtils::getContents with folder (#19157) * fix FileUtils::getContents on linux/mac * use stat.st_mode * simplify * [CCFileUtils] win32 getFileSize (#19176) * win32 getFileSize * fix stat * [cpp test-Android]20:FileUtils/2 change title (#19197) * sync #19200 * sync #19231 * [android lua] improve performance of lua loader (#19234) * [lua] improve performance of lua loader * remove cache fix * Revert "fix spritecache plist parsing issue (#19269)" This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf. * remove win32 project files ref in template.json * add metal framework lnk ref into cpp template * test on iOS, and disable part cases * alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227) * changes AudioCache to use alBufferData instead of alBufferDataStatic (also makes test 19 faster to trigger openal bugs faster) The original problem: CrashIfClientProvidedBogusAudioBufferList https://github.com/cocos2d/cocos2d-x/issues/18948 is not happening anymore, but there's still a not very frequent issue that makes OpenAL crash with a call stack like this. AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList It happes more frequently when the device is "cold", which means after half an hour of not using the device (locked). I could not find the actual source code for iOS OpenAL, so I used the macOS versions: https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html They seem to use CAGuard.h to make sure the dead buffer list has no threading issues. I'm worried because the CAGuard code I found has macos and win32 define but no iOS, so I'm not sure. I guess the iOS version is different and has the guard. I could not find a place in the code that's unprotected by the locks except the InitializeBufferMap() which should not be called more than once from cocos, and there's a workaround in AudioEngine-impl for it. I reduced the occurence of the CleanUpDeadBufferList crash by moving the guard in ~AudioCache to cover the alDeleteBuffers call. * remove hack method "setTimeout" on audio * AutoTest works on iOS * support set ios deployment target for root project * enable all texture2d cases, since Jiang have fixed * add CCTextureUtils to xcode project file (#176) * add leak cases for SpriteFrameCache (#177) * re-add SpriteFrameCache cases * update template file json * Update SpriteFrameCacheTest.cpp * fix compiling error
2019-01-18 15:08:25 +08:00
CC_UNUSED_PARAM(e);
CCASSERT(e.second->getReferenceCount() == 2, "e.second's reference's count is 2.");
2014-01-03 20:14:03 +08:00
}
}
2021-12-28 17:20:17 +08:00
void TemplateMapTest::constFunc(const StringMap<Node*>& map) const
2014-01-03 20:14:03 +08:00
{
log("[%s]=(tag)%d", "0", map.at("0")->getTag());
log("[%s]=(tag)%d", "1", map.find("1")->second->getTag());
}
std::string TemplateMapTest::subtitle() const
{
return "Map<K, V>, should not crash";
}
2014-01-03 21:06:33 +08:00
//----------------------------------
void ValueTest::onEnter()
{
UnitTestDemo::onEnter();
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v1;
CCASSERT(v1.getType() == Value::Type::NONE, "v1's value type should be VALUE::Type::NONE.");
CCASSERT(v1.isNull(), "v1 is null.");
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v2(100);
CCASSERT(v2.getType() == Value::Type::INTEGER, "v2's value type should be VALUE::Type::INTEGER.");
CCASSERT(!v2.isNull(), "v2 is not null.");
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v3(101.4f);
CCASSERT(v3.getType() == Value::Type::FLOAT, "v3's value type should be VALUE::Type::FLOAT.");
CCASSERT(!v3.isNull(), "v3 is not null.");
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v4(106.1);
CCASSERT(v4.getType() == Value::Type::DOUBLE, "v4's value type should be VALUE::Type::DOUBLE.");
CCASSERT(!v4.isNull(), "v4 is not null.");
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
unsigned char byte = 50;
Value v5(byte);
2021-11-19 09:21:17 +08:00
CCASSERT(v5.getType() == Value::Type::INT_UI32, "v5's value type should be Value::Type::INT_UI32.");
CCASSERT(!v5.isNull(), "v5 is not null.");
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v6(true);
CCASSERT(v6.getType() == Value::Type::BOOLEAN, "v6's value type is Value::Type::BOOLEAN.");
CCASSERT(!v6.isNull(), "v6 is not null.");
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v7("string");
CCASSERT(v7.getType() == Value::Type::STRING, "v7's value type is Value::type::STRING.");
CCASSERT(!v7.isNull(), "v7 is not null.");
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v8(std::string("string2"));
CCASSERT(v8.getType() == Value::Type::STRING, "v8's value type is Value::Type::STRING.");
CCASSERT(!v8.isNull(), "v8 is not null.");
2014-01-03 21:06:33 +08:00
2021-12-28 16:06:23 +08:00
auto createValueVector = [&]() {
2014-01-03 21:06:33 +08:00
ValueVector ret;
ret.push_back(v1);
ret.push_back(v2);
ret.push_back(v3);
return ret;
};
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v9(createValueVector());
CCASSERT(v9.getType() == Value::Type::VECTOR, "v9's value type is Value::Type::VECTOR.");
CCASSERT(!v9.isNull(), "v9 is not null.");
2014-01-03 21:06:33 +08:00
2021-12-28 16:06:23 +08:00
auto createValueMap = [&]() {
2014-01-03 21:06:33 +08:00
ValueMap ret;
ret["aaa"] = v1;
ret["bbb"] = v2;
ret["ccc"] = v3;
return ret;
};
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v10(createValueMap());
CCASSERT(v10.getType() == Value::Type::MAP, "v10's value type is Value::Type::MAP.");
CCASSERT(!v10.isNull(), "v10 is not null.");
2021-12-28 16:06:23 +08:00
auto createValueMapIntKey = [&]() {
2014-01-03 21:06:33 +08:00
ValueMapIntKey ret;
ret[111] = v1;
ret[222] = v2;
ret[333] = v3;
return ret;
};
2021-12-28 16:06:23 +08:00
2014-01-03 21:06:33 +08:00
Value v11(createValueMapIntKey());
CCASSERT(v11.getType() == Value::Type::INT_KEY_MAP, "v11's value type is Value::Type::INT_KEY_MAP.");
CCASSERT(!v11.isNull(), "v11 is not null.");
2014-01-03 21:06:33 +08:00
}
std::string ValueTest::subtitle() const
{
return "Value Test, should not crash";
}
2021-12-28 16:06:23 +08:00
void ValueTest::constFunc(const Value& /*value*/) const {}
// UTFConversionTest
// FIXME: made as define to prevent compile warnings in release mode. Better is to be a `const static int`
#define TEST_CODE_NUM 11
2021-12-28 16:06:23 +08:00
static const char16_t __utf16Code[] = {
0x3042, 0x3044, 0x3046, 0x3048, 0x304A, 0x3042, 0x3044, 0x3046, 0x3048, 0x304A, 0x0041, 0x0000,
};
// to avoid Xcode error, char => unsigned char
// If you use this table, please cast manually as (const char *).
2021-12-28 16:06:23 +08:00
static const unsigned char __utf8Code[] = {
0xE3, 0x81, 0x82, 0xE3, 0x81, 0x84, 0xE3, 0x81, 0x86, 0xE3, 0x81, 0x88, 0xE3, 0x81, 0x8A, 0xE3,
0x81, 0x82, 0xE3, 0x81, 0x84, 0xE3, 0x81, 0x86, 0xE3, 0x81, 0x88, 0xE3, 0x81, 0x8A, 0x41, 0x00,
};
2021-12-28 16:06:23 +08:00
static const char16_t WHITE_SPACE_CODE[] = {0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x0020, 0x0085, 0x00A0, 0x1680,
0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008,
0x2009, 0x200A, 0x2028, 0x2029, 0x202F, 0x205F, 0x3000};
static void doUTFConversion()
{
bool isSuccess = false;
2021-12-28 16:06:23 +08:00
std::string originalUTF8 = (const char*)__utf8Code;
std::u16string originalUTF16 = __utf16Code;
2021-12-28 16:06:23 +08:00
//---------------------------
std::string utf8Str;
isSuccess = StringUtils::UTF16ToUTF8(originalUTF16, utf8Str);
2021-12-28 16:06:23 +08:00
if (isSuccess)
{
2021-12-28 16:06:23 +08:00
isSuccess = memcmp(utf8Str.data(), originalUTF8.data(), originalUTF8.length() + 1) == 0;
}
2021-12-28 16:06:23 +08:00
CCASSERT(isSuccess, "StringUtils::UTF16ToUTF8 failed");
2021-12-28 16:06:23 +08:00
//---------------------------
std::u16string utf16Str;
isSuccess = StringUtils::UTF8ToUTF16(originalUTF8, utf16Str);
2021-12-28 16:06:23 +08:00
if (isSuccess)
{
2021-12-28 16:06:23 +08:00
isSuccess = memcmp(utf16Str.data(), originalUTF16.data(), originalUTF16.length() + 1) == 0;
}
2021-12-28 16:06:23 +08:00
CCASSERT(isSuccess && (utf16Str.length() == TEST_CODE_NUM), "StringUtils::UTF8ToUTF16 failed");
2021-12-28 16:06:23 +08:00
//---------------------------
auto vec1 = StringUtils::getChar16VectorFromUTF16String(originalUTF16);
2021-12-28 16:06:23 +08:00
CCASSERT(vec1.size() == originalUTF16.length(), "StringUtils::getChar16VectorFromUTF16String failed");
2021-12-28 16:06:23 +08:00
//---------------------------
2021-12-28 16:06:23 +08:00
std::vector<char16_t> vec2(vec1);
vec2.push_back(0x2009);
vec2.push_back(0x2009);
vec2.push_back(0x2009);
vec2.push_back(0x2009);
2021-12-28 16:06:23 +08:00
std::vector<char16_t> vec3(vec2);
StringUtils::trimUTF16Vector(vec2);
2021-12-28 16:06:23 +08:00
CCASSERT(vec1.size() == vec2.size(), "StringUtils::trimUTF16Vector failed");
2021-12-28 16:06:23 +08:00
for (size_t i = 0; i < vec2.size(); i++)
{
CCASSERT(vec1.at(i) == vec2.at(i), "StringUtils::trimUTF16Vector failed");
}
2021-12-28 16:06:23 +08:00
//---------------------------
2021-12-28 16:06:23 +08:00
CCASSERT(StringUtils::getCharacterCountInUTF8String(originalUTF8) == TEST_CODE_NUM,
"StringUtils::getCharacterCountInUTF8String failed");
//---------------------------
2021-12-28 16:06:23 +08:00
CCASSERT(StringUtils::getIndexOfLastNotChar16(vec3, 0x2009) == (vec1.size() - 1),
"StringUtils::getIndexOfLastNotChar16 failed");
//---------------------------
2021-12-28 16:06:23 +08:00
CCASSERT(originalUTF16.length() == TEST_CODE_NUM,
"The length of the original utf16 string isn't equal to TEST_CODE_NUM");
//---------------------------
size_t whiteCodeNum = sizeof(WHITE_SPACE_CODE) / sizeof(WHITE_SPACE_CODE[0]);
2021-12-28 16:06:23 +08:00
for (size_t i = 0; i < whiteCodeNum; i++)
{
CCASSERT(StringUtils::isUnicodeSpace(WHITE_SPACE_CODE[i]), "StringUtils::isUnicodeSpace failed");
}
2021-12-28 16:06:23 +08:00
CCASSERT(!StringUtils::isUnicodeSpace(0xFFFF), "StringUtils::isUnicodeSpace failed");
2021-12-28 16:06:23 +08:00
CCASSERT(!StringUtils::isCJKUnicode(0xFFFF) && StringUtils::isCJKUnicode(0x3100),
"StringUtils::isCJKUnicode failed");
}
void UTFConversionTest::onEnter()
{
UnitTestDemo::onEnter();
for (int i = 0; i < 10000; ++i)
{
doUTFConversion();
}
}
std::string UTFConversionTest::subtitle() const
{
return "UTF8 <-> UTF16 Conversion Test, no crash";
}
2014-11-22 15:52:02 +08:00
2016-06-30 01:24:23 +08:00
// UIHelperSubStringTest
void UIHelperSubStringTest::onEnter()
{
UnitTestDemo::onEnter();
using cocos2d::ui::Helper;
{
// Trivial case
std::string source = "abcdefghij";
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 2) == "ab");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 2, 2) == "cd");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 4, 2) == "ef");
}
{
// Empty string
std::string source = "";
// OK
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 1) == "");
// Error: These cases cause "out of range" error
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 1) == "");
}
{
// Ascii
std::string source = "abc";
// OK
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 2, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 3, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 3) == "abc");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 4) == "abc");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 2) == "bc");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 3) == "bc");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 2, 1) == "c");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 2, 2) == "c");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 3, 1) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 3, 2) == "");
// Error: These cases cause "out of range" error
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 4, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 4, 1) == "");
}
{
// CJK characters
std::string source = "这里是中文测试例";
// OK
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 7, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 8, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 8, 1) == "");
2016-08-11 15:54:51 +08:00
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 1) == "\xe8\xbf\x99");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 4) == "\xe8\xbf\x99\xe9\x87\x8c\xe6\x98\xaf\xe4\xb8\xad");
2021-12-28 16:06:23 +08:00
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 8) ==
"\xe8\xbf\x99\xe9\x87\x8c\xe6\x98\xaf\xe4\xb8\xad\xe6\x96\x87\xe6\xb5\x8b\xe8\xaf\x95\xe4\xbe\x8b");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 100) ==
"\xe8\xbf\x99\xe9\x87\x8c\xe6\x98\xaf\xe4\xb8\xad\xe6\x96\x87\xe6\xb5\x8b\xe8\xaf\x95\xe4\xbe\x8b");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 2, 5) ==
"\xe6\x98\xaf\xe4\xb8\xad\xe6\x96\x87\xe6\xb5\x8b\xe8\xaf\x95");
2016-08-11 15:54:51 +08:00
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 6, 2) == "\xe8\xaf\x95\xe4\xbe\x8b");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 6, 100) == "\xe8\xaf\x95\xe4\xbe\x8b");
2016-06-30 01:24:23 +08:00
// Error: These cases cause "out of range" error
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 9, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 9, 1) == "");
}
{
// Redundant UTF-8 sequence for Directory traversal attack (1)
std::string source = "\xC0\xAF";
// Error: Can't convert string to correct encoding such as UTF-32
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 1) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 1) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 2) == "");
}
{
// Redundant UTF-8 sequence for Directory traversal attack (2)
std::string source = "\xE0\x80\xAF";
// Error: Can't convert string to correct encoding such as UTF-32
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 1) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 1) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 3) == "");
}
{
// Redundant UTF-8 sequence for Directory traversal attack (3)
std::string source = "\xF0\x80\x80\xAF";
// Error: Can't convert string to correct encoding such as UTF-32
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 1) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 0) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 1, 1) == "");
CC_ASSERT(Helper::getSubStringOfUTF8String(source, 0, 4) == "");
}
}
std::string UIHelperSubStringTest::subtitle() const
{
return "ui::Helper::getSubStringOfUTF8String Test";
}
2019-07-19 11:57:11 +08:00
// ParseIntegerListTest
2021-12-28 16:06:23 +08:00
void ParseIntegerListTest::onEnter()
{
2019-07-19 11:57:11 +08:00
UnitTestDemo::onEnter();
{
using cocos2d::utils::parseIntegerList;
std::vector<int> res1{};
EXPECT_EQ(res1, parseIntegerList(""));
std::vector<int> res2{1};
EXPECT_EQ(res2, parseIntegerList("1"));
std::vector<int> res3{1, 2};
EXPECT_EQ(res3, parseIntegerList("1 2"));
std::vector<int> res4{2, 4, 3, 1, 4, 2, 0, 4, 1, 0, 4, 5};
EXPECT_EQ(res4, parseIntegerList("2 4 3 1 4 2 0 4 1 0 4 5"));
std::vector<int> res5{73, 48, 57, 117, 27, 117, 29, 77, 14, 62, 26, 7, 55, 2};
EXPECT_EQ(res5, parseIntegerList("73 48 57 117 27 117 29 77 14 62 26 7 55 2"));
}
}
std::string ParseIntegerListTest::subtitle() const
{
return "utils::parseIntegerList Test";
}
// ParseUriTest
void ParseUriTest::onEnter()
{
UnitTestDemo::onEnter();
{
std::string s("http://www.facebook.com/hello/world?query#fragment");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("www.facebook.com", u.getHost());
2021-09-04 00:22:47 +08:00
EXPECT_EQ(80, u.getPort());
EXPECT_EQ("www.facebook.com", u.getAuthority());
EXPECT_EQ("/hello/world", u.getPath());
EXPECT_EQ("query", u.getQuery());
EXPECT_EQ("fragment", u.getFragment());
EXPECT_EQ(s, u.toString()); // canonical
}
{
std::string s("http://www.facebook.com:8080/hello/world?query#fragment");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("www.facebook.com", u.getHost());
EXPECT_EQ(8080, u.getPort());
EXPECT_EQ("www.facebook.com:8080", u.getAuthority());
EXPECT_EQ("/hello/world", u.getPath());
EXPECT_EQ("query", u.getQuery());
EXPECT_EQ("fragment", u.getFragment());
EXPECT_EQ(s, u.toString()); // canonical
}
{
std::string s("http://127.0.0.1:8080/hello/world?query#fragment");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("127.0.0.1", u.getHost());
EXPECT_EQ(8080, u.getPort());
EXPECT_EQ("127.0.0.1:8080", u.getAuthority());
EXPECT_EQ("/hello/world", u.getPath());
EXPECT_EQ("query", u.getQuery());
EXPECT_EQ("fragment", u.getFragment());
EXPECT_EQ(s, u.toString()); // canonical
}
{
std::string s("http://[::1]:8080/hello/world?query#fragment");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("[::1]", u.getHost());
EXPECT_EQ("::1", u.getHostName());
EXPECT_EQ(8080, u.getPort());
EXPECT_EQ("[::1]:8080", u.getAuthority());
EXPECT_EQ("/hello/world", u.getPath());
EXPECT_EQ("query", u.getQuery());
EXPECT_EQ("fragment", u.getFragment());
EXPECT_EQ(s, u.toString()); // canonical
}
{
std::string s("http://[2401:db00:20:7004:face:0:29:0]:8080/hello/world?query");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("[2401:db00:20:7004:face:0:29:0]", u.getHost());
EXPECT_EQ("2401:db00:20:7004:face:0:29:0", u.getHostName());
EXPECT_EQ(8080, u.getPort());
EXPECT_EQ("[2401:db00:20:7004:face:0:29:0]:8080", u.getAuthority());
EXPECT_EQ("/hello/world", u.getPath());
EXPECT_EQ("query", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ(s, u.toString()); // canonical
}
{
std::string s("http://[2401:db00:20:7004:face:0:29:0]/hello/world?query");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("[2401:db00:20:7004:face:0:29:0]", u.getHost());
EXPECT_EQ("2401:db00:20:7004:face:0:29:0", u.getHostName());
2021-09-04 00:22:47 +08:00
EXPECT_EQ(80, u.getPort());
EXPECT_EQ("[2401:db00:20:7004:face:0:29:0]", u.getAuthority());
EXPECT_EQ("/hello/world", u.getPath());
EXPECT_EQ("query", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ(s, u.toString()); // canonical
}
{
std::string s("http://user:pass@host.com/");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("user", u.getUserName());
EXPECT_EQ("pass", u.getPassword());
EXPECT_EQ("host.com", u.getHost());
2021-09-04 00:22:47 +08:00
EXPECT_EQ(80, u.getPort());
EXPECT_EQ("user:pass@host.com", u.getAuthority());
EXPECT_EQ("/", u.getPath());
EXPECT_EQ("", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ(s, u.toString());
}
{
std::string s("http://user@host.com/");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("user", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("host.com", u.getHost());
2021-09-04 00:22:47 +08:00
EXPECT_EQ(80, u.getPort());
EXPECT_EQ("user@host.com", u.getAuthority());
EXPECT_EQ("/", u.getPath());
EXPECT_EQ("", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ(s, u.toString());
}
{
std::string s("http://user:@host.com/");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("user", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("host.com", u.getHost());
2021-09-04 00:22:47 +08:00
EXPECT_EQ(80, u.getPort());
EXPECT_EQ("user@host.com", u.getAuthority());
EXPECT_EQ("/", u.getPath());
EXPECT_EQ("", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ("http://user@host.com/", u.toString());
}
{
std::string s("http://:pass@host.com/");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("pass", u.getPassword());
EXPECT_EQ("host.com", u.getHost());
2021-09-04 00:22:47 +08:00
EXPECT_EQ(80, u.getPort());
EXPECT_EQ(":pass@host.com", u.getAuthority());
EXPECT_EQ("/", u.getPath());
EXPECT_EQ("", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ(s, u.toString());
}
{
std::string s("http://@host.com/");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("host.com", u.getHost());
2021-09-04 00:22:47 +08:00
EXPECT_EQ(80, u.getPort());
EXPECT_EQ("host.com", u.getAuthority());
EXPECT_EQ("/", u.getPath());
EXPECT_EQ("", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ("http://host.com/", u.toString());
}
{
std::string s("http://:@host.com/");
Uri u = Uri::parse(s);
EXPECT_EQ("http", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("host.com", u.getHost());
2021-09-04 00:22:47 +08:00
EXPECT_EQ(80, u.getPort());
EXPECT_EQ("host.com", u.getAuthority());
EXPECT_EQ("/", u.getPath());
EXPECT_EQ("", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ("http://host.com/", u.toString());
}
{
std::string s("file:///etc/motd");
Uri u = Uri::parse(s);
EXPECT_EQ("file", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("", u.getHost());
EXPECT_EQ(0, u.getPort());
EXPECT_EQ("", u.getAuthority());
EXPECT_EQ("/etc/motd", u.getPath());
EXPECT_EQ("", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ(s, u.toString());
}
{
std::string s("file://etc/motd");
Uri u = Uri::parse(s);
EXPECT_EQ("file", u.getScheme());
EXPECT_EQ("", u.getUserName());
EXPECT_EQ("", u.getPassword());
EXPECT_EQ("etc", u.getHost());
EXPECT_EQ(0, u.getPort());
EXPECT_EQ("etc", u.getAuthority());
EXPECT_EQ("/motd", u.getPath());
EXPECT_EQ("", u.getQuery());
EXPECT_EQ("", u.getFragment());
EXPECT_EQ(s, u.toString());
}
{
// test query parameters
std::string s("http://localhost?&key1=foo&key2=&key3&=bar&=bar=&");
2021-12-28 16:06:23 +08:00
Uri u = Uri::parse(s);
auto paramsList = u.getQueryParams();
std::map<std::string, std::string> params;
2021-12-28 16:06:23 +08:00
for (auto& param : paramsList)
{
params[param.first] = param.second;
}
EXPECT_EQ(3, params.size());
EXPECT_EQ("foo", params["key1"]);
EXPECT_NE(params.end(), params.find("key2"));
EXPECT_EQ("", params["key2"]);
EXPECT_NE(params.end(), params.find("key3"));
EXPECT_EQ("", params["key3"]);
}
{
// test query parameters
std::string s("http://localhost?&&&&&&&&&&&&&&&");
2021-12-28 16:06:23 +08:00
Uri u = Uri::parse(s);
auto params = u.getQueryParams();
EXPECT_TRUE(params.empty());
}
{
// test query parameters
std::string s("http://localhost?&=invalid_key&key2&key3=foo");
2021-12-28 16:06:23 +08:00
Uri u = Uri::parse(s);
auto paramsList = u.getQueryParams();
std::map<std::string, std::string> params;
2021-12-28 16:06:23 +08:00
for (auto& param : paramsList)
{
params[param.first] = param.second;
}
EXPECT_EQ(2, params.size());
EXPECT_NE(params.end(), params.find("key2"));
EXPECT_EQ("", params["key2"]);
EXPECT_EQ("foo", params["key3"]);
}
{
// test query parameters
std::string s("http://localhost?&key1=====&&=key2&key3=");
2021-12-28 16:06:23 +08:00
Uri u = Uri::parse(s);
auto paramsList = u.getQueryParams();
std::map<std::string, std::string> params;
2021-12-28 16:06:23 +08:00
for (auto& param : paramsList)
{
params[param.first] = param.second;
}
EXPECT_EQ(1, params.size());
EXPECT_NE(params.end(), params.find("key3"));
EXPECT_EQ("", params["key3"]);
}
{
// test query parameters
std::string s("ws://localhost:90?key1=foo=bar&key2=foobar&");
2021-12-28 16:06:23 +08:00
Uri u = Uri::parse(s);
auto paramsList = u.getQueryParams();
std::map<std::string, std::string> params;
2021-12-28 16:06:23 +08:00
for (auto& param : paramsList)
{
params[param.first] = param.second;
}
EXPECT_EQ(1, params.size());
EXPECT_EQ("foobar", params["key2"]);
// copy constructor
{
Uri v(u);
u = v = u;
EXPECT_TRUE(v.isValid());
EXPECT_EQ("ws", v.getScheme());
EXPECT_EQ("localhost", v.getHost());
EXPECT_EQ("localhost", v.getHostName());
2022-05-21 20:55:25 +08:00
EXPECT_EQ("/", v.getPath());
EXPECT_EQ(90, v.getPort());
EXPECT_EQ("", v.getFragment());
EXPECT_EQ("key1=foo=bar&key2=foobar&", v.getQuery());
EXPECT_EQ(u, v);
}
// copy assign operator
{
Uri v;
v = u;
EXPECT_TRUE(v.isValid());
EXPECT_EQ("ws", v.getScheme());
EXPECT_EQ("localhost", v.getHost());
EXPECT_EQ("localhost", v.getHostName());
2022-05-21 20:55:25 +08:00
EXPECT_EQ("/", v.getPath());
EXPECT_EQ(90, v.getPort());
EXPECT_EQ("", v.getFragment());
EXPECT_EQ("key1=foo=bar&key2=foobar&", v.getQuery());
EXPECT_EQ(u, v);
}
// Self move assignment
{
u = u;
EXPECT_TRUE(u.isValid());
}
// Self move assignment
{
u = std::move(u);
EXPECT_TRUE(u.isValid());
}
// move constructor
{
Uri v = std::move(u);
EXPECT_FALSE(u.isValid());
EXPECT_TRUE(v.isValid());
EXPECT_EQ("ws", v.getScheme());
EXPECT_EQ("localhost", v.getHost());
EXPECT_EQ("localhost", v.getHostName());
2022-05-21 20:55:25 +08:00
EXPECT_EQ("/", v.getPath());
EXPECT_EQ(90, v.getPort());
EXPECT_EQ("", v.getFragment());
EXPECT_EQ("key1=foo=bar&key2=foobar&", v.getQuery());
u = std::move(v);
}
// copy assign operator
{
Uri v;
v = std::move(u);
EXPECT_FALSE(u.isValid());
EXPECT_TRUE(v.isValid());
EXPECT_EQ("ws", v.getScheme());
EXPECT_EQ("localhost", v.getHost());
EXPECT_EQ("localhost", v.getHostName());
2022-05-21 20:55:25 +08:00
EXPECT_EQ("/", v.getPath());
EXPECT_EQ(90, v.getPort());
EXPECT_EQ("", v.getFragment());
EXPECT_EQ("key1=foo=bar&key2=foobar&", v.getQuery());
u = v;
}
}
{
std::string s("2http://www.facebook.com");
Uri u = Uri::parse(s);
EXPECT_FALSE(u.isValid());
}
{
std::string s("www[facebook]com");
Uri u = Uri::parse("http://" + s);
EXPECT_FALSE(u.isValid());
}
{
std::string s("http://[::1:8080/hello/world?query#fragment");
Uri u = Uri::parse(s);
EXPECT_FALSE(u.isValid());
}
{
std::string s("http://::1]:8080/hello/world?query#fragment");
Uri u = Uri::parse(s);
EXPECT_FALSE(u.isValid());
}
{
std::string s("http://::1:8080/hello/world?query#fragment");
Uri u = Uri::parse(s);
EXPECT_FALSE(u.isValid());
}
{
std::string s("http://2401:db00:20:7004:face:0:29:0/hello/world?query");
Uri u = Uri::parse(s);
EXPECT_FALSE(u.isValid());
}
{
2021-12-28 16:06:23 +08:00
Uri http = Uri::parse("http://google.com");
Uri https = Uri::parse("https://www.google.com:90");
Uri query = Uri::parse("http://google.com:8080/foo/bar?foo=bar");
Uri localhost = Uri::parse("http://localhost:8080");
Uri ipv6 = Uri::parse("https://[2001:0db8:85a3:0042:1000:8a2e:0370:7334]");
Uri ipv6short = Uri::parse("http://[2001:db8:85a3:42:1000:8a2e:370:7334]");
Uri ipv6port = Uri::parse("http://[2001:db8:85a3:42:1000:8a2e:370:7334]:90");
Uri ipv6abbrev = Uri::parse("http://[2001::7334:a:90]");
2021-12-28 16:06:23 +08:00
Uri ipv6http = Uri::parse("http://[2001::7334:a]:90");
Uri ipv6query = Uri::parse("http://[2001::7334:a]:90/foo/bar?foo=bar");
EXPECT_EQ(http.getScheme(), "http");
2021-09-04 00:22:47 +08:00
EXPECT_EQ(http.getPort(), 80);
EXPECT_EQ(http.getHost(), "google.com");
EXPECT_EQ(https.getScheme(), "https");
EXPECT_EQ(https.getPort(), 90);
EXPECT_EQ(https.getHost(), "www.google.com");
EXPECT_EQ(query.getPort(), 8080);
EXPECT_EQ(query.getPathEtc(), "/foo/bar?foo=bar");
EXPECT_EQ(localhost.getScheme(), "http");
EXPECT_EQ(localhost.getHost(), "localhost");
EXPECT_EQ(localhost.getPort(), 8080);
EXPECT_EQ(ipv6.getScheme(), "https");
EXPECT_EQ(ipv6.getHostName(), "2001:0db8:85a3:0042:1000:8a2e:0370:7334");
2021-09-04 00:22:47 +08:00
EXPECT_EQ(ipv6.getPort(), 443);
EXPECT_EQ(ipv6short.getScheme(), "http");
EXPECT_EQ(ipv6short.getHostName(), "2001:db8:85a3:42:1000:8a2e:370:7334");
2021-09-04 00:22:47 +08:00
EXPECT_EQ(ipv6short.getPort(), 80);
EXPECT_EQ(ipv6port.getScheme(), "http");
EXPECT_EQ(ipv6port.getHostName(), "2001:db8:85a3:42:1000:8a2e:370:7334");
EXPECT_EQ(ipv6port.getPort(), 90);
EXPECT_EQ(ipv6abbrev.getScheme(), "http");
EXPECT_EQ(ipv6abbrev.getHostName(), "2001::7334:a:90");
2021-09-04 00:22:47 +08:00
EXPECT_EQ(ipv6abbrev.getPort(), 80);
EXPECT_EQ(ipv6http.getScheme(), "http");
EXPECT_EQ(ipv6http.getPort(), 90);
EXPECT_EQ(ipv6http.getHostName(), "2001::7334:a");
EXPECT_EQ(ipv6query.getScheme(), "http");
EXPECT_EQ(ipv6query.getPort(), 90);
EXPECT_EQ(ipv6query.getHostName(), "2001::7334:a");
EXPECT_EQ(ipv6query.getPathEtc(), "/foo/bar?foo=bar");
}
{
Uri u0 = Uri::parse("http://localhost:84/foo.html?&q=123");
Uri u1 = Uri::parse("https://localhost:82/foo.html?&q=1");
Uri u2 = Uri::parse("ws://localhost/foo");
Uri u3 = Uri::parse("localhost/foo");
Uri u4 = Uri::parse("localhost:8080");
Uri u5 = Uri::parse("bb://localhost?&foo=12:4&ccc=13");
Uri u6 = Uri::parse("cc://localhost:91?&foo=321&bbb=1");
EXPECT_EQ(u0.getScheme(), "http");
EXPECT_EQ(u0.getHost(), "localhost");
EXPECT_EQ(u0.getPort(), 84);
EXPECT_EQ(u0.getPath(), "/foo.html");
EXPECT_EQ(u0.getPathEtc(), "/foo.html?&q=123");
EXPECT_EQ(u1.getScheme(), "https");
EXPECT_EQ(u1.getHost(), "localhost");
EXPECT_EQ(u1.getPort(), 82);
EXPECT_EQ(u1.getPathEtc(), "/foo.html?&q=1");
EXPECT_EQ(u2.getScheme(), "ws");
EXPECT_EQ(u2.getHost(), "localhost");
2021-09-04 00:22:47 +08:00
EXPECT_EQ(u2.getPort(), 80);
EXPECT_EQ(u2.getPath(), "/foo");
EXPECT_EQ(u3.getScheme(), "");
EXPECT_EQ(u3.getHost(), "localhost");
EXPECT_EQ(u3.getPort(), 0);
EXPECT_EQ(u3.getPath(), "/foo");
EXPECT_EQ(u4.getScheme(), "");
EXPECT_EQ(u4.getHost(), "localhost");
EXPECT_EQ(u4.getPort(), 8080);
2022-05-21 20:55:25 +08:00
EXPECT_EQ(u4.getPath(), "/");
EXPECT_EQ(u4.getPathEtc(), "");
EXPECT_EQ(u5.getScheme(), "bb");
EXPECT_EQ(u5.getHost(), "localhost");
EXPECT_EQ(u5.getPort(), 0);
2022-05-21 20:55:25 +08:00
EXPECT_EQ(u5.getPath(), "/");
EXPECT_EQ(u5.getPathEtc(), "?&foo=12:4&ccc=13");
EXPECT_EQ(u5.getQuery(), "&foo=12:4&ccc=13");
EXPECT_EQ(u6.getScheme(), "cc");
EXPECT_EQ(u6.getHost(), "localhost");
EXPECT_EQ(u6.getPort(), 91);
2022-05-21 20:55:25 +08:00
EXPECT_EQ(u6.getPath(), "/");
EXPECT_EQ(u6.getPathEtc(), "?&foo=321&bbb=1");
EXPECT_EQ(u6.getQuery(), "&foo=321&bbb=1");
}
}
std::string ParseUriTest::subtitle() const
{
return "Uri::parse Test";
}
2014-11-22 15:52:02 +08:00
// MathUtilTest
2021-12-28 16:06:23 +08:00
namespace UnitTest
{
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
2021-12-28 16:06:23 +08:00
# include "math/MathUtilNeon.inl"
2014-11-22 15:52:02 +08:00
#endif
#ifdef INCLUDE_NEON64
2021-12-28 16:06:23 +08:00
# include "math/MathUtilNeon64.inl"
2014-11-22 15:52:02 +08:00
#endif
#ifdef INCLUDE_SSE
2021-12-28 16:06:23 +08:00
// FIXME: #include "math/MathUtilSSE.inl"
2014-11-22 15:52:02 +08:00
#endif
#include "math/MathUtil.inl"
2021-12-28 16:06:23 +08:00
} // namespace UnitTest
// I know the next line looks ugly, but it's a way to test MathUtil. :)
using namespace UnitTest::cocos2d;
2014-11-22 15:52:02 +08:00
static void __checkMathUtilResult(const char* description, const float* a1, const float* a2, int size)
{
log("-------------checking %s ----------------------------", description);
// Check whether the result of the optimized instruction is the same as which is implemented in C
for (int i = 0; i < size; ++i)
{
2021-12-28 16:06:23 +08:00
bool r = fabs(a1[i] - a2[i]) < 0.00001f; // FLT_EPSILON;
2014-11-22 15:52:02 +08:00
if (r)
{
log("Correct: a1[%d]=%f, a2[%d]=%f", i, a1[i], i, a2[i]);
}
else
{
log("Wrong: a1[%d]=%f, a2[%d]=%f", i, a1[i], i, a2[i]);
}
CCASSERT(r, "The optimized instruction is implemented in a wrong way, please check it!");
2014-11-22 15:52:02 +08:00
}
}
void MathUtilTest::onEnter()
{
UnitTestDemo::onEnter();
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
const int MAT4_SIZE = 16;
const int VEC4_SIZE = 4;
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
const float inMat41[MAT4_SIZE] = {
2021-12-28 16:06:23 +08:00
0.234023f, 2.472349f, 1.984244f, 2.23348f, 0.634124f, 0.234975f, 6.384572f, 0.82368f,
0.738028f, 1.845237f, 1.934721f, 1.62343f, 0.339023f, 3.472452f, 1.324714f, 4.23852f,
2014-11-22 15:52:02 +08:00
};
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
const float inMat42[MAT4_SIZE] = {
2021-12-28 16:06:23 +08:00
1.640232f, 4.472349f, 0.983244f, 1.23343f, 2.834124f, 8.234975f, 0.082572f, 3.82464f,
3.238028f, 2.845237f, 0.331721f, 4.62544f, 4.539023f, 9.472452f, 3.520714f, 2.23252f,
2014-11-22 15:52:02 +08:00
};
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
const float scalar = 1.323298f;
2021-12-28 16:06:23 +08:00
const float x = 0.432234f;
const float y = 1.333229f;
const float z = 2.535292f;
const float w = 4.632234f;
const float inVec4[VEC4_SIZE] = {2.323478f, 0.238482f, 4.223783f, 7.238238f};
2014-11-22 15:52:02 +08:00
const float inVec42[VEC4_SIZE] = {0.322374f, 8.258883f, 3.293683f, 2.838337f};
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
float outMat4Opt[MAT4_SIZE] = {0};
2021-12-28 16:06:23 +08:00
float outMat4C[MAT4_SIZE] = {0};
2014-11-22 15:52:02 +08:00
float outVec4Opt[VEC4_SIZE] = {0};
2021-12-28 16:06:23 +08:00
float outVec4C[VEC4_SIZE] = {0};
2014-11-22 15:52:02 +08:00
// inline static void addMatrix(const float* m, float scalar, float* dst);
MathUtilC::addMatrix(inMat41, scalar, outMat4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::addMatrix(inMat41, scalar, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::addMatrix(inMat41, scalar, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void addMatrix(const float* m, float scalar, float* dst);", outMat4C,
outMat4Opt, MAT4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
// inline static void addMatrix(const float* m1, const float* m2, float* dst);
MathUtilC::addMatrix(inMat41, inMat42, outMat4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::addMatrix(inMat41, inMat42, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::addMatrix(inMat41, inMat42, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void addMatrix(const float* m1, const float* m2, float* dst);", outMat4C,
outMat4Opt, MAT4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
// inline static void subtractMatrix(const float* m1, const float* m2, float* dst);
MathUtilC::subtractMatrix(inMat41, inMat42, outMat4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::subtractMatrix(inMat41, inMat42, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::subtractMatrix(inMat41, inMat42, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void subtractMatrix(const float* m1, const float* m2, float* dst);", outMat4C,
outMat4Opt, MAT4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
// inline static void multiplyMatrix(const float* m, float scalar, float* dst);
MathUtilC::multiplyMatrix(inMat41, scalar, outMat4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::multiplyMatrix(inMat41, scalar, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::multiplyMatrix(inMat41, scalar, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void multiplyMatrix(const float* m, float scalar, float* dst);", outMat4C,
outMat4Opt, MAT4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
// inline static void multiplyMatrix(const float* m1, const float* m2, float* dst);
MathUtilC::multiplyMatrix(inMat41, inMat42, outMat4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::multiplyMatrix(inMat41, inMat42, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::multiplyMatrix(inMat41, inMat42, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void multiplyMatrix(const float* m1, const float* m2, float* dst);", outMat4C,
outMat4Opt, MAT4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
// inline static void negateMatrix(const float* m, float* dst);
MathUtilC::negateMatrix(inMat41, outMat4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::negateMatrix(inMat41, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::negateMatrix(inMat41, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void negateMatrix(const float* m, float* dst);", outMat4C, outMat4Opt,
MAT4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
// inline static void transposeMatrix(const float* m, float* dst);
MathUtilC::transposeMatrix(inMat41, outMat4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::transposeMatrix(inMat41, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::transposeMatrix(inMat41, outMat4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void transposeMatrix(const float* m, float* dst);", outMat4C, outMat4Opt,
MAT4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
// inline static void transformVec4(const float* m, float x, float y, float z, float w, float* dst);
MathUtilC::transformVec4(inMat41, x, y, z, w, outVec4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::transformVec4(inMat41, x, y, z, w, outVec4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::transformVec4(inMat41, x, y, z, w, outVec4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult(
"inline static void transformVec4(const float* m, float x, float y, float z, float w, float* dst);", outVec4C,
outVec4Opt, VEC4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outVec4C, 0, sizeof(outVec4C));
memset(outVec4Opt, 0, sizeof(outVec4Opt));
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
// inline static void transformVec4(const float* m, const float* v, float* dst);
MathUtilC::transformVec4(inMat41, inVec4, outVec4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::transformVec4(inMat41, inVec4, outVec4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::transformVec4(inMat41, inVec4, outVec4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void transformVec4(const float* m, const float* v, float* dst);", outVec4C,
outVec4Opt, VEC4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outVec4C, 0, sizeof(outVec4C));
memset(outVec4Opt, 0, sizeof(outVec4Opt));
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
// inline static void crossVec3(const float* v1, const float* v2, float* dst);
MathUtilC::crossVec3(inVec4, inVec42, outVec4C);
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON32
MathUtilNeon::crossVec3(inVec4, inVec42, outVec4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_NEON64
MathUtilNeon64::crossVec3(inVec4, inVec42, outVec4Opt);
#endif
2021-12-28 16:06:23 +08:00
2014-11-22 15:52:02 +08:00
#ifdef INCLUDE_SSE
// FIXME:
#endif
2021-12-28 16:06:23 +08:00
__checkMathUtilResult("inline static void crossVec3(const float* v1, const float* v2, float* dst);", outVec4C,
outVec4Opt, VEC4_SIZE);
2014-11-22 15:52:02 +08:00
// Clean
memset(outVec4C, 0, sizeof(outVec4C));
memset(outVec4Opt, 0, sizeof(outVec4Opt));
}
std::string MathUtilTest::subtitle() const
{
return "MathUtilTest";
}
// ResizableBufferAdapterTest
void ResizableBufferAdapterTest::onEnter()
{
UnitTestDemo::onEnter();
2022-05-14 04:38:37 +08:00
yasio::byte_buffer buffer;
FileUtils::getInstance()->getContents("effect1.wav", &buffer);
2022-05-14 04:38:37 +08:00
EXPECT_EQ(buffer.size(), 10026);
FileUtils::getInstance()->getContents("effect2.ogg", &buffer);
2022-05-14 04:38:37 +08:00
EXPECT_EQ(buffer.size(), 4278);
FileUtils::getInstance()->getContents("effect1.wav", &buffer);
2022-05-14 04:38:37 +08:00
EXPECT_EQ(buffer.size(), 10026);
}
std::string ResizableBufferAdapterTest::subtitle() const
{
2022-05-14 04:38:37 +08:00
return "ResiziableBufferAdapter<yasio::byte_buffer> Test";
}