Skip to content

Commit 9761254

Browse files
committed
Merge commit '0c576892132a619d2ee2fc7861ddd496a5f47001' into scgamex-v3
STEVE: removed all scripting/3d/etc support previously removed * commit '0c576892132a619d2ee2fc7861ddd496a5f47001': Lua: add manual bindings for EventDispatcher::addCustomEventListener (cocos2d#19405) [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19431) refine travis, don't generate binding codes for cpp only target (cocos2d#19430) remove unneeded codes (cocos2d#19421) need to generate binding codes for all targets (cocos2d#19424) Fix memory leak if invoking Texture2D::setAlphaTexture many times. (cocos2d#19400) fix header path include style (cocos2d#19395) Font atlas texture initialization delayed (cocos2d#19384) If path to file is tool long crash is possible. (cocos2d#19383) Checking, does the touch is within the height of the line, not the height of the sprite? (cocos2d#19394) [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19390) Adds Configuration::getInfoAsMap() (cocos2d#19381) # Conflicts: # build/cocos2d_libs.xcodeproj/project.pbxproj # build/cocos2d_tests.xcodeproj/project.pbxproj # cocos/2d/CCTextFieldTTF.cpp # cocos/editor-support/spine/Animation.c # cocos/editor-support/spine/Animation.h # cocos/editor-support/spine/AnimationState.c # cocos/editor-support/spine/AnimationState.h # cocos/editor-support/spine/AnimationStateData.c # cocos/editor-support/spine/AnimationStateData.h # cocos/editor-support/spine/Array.c # cocos/editor-support/spine/Array.h # cocos/editor-support/spine/Atlas.c # cocos/editor-support/spine/Atlas.h # cocos/editor-support/spine/AtlasAttachmentLoader.c # cocos/editor-support/spine/AtlasAttachmentLoader.h # cocos/editor-support/spine/Attachment.c # cocos/editor-support/spine/Attachment.h # cocos/editor-support/spine/AttachmentLoader.c # cocos/editor-support/spine/AttachmentLoader.h # cocos/editor-support/spine/AttachmentVertices.cpp # cocos/editor-support/spine/Bone.c # cocos/editor-support/spine/Bone.h # cocos/editor-support/spine/BoneData.c # cocos/editor-support/spine/BoneData.h # cocos/editor-support/spine/BoundingBoxAttachment.c # cocos/editor-support/spine/BoundingBoxAttachment.h # cocos/editor-support/spine/ClippingAttachment.c # cocos/editor-support/spine/ClippingAttachment.h # cocos/editor-support/spine/Cocos2dAttachmentLoader.cpp # cocos/editor-support/spine/Cocos2dAttachmentLoader.h # cocos/editor-support/spine/Color.c # cocos/editor-support/spine/Color.h # cocos/editor-support/spine/Event.c # cocos/editor-support/spine/Event.h # cocos/editor-support/spine/EventData.c # cocos/editor-support/spine/EventData.h # cocos/editor-support/spine/IkConstraint.c # cocos/editor-support/spine/IkConstraint.h # cocos/editor-support/spine/IkConstraintData.c # cocos/editor-support/spine/IkConstraintData.h # cocos/editor-support/spine/Json.c # cocos/editor-support/spine/MeshAttachment.c # cocos/editor-support/spine/MeshAttachment.h # cocos/editor-support/spine/PathAttachment.c # cocos/editor-support/spine/PathAttachment.h # cocos/editor-support/spine/PathConstraint.c # cocos/editor-support/spine/PathConstraint.h # cocos/editor-support/spine/PathConstraintData.c # cocos/editor-support/spine/PathConstraintData.h # cocos/editor-support/spine/PointAttachment.c # cocos/editor-support/spine/PointAttachment.h # cocos/editor-support/spine/RegionAttachment.c # cocos/editor-support/spine/RegionAttachment.h # cocos/editor-support/spine/Skeleton.c # cocos/editor-support/spine/Skeleton.h # cocos/editor-support/spine/SkeletonAnimation.cpp # cocos/editor-support/spine/SkeletonAnimation.h # cocos/editor-support/spine/SkeletonBatch.cpp # cocos/editor-support/spine/SkeletonBatch.h # cocos/editor-support/spine/SkeletonBinary.c # cocos/editor-support/spine/SkeletonBinary.h # cocos/editor-support/spine/SkeletonBounds.c # cocos/editor-support/spine/SkeletonBounds.h # cocos/editor-support/spine/SkeletonClipping.c # cocos/editor-support/spine/SkeletonClipping.h # cocos/editor-support/spine/SkeletonData.c # cocos/editor-support/spine/SkeletonData.h # cocos/editor-support/spine/SkeletonJson.c # cocos/editor-support/spine/SkeletonJson.h # cocos/editor-support/spine/SkeletonRenderer.cpp # cocos/editor-support/spine/SkeletonRenderer.h # cocos/editor-support/spine/SkeletonTwoColorBatch.cpp # cocos/editor-support/spine/SkeletonTwoColorBatch.h # cocos/editor-support/spine/Skin.c # cocos/editor-support/spine/Skin.h # cocos/editor-support/spine/Slot.c # cocos/editor-support/spine/Slot.h # cocos/editor-support/spine/SlotData.c # cocos/editor-support/spine/SlotData.h # cocos/editor-support/spine/TransformConstraint.c # cocos/editor-support/spine/TransformConstraint.h # cocos/editor-support/spine/TransformConstraintData.c # cocos/editor-support/spine/TransformConstraintData.h # cocos/editor-support/spine/Triangulator.c # cocos/editor-support/spine/Triangulator.h # cocos/editor-support/spine/VertexAttachment.c # cocos/editor-support/spine/VertexAttachment.h # cocos/editor-support/spine/VertexEffect.c # cocos/editor-support/spine/VertexEffect.h # cocos/editor-support/spine/extension.c # cocos/editor-support/spine/extension.h # cocos/editor-support/spine/spine-cocos2dx.cpp # cocos/editor-support/spine/spine-cocos2dx.h # cocos/editor-support/spine/spine.h # cocos/platform/winrt/CCGLViewImpl-winrt.h # cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js # cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp # cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp # cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj # cocos/scripting/lua-bindings/auto/api/Application.lua # cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp # cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp # cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj # tests/cpp-tests/Classes/Box2DTestBed/Test.h # tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp # tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp # tests/cpp-tests/Classes/SpineTest/SpineTest.h # tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua
2 parents 43dab73 + 0c57689 commit 9761254

File tree

132 files changed

+106
-21453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+106
-21453
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ matrix:
2525
sudo: required
2626
# android ndk-build
2727
- os: linux
28-
env: BUILD_TARGET=android_ndk-build
28+
env: BUILD_TARGET=android_cpp_ndk-build
2929
language: android
3030
sudo: required
3131
# android_lua ndk-build
@@ -35,7 +35,7 @@ matrix:
3535
sudo: required
3636
# android cmake
3737
- os: linux
38-
env: BUILD_TARGET=android_cmake
38+
env: BUILD_TARGET=android_cpp_cmake
3939
language: android
4040
sudo: required
4141
# android_lua cmake
@@ -61,12 +61,12 @@ matrix:
6161
osx_image: xcode9.3
6262
sudo: required
6363
- os: linux
64-
env: BUILD_TARGET=android_cocos_new_test
64+
env: BUILD_TARGET=android_cocos_new_cpp_test
6565
language: android
6666
sudo: required
6767
- os: linux
6868
dist: xenial
69-
env: BUILD_TARGET=linux_cocos_new_test
69+
env: BUILD_TARGET=linux_cocos_new_lua_test
7070
language: cpp
7171
sudo: required
7272

build/cocos2d_libs.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4771,6 +4771,8 @@
47714771
1551A34D158F2AB200E66CFE /* Debug */ = {
47724772
isa = XCBuildConfiguration;
47734773
buildSettings = {
4774+
ALWAYS_SEARCH_USER_PATHS = NO;
4775+
CLANG_ENABLE_OBJC_WEAK = YES;
47744776
COMBINE_HIDPI_IMAGES = YES;
47754777
EXECUTABLE_EXTENSION = a;
47764778
EXECUTABLE_PREFIX = "";
@@ -4826,6 +4828,8 @@
48264828
1551A34E158F2AB200E66CFE /* Release */ = {
48274829
isa = XCBuildConfiguration;
48284830
buildSettings = {
4831+
ALWAYS_SEARCH_USER_PATHS = NO;
4832+
CLANG_ENABLE_OBJC_WEAK = YES;
48294833
COMBINE_HIDPI_IMAGES = YES;
48304834
EXECUTABLE_EXTENSION = a;
48314835
EXECUTABLE_PREFIX = "";
@@ -4878,6 +4882,8 @@
48784882
A07A4D621783777C0073F6A7 /* Debug */ = {
48794883
isa = XCBuildConfiguration;
48804884
buildSettings = {
4885+
ALWAYS_SEARCH_USER_PATHS = NO;
4886+
CLANG_ENABLE_OBJC_WEAK = YES;
48814887
ENABLE_BITCODE = NO;
48824888
EXECUTABLE_PREFIX = "";
48834889
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -4922,6 +4928,8 @@
49224928
A07A4D631783777C0073F6A7 /* Release */ = {
49234929
isa = XCBuildConfiguration;
49244930
buildSettings = {
4931+
ALWAYS_SEARCH_USER_PATHS = NO;
4932+
CLANG_ENABLE_OBJC_WEAK = YES;
49254933
ENABLE_BITCODE = NO;
49264934
EXECUTABLE_PREFIX = "";
49274935
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;

build/cocos2d_tests.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,6 +2873,7 @@
28732873
1A0EE41118CDF775004CD58F /* Debug */ = {
28742874
isa = XCBuildConfiguration;
28752875
buildSettings = {
2876+
ALWAYS_SEARCH_USER_PATHS = NO;
28762877
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-cpp-empty-test";
28772878
CODE_SIGN_IDENTITY = "iPhone Developer";
28782879
DEVELOPMENT_TEAM = 63UZQ327C5;

cocos/2d/CCFontAtlas.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ FontAtlas::FontAtlas(Font &theFont)
7272
{
7373
_letterPadding += 2 * FontFreeType::DistanceMapSpread;
7474
}
75-
76-
reinit();
7775

7876
#if CC_ENABLE_CACHE_TEXTURE_DATA
7977
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
@@ -344,7 +342,10 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
344342
{
345343
return false;
346344
}
347-
345+
346+
if (!_currentPageData)
347+
reinit();
348+
348349
std::unordered_map<unsigned int, unsigned int> codeMapOfNewChar;
349350
findNewCharacters(utf32Text, codeMapOfNewChar);
350351
if (codeMapOfNewChar.empty())

cocos/2d/CCFontAtlasCache.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
NS_CC_BEGIN
3737

3838
std::unordered_map<std::string, FontAtlas *> FontAtlasCache::_atlasMap;
39-
#define ATLAS_MAP_KEY_BUFFER 255
39+
#define ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE 255
4040

4141
void FontAtlasCache::purgeCachedData()
4242
{
@@ -60,15 +60,11 @@ FontAtlas* FontAtlasCache::getFontAtlasTTF(const _ttfConfig* config)
6060
useDistanceField = false;
6161
}
6262

63-
char tmp[ATLAS_MAP_KEY_BUFFER];
64-
if (useDistanceField) {
65-
snprintf(tmp, ATLAS_MAP_KEY_BUFFER, "df %.2f %d %s", config->fontSize, config->outlineSize,
66-
realFontFilename.c_str());
67-
} else {
68-
snprintf(tmp, ATLAS_MAP_KEY_BUFFER, "%.2f %d %s", config->fontSize, config->outlineSize,
69-
realFontFilename.c_str());
70-
}
71-
std::string atlasName = tmp;
63+
std::string key;
64+
char keyPrefix[ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE];
65+
snprintf(keyPrefix, ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE, useDistanceField ? "df %.2f %d " : "%.2f %d ", config->fontSize, config->outlineSize);
66+
std::string atlasName(keyPrefix);
67+
atlasName += realFontFilename;
7268

7369
auto it = _atlasMap.find(atlasName);
7470

@@ -95,9 +91,10 @@ FontAtlas* FontAtlasCache::getFontAtlasTTF(const _ttfConfig* config)
9591
FontAtlas* FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset /* = Vec2::ZERO */)
9692
{
9793
auto realFontFilename = FileUtils::getInstance()->getNewFilename(fontFileName); // resolves real file path, to prevent storing multiple atlases for the same file.
98-
char tmp[ATLAS_MAP_KEY_BUFFER];
99-
snprintf(tmp, ATLAS_MAP_KEY_BUFFER, "%.2f %.2f %s", imageOffset.x, imageOffset.y, realFontFilename.c_str());
100-
std::string atlasName = tmp;
94+
char keyPrefix[ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE];
95+
snprintf(keyPrefix, ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE, "%.2f %.2f ", imageOffset.x, imageOffset.y);
96+
std::string atlasName(keyPrefix);
97+
atlasName += realFontFilename;
10198

10299
auto it = _atlasMap.find(atlasName);
103100
if ( it == _atlasMap.end() )
@@ -147,9 +144,9 @@ FontAtlas* FontAtlasCache::getFontAtlasCharMap(const std::string& plistFile)
147144

148145
FontAtlas* FontAtlasCache::getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
149146
{
150-
char tmp[30];
151-
sprintf(tmp,"name:%u_%d_%d_%d",texture->getName(),itemWidth,itemHeight,startCharMap);
152-
std::string atlasName = tmp;
147+
char key[ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE];
148+
sprintf(key,"name:%u_%d_%d_%d",texture->getName(),itemWidth,itemHeight,startCharMap);
149+
std::string atlasName = key;
153150

154151
auto it = _atlasMap.find(atlasName);
155152
if ( it == _atlasMap.end() )
@@ -174,9 +171,10 @@ FontAtlas* FontAtlasCache::getFontAtlasCharMap(Texture2D* texture, int itemWidth
174171

175172
FontAtlas* FontAtlasCache::getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
176173
{
177-
char tmp[ATLAS_MAP_KEY_BUFFER];
178-
snprintf(tmp, ATLAS_MAP_KEY_BUFFER, "%d %d %d %s", itemWidth, itemHeight, startCharMap, charMapFile.c_str());
179-
std::string atlasName = tmp;
174+
char keyPrefix[ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE];
175+
snprintf(keyPrefix, ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE, "%d %d %d ", itemWidth, itemHeight, startCharMap);
176+
std::string atlasName(keyPrefix);
177+
atlasName += charMapFile;
180178

181179
auto it = _atlasMap.find(atlasName);
182180
if ( it == _atlasMap.end() )
@@ -224,9 +222,10 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas)
224222

225223
void FontAtlasCache::reloadFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset/* = Vec2::ZERO*/)
226224
{
227-
char tmp[ATLAS_MAP_KEY_BUFFER];
228-
snprintf(tmp, ATLAS_MAP_KEY_BUFFER, "%.2f %.2f %s", imageOffset.x, imageOffset.y, fontFileName.c_str());
229-
std::string atlasName = tmp;
225+
char keyPrefix[ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE];
226+
snprintf(keyPrefix, ATLAS_MAP_KEY_PREFIX_BUFFER_SIZE, "%.2f %.2f ", imageOffset.x, imageOffset.y);
227+
std::string atlasName(keyPrefix);
228+
atlasName += fontFileName;
230229

231230
auto it = _atlasMap.find(atlasName);
232231
if (it != _atlasMap.end())

cocos/2d/CCFontFreeType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "2d/CCFont.h"
3333

3434
#include <string>
35-
#include <ft2build.h>
35+
#include "ft2build.h"
3636

3737
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
3838
#define generic GenericFromFreeTypeLibrary

cocos/base/CCConfiguration.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ class CC_DLL Configuration : public Ref
229229
* @return The Configuration info.
230230
*/
231231
std::string getInfo() const;
232+
233+
/**
234+
Returns the configuration as value map
235+
@return the configuration map
236+
@since 3.18
237+
@js NA
238+
@lua NA
239+
*/
240+
const ValueMap& getInfoAsMap()const { return _valueDict; }
232241

233242
/** Gathers OpenGL / GPU information.
234243
*/

cocos/base/CCDirector.cpp

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ THE SOFTWARE.
6868
#include "base/CCScriptSupport.h"
6969
#endif
7070

71-
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
72-
#include "platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxEngineDataManager.h"
73-
#endif
74-
7571
/**
7672
Position of the FPS
7773
@@ -118,7 +114,7 @@ Director::Director()
118114
{
119115
}
120116

121-
bool Director::init(void)
117+
bool Director::init()
122118
{
123119
setDefaultValues();
124120

@@ -161,13 +157,10 @@ bool Director::init(void)
161157
_renderer = new (std::nothrow) Renderer;
162158
RenderState::initialize();
163159

164-
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
165-
EngineDataManager::init();
166-
#endif
167160
return true;
168161
}
169162

170-
Director::~Director(void)
163+
Director::~Director()
171164
{
172165
CCLOGINFO("deallocing Director: %p", this);
173166

@@ -1135,10 +1128,7 @@ void Director::purgeDirector()
11351128
_openGLView->end();
11361129
_openGLView = nullptr;
11371130
}
1138-
1139-
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
1140-
EngineDataManager::destroy();
1141-
#endif
1131+
11421132
// delete Director
11431133
release();
11441134
}
@@ -1220,7 +1210,7 @@ void Director::pause()
12201210
_oldAnimationInterval = _animationInterval;
12211211

12221212
// when paused, don't consume CPU
1223-
setAnimationInterval(1 / 4.0, SetIntervalReason::BY_DIRECTOR_PAUSE);
1213+
setAnimationInterval(1 / 4.0);
12241214
_paused = true;
12251215
}
12261216

@@ -1231,7 +1221,7 @@ void Director::resume()
12311221
return;
12321222
}
12331223

1234-
setAnimationInterval(_oldAnimationInterval, SetIntervalReason::BY_ENGINE);
1224+
setAnimationInterval(_oldAnimationInterval);
12351225

12361226
_paused = false;
12371227
_deltaTime = 0;
@@ -1456,19 +1446,14 @@ void Director::setEventDispatcher(EventDispatcher* dispatcher)
14561446
}
14571447

14581448
void Director::startAnimation()
1459-
{
1460-
startAnimation(SetIntervalReason::BY_ENGINE);
1461-
}
1462-
1463-
void Director::startAnimation(SetIntervalReason reason)
14641449
{
14651450
_lastUpdate = std::chrono::steady_clock::now();
14661451

14671452
_invalid = false;
14681453

14691454
_cocos2d_thread_id = std::this_thread::get_id();
14701455

1471-
Application::getInstance()->setAnimationInterval(_animationInterval, reason);
1456+
Application::getInstance()->setAnimationInterval(_animationInterval);
14721457

14731458
// fix issue #3509, skip one fps to avoid incorrect time calculation.
14741459
setNextDeltaTimeZero(true);
@@ -1508,17 +1493,12 @@ void Director::stopAnimation()
15081493
}
15091494

15101495
void Director::setAnimationInterval(float interval)
1511-
{
1512-
setAnimationInterval(interval, SetIntervalReason::BY_GAME);
1513-
}
1514-
1515-
void Director::setAnimationInterval(float interval, SetIntervalReason reason)
15161496
{
15171497
_animationInterval = interval;
15181498
if (! _invalid)
15191499
{
15201500
stopAnimation();
1521-
startAnimation(reason);
1501+
startAnimation();
15221502
}
15231503
}
15241504

cocos/base/CCDirector.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,6 @@ class CC_DLL Director : public Ref
585585

586586
protected:
587587
void reset();
588-
589-
590-
virtual void startAnimation(SetIntervalReason reason);
591-
virtual void setAnimationInterval(float interval, SetIntervalReason reason);
592588

593589
void purgeDirector();
594590
bool _purgeDirectorInNextLoop = false; // this flag will be set to true in end()

cocos/base/ccTypes.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -634,15 +634,6 @@ class CC_DLL Acceleration
634634
extern const std::string CC_DLL STD_STRING_EMPTY;
635635
extern const ssize_t CC_DLL CC_INVALID_INDEX;
636636

637-
enum class SetIntervalReason : char
638-
{
639-
BY_GAME = 0,
640-
BY_ENGINE,
641-
BY_SYSTEM,
642-
BY_SCENE_CHANGE,
643-
BY_DIRECTOR_PAUSE
644-
};
645-
646637
NS_CC_END
647638
// end group
648639
/// @}

0 commit comments

Comments
 (0)