mirror of https://github.com/axmolengine/axmol.git
merge cocos
This commit is contained in:
commit
3d77c7535d
|
@ -1,5 +1,6 @@
|
|||
cocos2d-x-3.4 ??
|
||||
[NEW] UI:LoadingBar: add TextureResType to LoadingBar's create method
|
||||
[NEW] Allocator: add custom allocator support, global, default, fixed block, object pool.
|
||||
|
||||
[FIX] FileUtils: WebP format with alpha channel displayed wrong
|
||||
[FIX] Label: content size of Label is incorrect if the string is set to empty string
|
||||
|
|
|
@ -73,7 +73,7 @@ else(DEBUG_MODE)
|
|||
set(CMAKE_BUILD_TYPE RELEASE)
|
||||
endif(DEBUG_MODE)
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCOCOS2D_DEBUG=1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
||||
|
||||
# Compiler options
|
||||
|
|
|
@ -1923,10 +1923,34 @@
|
|||
B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; };
|
||||
B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; };
|
||||
B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; };
|
||||
B621CE7D1A3ED8CB00646956 /* CCAsyncTaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B621CE7B1A3ED8CB00646956 /* CCAsyncTaskPool.cpp */; };
|
||||
B621CE7E1A3ED8CB00646956 /* CCAsyncTaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B621CE7B1A3ED8CB00646956 /* CCAsyncTaskPool.cpp */; };
|
||||
B621CE7F1A3ED8CB00646956 /* CCAsyncTaskPool.h in Headers */ = {isa = PBXBuildFile; fileRef = B621CE7C1A3ED8CB00646956 /* CCAsyncTaskPool.h */; };
|
||||
B621CE801A3ED8CB00646956 /* CCAsyncTaskPool.h in Headers */ = {isa = PBXBuildFile; fileRef = B621CE7C1A3ED8CB00646956 /* CCAsyncTaskPool.h */; };
|
||||
B63990CC1A490AFE00B07923 /* CCAsyncTaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B63990CA1A490AFE00B07923 /* CCAsyncTaskPool.cpp */; };
|
||||
B63990CD1A490AFE00B07923 /* CCAsyncTaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B63990CA1A490AFE00B07923 /* CCAsyncTaskPool.cpp */; };
|
||||
B63990CE1A490AFE00B07923 /* CCAsyncTaskPool.h in Headers */ = {isa = PBXBuildFile; fileRef = B63990CB1A490AFE00B07923 /* CCAsyncTaskPool.h */; };
|
||||
B63990CF1A490AFE00B07923 /* CCAsyncTaskPool.h in Headers */ = {isa = PBXBuildFile; fileRef = B63990CB1A490AFE00B07923 /* CCAsyncTaskPool.h */; };
|
||||
D0FD03491A3B51AA00825BB5 /* CCAllocatorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD033B1A3B51AA00825BB5 /* CCAllocatorBase.h */; };
|
||||
D0FD034A1A3B51AA00825BB5 /* CCAllocatorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD033B1A3B51AA00825BB5 /* CCAllocatorBase.h */; };
|
||||
D0FD034B1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FD033C1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp */; };
|
||||
D0FD034C1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FD033C1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp */; };
|
||||
D0FD034D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD033D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h */; };
|
||||
D0FD034E1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD033D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h */; };
|
||||
D0FD034F1A3B51AA00825BB5 /* CCAllocatorGlobal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FD033E1A3B51AA00825BB5 /* CCAllocatorGlobal.cpp */; };
|
||||
D0FD03501A3B51AA00825BB5 /* CCAllocatorGlobal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FD033E1A3B51AA00825BB5 /* CCAllocatorGlobal.cpp */; };
|
||||
D0FD03511A3B51AA00825BB5 /* CCAllocatorGlobal.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD033F1A3B51AA00825BB5 /* CCAllocatorGlobal.h */; };
|
||||
D0FD03521A3B51AA00825BB5 /* CCAllocatorGlobal.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD033F1A3B51AA00825BB5 /* CCAllocatorGlobal.h */; };
|
||||
D0FD03531A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FD03401A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp */; };
|
||||
D0FD03541A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FD03401A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp */; };
|
||||
D0FD03551A3B51AA00825BB5 /* CCAllocatorMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03411A3B51AA00825BB5 /* CCAllocatorMacros.h */; };
|
||||
D0FD03561A3B51AA00825BB5 /* CCAllocatorMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03411A3B51AA00825BB5 /* CCAllocatorMacros.h */; };
|
||||
D0FD03571A3B51AA00825BB5 /* CCAllocatorMutex.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03421A3B51AA00825BB5 /* CCAllocatorMutex.h */; };
|
||||
D0FD03581A3B51AA00825BB5 /* CCAllocatorMutex.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03421A3B51AA00825BB5 /* CCAllocatorMutex.h */; };
|
||||
D0FD03591A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03431A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h */; };
|
||||
D0FD035A1A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03431A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h */; };
|
||||
D0FD035B1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03441A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h */; };
|
||||
D0FD035C1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03441A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h */; };
|
||||
D0FD035D1A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03451A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h */; };
|
||||
D0FD035E1A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03451A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h */; };
|
||||
D0FD035F1A3B51AA00825BB5 /* CCAllocatorStrategyPool.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03461A3B51AA00825BB5 /* CCAllocatorStrategyPool.h */; };
|
||||
D0FD03601A3B51AA00825BB5 /* CCAllocatorStrategyPool.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FD03461A3B51AA00825BB5 /* CCAllocatorStrategyPool.h */; };
|
||||
DA8C62A219E52C6400000516 /* ioapi_mem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA8C62A019E52C6400000516 /* ioapi_mem.cpp */; };
|
||||
DA8C62A319E52C6400000516 /* ioapi_mem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA8C62A019E52C6400000516 /* ioapi_mem.cpp */; };
|
||||
DA8C62A419E52C6400000516 /* ioapi_mem.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8C62A119E52C6400000516 /* ioapi_mem.h */; };
|
||||
|
@ -2980,11 +3004,23 @@
|
|||
B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = "<group>"; };
|
||||
B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBillBoard.cpp; sourceTree = "<group>"; };
|
||||
B60C5BD319AC68B10056FBDE /* CCBillBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBillBoard.h; sourceTree = "<group>"; };
|
||||
B621CE7B1A3ED8CB00646956 /* CCAsyncTaskPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCAsyncTaskPool.cpp; path = ../base/CCAsyncTaskPool.cpp; sourceTree = "<group>"; };
|
||||
B621CE7C1A3ED8CB00646956 /* CCAsyncTaskPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCAsyncTaskPool.h; path = ../base/CCAsyncTaskPool.h; sourceTree = "<group>"; };
|
||||
B63990CA1A490AFE00B07923 /* CCAsyncTaskPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCAsyncTaskPool.cpp; path = ../base/CCAsyncTaskPool.cpp; sourceTree = "<group>"; };
|
||||
B63990CB1A490AFE00B07923 /* CCAsyncTaskPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCAsyncTaskPool.h; path = ../base/CCAsyncTaskPool.h; sourceTree = "<group>"; };
|
||||
B67C624319D4186F00F11FC6 /* ccShader_3D_ColorNormal.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_ColorNormal.frag; sourceTree = "<group>"; };
|
||||
B67C624419D4186F00F11FC6 /* ccShader_3D_ColorNormalTex.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_ColorNormalTex.frag; sourceTree = "<group>"; };
|
||||
B67C624519D4186F00F11FC6 /* ccShader_3D_PositionNormalTex.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_PositionNormalTex.vert; sourceTree = "<group>"; };
|
||||
D0FD033B1A3B51AA00825BB5 /* CCAllocatorBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorBase.h; sourceTree = "<group>"; };
|
||||
D0FD033C1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAllocatorDiagnostics.cpp; sourceTree = "<group>"; };
|
||||
D0FD033D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorDiagnostics.h; sourceTree = "<group>"; };
|
||||
D0FD033E1A3B51AA00825BB5 /* CCAllocatorGlobal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAllocatorGlobal.cpp; sourceTree = "<group>"; };
|
||||
D0FD033F1A3B51AA00825BB5 /* CCAllocatorGlobal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorGlobal.h; sourceTree = "<group>"; };
|
||||
D0FD03401A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAllocatorGlobalNewDelete.cpp; sourceTree = "<group>"; };
|
||||
D0FD03411A3B51AA00825BB5 /* CCAllocatorMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorMacros.h; sourceTree = "<group>"; };
|
||||
D0FD03421A3B51AA00825BB5 /* CCAllocatorMutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorMutex.h; sourceTree = "<group>"; };
|
||||
D0FD03431A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorStrategyDefault.h; sourceTree = "<group>"; };
|
||||
D0FD03441A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorStrategyFixedBlock.h; sourceTree = "<group>"; };
|
||||
D0FD03451A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorStrategyGlobalSmallBlock.h; sourceTree = "<group>"; };
|
||||
D0FD03461A3B51AA00825BB5 /* CCAllocatorStrategyPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAllocatorStrategyPool.h; sourceTree = "<group>"; };
|
||||
DA8C62A019E52C6400000516 /* ioapi_mem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ioapi_mem.cpp; sourceTree = "<group>"; };
|
||||
DA8C62A119E52C6400000516 /* ioapi_mem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi_mem.h; sourceTree = "<group>"; };
|
||||
DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCClippingRectangleNode.cpp; sourceTree = "<group>"; };
|
||||
|
@ -3193,8 +3229,9 @@
|
|||
1A5700A2180BC5E60088DEC7 /* base */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B621CE7B1A3ED8CB00646956 /* CCAsyncTaskPool.cpp */,
|
||||
B621CE7C1A3ED8CB00646956 /* CCAsyncTaskPool.h */,
|
||||
B63990CA1A490AFE00B07923 /* CCAsyncTaskPool.cpp */,
|
||||
B63990CB1A490AFE00B07923 /* CCAsyncTaskPool.h */,
|
||||
D0FD03391A3B51AA00825BB5 /* allocator */,
|
||||
299CF1F919A434BC00C378C1 /* ccRandom.cpp */,
|
||||
299CF1FA19A434BC00C378C1 /* ccRandom.h */,
|
||||
464AD6E3197EBB1400E502D8 /* pvr.cpp */,
|
||||
|
@ -5118,6 +5155,26 @@
|
|||
path = ../cocos/3d;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D0FD03391A3B51AA00825BB5 /* allocator */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0FD033B1A3B51AA00825BB5 /* CCAllocatorBase.h */,
|
||||
D0FD033C1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp */,
|
||||
D0FD033D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h */,
|
||||
D0FD033E1A3B51AA00825BB5 /* CCAllocatorGlobal.cpp */,
|
||||
D0FD033F1A3B51AA00825BB5 /* CCAllocatorGlobal.h */,
|
||||
D0FD03401A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp */,
|
||||
D0FD03411A3B51AA00825BB5 /* CCAllocatorMacros.h */,
|
||||
D0FD03421A3B51AA00825BB5 /* CCAllocatorMutex.h */,
|
||||
D0FD03431A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h */,
|
||||
D0FD03441A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h */,
|
||||
D0FD03451A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h */,
|
||||
D0FD03461A3B51AA00825BB5 /* CCAllocatorStrategyPool.h */,
|
||||
);
|
||||
name = allocator;
|
||||
path = ../base/allocator;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
|
@ -5132,6 +5189,7 @@
|
|||
5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */,
|
||||
292DB14B19B4574100A80320 /* UIEditBoxImpl-mac.h in Headers */,
|
||||
B29A7E3F19EE1B7700872B35 /* AnimationState.h in Headers */,
|
||||
D0FD03591A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h in Headers */,
|
||||
50ABBE891925AB6F00A911A9 /* CCMap.h in Headers */,
|
||||
50ABBE8D1925AB6F00A911A9 /* CCNS.h in Headers */,
|
||||
B29A7DFD19EE1B7700872B35 /* IkConstraintData.h in Headers */,
|
||||
|
@ -5147,6 +5205,7 @@
|
|||
5034CA3F191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */,
|
||||
B29A7DD319EE1B7700872B35 /* Skin.h in Headers */,
|
||||
50ABBD461925AB0000A911A9 /* CCVertex.h in Headers */,
|
||||
B63990CE1A490AFE00B07923 /* CCAsyncTaskPool.h in Headers */,
|
||||
15AE180A19AAD2F700C27E9E /* CCAABB.h in Headers */,
|
||||
46A170E71807CECA005B8026 /* CCPhysicsBody.h in Headers */,
|
||||
15AE1A5A19AAD40300C27E9E /* b2StackAllocator.h in Headers */,
|
||||
|
@ -5155,6 +5214,7 @@
|
|||
15AE1A8119AAD40300C27E9E /* b2FrictionJoint.h in Headers */,
|
||||
15AE18DD19AAD35000C27E9E /* CocoLoader.h in Headers */,
|
||||
46A170EB1807CECA005B8026 /* CCPhysicsJoint.h in Headers */,
|
||||
D0FD03511A3B51AA00825BB5 /* CCAllocatorGlobal.h in Headers */,
|
||||
15AE191E19AAD35000C27E9E /* CCTween.h in Headers */,
|
||||
15AE184619AAD2F700C27E9E /* CCSprite3DMaterial.h in Headers */,
|
||||
50ABBD3E1925AB0000A911A9 /* CCGeometry.h in Headers */,
|
||||
|
@ -5238,6 +5298,7 @@
|
|||
29394CF419B01DBA00D2DE1A /* UIWebViewImpl-ios.h in Headers */,
|
||||
B29A7E1719EE1B7700872B35 /* Atlas.h in Headers */,
|
||||
1A57009A180BC5C10088DEC7 /* CCAtlasNode.h in Headers */,
|
||||
D0FD035B1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */,
|
||||
15AE190819AAD35000C27E9E /* CCDatas.h in Headers */,
|
||||
B29A7E1119EE1B7700872B35 /* EventData.h in Headers */,
|
||||
1A5700A0180BC5D20088DEC7 /* CCNode.h in Headers */,
|
||||
|
@ -5289,8 +5350,10 @@
|
|||
15AE186419AAD31D00C27E9E /* CDConfig.h in Headers */,
|
||||
15AE1BB819AADFEF00C27E9E /* WebSocket.h in Headers */,
|
||||
1A5701B7180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */,
|
||||
D0FD03551A3B51AA00825BB5 /* CCAllocatorMacros.h in Headers */,
|
||||
3823842A1A2590F9002C4610 /* NodeReader.h in Headers */,
|
||||
1A5701BB180BCB5A0088DEC7 /* CCLabel.h in Headers */,
|
||||
D0FD035D1A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h in Headers */,
|
||||
15AE182619AAD2F700C27E9E /* CCMesh.h in Headers */,
|
||||
15AE192019AAD35000C27E9E /* CCUtilMath.h in Headers */,
|
||||
15AE1BC119AADFFB00C27E9E /* cocos-ext.h in Headers */,
|
||||
|
@ -5438,6 +5501,7 @@
|
|||
15AE181E19AAD2F700C27E9E /* CCBundle3DData.h in Headers */,
|
||||
1A5702F8180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */,
|
||||
5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */,
|
||||
D0FD03491A3B51AA00825BB5 /* CCAllocatorBase.h in Headers */,
|
||||
15AE1A2419AAD3D500C27E9E /* b2BroadPhase.h in Headers */,
|
||||
B29A7E3919EE1B7700872B35 /* Animation.h in Headers */,
|
||||
382384381A259126002C4610 /* ProjectNodeReader.h in Headers */,
|
||||
|
@ -5589,7 +5653,6 @@
|
|||
50ABBE2D1925AB6F00A911A9 /* ccCArray.h in Headers */,
|
||||
50ABBD5E1925AB0000A911A9 /* Vec3.h in Headers */,
|
||||
15AE188919AAD33D00C27E9E /* CCControlButtonLoader.h in Headers */,
|
||||
B621CE7F1A3ED8CB00646956 /* CCAsyncTaskPool.h in Headers */,
|
||||
15AE189119AAD33D00C27E9E /* CCLayerColorLoader.h in Headers */,
|
||||
50ABBE211925AB6F00A911A9 /* atitc.h in Headers */,
|
||||
15AE19A519AAD39600C27E9E /* TextFieldReader.h in Headers */,
|
||||
|
@ -5603,8 +5666,10 @@
|
|||
50ABBDB31925AB4100A911A9 /* ccShaders.h in Headers */,
|
||||
50ABBDAB1925AB4100A911A9 /* CCRenderCommandPool.h in Headers */,
|
||||
5034CA45191D591100CE6051 /* ccShader_Label_outline.frag in Headers */,
|
||||
D0FD035F1A3B51AA00825BB5 /* CCAllocatorStrategyPool.h in Headers */,
|
||||
50ABBEB11925AB6F00A911A9 /* CCUserDefault.h in Headers */,
|
||||
B29A7DEF19EE1B7700872B35 /* SkeletonBounds.h in Headers */,
|
||||
D0FD034D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h in Headers */,
|
||||
50ABBEC71925AB6F00A911A9 /* etc1.h in Headers */,
|
||||
B29A7E3519EE1B7700872B35 /* AnimationStateData.h in Headers */,
|
||||
15AE1BC619AAE00000C27E9E /* AssetsManager.h in Headers */,
|
||||
|
@ -5620,6 +5685,7 @@
|
|||
3EACC9A219F5014D00EB3C5E /* CCCamera.h in Headers */,
|
||||
50ABBECD1925AB6F00A911A9 /* s3tc.h in Headers */,
|
||||
15AE1BD119AAE01E00C27E9E /* CCControlHuePicker.h in Headers */,
|
||||
D0FD03571A3B51AA00825BB5 /* CCAllocatorMutex.h in Headers */,
|
||||
50ABBE771925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */,
|
||||
5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */,
|
||||
50ABC0171926664800A911A9 /* CCImage.h in Headers */,
|
||||
|
@ -5657,6 +5723,7 @@
|
|||
15AE1B8119AADA9A00C27E9E /* UITextAtlas.h in Headers */,
|
||||
B29A7E3A19EE1B7700872B35 /* Animation.h in Headers */,
|
||||
15B3708319EE414C00ABE682 /* CCEventListenerAssetsManagerEx.h in Headers */,
|
||||
D0FD03521A3B51AA00825BB5 /* CCAllocatorGlobal.h in Headers */,
|
||||
50ABBE7C1925AB6F00A911A9 /* CCEventMouse.h in Headers */,
|
||||
B29A7E2C19EE1B7700872B35 /* AtlasAttachmentLoader.h in Headers */,
|
||||
46A171011807CECB005B8026 /* CCPhysicsJoint.h in Headers */,
|
||||
|
@ -5713,6 +5780,7 @@
|
|||
1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */,
|
||||
15AE195C19AAD35100C27E9E /* CCSGUIReader.h in Headers */,
|
||||
5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */,
|
||||
D0FD034E1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h in Headers */,
|
||||
DABC9FAC19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */,
|
||||
50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */,
|
||||
50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */,
|
||||
|
@ -5787,6 +5855,7 @@
|
|||
15AE1A4F19AAD3D500C27E9E /* b2Shape.h in Headers */,
|
||||
29394CF519B01DBA00D2DE1A /* UIWebViewImpl-ios.h in Headers */,
|
||||
50ABBD5B1925AB0000A911A9 /* Vec2.h in Headers */,
|
||||
D0FD035E1A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h in Headers */,
|
||||
50ABBD411925AB0000A911A9 /* CCMath.h in Headers */,
|
||||
1A5701A0180BCB590088DEC7 /* CCFont.h in Headers */,
|
||||
292DB14819B4574100A80320 /* UIEditBoxImpl-ios.h in Headers */,
|
||||
|
@ -5802,6 +5871,7 @@
|
|||
15AE1ACB19AAD40300C27E9E /* b2MouseJoint.h in Headers */,
|
||||
50ABBD3F1925AB0000A911A9 /* CCGeometry.h in Headers */,
|
||||
B29A7DD019EE1B7700872B35 /* RegionAttachment.h in Headers */,
|
||||
D0FD034A1A3B51AA00825BB5 /* CCAllocatorBase.h in Headers */,
|
||||
15AE1AD319AAD40300C27E9E /* b2RopeJoint.h in Headers */,
|
||||
50ABBFFE1926664800A911A9 /* CCFileUtils-apple.h in Headers */,
|
||||
15AE1AAD19AAD40300C27E9E /* b2WorldCallbacks.h in Headers */,
|
||||
|
@ -5824,7 +5894,6 @@
|
|||
50ABBE681925AB6F00A911A9 /* CCEventListenerCustom.h in Headers */,
|
||||
15AE196B19AAD35100C27E9E /* DictionaryHelper.h in Headers */,
|
||||
15AE1AA619AAD40300C27E9E /* b2Fixture.h in Headers */,
|
||||
B621CE801A3ED8CB00646956 /* CCAsyncTaskPool.h in Headers */,
|
||||
15AE1BBA19AADFF000C27E9E /* HttpClient.h in Headers */,
|
||||
292DB14619B4574100A80320 /* UIEditBoxImpl-android.h in Headers */,
|
||||
15AE1B9419AADA9A00C27E9E /* GUIDefine.h in Headers */,
|
||||
|
@ -5856,6 +5925,7 @@
|
|||
3EACC9A719F5014D00EB3C5E /* CCLight.h in Headers */,
|
||||
15AE194E19AAD35100C27E9E /* CCDataReaderHelper.h in Headers */,
|
||||
15AE1ADB19AAD41000C27E9E /* b2Rope.h in Headers */,
|
||||
D0FD03561A3B51AA00825BB5 /* CCAllocatorMacros.h in Headers */,
|
||||
1A5701CE180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */,
|
||||
15AE1AB119AAD40300C27E9E /* b2ChainAndPolygonContact.h in Headers */,
|
||||
1A5701E1180BCB8C0088DEC7 /* CCLayer.h in Headers */,
|
||||
|
@ -5950,6 +6020,7 @@
|
|||
15AE18D119AAD33D00C27E9E /* CCNodeLoaderLibrary.h in Headers */,
|
||||
15AE1AC319AAD40300C27E9E /* b2DistanceJoint.h in Headers */,
|
||||
50ABBE741925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */,
|
||||
D0FD03581A3B51AA00825BB5 /* CCAllocatorMutex.h in Headers */,
|
||||
B29A7E1219EE1B7700872B35 /* EventData.h in Headers */,
|
||||
1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */,
|
||||
1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */,
|
||||
|
@ -5980,6 +6051,7 @@
|
|||
B375107F1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */,
|
||||
15AE185D19AAD31200C27E9E /* CocosDenshion.h in Headers */,
|
||||
15AE194319AAD35100C27E9E /* CCColliderDetector.h in Headers */,
|
||||
D0FD035C1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */,
|
||||
15AE1BC419AADFFB00C27E9E /* ExtensionMacros.h in Headers */,
|
||||
15AE185A19AAD31200C27E9E /* CDConfig.h in Headers */,
|
||||
B29A7DE819EE1B7700872B35 /* spine.h in Headers */,
|
||||
|
@ -6047,6 +6119,7 @@
|
|||
50ABC0081926664800A911A9 /* CCApplicationProtocol.h in Headers */,
|
||||
1ABA68B11888D700007D1BB4 /* CCFontCharMap.h in Headers */,
|
||||
15AE1ACF19AAD40300C27E9E /* b2PulleyJoint.h in Headers */,
|
||||
D0FD03601A3B51AA00825BB5 /* CCAllocatorStrategyPool.h in Headers */,
|
||||
15AE198019AAD35700C27E9E /* CCTimeLine.h in Headers */,
|
||||
38B8E2E419E671D2002D7CE7 /* UILayoutComponent.h in Headers */,
|
||||
50ABBD4F1925AB0000A911A9 /* MathUtil.h in Headers */,
|
||||
|
@ -6076,6 +6149,7 @@
|
|||
50CB247619D9C5A100687767 /* AudioCache.h in Headers */,
|
||||
B29A7DDA19EE1B7700872B35 /* SkeletonRenderer.h in Headers */,
|
||||
15AE194119AAD35100C27E9E /* CCBone.h in Headers */,
|
||||
D0FD035A1A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h in Headers */,
|
||||
50ABBD471925AB0000A911A9 /* CCVertex.h in Headers */,
|
||||
15AE195A19AAD35100C27E9E /* CCProcessBase.h in Headers */,
|
||||
15AE193D19AAD35100C27E9E /* CCArmatureDefine.h in Headers */,
|
||||
|
@ -6140,6 +6214,7 @@
|
|||
B29A7DF019EE1B7700872B35 /* SkeletonBounds.h in Headers */,
|
||||
15AE1BE919AAE01E00C27E9E /* CCControl.h in Headers */,
|
||||
15AE193719AAD35100C27E9E /* CCArmature.h in Headers */,
|
||||
B63990CF1A490AFE00B07923 /* CCAsyncTaskPool.h in Headers */,
|
||||
15AE1BC319AADFFB00C27E9E /* cocos-ext.h in Headers */,
|
||||
15AE1B8B19AADA9A00C27E9E /* UIImageView.h in Headers */,
|
||||
15AE1A4619AAD3D500C27E9E /* b2TimeOfImpact.h in Headers */,
|
||||
|
@ -6315,7 +6390,6 @@
|
|||
1A57007D180BC5A10088DEC7 /* CCActionInterval.cpp in Sources */,
|
||||
15AE189F19AAD33D00C27E9E /* CCNodeLoaderLibrary.cpp in Sources */,
|
||||
1A570081180BC5A10088DEC7 /* CCActionManager.cpp in Sources */,
|
||||
B621CE7D1A3ED8CB00646956 /* CCAsyncTaskPool.cpp in Sources */,
|
||||
15AE1A6119AAD40300C27E9E /* b2Fixture.cpp in Sources */,
|
||||
1A570085180BC5A10088DEC7 /* CCActionPageTurn3D.cpp in Sources */,
|
||||
382384441A25915C002C4610 /* SpriteReader.cpp in Sources */,
|
||||
|
@ -6333,6 +6407,7 @@
|
|||
15AE1B5F19AADA9900C27E9E /* UITextField.cpp in Sources */,
|
||||
15AE187C19AAD33D00C27E9E /* CCBFileLoader.cpp in Sources */,
|
||||
50ABBE651925AB6F00A911A9 /* CCEventListenerCustom.cpp in Sources */,
|
||||
D0FD034B1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp in Sources */,
|
||||
15AE189B19AAD33D00C27E9E /* CCNode+CCBRelativePositioning.cpp in Sources */,
|
||||
15AE183819AAD2F700C27E9E /* CCRay.cpp in Sources */,
|
||||
B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */,
|
||||
|
@ -6408,6 +6483,7 @@
|
|||
B24AA985195A675C007B4522 /* CCFastTMXLayer.cpp in Sources */,
|
||||
15AE1A6A19AAD40300C27E9E /* b2ChainAndCircleContact.cpp in Sources */,
|
||||
15B3708819EE414C00ABE682 /* Manifest.cpp in Sources */,
|
||||
B63990CC1A490AFE00B07923 /* CCAsyncTaskPool.cpp in Sources */,
|
||||
1A5701EA180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */,
|
||||
15AE186B19AAD31D00C27E9E /* SimpleAudioEngine.mm in Sources */,
|
||||
50ABBDAD1925AB4100A911A9 /* CCRenderer.cpp in Sources */,
|
||||
|
@ -6598,6 +6674,7 @@
|
|||
DABC9FA919E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */,
|
||||
3E2F27A619CFBFE100E7C490 /* AudioEngine.cpp in Sources */,
|
||||
15AE1A3619AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */,
|
||||
D0FD03531A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp in Sources */,
|
||||
50ABBD9B1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */,
|
||||
15AE188119AAD33D00C27E9E /* CCBReader.cpp in Sources */,
|
||||
50ABBDB91925AB4100A911A9 /* CCTextureAtlas.cpp in Sources */,
|
||||
|
@ -6610,6 +6687,7 @@
|
|||
50ABBECF1925AB6F00A911A9 /* TGAlib.cpp in Sources */,
|
||||
15AE199E19AAD39600C27E9E /* SliderReader.cpp in Sources */,
|
||||
50ABBE451925AB6F00A911A9 /* CCEvent.cpp in Sources */,
|
||||
D0FD034F1A3B51AA00825BB5 /* CCAllocatorGlobal.cpp in Sources */,
|
||||
50ABBE611925AB6F00A911A9 /* CCEventListenerAcceleration.cpp in Sources */,
|
||||
50ABBD9F1925AB4100A911A9 /* CCGroupCommand.cpp in Sources */,
|
||||
15AE1A8E19AAD40300C27E9E /* b2RopeJoint.cpp in Sources */,
|
||||
|
@ -6669,6 +6747,7 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D0FD03541A3B51AA00825BB5 /* CCAllocatorGlobalNewDelete.cpp in Sources */,
|
||||
15AE1B9819AADAA100C27E9E /* UIVideoPlayer-ios.mm in Sources */,
|
||||
15AE1C0519AAE01E00C27E9E /* CCTableViewCell.cpp in Sources */,
|
||||
15AE198A19AAD36A00C27E9E /* ButtonReader.cpp in Sources */,
|
||||
|
@ -6976,7 +7055,6 @@
|
|||
15AE1BA519AADFDF00C27E9E /* UIHBox.cpp in Sources */,
|
||||
1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */,
|
||||
382384221A2590DA002C4610 /* GameMapReader.cpp in Sources */,
|
||||
B621CE7E1A3ED8CB00646956 /* CCAsyncTaskPool.cpp in Sources */,
|
||||
15AE1BAF19AADFDF00C27E9E /* UILayoutManager.cpp in Sources */,
|
||||
15AE182119AAD2F700C27E9E /* CCBundleReader.cpp in Sources */,
|
||||
50ABBD3D1925AB0000A911A9 /* CCGeometry.cpp in Sources */,
|
||||
|
@ -6990,6 +7068,7 @@
|
|||
50ABBE8C1925AB6F00A911A9 /* CCNS.cpp in Sources */,
|
||||
B29A7DE019EE1B7700872B35 /* IkConstraintData.c in Sources */,
|
||||
B29A7DFC19EE1B7700872B35 /* spine-cocos2dx.cpp in Sources */,
|
||||
D0FD03501A3B51AA00825BB5 /* CCAllocatorGlobal.cpp in Sources */,
|
||||
15AE1BA919AADFDF00C27E9E /* UIVBox.cpp in Sources */,
|
||||
50ABBDAE1925AB4100A911A9 /* CCRenderer.cpp in Sources */,
|
||||
382383FB1A258FA7002C4610 /* idl_gen_go.cpp in Sources */,
|
||||
|
@ -7080,6 +7159,7 @@
|
|||
15AE180919AAD2F700C27E9E /* CCAABB.cpp in Sources */,
|
||||
15AE1AA719AAD40300C27E9E /* b2Island.cpp in Sources */,
|
||||
3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */,
|
||||
B63990CD1A490AFE00B07923 /* CCAsyncTaskPool.cpp in Sources */,
|
||||
50ABBE361925AB6F00A911A9 /* CCConsole.cpp in Sources */,
|
||||
B29A7E1419EE1B7700872B35 /* Bone.c in Sources */,
|
||||
503DD8E51926736A00CD74DD /* CCDirectorCaller-ios.mm in Sources */,
|
||||
|
@ -7102,6 +7182,7 @@
|
|||
15AE196519AAD35100C27E9E /* CCTween.cpp in Sources */,
|
||||
46C02E0818E91123004B7456 /* xxhash.c in Sources */,
|
||||
15AE183519AAD2F700C27E9E /* CCObjLoader.cpp in Sources */,
|
||||
D0FD034C1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp in Sources */,
|
||||
50ABBED01925AB6F00A911A9 /* TGAlib.cpp in Sources */,
|
||||
1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */,
|
||||
B29A7E2219EE1B7700872B35 /* PolygonBatch.cpp in Sources */,
|
||||
|
|
|
@ -821,6 +821,8 @@
|
|||
C08689C218D370C90093E810 /* background.caf in Resources */ = {isa = PBXBuildFile; fileRef = C08689C018D370C90093E810 /* background.caf */; };
|
||||
C08689C318D370C90093E810 /* background.caf in Resources */ = {isa = PBXBuildFile; fileRef = C08689C018D370C90093E810 /* background.caf */; };
|
||||
C08689C418D370C90093E810 /* background.caf in Resources */ = {isa = PBXBuildFile; fileRef = C08689C018D370C90093E810 /* background.caf */; };
|
||||
D0FD03641A3B546400825BB5 /* AllocatorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FD03621A3B546400825BB5 /* AllocatorTest.cpp */; };
|
||||
D0FD03651A3B546400825BB5 /* AllocatorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FD03621A3B546400825BB5 /* AllocatorTest.cpp */; };
|
||||
D60AE43417F7FFE100757E4B /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; };
|
||||
EDCC747F17C455FD007B692C /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
@ -1744,6 +1746,8 @@
|
|||
C04F93581941B05400E9FEAB /* TileMapTest2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TileMapTest2.cpp; sourceTree = "<group>"; };
|
||||
C04F93591941B05400E9FEAB /* TileMapTest2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileMapTest2.h; sourceTree = "<group>"; };
|
||||
C08689C018D370C90093E810 /* background.caf */ = {isa = PBXFileReference; lastKnownFileType = file; name = background.caf; path = "../tests/cpp-tests/Resources/background.caf"; sourceTree = "<group>"; };
|
||||
D0FD03621A3B546400825BB5 /* AllocatorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AllocatorTest.cpp; path = AllocatorTest/AllocatorTest.cpp; sourceTree = "<group>"; };
|
||||
D0FD03631A3B546400825BB5 /* AllocatorTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AllocatorTest.h; path = AllocatorTest/AllocatorTest.h; sourceTree = "<group>"; };
|
||||
D60AE43317F7FFE100757E4B /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; };
|
||||
EDCC747E17C455FD007B692C /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -2151,6 +2155,7 @@
|
|||
1AC3592418CECF0A00F37B72 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0FD03611A3B543700825BB5 /* AllocatorTest */,
|
||||
B6C039D619C95D28007207DC /* LightTest */,
|
||||
B609E67019C18D90003D0074 /* BillBoardTest */,
|
||||
3E2BDACD19BEA3410055CDCD /* NewAudioEngineTest */,
|
||||
|
@ -3933,6 +3938,15 @@
|
|||
name = LightTest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D0FD03611A3B543700825BB5 /* AllocatorTest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0FD03621A3B546400825BB5 /* AllocatorTest.cpp */,
|
||||
D0FD03631A3B546400825BB5 /* AllocatorTest.h */,
|
||||
);
|
||||
name = AllocatorTest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
|
@ -4798,6 +4812,7 @@
|
|||
1AC35BE718CECF0C00F37B72 /* CCControlScene.cpp in Sources */,
|
||||
B609E67319C18DAD003D0074 /* BillBoardTest.cpp in Sources */,
|
||||
292CF01419A1965E00E8E6A0 /* UIEditBoxTest.cpp in Sources */,
|
||||
D0FD03641A3B546400825BB5 /* AllocatorTest.cpp in Sources */,
|
||||
29080DBF191B595E0066F8DF /* UIPageViewTest_Editor.cpp in Sources */,
|
||||
1AC35B5F18CECF0C00F37B72 /* DataVisitorTest.cpp in Sources */,
|
||||
1AC35B5D18CECF0C00F37B72 /* CurrentLanguageTest.cpp in Sources */,
|
||||
|
@ -4980,6 +4995,7 @@
|
|||
1AC35B6218CECF0C00F37B72 /* DrawPrimitivesTest.cpp in Sources */,
|
||||
29080DDC191B595E0066F8DF /* UITextFieldTest.cpp in Sources */,
|
||||
1AC35C1818CECF0C00F37B72 /* MotionStreakTest.cpp in Sources */,
|
||||
D0FD03651A3B546400825BB5 /* AllocatorTest.cpp in Sources */,
|
||||
1AC35C0618CECF0C00F37B72 /* FontTest.cpp in Sources */,
|
||||
1AC35C3818CECF0C00F37B72 /* PerformanceTest.cpp in Sources */,
|
||||
1F33635018E37E840074764D /* RefPtrTest.cpp in Sources */,
|
||||
|
|
|
@ -31,26 +31,6 @@
|
|||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
if(USE_PREBUILT_LIBS)
|
||||
find_path(JPEG_INCLUDE_DIR jpeglib.h
|
||||
PATH_SUFFIXES include/${PLATFORM_FOLDER} include
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/jpeg
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
find_library(JPEG_LIBRARY NAMES jpeg
|
||||
PATH_SUFFIXES
|
||||
prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
prebuilt/${PLATFORM_FOLDER}
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/jpeg
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
|
||||
if(NOT JPEG_INCLUDE_DIR OR NOT JPEG_LIBRARY)
|
||||
unset(JPEG_INCLUDE_DIR CACHE)
|
||||
unset(JPEG_LIBRARY CACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_path(JPEG_INCLUDE_DIR jpeglib.h)
|
||||
|
||||
set(JPEG_NAMES ${JPEG_NAMES} jpeg)
|
||||
|
|
|
@ -48,24 +48,6 @@ if(PNG_FIND_QUIETLY)
|
|||
endif()
|
||||
find_package(ZLIB ${_FIND_ZLIB_ARG})
|
||||
|
||||
if(USE_PREBUILT_LIBS)
|
||||
find_path(PNG_PNG_INCLUDE_DIR png.h
|
||||
PATH_SUFFIXES include/${PLATFORM_FOLDER} include
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/png NO_DEFAULT_PATH
|
||||
)
|
||||
find_library(PNG_LIBRARY NAMES png libpng
|
||||
PATH_SUFFIXES
|
||||
prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
prebuilt/${PLATFORM_FOLDER}
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/png NO_DEFAULT_PATH
|
||||
)
|
||||
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
|
||||
if(NOT PNG_PNG_INCLUDE_DIR OR NOT PNG_LIBRARY)
|
||||
unset(PNG_PNG_INCLUDE_DIR CACHE)
|
||||
unset(PNG_LIBRARY CACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ZLIB_FOUND)
|
||||
find_path(PNG_PNG_INCLUDE_DIR png.h
|
||||
HINTS ENV PNG_DIR
|
||||
|
|
|
@ -33,24 +33,6 @@
|
|||
|
||||
set(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3)
|
||||
|
||||
if(USE_PREBUILT_LIBS)
|
||||
find_path(TIFF_INCLUDE_DIR tiff.h
|
||||
PATH_SUFFIXES include/${PLATFORM_FOLDER} include
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/tiff NO_DEFAULT_PATH
|
||||
)
|
||||
find_library(TIFF_LIBRARY NAMES ${TIFF_NAMES}
|
||||
PATH_SUFFIXES
|
||||
prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
prebuilt/${PLATFORM_FOLDER}
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/tiff NO_DEFAULT_PATH
|
||||
)
|
||||
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
|
||||
if(NOT TIFF_INCLUDE_DIR OR NOT TIFF_LIBRARY)
|
||||
unset(TIFF_INCLUDE_DIR CACHE)
|
||||
unset(TIFF_LIBRARY CACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_path(TIFF_INCLUDE_DIR tiff.h
|
||||
HINTS ENV TIFF_DIR
|
||||
PATH_SUFFIXES include/libtiff include
|
||||
|
|
|
@ -13,29 +13,6 @@
|
|||
# TINYXML2_INCLUDE_DIRS, where to find headers.
|
||||
#
|
||||
|
||||
# Try find tinyxml for our arch in external folder
|
||||
if(USE_PREBUILT_LIBS)
|
||||
find_path(TinyXML2_INCLUDE_DIR tinyxml2.h
|
||||
PATH_SUFFIXES
|
||||
include/tinyxml2
|
||||
include
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/tinyxml2
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
find_library(TinyXML2_LIBRARY NAMES tinyxml2 libtinyxml2
|
||||
PATH_SUFFIXES
|
||||
prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
prebuilt/${PLATFORM_FOLDER}
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/tinyxml2
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
|
||||
if(NOT TinyXML2_INCLUDE_DIR OR NOT TinyXML2_LIBRARY)
|
||||
unset(TinyXML2_INCLUDE_DIR CACHE)
|
||||
unset(TinyXML2_LIBRARY CACHE)
|
||||
endif()
|
||||
endif(USE_PREBUILT_LIBS)
|
||||
|
||||
find_path(TinyXML2_INCLUDE_DIR tinyxml2.h
|
||||
HINTS ENV TinyXML2_DIR
|
||||
PATH_SUFFIXES include/tinyxml2 include
|
||||
|
|
|
@ -11,26 +11,6 @@
|
|||
# WEBSOCKETS_FOUND, If false, do not try to use WEBSOCKETS.
|
||||
#
|
||||
|
||||
if(USE_PREBUILT_LIBS)
|
||||
find_path(WEBSOCKETS_INCLUDE_DIR libwebsockets.h
|
||||
PATH_SUFFIXES include/${PLATFORM_FOLDER} include
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/websockets
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
find_library(WEBSOCKETS_LIBRARY NAMES websockets libwebsockets
|
||||
PATH_SUFFIXES
|
||||
prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
prebuilt/${PLATFORM_FOLDER}
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/websockets
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
|
||||
if(NOT WEBSOCKETS_INCLUDE_DIR OR NOT WEBSOCKETS_LIBRARY)
|
||||
unset(WEBSOCKETS_INCLUDE_DIR CACHE)
|
||||
unset(WEBSOCKETS_LIBRARY CACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_path(WEBSOCKETS_INCLUDE_DIR libwebsockets.h
|
||||
HINTS ENV WEBSOCKETS_DIR
|
||||
PATH_SUFFIXES include/websockets include/libwebsockets include
|
||||
|
|
|
@ -27,27 +27,6 @@
|
|||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# Try find WebP for our arch in external folder
|
||||
if(USE_PREBUILT_LIBS)
|
||||
find_path(WEBP_INCLUDE_DIR decode.h
|
||||
PATH_SUFFIXES include/${PLATFORM_FOLDER} include
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/webp
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
find_library(WEBP_LIBRARY NAMES webp libwebp
|
||||
PATH_SUFFIXES
|
||||
prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
prebuilt/${PLATFORM_FOLDER}
|
||||
PATHS ${COCOS_EXTERNAL_DIR}/webp
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
|
||||
if(NOT WEBP_INCLUDE_DIR OR NOT WEBP_LIBRARY)
|
||||
unset(WEBP_INCLUDE_DIR CACHE)
|
||||
unset(WEBP_LIBRARY CACHE)
|
||||
endif()
|
||||
endif(USE_PREBUILT_LIBS)
|
||||
|
||||
FIND_PATH(WEBP_INCLUDE_DIR decode.h
|
||||
HINTS
|
||||
ENV WEBP_DIR
|
||||
|
|
|
@ -1041,22 +1041,46 @@ RotateBy* RotateBy::reverse() const
|
|||
|
||||
MoveBy* MoveBy::create(float duration, const Vec2& deltaPosition)
|
||||
{
|
||||
MoveBy *ret = new (std::nothrow) MoveBy();
|
||||
ret->initWithDuration(duration, deltaPosition);
|
||||
ret->autorelease();
|
||||
return MoveBy::create(duration, Vec3(deltaPosition.x, deltaPosition.y, 0));
|
||||
}
|
||||
|
||||
MoveBy* MoveBy::create(float duration, const Vec3 &deltaPosition)
|
||||
{
|
||||
MoveBy *ret = new (std::nothrow) MoveBy();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithDuration(duration, deltaPosition))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MoveBy::initWithDuration(float duration, const Vec2& deltaPosition)
|
||||
{
|
||||
return MoveBy::initWithDuration(duration, Vec3(deltaPosition.x, deltaPosition.y, 0));
|
||||
}
|
||||
|
||||
bool MoveBy::initWithDuration(float duration, const Vec3& deltaPosition)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (ActionInterval::initWithDuration(duration))
|
||||
{
|
||||
_positionDelta = deltaPosition;
|
||||
return true;
|
||||
_is3D = true;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MoveBy* MoveBy::clone() const
|
||||
|
@ -1071,12 +1095,12 @@ MoveBy* MoveBy::clone() const
|
|||
void MoveBy::startWithTarget(Node *target)
|
||||
{
|
||||
ActionInterval::startWithTarget(target);
|
||||
_previousPosition = _startPosition = target->getPosition();
|
||||
_previousPosition = _startPosition = target->getPosition3D();
|
||||
}
|
||||
|
||||
MoveBy* MoveBy::reverse() const
|
||||
{
|
||||
return MoveBy::create(_duration, Vec2( -_positionDelta.x, -_positionDelta.y));
|
||||
return MoveBy::create(_duration, -_positionDelta);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1085,14 +1109,14 @@ void MoveBy::update(float t)
|
|||
if (_target)
|
||||
{
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Vec2 currentPos = _target->getPosition();
|
||||
Vec2 diff = currentPos - _previousPosition;
|
||||
Vec3 currentPos = _target->getPosition3D();
|
||||
Vec3 diff = currentPos - _previousPosition;
|
||||
_startPosition = _startPosition + diff;
|
||||
Vec2 newPos = _startPosition + (_positionDelta * t);
|
||||
_target->setPosition(newPos);
|
||||
Vec3 newPos = _startPosition + (_positionDelta * t);
|
||||
_target->setPosition3D(newPos);
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
_target->setPosition(_startPosition + _positionDelta * t);
|
||||
_target->setPosition3D(_startPosition + _positionDelta * t);
|
||||
#endif // CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
@ -1103,22 +1127,45 @@ void MoveBy::update(float t)
|
|||
|
||||
MoveTo* MoveTo::create(float duration, const Vec2& position)
|
||||
{
|
||||
MoveTo *ret = new (std::nothrow) MoveTo();
|
||||
ret->initWithDuration(duration, position);
|
||||
ret->autorelease();
|
||||
return MoveTo::create(duration, Vec3(position.x, position.y, 0));
|
||||
}
|
||||
|
||||
MoveTo* MoveTo::create(float duration, const Vec3& position)
|
||||
{
|
||||
MoveTo *ret = new (std::nothrow) MoveTo();
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (ret->initWithDuration(duration, position))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete ret;
|
||||
ret = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MoveTo::initWithDuration(float duration, const Vec2& position)
|
||||
{
|
||||
return initWithDuration(duration, Vec3(position.x, position.y, 0));
|
||||
}
|
||||
|
||||
bool MoveTo::initWithDuration(float duration, const Vec3& position)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (ActionInterval::initWithDuration(duration))
|
||||
{
|
||||
_endPosition = position;
|
||||
return true;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MoveTo* MoveTo::clone() const
|
||||
|
@ -1133,7 +1180,7 @@ MoveTo* MoveTo::clone() const
|
|||
void MoveTo::startWithTarget(Node *target)
|
||||
{
|
||||
MoveBy::startWithTarget(target);
|
||||
_positionDelta = _endPosition - target->getPosition();
|
||||
_positionDelta = _endPosition - target->getPosition3D();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2237,7 +2284,7 @@ bool Animate::initWithAnimation(Animation* animation)
|
|||
float accumUnitsOfTime = 0;
|
||||
float newUnitOfTimeValue = singleDuration / animation->getTotalDelayUnits();
|
||||
|
||||
auto frames = animation->getFrames();
|
||||
auto& frames = animation->getFrames();
|
||||
|
||||
for (auto& frame : frames)
|
||||
{
|
||||
|
@ -2312,7 +2359,7 @@ void Animate::update(float t)
|
|||
t = fmodf(t, 1.0f);
|
||||
}
|
||||
|
||||
auto frames = _animation->getFrames();
|
||||
auto& frames = _animation->getFrames();
|
||||
auto numberOfFrames = frames.size();
|
||||
SpriteFrame *frameToDisplay = nullptr;
|
||||
|
||||
|
@ -2346,7 +2393,7 @@ void Animate::update(float t)
|
|||
|
||||
Animate* Animate::reverse() const
|
||||
{
|
||||
auto oldArray = _animation->getFrames();
|
||||
auto& oldArray = _animation->getFrames();
|
||||
Vector<AnimationFrame*> newArray(oldArray.size());
|
||||
|
||||
if (oldArray.size() > 0)
|
||||
|
|
|
@ -427,6 +427,7 @@ class CC_DLL MoveBy : public ActionInterval
|
|||
public:
|
||||
/** creates the action */
|
||||
static MoveBy* create(float duration, const Vec2& deltaPosition);
|
||||
static MoveBy* create(float duration, const Vec3& deltaPosition);
|
||||
|
||||
//
|
||||
// Overrides
|
||||
|
@ -437,16 +438,18 @@ public:
|
|||
virtual void update(float time) override;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
MoveBy() {}
|
||||
MoveBy():_is3D(false) {}
|
||||
virtual ~MoveBy() {}
|
||||
|
||||
/** initializes the action */
|
||||
bool initWithDuration(float duration, const Vec2& deltaPosition);
|
||||
bool initWithDuration(float duration, const Vec3& deltaPosition);
|
||||
|
||||
protected:
|
||||
Vec2 _positionDelta;
|
||||
Vec2 _startPosition;
|
||||
Vec2 _previousPosition;
|
||||
bool _is3D;
|
||||
Vec3 _positionDelta;
|
||||
Vec3 _startPosition;
|
||||
Vec3 _previousPosition;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(MoveBy);
|
||||
|
@ -462,6 +465,7 @@ class CC_DLL MoveTo : public MoveBy
|
|||
public:
|
||||
/** creates the action */
|
||||
static MoveTo* create(float duration, const Vec2& position);
|
||||
static MoveTo* create(float duration, const Vec3& position);
|
||||
|
||||
//
|
||||
// Overrides
|
||||
|
@ -475,9 +479,10 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
|
||||
/** initializes the action */
|
||||
bool initWithDuration(float duration, const Vec2& position);
|
||||
bool initWithDuration(float duration, const Vec3& position);
|
||||
|
||||
protected:
|
||||
Vec2 _endPosition;
|
||||
Vec3 _endPosition;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(MoveTo);
|
||||
|
|
|
@ -75,12 +75,12 @@ void Font::setCurrentGlyphCollection(GlyphCollection glyphs, const char *customG
|
|||
default:
|
||||
if (customGlyphs)
|
||||
{
|
||||
size_t lenght = strlen(customGlyphs);
|
||||
_customGlyphs = new char [lenght + 2];
|
||||
memcpy(_customGlyphs, customGlyphs, lenght);
|
||||
size_t length = strlen(customGlyphs);
|
||||
_customGlyphs = new char [length + 2];
|
||||
memcpy(_customGlyphs, customGlyphs, length);
|
||||
|
||||
_customGlyphs[lenght] = 0;
|
||||
_customGlyphs[lenght+1] = 0;
|
||||
_customGlyphs[length] = 0;
|
||||
_customGlyphs[length+1] = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -592,12 +592,12 @@ void Label::alignText()
|
|||
batchNode->getTextureAtlas()->removeAllQuads();
|
||||
}
|
||||
_fontAtlas->prepareLetterDefinitions(_currentUTF16String);
|
||||
auto textures = _fontAtlas->getTextures();
|
||||
auto& textures = _fontAtlas->getTextures();
|
||||
if (textures.size() > _batchNodes.size())
|
||||
{
|
||||
for (auto index = _batchNodes.size(); index < textures.size(); ++index)
|
||||
{
|
||||
auto batchNode = SpriteBatchNode::createWithTexture(textures[index]);
|
||||
auto batchNode = SpriteBatchNode::createWithTexture(textures.at(index));
|
||||
batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
|
||||
batchNode->setPosition(Vec2::ZERO);
|
||||
Node::addChild(batchNode,0,Node::INVALID_TAG);
|
||||
|
@ -630,9 +630,9 @@ void Label::alignText()
|
|||
uvRect.origin.x = _lettersInfo[tag].def.U;
|
||||
uvRect.origin.y = _lettersInfo[tag].def.V;
|
||||
|
||||
letterSprite->setTexture(textures[_lettersInfo[tag].def.textureID]);
|
||||
letterSprite->setTexture(textures.at(_lettersInfo[tag].def.textureID));
|
||||
letterSprite->setTextureRect(uvRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -243,6 +243,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
|||
<ClCompile Include="..\audio\win32\AudioPlayer.cpp" />
|
||||
<ClCompile Include="..\audio\win32\MciPlayer.cpp" />
|
||||
<ClCompile Include="..\audio\win32\SimpleAudioEngine.cpp" />
|
||||
<ClCompile Include="..\base\allocator\CCAllocatorDiagnostics.cpp" />
|
||||
<ClCompile Include="..\base\allocator\CCAllocatorGlobal.cpp" />
|
||||
<ClCompile Include="..\base\allocator\CCAllocatorGlobalNewDelete.cpp" />
|
||||
<ClCompile Include="..\base\atitc.cpp" />
|
||||
<ClCompile Include="..\base\base64.cpp" />
|
||||
<ClCompile Include="..\base\CCAsyncTaskPool.cpp" />
|
||||
|
@ -611,6 +614,15 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
|||
<ClInclude Include="..\audio\win32\AudioEngine-win32.h" />
|
||||
<ClInclude Include="..\audio\win32\AudioPlayer.h" />
|
||||
<ClInclude Include="..\audio\win32\MciPlayer.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorBase.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorDiagnostics.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorGlobal.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorMacros.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorMutex.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyDefault.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyFixedBlock.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyGlobalSmallBlock.h" />
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyPool.h" />
|
||||
<ClInclude Include="..\base\atitc.h" />
|
||||
<ClInclude Include="..\base\base64.h" />
|
||||
<ClInclude Include="..\base\CCAsyncTaskPool.h" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="physics">
|
||||
|
@ -238,6 +238,9 @@
|
|||
<Filter Include="cocostudio\reader\WidgetReader\SpriteReader">
|
||||
<UniqueIdentifier>{9aee531c-f935-4836-bf84-be42e78e38bb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="base\allocator">
|
||||
<UniqueIdentifier>{92ff4e66-3943-47da-a439-c8f182bb871a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\physics\CCPhysicsBody.cpp">
|
||||
|
@ -1292,6 +1295,15 @@
|
|||
<ClCompile Include="..\base\CCAsyncTaskPool.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\allocator\CCAllocatorDiagnostics.cpp">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\allocator\CCAllocatorGlobal.cpp">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\allocator\CCAllocatorGlobalNewDelete.cpp">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||
|
@ -2511,6 +2523,33 @@
|
|||
<ClInclude Include="..\base\CCAsyncTaskPool.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorGlobal.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorBase.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorDiagnostics.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorMacros.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorMutex.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyDefault.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyFixedBlock.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyGlobalSmallBlock.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyPool.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\math\Mat4.inl">
|
||||
|
|
|
@ -141,6 +141,9 @@ base/pvr.cpp \
|
|||
base/s3tc.cpp \
|
||||
base/CCController.cpp \
|
||||
base/CCController-android.cpp \
|
||||
base/allocator/CCAllocatorDiagnostics.cpp \
|
||||
base/allocator/CCAllocatorGlobal.cpp \
|
||||
base/allocator/CCAllocatorGlobalNewDelete.cpp \
|
||||
base/ObjectFactory.cpp \
|
||||
renderer/CCBatchCommand.cpp \
|
||||
renderer/CCCustomCommand.cpp \
|
||||
|
|
|
@ -27,8 +27,13 @@
|
|||
|
||||
#include "AudioEngine-win32.h"
|
||||
#include <condition_variable>
|
||||
#ifdef OPENAL_PLAIN_INCLUDES
|
||||
#include "alc.h"
|
||||
#include "alext.h"
|
||||
#else
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
#endif
|
||||
#include "audio/include/AudioEngine.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCScheduler.h"
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "renderer/CCTextureCache.h"
|
||||
#include "base/base64.h"
|
||||
#include "base/ccUtils.h"
|
||||
#include "base/allocator/CCAllocatorDiagnostics.h"
|
||||
NS_CC_BEGIN
|
||||
|
||||
extern const char* cocos2dVersion(void);
|
||||
|
@ -160,14 +161,14 @@ static void printFileUtils(int fd)
|
|||
FileUtils* fu = FileUtils::getInstance();
|
||||
|
||||
mydprintf(fd, "\nSearch Paths:\n");
|
||||
auto list = fu->getSearchPaths();
|
||||
auto& list = fu->getSearchPaths();
|
||||
for( const auto &item : list) {
|
||||
mydprintf(fd, "%s\n", item.c_str());
|
||||
}
|
||||
|
||||
mydprintf(fd, "\nResolution Order:\n");
|
||||
list = fu->getSearchResolutionsOrder();
|
||||
for( const auto &item : list) {
|
||||
auto& list1 = fu->getSearchResolutionsOrder();
|
||||
for( const auto &item : list1) {
|
||||
mydprintf(fd, "%s\n", item.c_str());
|
||||
}
|
||||
|
||||
|
@ -175,7 +176,7 @@ static void printFileUtils(int fd)
|
|||
mydprintf(fd, "%s\n", fu->getWritablePath().c_str());
|
||||
|
||||
mydprintf(fd, "\nFull Path Cache:\n");
|
||||
auto cache = fu->getFullPathCache();
|
||||
auto& cache = fu->getFullPathCache();
|
||||
for( const auto &item : cache) {
|
||||
mydprintf(fd, "%s -> %s\n", item.first.c_str(), item.second.c_str());
|
||||
}
|
||||
|
@ -261,6 +262,7 @@ Console::Console()
|
|||
{
|
||||
// VS2012 doesn't support initializer list, so we create a new array and assign its elements to '_command'.
|
||||
Command commands[] = {
|
||||
{ "allocator", "Display allocator diagnostics for all allocators", std::bind(&Console::commandAllocator, this, std::placeholders::_1, std::placeholders::_2) },
|
||||
{ "config", "Print the Configuration object", std::bind(&Console::commandConfig, this, std::placeholders::_1, std::placeholders::_2) },
|
||||
{ "debugmsg", "Whether or not to forward the debug messages on the console. Args: [on | off]", [&](int fd, const std::string& args) {
|
||||
if( args.compare("on")==0 || args.compare("off")==0) {
|
||||
|
@ -771,6 +773,16 @@ void Console::commandTouch(int fd, const std::string& args)
|
|||
}
|
||||
}
|
||||
|
||||
void Console::commandAllocator(int fd, const std::string& args)
|
||||
{
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
auto info = allocator::AllocatorDiagnostics::instance()->diagnostics();
|
||||
mydprintf(fd, info.c_str());
|
||||
#else
|
||||
mydprintf(fd, "allocator diagnostics not available. CC_ENABLE_ALLOCATOR_DIAGNOSTICS must be set to 1 in ccConfig.h");
|
||||
#endif
|
||||
}
|
||||
|
||||
static char invalid_filename_char[] = {':', '/', '\\', '?', '%', '*', '<', '>', '"', '|', '\r', '\n', '\t'};
|
||||
|
||||
void Console::commandUpload(int fd)
|
||||
|
|
|
@ -122,6 +122,7 @@ protected:
|
|||
void commandDirector(int fd, const std::string &args);
|
||||
void commandTouch(int fd, const std::string &args);
|
||||
void commandUpload(int fd);
|
||||
void commandAllocator(int fd, const std::string &args);
|
||||
// file descriptor: socket, console, etc.
|
||||
int _listenfd;
|
||||
int _maxfd;
|
||||
|
|
|
@ -8,6 +8,9 @@ endif()
|
|||
# todo: also base/CCController-android.cpp
|
||||
|
||||
set(COCOS_BASE_SRC
|
||||
base/allocator/CCAllocatorDiagnostics.cpp
|
||||
base/allocator/CCAllocatorGlobal.cpp
|
||||
base/allocator/CCAllocatorGlobalNewDelete.cpp
|
||||
base/ccFPSImages.c
|
||||
base/CCAsyncTaskPool.cpp
|
||||
base/CCAutoreleasePool.cpp
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_BASE_H
|
||||
#define CC_ALLOCATOR_BASE_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include "base/allocator/CCAllocatorMacros.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
// @brief
|
||||
// AllocatorBase
|
||||
// Provides a base that contains a few methods and definitions that are helpful to all allocation strategies.
|
||||
// Also provides a common base that can be used to point to all allocators generically.
|
||||
class AllocatorBase
|
||||
{
|
||||
public:
|
||||
|
||||
typedef void* pointer;
|
||||
|
||||
enum { kDefaultAlignment = 16 };
|
||||
|
||||
// this must be true for SSE instructions to be 16 byte aligned
|
||||
// we can now use kDefault alignment as our smallest alloc size
|
||||
static_assert(sizeof(uintptr_t) <= kDefaultAlignment, "pointer size must be smaller than default alignment");
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
AllocatorBase()
|
||||
: _next_allocator(nullptr)
|
||||
{}
|
||||
#endif
|
||||
|
||||
virtual ~AllocatorBase()
|
||||
{}
|
||||
|
||||
// @brief
|
||||
// Given an address and alignment in bytes, returns an address aligned to the number of bytes
|
||||
// For example, if the alignment is 4 which is standard, then the address is divisible evenly by 4.
|
||||
CC_ALLOCATOR_INLINE pointer aligned(const pointer address, const size_t alignment = kDefaultAlignment) const
|
||||
{
|
||||
return (pointer) (((intptr_t)address + (alignment - 1)) & ~(alignment - 1));
|
||||
}
|
||||
|
||||
// @brief Calculate the next power of two for a given size.
|
||||
// Most blocks requested are already a power of two. For small block alloc
|
||||
// this means we cannot add overhead, hence the slightly less performant
|
||||
// searching of fixed block pages to determine size if none is specified.
|
||||
CC_ALLOCATOR_INLINE size_t nextPow2BlockSize(size_t size) const
|
||||
{
|
||||
--size;
|
||||
size |= size >> 1;
|
||||
size |= size >> 2;
|
||||
size |= size >> 4;
|
||||
size |= size >> 8;
|
||||
size |= size >> 16;
|
||||
return ++size;
|
||||
}
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
void setTag(const char* tag)
|
||||
{
|
||||
strncpy(_tag, tag, sizeof(_tag)-1);
|
||||
}
|
||||
|
||||
const char* tag() const
|
||||
{
|
||||
return _tag;
|
||||
}
|
||||
|
||||
// cannot use std::string as it allocates memory.
|
||||
// for some allocator this tag is set before the new/delete allocator has finished initializing.
|
||||
char _tag[1000];
|
||||
|
||||
// @brief return any diagnostic info for this allocator
|
||||
virtual std::string diagnostics() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
AllocatorBase* _next_allocator;
|
||||
#endif//CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
};
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif//CC_ALLOCATOR_BASE_H
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCAllocatorDiagnostics.h"
|
||||
#include "CCAllocatorGlobal.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
AllocatorDiagnostics::AllocatorDiagnostics()
|
||||
: _allocators(nullptr)
|
||||
{}
|
||||
|
||||
AllocatorDiagnostics* AllocatorDiagnostics::instance()
|
||||
{
|
||||
static AllocatorDiagnostics* _this = nullptr;
|
||||
if (nullptr == _this)
|
||||
{
|
||||
// have to use global allocator because none of the constructors will have been called.
|
||||
_this = (AllocatorDiagnostics*)ccAllocatorGlobal.allocate(sizeof(AllocatorDiagnostics));
|
||||
new (_this) AllocatorDiagnostics();
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
|
||||
void AllocatorDiagnostics::trackAllocator(AllocatorBase* allocator)
|
||||
{
|
||||
LOCK(_mutex);
|
||||
auto p = _allocators;
|
||||
for (; nullptr != p; p = p->_next_allocator)
|
||||
{
|
||||
CC_ASSERT(p != allocator);
|
||||
}
|
||||
allocator->_next_allocator = _allocators;
|
||||
_allocators = allocator;
|
||||
UNLOCK(_mutex);
|
||||
}
|
||||
|
||||
void AllocatorDiagnostics::untrackAllocator(AllocatorBase* allocator)
|
||||
{
|
||||
LOCK(_mutex);
|
||||
auto pp = &_allocators;
|
||||
for (; *pp != allocator; pp = &(*pp)->_next_allocator);
|
||||
if (*pp == allocator)
|
||||
*pp = (*pp)->_next_allocator;
|
||||
UNLOCK(_mutex);
|
||||
}
|
||||
|
||||
std::string AllocatorDiagnostics::diagnostics()
|
||||
{
|
||||
std::string data;
|
||||
LOCK(_mutex);
|
||||
auto a = _allocators;
|
||||
while (a)
|
||||
{
|
||||
data += a->diagnostics();
|
||||
a = a->_next_allocator;
|
||||
}
|
||||
UNLOCK(_mutex);
|
||||
return data;
|
||||
}
|
||||
#endif//CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_DIAGNOSTICS_H
|
||||
#define CC_ALLOCATOR_DIAGNOSTICS_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "base/allocator/CCAllocatorMacros.h"
|
||||
#include "base/allocator/CCAllocatorMutex.h"
|
||||
#include "base/allocator/CCAllocatorBase.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
class AllocatorBase;
|
||||
class AllocatorDiagnostics
|
||||
{
|
||||
public:
|
||||
|
||||
AllocatorDiagnostics();
|
||||
static AllocatorDiagnostics* instance();
|
||||
void trackAllocator(AllocatorBase* allocator);
|
||||
void untrackAllocator(AllocatorBase* allocator);
|
||||
std::string diagnostics();
|
||||
|
||||
protected:
|
||||
|
||||
AllocatorMutex _mutex;
|
||||
AllocatorBase* _allocators;
|
||||
};
|
||||
#endif//CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif//CC_ALLOCATOR_DIAGNOSTICS_H
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/allocator/CCAllocatorGlobal.h"
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
// @brief Declare the global allocator instance
|
||||
CC_ALLOCATOR_GLOBAL ccAllocatorGlobal;
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_ENABLE_ALLOCATOR
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_GLOBAL_H
|
||||
#define CC_ALLOCATOR_GLOBAL_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/allocator/CCAllocatorMacros.h"
|
||||
#include "base/allocator/CCAllocatorStrategyDefault.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
// @brief Make visible at the global scope.
|
||||
extern CC_ALLOCATOR_GLOBAL ccAllocatorGlobal;
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif//CC_ALLOCATOR_GLOBAL_H
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/allocator/CCAllocatorStrategyGlobalSmallBlock.h"
|
||||
#include <new>
|
||||
#include <exception>
|
||||
|
||||
USING_NS_CC_ALLOCATOR;
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR
|
||||
#if CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE
|
||||
|
||||
namespace
|
||||
{
|
||||
// @brief Declare the allocator for global new/delete
|
||||
static CC_ALLOCATOR_GLOBAL_NEW_DELETE global;
|
||||
}
|
||||
|
||||
// @brief overrides global operator new array
|
||||
void* operator new[] (std::size_t size)
|
||||
{
|
||||
void* ptr = global.allocate(size);
|
||||
#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
|
||||
if (nullptr == ptr)
|
||||
throw std::bad_alloc();
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// @brief overrides global operator new
|
||||
void* operator new(std::size_t size)
|
||||
{
|
||||
void* ptr = global.allocate(size);
|
||||
#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
|
||||
if (nullptr == ptr)
|
||||
throw std::bad_alloc();
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// @brief overrides global operator delete
|
||||
void operator delete(void* p) throw()
|
||||
{
|
||||
if (p)
|
||||
global.deallocate(p);
|
||||
}
|
||||
|
||||
#endif // CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE
|
||||
#endif // CC_ENABLE_ALLOCATOR
|
|
@ -0,0 +1,130 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_MACROS_H
|
||||
#define CC_ALLOCATOR_MACROS_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/ccConfig.h"
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
|
||||
// namespace allocator {}
|
||||
#ifdef __cplusplus
|
||||
#define NS_CC_ALLOCATOR_BEGIN namespace allocator {
|
||||
#define NS_CC_ALLOCATOR_END }
|
||||
#define USING_NS_CC_ALLOCATOR using namespace cocos2d::allocator
|
||||
#define NS_CC_ALLOCATOR ::cocos2d::allocator
|
||||
#else
|
||||
#define NS_CC_ALLOCATOR_BEGIN
|
||||
#define NS_CC_ALLOCATOR_END
|
||||
#define USING_NS_CC_ALLOCATOR
|
||||
#define NS_CC_ALLOCATOR
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG
|
||||
|
||||
// @brief CC_ALLOCATOR_INLINE
|
||||
// Turn off inlining of methods when debugging to make stack traces readable and stepping through code sane.
|
||||
#define CC_ALLOCATOR_INLINE
|
||||
|
||||
// printf is safe to use
|
||||
#define LOG printf
|
||||
|
||||
#else
|
||||
|
||||
#define CC_ALLOCATOR_INLINE inline
|
||||
#define LOG
|
||||
|
||||
#endif
|
||||
|
||||
// allocator macros
|
||||
#if CC_ENABLE_ALLOCATOR
|
||||
|
||||
// @brief macros for new/delete
|
||||
// we let global new/delete handle these as they are overridden.
|
||||
#define CC_NEW(klass, ...) new klass(__VAR_ARGS__)
|
||||
#define CC_DELETE(object) delete object;
|
||||
|
||||
// @brief macros for malloc/free
|
||||
// these will use the global allocator
|
||||
#define CC_MALLOC(size) ccAllocatorGlobal.allocate(size)
|
||||
#define CC_FREE(address) ccAllocatorGlobal.deallocate(address)
|
||||
|
||||
// alloc on the stack
|
||||
#define CC_ALLOCA(size) alloca(size)
|
||||
|
||||
// @brief helper macro for overriding new/delete operators for a class.
|
||||
// This correctly passes the size in the deallocate method which is needed.
|
||||
#define CC_USE_ALLOCATOR_POOL(T, A) \
|
||||
CC_ALLOCATOR_INLINE void* operator new (size_t size) \
|
||||
{ \
|
||||
return (void*)A.allocate(size); \
|
||||
} \
|
||||
CC_ALLOCATOR_INLINE void operator delete (void* object, size_t size) \
|
||||
{ \
|
||||
A.deallocate((T*)object, size); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// macros for new/delete
|
||||
// these will use a general thread safe allocator
|
||||
#define CC_NEW(klass, ...) new klass(__VAR_ARGS__)
|
||||
#define CC_DELETE(object) delete object
|
||||
|
||||
// macros for malloc/free
|
||||
// these will use a general thread safe allocator
|
||||
#define CC_MALLOC(size) malloc(size)
|
||||
#define CC_FREE(address) free(address)
|
||||
|
||||
// alloc on the stack
|
||||
#define CC_ALLOCA(size) alloca(size)
|
||||
|
||||
// throw these away if not enabled
|
||||
#define CC_USE_ALLOCATOR_POOL(...)
|
||||
#define CC_OVERRIDE_GLOBAL_NEWDELETE_WITH_ALLOCATOR(...)
|
||||
|
||||
#endif
|
||||
|
||||
// @ brief Quick and dirty macro to dump an area of memory
|
||||
// useful for debugging blocks of memory from allocators.
|
||||
#define DUMP(a, l, C) \
|
||||
{ \
|
||||
LOG("> %p len %zu\n", a, l); \
|
||||
uint8_t* p = (uint8_t*)a; \
|
||||
uint8_t* e = p + l; \
|
||||
while (p < e) \
|
||||
{ \
|
||||
LOG("%p ", p); \
|
||||
for (int i = 0; i < C && &p[i] < e; ++i) \
|
||||
LOG("%02x ", p[i]); \
|
||||
for (int i = 0; i < C && &p[i] < e; ++i) \
|
||||
LOG("%c ", isalnum(p[i]) ? p[i] : '.'); \
|
||||
LOG("\n"); \
|
||||
p = p + C > e ? e : p + C; \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif//CC_ALLOCATOR_MACROS_H
|
|
@ -0,0 +1,113 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_MUTEX_H
|
||||
#define CC_ALLOCATOR_MUTEX_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||
#include "pthread.h"
|
||||
#define MUTEX pthread_mutex_t
|
||||
#define MUTEX_INIT(m) \
|
||||
pthread_mutexattr_t mta; \
|
||||
pthread_mutexattr_init(&mta); \
|
||||
pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); \
|
||||
pthread_mutex_init(&m, &mta)
|
||||
#define MUTEX_LOCK(m) \
|
||||
pthread_mutex_lock(&m);
|
||||
#define MUTEX_UNLOCK(m) \
|
||||
pthread_mutex_unlock(&m);
|
||||
#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
#include "windows.h"
|
||||
#define MUTEX HANDLE
|
||||
#define MUTEX_INIT(m) \
|
||||
m = CreateMutex(0, FALSE, 0)
|
||||
#define MUTEX_LOCK(m) \
|
||||
WaitForSingleObject(m, INFINITE)
|
||||
#define MUTEX_UNLOCK(m) \
|
||||
ReleaseMutex(m)
|
||||
#else
|
||||
#error "Unsupported platform for AllocatorMutex"
|
||||
#endif
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
// so we cannot use std::mutex because it allocates memory
|
||||
// which causes an infinite loop of death and exceptions.
|
||||
class AllocatorMutex
|
||||
{
|
||||
public:
|
||||
|
||||
AllocatorMutex()
|
||||
{
|
||||
MUTEX_INIT(_mutex);
|
||||
}
|
||||
|
||||
void lock()
|
||||
{
|
||||
MUTEX_LOCK(_mutex);
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
MUTEX_UNLOCK(_mutex);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
MUTEX _mutex;
|
||||
};
|
||||
|
||||
#define LOCK(m) m.lock()
|
||||
#define UNLOCK(m) m.unlock()
|
||||
|
||||
// @param implementation that provides a mutex with locking semantics.
|
||||
struct locking_semantics
|
||||
{
|
||||
AllocatorMutex _mutex;
|
||||
CC_ALLOCATOR_INLINE void lock()
|
||||
{
|
||||
LOCK(_mutex);
|
||||
}
|
||||
CC_ALLOCATOR_INLINE void unlock()
|
||||
{
|
||||
UNLOCK(_mutex);
|
||||
}
|
||||
};
|
||||
|
||||
// @param implementation that provides lockless semantics that should optimize away.
|
||||
struct lockless_semantics
|
||||
{
|
||||
CC_ALLOCATOR_INLINE void lock() {}
|
||||
CC_ALLOCATOR_INLINE void unlock() {}
|
||||
};
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif//CC_ALLOCATOR_MUTEX_H
|
|
@ -0,0 +1,58 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_STRATEGY_DEFAULT_H
|
||||
#define CC_ALLOCATOR_STRATEGY_DEFAULT_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/allocator/CCAllocatorMacros.h"
|
||||
#include "base/allocator/CCAllocatorBase.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
// @brief
|
||||
// The default allocation strategy that just falls through to malloc and free
|
||||
class AllocatorStrategyDefault
|
||||
: public AllocatorBase
|
||||
{
|
||||
public:
|
||||
|
||||
CC_ALLOCATOR_INLINE void* allocate(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
CC_ALLOCATOR_INLINE void deallocate(void* address, size_t size = 0)
|
||||
{
|
||||
if (nullptr != address)
|
||||
free(address);
|
||||
}
|
||||
};
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif//CC_ALLOCATOR_STRATEGY_DEFAULT_H
|
|
@ -0,0 +1,276 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_STRATEGY_FIXED_BLOCK_H
|
||||
#define CC_ALLOCATOR_STRATEGY_FIXED_BLOCK_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
WARNING!
|
||||
Do not use Console::log or any other methods that use NEW inside of this
|
||||
allocator. Failure to do so will result in recursive memory allocation.
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
#include <sstream>
|
||||
|
||||
#include "base/allocator/CCAllocatorBase.h"
|
||||
#include "base/allocator/CCAllocatorMacros.h"
|
||||
#include "base/allocator/CCAllocatorGlobal.h"
|
||||
#include "base/allocator/CCAllocatorMutex.h"
|
||||
#include "base/allocator/CCAllocatorDiagnostics.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
// @brief define this to cause this allocator to fallback to the global allocator
|
||||
// this is just for testing purposes to see if this allocator is broken.
|
||||
//#define FALLBACK_TO_GLOBAL
|
||||
|
||||
// @brief
|
||||
// Fixed sized block allocator strategy for allocating blocks
|
||||
// of memory that are the same size.
|
||||
// Optionally takes a page size which determines how many blocks
|
||||
// are added when the allocator needs more storage.
|
||||
// @param _block_size the size of the fixed block allocated by this allocator.
|
||||
// @param _page_size the number of blocks to allocate when growing the free list.
|
||||
// @param _alignment the alignment size in bytes of each block.
|
||||
// @param locking_semantics which locking strategy to use.
|
||||
template <size_t _block_size, size_t _alignment = 16, typename lock_traits = locking_semantics>
|
||||
class AllocatorStrategyFixedBlock
|
||||
: public AllocatorBase
|
||||
, public lock_traits
|
||||
{
|
||||
public:
|
||||
|
||||
static const size_t block_size = _block_size;
|
||||
static const size_t alignment = _alignment;
|
||||
|
||||
AllocatorStrategyFixedBlock(const char* tag = nullptr, size_t pageSize = 100)
|
||||
: _list(nullptr)
|
||||
, _pages(nullptr)
|
||||
, _pageSize(pageSize)
|
||||
, _allocated(0)
|
||||
{
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
_highestCount = 0;
|
||||
AllocatorDiagnostics::instance()->trackAllocator(this);
|
||||
AllocatorBase::setTag(tag ? tag : typeid(AllocatorStrategyFixedBlock).name());
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual ~AllocatorStrategyFixedBlock()
|
||||
{
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
AllocatorDiagnostics::instance()->untrackAllocator(this);
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
intptr_t* page = (intptr_t*)_pages;
|
||||
intptr_t* next = (intptr_t*)*page;
|
||||
ccAllocatorGlobal.deallocate(page);
|
||||
_pages = (void*)next;
|
||||
}
|
||||
while (_pages);
|
||||
}
|
||||
|
||||
// @brief
|
||||
// allocate a block of memory by returning the first item in the list or if empty
|
||||
// then allocate a new page of blocks, and return the first element and store the rest.
|
||||
// if _block_size does not match the requested size, then we assert.
|
||||
CC_ALLOCATOR_INLINE void* allocate(size_t size)
|
||||
{
|
||||
CC_ASSERT(block_size == size);
|
||||
#ifdef FALLBACK_TO_GLOBAL
|
||||
return ccAllocatorGlobal.allocate(size);
|
||||
#else
|
||||
lock_traits::lock();
|
||||
auto r = pop_front();
|
||||
lock_traits::unlock();
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
// @brief Deallocate a block by pushing it on the head of a linked list of free blocks.
|
||||
CC_ALLOCATOR_INLINE void deallocate(void* address, size_t size = 0)
|
||||
{
|
||||
CC_ASSERT(0 == size || block_size == size);
|
||||
#ifdef FALLBACK_TO_GLOBAL
|
||||
ccAllocatorGlobal.deallocate(address);
|
||||
#else
|
||||
lock_traits::lock();
|
||||
push_front(address);
|
||||
lock_traits::unlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
// @brief Checks allocated pages to determine whether or not a block
|
||||
// is owned by this allocator. This should be reasonably fast
|
||||
// for properly configured allocators with few large pages.
|
||||
CC_ALLOCATOR_INLINE bool owns(const void* const address)
|
||||
{
|
||||
#ifdef FALLBACK_TO_GLOBAL
|
||||
return true; // since everything uses the global allocator, we can just lie and say we own this address.
|
||||
#else
|
||||
lock_traits::lock();
|
||||
|
||||
const uint8_t* const a = (const uint8_t* const)address;
|
||||
const uint8_t* p = (uint8_t*)_pages;
|
||||
const size_t pSize = pageSize();
|
||||
while (p)
|
||||
{
|
||||
if (a >= p && a < (p + pSize))
|
||||
{
|
||||
lock_traits::unlock();
|
||||
return true;
|
||||
}
|
||||
p = (uint8_t*)(*(uintptr_t*)p);
|
||||
}
|
||||
lock_traits::unlock();
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
std::string diagnostics() const
|
||||
{
|
||||
std::stringstream s;
|
||||
s << AllocatorBase::tag() << " initial:" << _pageSize << " count:" << _allocated << " highest:" << _highestCount << "\n";
|
||||
return s.str();
|
||||
}
|
||||
size_t _highestCount;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// @brief Method to push an allocated block onto the free list.
|
||||
// No check is made that the block hasn't been already added to this allocator.
|
||||
CC_ALLOCATOR_INLINE void push_front(void* block)
|
||||
{
|
||||
CC_ASSERT(block);
|
||||
CC_ASSERT(block_size < AllocatorBase::kDefaultAlignment || 0 == ((intptr_t)block & (AllocatorBase::kDefaultAlignment - 1)));
|
||||
|
||||
#if COCOS2D_DEBUG
|
||||
// additional debug build checks
|
||||
CC_ASSERT(true == owns(block));
|
||||
#endif
|
||||
|
||||
if (nullptr == _list)
|
||||
{
|
||||
_list = block;
|
||||
*(uintptr_t*)block = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uintptr_t* p = (uintptr_t*)(block);
|
||||
*p = (uintptr_t)_list;
|
||||
_list = block;
|
||||
}
|
||||
CC_ASSERT(_allocated > 0);
|
||||
--_allocated;
|
||||
}
|
||||
|
||||
// @brief Method to pop a block off the free list.
|
||||
// If no blocks are available, then the list is grown by _page_size
|
||||
// Tuning of the page size is critical to getting good performance.
|
||||
// Ideally you would use a page size that is around the high water mark
|
||||
// for the number of blocks of this size being allocated.
|
||||
CC_ALLOCATOR_INLINE void* pop_front()
|
||||
{
|
||||
if (nullptr == _list)
|
||||
{
|
||||
allocatePage();
|
||||
}
|
||||
auto next = (void*)*(uintptr_t*)_list;
|
||||
auto block = _list;
|
||||
_list = next;
|
||||
++_allocated;
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
if (_allocated > _highestCount)
|
||||
_highestCount = _allocated;
|
||||
#endif
|
||||
CC_ASSERT(block_size < AllocatorBase::kDefaultAlignment || 0 == ((intptr_t)block & (AllocatorBase::kDefaultAlignment - 1)));
|
||||
return block;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// @brief Returns the size of a page in bytes + overhead.
|
||||
const size_t pageSize() const
|
||||
{
|
||||
return AllocatorBase::kDefaultAlignment + AllocatorBase::nextPow2BlockSize(block_size) * _pageSize;
|
||||
}
|
||||
|
||||
// @brief Allocates a new page from the global allocator,
|
||||
// and adds all the blocks to the free list.
|
||||
CC_ALLOCATOR_INLINE void allocatePage()
|
||||
{
|
||||
uint8_t* p = (uint8_t*)AllocatorBase::aligned(ccAllocatorGlobal.allocate(pageSize()));
|
||||
intptr_t* page = (intptr_t*)p;
|
||||
if (nullptr == _pages)
|
||||
{
|
||||
_pages = page;
|
||||
*page = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*page = (intptr_t)_pages;
|
||||
_pages = page;
|
||||
}
|
||||
|
||||
p += AllocatorBase::kDefaultAlignment; // step past the linked list node
|
||||
|
||||
_allocated += _pageSize;
|
||||
size_t aligned_size = AllocatorBase::nextPow2BlockSize(block_size);
|
||||
uint8_t* block = (uint8_t*)p;
|
||||
for (int i = 0; i < _pageSize; ++i, block += aligned_size)
|
||||
{
|
||||
push_front(block);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// @brief Linked list of free blocks.
|
||||
void* _list;
|
||||
|
||||
// @brief Linked list of allocated pages.
|
||||
void* _pages;
|
||||
|
||||
// @brief number of blocks per page.
|
||||
size_t _pageSize;
|
||||
|
||||
// @brief Number of blocks that are currently allocated.
|
||||
size_t _allocated;
|
||||
};
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif//CC_ALLOCATOR_STRATEGY_FIXED_BLOCK_H
|
|
@ -0,0 +1,318 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_STRATEGY_GLOBAL_SMALL_BLOCK_H
|
||||
#define CC_ALLOCATOR_STRATEGY_GLOBAL_SMALL_BLOCK_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
WARNING!
|
||||
Do not use Console::log or any other methods that use NEW inside of this
|
||||
allocator. Failure to do so will result in recursive memory allocation.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/allocator/CCAllocatorMacros.h"
|
||||
#include "base/allocator/CCAllocatorBase.h"
|
||||
#include "base/allocator/CCAllocatorGlobal.h"
|
||||
#include "base/allocator/CCAllocatorStrategyFixedBlock.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
#define TRACK(slot, size, op) _smallBlockAllocations[slot] op size
|
||||
#else
|
||||
#define TRACK(...)
|
||||
#endif
|
||||
|
||||
// @brief
|
||||
class AllocatorStrategyGlobalSmallBlock
|
||||
: public AllocatorBase
|
||||
{
|
||||
public:
|
||||
|
||||
// default number of block to allocate per page.
|
||||
static const size_t kDefaultSmallBlockCount = 100;
|
||||
|
||||
// default max small block size pool.
|
||||
static const size_t kMaxSmallBlockPower = 13; // 2^13 8kb
|
||||
|
||||
// @brief define for allocator strategy, cannot be typedef because we want to eval at use
|
||||
#define SType(size) AllocatorStrategyFixedBlock<size>
|
||||
|
||||
void _lazy_init()
|
||||
{
|
||||
// this gets called before static constructors
|
||||
// so make sure we only get called once.
|
||||
static bool once = true;
|
||||
if (once)
|
||||
{
|
||||
once = false;
|
||||
|
||||
// call our own constructor. Global new can be called before the constructors are called.
|
||||
// Make sure it gets called by having it done lazily in the call to allocate.
|
||||
new (this) AllocatorStrategyGlobalSmallBlock();
|
||||
}
|
||||
}
|
||||
|
||||
AllocatorStrategyGlobalSmallBlock()
|
||||
{
|
||||
// this gets called before static constructors
|
||||
// so make sure we only get called once.
|
||||
static bool once = true;
|
||||
if (once)
|
||||
{
|
||||
once = false;
|
||||
|
||||
_maxBlockSize = 1 << kMaxSmallBlockPower;
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
AllocatorDiagnostics::instance()->trackAllocator(this);
|
||||
AllocatorBase::setTag("GlobalSmallBlock");
|
||||
#endif
|
||||
|
||||
memset(_smallBlockAllocators, 0, sizeof(_smallBlockAllocators));
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
memset(_smallBlockAllocations, 0, sizeof(_smallBlockAllocations));
|
||||
#endif
|
||||
// cannot call new on the allocator here because it will recurse
|
||||
// so instead we allocate from the global allocator and construct in place.
|
||||
#define SBA(n, size) \
|
||||
if (size <= _maxBlockSize) \
|
||||
{ \
|
||||
auto v = ccAllocatorGlobal.allocate(sizeof(SType(size))); \
|
||||
_smallBlockAllocators[n] = (AllocatorBase*)(new (v) SType(size)("GlobalSmallBlock::"#size)); \
|
||||
}
|
||||
|
||||
SBA(2, 4)
|
||||
SBA(3, 8);
|
||||
SBA(4, 16);
|
||||
SBA(5, 32);
|
||||
SBA(6, 64);
|
||||
SBA(7, 128);
|
||||
SBA(8, 256);
|
||||
SBA(9, 512);
|
||||
SBA(10, 1024);
|
||||
SBA(11, 2048);
|
||||
SBA(12, 4096);
|
||||
SBA(13, 8192);
|
||||
|
||||
#undef SBA
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~AllocatorStrategyGlobalSmallBlock()
|
||||
{
|
||||
for (int i = 0; i <= kMaxSmallBlockPower; ++i)
|
||||
if (_smallBlockAllocators[i])
|
||||
ccAllocatorGlobal.deallocate(_smallBlockAllocators[i]);
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
AllocatorDiagnostics::instance()->untrackAllocator(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
// @brief Allocate a block of some size. If the block is <= 8192 it is allocated out of an array
|
||||
// of fixed size block allocators. If larger, then we default back to the global allocator.
|
||||
// @param size Size of block to allocate. This will be rounded to the next power of two.
|
||||
CC_ALLOCATOR_INLINE void* allocate(size_t size)
|
||||
{
|
||||
_lazy_init();
|
||||
|
||||
if (size < sizeof(intptr_t)) // always allocate at least enough space to store a pointer. this is
|
||||
size = sizeof(intptr_t); // so we can link the empty blocks together in the block allocator.
|
||||
|
||||
// if the size is greater than what we determine to be a small block
|
||||
// size then fall through to calling the global allocator instead.
|
||||
if (size > _maxBlockSize)
|
||||
return ccAllocatorGlobal.allocate(size);
|
||||
|
||||
// make sure the size fits into one of the
|
||||
// fixed sized block allocators we have above.
|
||||
size_t adjusted_size = AllocatorBase::nextPow2BlockSize(size);
|
||||
|
||||
#define ALLOCATE(slot, size) \
|
||||
case size: \
|
||||
{ \
|
||||
void* v = _smallBlockAllocators[slot]; \
|
||||
CC_ASSERT(nullptr != v); \
|
||||
auto a = (SType(size)*)v; \
|
||||
address = a->allocate(adjusted_size); \
|
||||
TRACK(slot, size, +=); \
|
||||
} \
|
||||
break;
|
||||
|
||||
void* address;
|
||||
|
||||
switch (adjusted_size)
|
||||
{
|
||||
ALLOCATE(2, 4);
|
||||
ALLOCATE(3, 8);
|
||||
ALLOCATE(4, 16);
|
||||
ALLOCATE(5, 32);
|
||||
ALLOCATE(6, 64);
|
||||
ALLOCATE(7, 128);
|
||||
ALLOCATE(8, 256);
|
||||
ALLOCATE(9, 512);
|
||||
ALLOCATE(10, 1024);
|
||||
ALLOCATE(11, 2048);
|
||||
ALLOCATE(12, 4096);
|
||||
ALLOCATE(13, 8192);
|
||||
default:
|
||||
CC_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef ALLOCATE
|
||||
|
||||
CC_ASSERT(adjusted_size < AllocatorBase::kDefaultAlignment || 0 == ((intptr_t)address & (AllocatorBase::kDefaultAlignment - 1)));
|
||||
CC_ASSERT(nullptr != address);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
// @brief Deallocate a block by choosing one of the fixed size block allocators
|
||||
// or defaulting to the global allocator if we do not own this block.
|
||||
CC_ALLOCATOR_INLINE void deallocate(void* address, size_t size = 0)
|
||||
{
|
||||
// if we didn't get a size, then we need to find the allocator
|
||||
// by asking each if they own the block. For allocators that
|
||||
// have few large pages, this is extremely fast.
|
||||
if (0 == size)
|
||||
{
|
||||
#define OWNS(slot, S, address) \
|
||||
case S: \
|
||||
{ \
|
||||
void* v = _smallBlockAllocators[slot]; \
|
||||
if (v) \
|
||||
{ \
|
||||
auto a = (SType(S)*)v; \
|
||||
if (a->owns(address)) \
|
||||
{ \
|
||||
size = SType(S)::block_size; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
// falls through until found
|
||||
switch (sizeof(uint32_t))
|
||||
{
|
||||
OWNS(2, 4, address);
|
||||
OWNS(3, 8, address);
|
||||
OWNS(4, 16, address);
|
||||
OWNS(5, 32, address);
|
||||
OWNS(6, 64, address);
|
||||
OWNS(7, 128, address);
|
||||
OWNS(8, 256, address);
|
||||
OWNS(9, 512, address);
|
||||
OWNS(10, 1024, address);
|
||||
OWNS(11, 2048, address);
|
||||
OWNS(12, 4096, address);
|
||||
OWNS(13, 8192, address);
|
||||
}
|
||||
}
|
||||
|
||||
// if the size is greater than what we determine to be a small block
|
||||
// size then default to calling the global allocator instead.
|
||||
if (0 == size || size > _maxBlockSize)
|
||||
return ccAllocatorGlobal.deallocate(address, size);
|
||||
|
||||
if (size < sizeof(intptr_t)) // always allocate at least enough space to store a pointer. this is
|
||||
size = sizeof(intptr_t); // so we can link the empty blocks together in the block allocator.
|
||||
|
||||
// make sure the size fits into one of the
|
||||
// fixed sized block allocators we have above.
|
||||
size_t adjusted_size = AllocatorBase::nextPow2BlockSize(size);
|
||||
|
||||
#define DEALLOCATE(slot, size, address) \
|
||||
case size: \
|
||||
{ \
|
||||
void* v = _smallBlockAllocators[slot]; \
|
||||
CC_ASSERT(nullptr != v); \
|
||||
auto a = (SType(size)*)v; \
|
||||
a->deallocate(address, size); \
|
||||
TRACK(slot, size, -=); \
|
||||
} \
|
||||
break;
|
||||
|
||||
switch (adjusted_size)
|
||||
{
|
||||
DEALLOCATE(2, 4, address);
|
||||
DEALLOCATE(3, 8, address);
|
||||
DEALLOCATE(4, 16, address);
|
||||
DEALLOCATE(5, 32, address);
|
||||
DEALLOCATE(6, 64, address);
|
||||
DEALLOCATE(7, 128, address);
|
||||
DEALLOCATE(8, 256, address);
|
||||
DEALLOCATE(9, 512, address);
|
||||
DEALLOCATE(10, 1024, address);
|
||||
DEALLOCATE(11, 2048, address);
|
||||
DEALLOCATE(12, 4096, address);
|
||||
DEALLOCATE(13, 8192, address);
|
||||
default:
|
||||
CC_ASSERT(false);
|
||||
}
|
||||
|
||||
#undef DEALLOCATE
|
||||
}
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
std::string diagnostics() const
|
||||
{
|
||||
std::stringstream s;
|
||||
size_t total = 0;
|
||||
for (auto i = 2; i <= kMaxSmallBlockPower; ++i)
|
||||
{
|
||||
auto a = _smallBlockAllocators[i];
|
||||
if (a)
|
||||
{
|
||||
total += _smallBlockAllocations[i];
|
||||
s << a->tag() << " allocated:" << _smallBlockAllocations[i] << "\n";
|
||||
}
|
||||
}
|
||||
s << "Total:" << total << "\n";
|
||||
return s.str();
|
||||
}
|
||||
size_t _highestCount;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// @brief the max size of a block this allocator will pool before using global allocator
|
||||
size_t _maxBlockSize;
|
||||
|
||||
// @brief array of small block allocators from 2^0 -> 2^kMaxSmallBlockPower
|
||||
AllocatorBase* _smallBlockAllocators[kMaxSmallBlockPower + 1];
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
size_t _smallBlockAllocations[kMaxSmallBlockPower + 1];
|
||||
#endif
|
||||
};
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif//CC_ALLOCATOR_STRATEGY_GLOBAL_SMALL_BLOCK_H
|
|
@ -0,0 +1,160 @@
|
|||
|
||||
#ifndef CC_ALLOCATOR_STRATEGY_POOL_H
|
||||
#define CC_ALLOCATOR_STRATEGY_POOL_H
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
Author: Justin Graham (https://github.com/mannewalis)
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
#include <sstream>
|
||||
|
||||
#include "base/allocator/CCAllocatorMacros.h"
|
||||
#include "base/allocator/CCAllocatorGlobal.h"
|
||||
#include "base/allocator/CCAllocatorStrategyFixedBlock.h"
|
||||
#include "base/allocator/CCAllocatorDiagnostics.h"
|
||||
#include "base/CCConfiguration.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
NS_CC_ALLOCATOR_BEGIN
|
||||
|
||||
// @brief ObjectTraits describes an allocatable object
|
||||
// Templated class that represents a default allocatable object.
|
||||
// Provide custom implementations to change the constructor/destructor behavior,
|
||||
// or to change the default alignment of the object in memory.
|
||||
// @param T Type of object
|
||||
// @param _alignment Alignment of object T
|
||||
template <typename T, size_t _alignment = sizeof(uint32_t)>
|
||||
class ObjectTraits
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
static const size_t alignment = _alignment;
|
||||
|
||||
virtual ~ObjectTraits()
|
||||
{}
|
||||
|
||||
// @brief constructor implementation for type T
|
||||
void construct(T* address)
|
||||
{
|
||||
::new(address) T();
|
||||
}
|
||||
|
||||
// @brief destructor implementation for type T
|
||||
void destroy(T* address)
|
||||
{
|
||||
address->~T();
|
||||
}
|
||||
|
||||
// @brief returns the name of this object type T
|
||||
const char* name() const
|
||||
{
|
||||
return typeid(T).name();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// @brief
|
||||
// Fixed sized pool allocator strategy for objects of type T
|
||||
// Optionally takes a page size which determines how many objects
|
||||
// are added when the allocator needs more storage.
|
||||
// ObjectTraits allows you to control the alignment, construction
|
||||
// and destruction of an object in the pool.
|
||||
// @param T Type of object.
|
||||
// @param _page_size Number of objects of T in each page.
|
||||
// @param O ObjectTraits for type T
|
||||
// @see CC_USE_ALLOCATOR_POOL
|
||||
template <typename T, typename O = ObjectTraits<T>, typename locking_traits = lockless_semantics>
|
||||
class AllocatorStrategyPool
|
||||
: public AllocatorStrategyFixedBlock<sizeof(T), O::alignment, locking_traits>
|
||||
, public O
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
|
||||
// ugh wish I knew a way that I could declare this just once
|
||||
typedef AllocatorStrategyFixedBlock<sizeof(T), O::alignment, locking_traits> tParentStrategy;
|
||||
|
||||
AllocatorStrategyPool(const char* tag = nullptr, size_t poolSize = 100)
|
||||
: tParentStrategy(tag)
|
||||
{
|
||||
poolSize = Configuration::getInstance()->getValue(tag, Value((int)poolSize)).asInt();
|
||||
tParentStrategy::_pageSize = poolSize;
|
||||
}
|
||||
|
||||
// @brief Allocate block of size T
|
||||
// if size does not match sizeof(T) then the global allocator is called instead.
|
||||
// @see CC_USE_ALLOCATOR_POOL
|
||||
CC_ALLOCATOR_INLINE void* allocate(size_t size)
|
||||
{
|
||||
T* object;
|
||||
if (sizeof(T) == size)
|
||||
{
|
||||
object = (pointer)tParentStrategy::allocate(sizeof(T));
|
||||
}
|
||||
else
|
||||
{
|
||||
object = (T*)ccAllocatorGlobal.allocate(size);
|
||||
}
|
||||
O::construct(object);
|
||||
return object;
|
||||
}
|
||||
|
||||
// @brief Deallocate block of size T
|
||||
// if size does not match sizeof(T) then the global allocator is called instead.
|
||||
// @see CC_USE_ALLOCATOR_POOL
|
||||
CC_ALLOCATOR_INLINE void deallocate(void* address, size_t size = 0)
|
||||
{
|
||||
if (address)
|
||||
{
|
||||
O::destroy((T*)address);
|
||||
if (sizeof(T) == size)
|
||||
{
|
||||
tParentStrategy::deallocate(address, sizeof(T));
|
||||
}
|
||||
else
|
||||
{
|
||||
ccAllocatorGlobal.deallocate(address, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
std::string diagnostics() const
|
||||
{
|
||||
std::stringstream s;
|
||||
s << AllocatorBase::tag() << " initial:" << tParentStrategy::_pageSize << " count:" << tParentStrategy::_allocated << " highest:" << tParentStrategy::_highestCount << "\n";
|
||||
return s.str();
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
NS_CC_ALLOCATOR_END
|
||||
NS_CC_END
|
||||
|
||||
#endif//CC_ALLOCATOR_STRATEGY_POOL_H
|
|
@ -301,5 +301,43 @@ To enable set it to a value different than 0. Disabled by default.
|
|||
#ifndef CC_CONSTRUCTOR_ACCESS
|
||||
#define CC_CONSTRUCTOR_ACCESS protected
|
||||
#endif
|
||||
|
||||
|
||||
/** @def CC_ENABLE_ALLOCATOR
|
||||
Turn on creation of global allocator and pool allocators
|
||||
as specified by CC_ALLOCATOR_GLOBAL below.
|
||||
*/
|
||||
#ifndef CC_ENABLE_ALLOCATOR
|
||||
# define CC_ENABLE_ALLOCATOR 0
|
||||
#endif
|
||||
|
||||
/** @def CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
Turn on debugging of allocators. This is slower, uses
|
||||
more memory, and should not be used for production builds.
|
||||
*/
|
||||
#ifndef CC_ENABLE_ALLOCATOR_DIAGNOSTICS
|
||||
# define CC_ENABLE_ALLOCATOR_DIAGNOSTICS CC_ENABLE_ALLOCATOR
|
||||
#endif
|
||||
|
||||
/** @def CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE
|
||||
Turn on override of global new and delete
|
||||
as specified by CC_ALLOCATOR_GLOBAL_NEW_DELETE below.
|
||||
*/
|
||||
#ifndef CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE
|
||||
# define CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE 0
|
||||
# endif//CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE
|
||||
|
||||
/** @def CC_ALLOCATOR_GLOBAL
|
||||
Specify allocator to use for global allocator
|
||||
*/
|
||||
#ifndef CC_ALLOCATOR_GLOBAL
|
||||
# define CC_ALLOCATOR_GLOBAL cocos2d::allocator::AllocatorStrategyDefault
|
||||
#endif
|
||||
|
||||
/** @def CC_ALLOCATOR_GLOBAL_NEW_DELETE
|
||||
Specify allocator to use when overriding of new and delete
|
||||
*/
|
||||
#ifndef CC_ALLOCATOR_GLOBAL_NEW_DELETE
|
||||
# define CC_ALLOCATOR_GLOBAL_NEW_DELETE cocos2d::allocator::AllocatorStrategyGlobalSmallBlock
|
||||
#endif
|
||||
|
||||
#endif // __CCCONFIG_H__
|
||||
|
|
|
@ -204,7 +204,7 @@ void foreachNodeDescendant(Node* parent, tCallBack callback)
|
|||
{
|
||||
callback(parent);
|
||||
|
||||
auto children = parent->getChildren();
|
||||
auto& children = parent->getChildren();
|
||||
for (auto child : children)
|
||||
{
|
||||
foreachNodeDescendant(child, callback);
|
||||
|
|
|
@ -835,6 +835,12 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
|
|||
// _loadingNodeParentHierarchy.push_back(node);
|
||||
}
|
||||
|
||||
// If node is invalid, there is no necessity to process children of node.
|
||||
if (!node)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto children = nodetree->children();
|
||||
int size = children->size();
|
||||
CCLOG("size = %d", size);
|
||||
|
@ -1156,6 +1162,12 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
|
|||
// _loadingNodeParentHierarchy.push_back(node);
|
||||
}
|
||||
|
||||
// If node is invalid, there is no necessity to process children of node.
|
||||
if (!node)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto children = nodetree->children();
|
||||
int size = children->size();
|
||||
CCLOG("size = %d", size);
|
||||
|
|
|
@ -551,7 +551,7 @@ namespace cocostudio
|
|||
std::string normalErrorFilePath = "";
|
||||
auto normalDic = options->normalData();
|
||||
int normalType = normalDic->resourceType();
|
||||
std::string normalTexturePath = this->getResourcePath(normalDic->path()->c_str(), (Widget::TextureResType)normalType);
|
||||
std::string normalTexturePath = normalDic->path()->c_str();
|
||||
switch (normalType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -613,7 +613,7 @@ namespace cocostudio
|
|||
std::string pressedErrorFilePath = "";
|
||||
auto pressedDic = options->pressedData();
|
||||
int pressedType = pressedDic->resourceType();
|
||||
std::string pressedTexturePath = this->getResourcePath(pressedDic->path()->c_str(), (Widget::TextureResType)pressedType);
|
||||
std::string pressedTexturePath = pressedDic->path()->c_str();
|
||||
switch (pressedType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -677,7 +677,7 @@ namespace cocostudio
|
|||
std::string disabledErrorFilePath = "";
|
||||
auto disabledDic = options->disabledData();
|
||||
int disabledType = disabledDic->resourceType();
|
||||
std::string disabledTexturePath = this->getResourcePath(disabledDic->path()->c_str(), (Widget::TextureResType)disabledType);
|
||||
std::string disabledTexturePath = disabledDic->path()->c_str();
|
||||
switch (disabledType)
|
||||
{
|
||||
case 0:
|
||||
|
|
|
@ -433,7 +433,7 @@ namespace cocostudio
|
|||
std::string backGroundErrorFilePath = "";
|
||||
auto backGroundDic = options->backGroundBoxData();
|
||||
int backGroundType = backGroundDic->resourceType();
|
||||
std::string backGroundTexturePath = this->getResourcePath(backGroundDic->path()->c_str(), (Widget::TextureResType)backGroundType);
|
||||
std::string backGroundTexturePath = backGroundDic->path()->c_str();
|
||||
switch (backGroundType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -498,7 +498,7 @@ namespace cocostudio
|
|||
std::string backGroundSelectedErrorFilePath = "";
|
||||
auto backGroundSelectedDic = options->backGroundBoxSelectedData();
|
||||
int backGroundSelectedType = backGroundSelectedDic->resourceType();
|
||||
std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic->path()->c_str(), (Widget::TextureResType)backGroundSelectedType);
|
||||
std::string backGroundSelectedTexturePath = backGroundSelectedDic->path()->c_str();
|
||||
switch (backGroundSelectedType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -563,7 +563,7 @@ namespace cocostudio
|
|||
std::string frontCrossErrorFilePath = "";
|
||||
auto frontCrossDic = options->frontCrossData();
|
||||
int frontCrossType = frontCrossDic->resourceType();
|
||||
std::string frontCrossFileName = this->getResourcePath(frontCrossDic->path()->c_str(), (Widget::TextureResType)frontCrossType);
|
||||
std::string frontCrossFileName = frontCrossDic->path()->c_str();
|
||||
switch (frontCrossType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -628,7 +628,7 @@ namespace cocostudio
|
|||
std::string backGroundBoxDisabledErrorFilePath = "";
|
||||
auto backGroundDisabledDic = options->backGroundBoxDisabledData();
|
||||
int backGroundDisabledType = backGroundDisabledDic->resourceType();
|
||||
std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic->path()->c_str(), (Widget::TextureResType)backGroundDisabledType);
|
||||
std::string backGroundDisabledFileName = backGroundDisabledDic->path()->c_str();
|
||||
switch (backGroundDisabledType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -693,7 +693,7 @@ namespace cocostudio
|
|||
std::string frontCrossDisabledErrorFilePath = "";
|
||||
auto frontCrossDisabledDic = options->frontCrossDisabledData();
|
||||
int frontCrossDisabledType = frontCrossDisabledDic->resourceType();
|
||||
std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic->path()->c_str(), (Widget::TextureResType)frontCrossDisabledType);
|
||||
std::string frontCrossDisabledFileName = frontCrossDisabledDic->path()->c_str();
|
||||
switch (frontCrossDisabledType)
|
||||
{
|
||||
case 0:
|
||||
|
|
|
@ -295,7 +295,7 @@ namespace cocostudio
|
|||
std::string errorFilePath = "";
|
||||
auto imageFileNameDic = options->fileNameData();
|
||||
int imageFileNameType = imageFileNameDic->resourceType();
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
||||
switch (imageFileNameType)
|
||||
{
|
||||
case 0:
|
||||
|
|
|
@ -602,7 +602,7 @@ namespace cocostudio
|
|||
std::string errorFilePath = "";
|
||||
auto imageFileNameDic = options->backGroundImageData();
|
||||
int imageFileNameType = imageFileNameDic->resourceType();
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
||||
if (imageFileName != "")
|
||||
{
|
||||
switch (imageFileNameType)
|
||||
|
|
|
@ -245,7 +245,7 @@ namespace cocostudio
|
|||
std::string errorFilePath = "";
|
||||
auto imageFileNameDic = options->textureData();
|
||||
int imageFileNameType = imageFileNameDic->resourceType();
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
||||
switch (imageFileNameType)
|
||||
{
|
||||
case 0:
|
||||
|
|
|
@ -343,7 +343,7 @@ namespace cocostudio
|
|||
std::string errorFilePath = "";
|
||||
auto imageFileNameDic = options->backGroundImageData();
|
||||
int imageFileNameType = imageFileNameDic->resourceType();
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
||||
if (imageFileName != "")
|
||||
{
|
||||
switch (imageFileNameType)
|
||||
|
|
|
@ -429,7 +429,7 @@ namespace cocostudio
|
|||
std::string errorFilePath = "";
|
||||
auto imageFileNameDic = options->backGroundImageData();
|
||||
int imageFileNameType = imageFileNameDic->resourceType();
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
||||
if (imageFileName != "")
|
||||
{
|
||||
switch (imageFileNameType)
|
||||
|
|
|
@ -467,7 +467,7 @@ namespace cocostudio
|
|||
std::string imageErrorFilePath = "";
|
||||
auto imageFileNameDic = options->barFileNameData();
|
||||
int imageFileNameType = imageFileNameDic->resourceType();
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
||||
switch (imageFileNameType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -532,7 +532,7 @@ namespace cocostudio
|
|||
std::string normalErrorFilePath = "";
|
||||
auto normalDic = options->ballNormalData();
|
||||
int normalType = normalDic->resourceType();
|
||||
std::string normalFileName = this->getResourcePath(normalDic->path()->c_str(), (Widget::TextureResType)normalType);
|
||||
std::string normalFileName = normalDic->path()->c_str();
|
||||
switch (normalType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -597,7 +597,7 @@ namespace cocostudio
|
|||
std::string pressedErrorFilePath = "";
|
||||
auto pressedDic = options->ballPressedData();
|
||||
int pressedType = pressedDic->resourceType();
|
||||
std::string pressedFileName = this->getResourcePath(pressedDic->path()->c_str(), (Widget::TextureResType)pressedType);
|
||||
std::string pressedFileName = pressedDic->path()->c_str();
|
||||
switch (pressedType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -662,7 +662,7 @@ namespace cocostudio
|
|||
std::string disabledErrorFilePath = "";
|
||||
auto disabledDic = options->ballDisabledData();
|
||||
int disabledType = disabledDic->resourceType();
|
||||
std::string disabledFileName = this->getResourcePath(disabledDic->path()->c_str(), (Widget::TextureResType)disabledType);
|
||||
std::string disabledFileName = disabledDic->path()->c_str();
|
||||
switch (disabledType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -727,7 +727,7 @@ namespace cocostudio
|
|||
std::string progressErrorFilePath = "";
|
||||
auto progressBarDic = options->progressBarData();
|
||||
int progressBarType = progressBarDic->resourceType();
|
||||
std::string progressBarFileName = this->getResourcePath(progressBarDic->path()->c_str(), (Widget::TextureResType)progressBarType);
|
||||
std::string progressBarFileName = progressBarDic->path()->c_str();
|
||||
switch (progressBarType)
|
||||
{
|
||||
case 0:
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
-- @parent_module cc
|
||||
|
||||
--------------------------------
|
||||
-- creates the action
|
||||
-- @function [parent=#MoveBy] create
|
||||
-- @overload self, float, vec3_table
|
||||
-- @overload self, float, vec2_table
|
||||
-- @function [parent=#MoveBy] create
|
||||
-- @param self
|
||||
-- @param #float duration
|
||||
-- @param #vec2_table deltaPosition
|
||||
-- @return MoveBy#MoveBy ret (return value: cc.MoveBy)
|
||||
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#MoveBy] startWithTarget
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
-- @parent_module cc
|
||||
|
||||
--------------------------------
|
||||
-- creates the action
|
||||
-- @function [parent=#MoveTo] create
|
||||
-- @overload self, float, vec3_table
|
||||
-- @overload self, float, vec2_table
|
||||
-- @function [parent=#MoveTo] create
|
||||
-- @param self
|
||||
-- @param #float duration
|
||||
-- @param #vec2_table position
|
||||
-- @return MoveTo#MoveTo ret (return value: cc.MoveTo)
|
||||
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#MoveTo] startWithTarget
|
||||
|
|
|
@ -23447,7 +23447,6 @@ int lua_cocos2dx_MoveBy_create(lua_State* tolua_S)
|
|||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
@ -23456,24 +23455,41 @@ int lua_cocos2dx_MoveBy_create(lua_State* tolua_S)
|
|||
if (!tolua_isusertable(tolua_S,1,"cc.MoveBy",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
|
||||
if (argc == 2)
|
||||
do
|
||||
{
|
||||
double arg0;
|
||||
cocos2d::Vec2 arg1;
|
||||
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.MoveBy:create");
|
||||
ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.MoveBy:create");
|
||||
if(!ok)
|
||||
if (argc == 2)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MoveBy_create'", nullptr);
|
||||
return 0;
|
||||
double arg0;
|
||||
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.MoveBy:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::Vec3 arg1;
|
||||
ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.MoveBy:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::MoveBy* ret = cocos2d::MoveBy::create(arg0, arg1);
|
||||
object_to_luaval<cocos2d::MoveBy>(tolua_S, "cc.MoveBy",(cocos2d::MoveBy*)ret);
|
||||
return 1;
|
||||
}
|
||||
cocos2d::MoveBy* ret = cocos2d::MoveBy::create(arg0, arg1);
|
||||
object_to_luaval<cocos2d::MoveBy>(tolua_S, "cc.MoveBy",(cocos2d::MoveBy*)ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.MoveBy:create",argc, 2);
|
||||
} while (0);
|
||||
ok = true;
|
||||
do
|
||||
{
|
||||
if (argc == 2)
|
||||
{
|
||||
double arg0;
|
||||
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.MoveBy:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::Vec2 arg1;
|
||||
ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.MoveBy:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::MoveBy* ret = cocos2d::MoveBy::create(arg0, arg1);
|
||||
object_to_luaval<cocos2d::MoveBy>(tolua_S, "cc.MoveBy",(cocos2d::MoveBy*)ret);
|
||||
return 1;
|
||||
}
|
||||
} while (0);
|
||||
ok = true;
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.MoveBy:create",argc, 2);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
|
@ -23505,7 +23521,6 @@ int lua_cocos2dx_MoveTo_create(lua_State* tolua_S)
|
|||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
@ -23514,24 +23529,41 @@ int lua_cocos2dx_MoveTo_create(lua_State* tolua_S)
|
|||
if (!tolua_isusertable(tolua_S,1,"cc.MoveTo",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
|
||||
if (argc == 2)
|
||||
do
|
||||
{
|
||||
double arg0;
|
||||
cocos2d::Vec2 arg1;
|
||||
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.MoveTo:create");
|
||||
ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.MoveTo:create");
|
||||
if(!ok)
|
||||
if (argc == 2)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MoveTo_create'", nullptr);
|
||||
return 0;
|
||||
double arg0;
|
||||
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.MoveTo:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::Vec3 arg1;
|
||||
ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.MoveTo:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::MoveTo* ret = cocos2d::MoveTo::create(arg0, arg1);
|
||||
object_to_luaval<cocos2d::MoveTo>(tolua_S, "cc.MoveTo",(cocos2d::MoveTo*)ret);
|
||||
return 1;
|
||||
}
|
||||
cocos2d::MoveTo* ret = cocos2d::MoveTo::create(arg0, arg1);
|
||||
object_to_luaval<cocos2d::MoveTo>(tolua_S, "cc.MoveTo",(cocos2d::MoveTo*)ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.MoveTo:create",argc, 2);
|
||||
} while (0);
|
||||
ok = true;
|
||||
do
|
||||
{
|
||||
if (argc == 2)
|
||||
{
|
||||
double arg0;
|
||||
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.MoveTo:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::Vec2 arg1;
|
||||
ok &= luaval_to_vec2(tolua_S, 3, &arg1, "cc.MoveTo:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::MoveTo* ret = cocos2d::MoveTo::create(arg0, arg1);
|
||||
object_to_luaval<cocos2d::MoveTo>(tolua_S, "cc.MoveTo",(cocos2d::MoveTo*)ret);
|
||||
return 1;
|
||||
}
|
||||
} while (0);
|
||||
ok = true;
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.MoveTo:create",argc, 2);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
|
|
|
@ -1696,7 +1696,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction)c
|
|||
return true;
|
||||
}
|
||||
|
||||
auto container = parent->getChildren();
|
||||
auto& container = parent->getChildren();
|
||||
ssize_t index = container.getIndex(widget);
|
||||
if (parent->getLayoutType() == Type::HORIZONTAL)
|
||||
{
|
||||
|
|
|
@ -430,6 +430,18 @@
|
|||
"cocos/base/TGAlib.h",
|
||||
"cocos/base/ZipUtils.cpp",
|
||||
"cocos/base/ZipUtils.h",
|
||||
"cocos/base/allocator/CCAllocatorBase.h",
|
||||
"cocos/base/allocator/CCAllocatorDiagnostics.cpp",
|
||||
"cocos/base/allocator/CCAllocatorDiagnostics.h",
|
||||
"cocos/base/allocator/CCAllocatorGlobal.cpp",
|
||||
"cocos/base/allocator/CCAllocatorGlobal.h",
|
||||
"cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp",
|
||||
"cocos/base/allocator/CCAllocatorMacros.h",
|
||||
"cocos/base/allocator/CCAllocatorMutex.h",
|
||||
"cocos/base/allocator/CCAllocatorStrategyDefault.h",
|
||||
"cocos/base/allocator/CCAllocatorStrategyFixedBlock.h",
|
||||
"cocos/base/allocator/CCAllocatorStrategyGlobalSmallBlock.h",
|
||||
"cocos/base/allocator/CCAllocatorStrategyPool.h",
|
||||
"cocos/base/atitc.cpp",
|
||||
"cocos/base/atitc.h",
|
||||
"cocos/base/base64.cpp",
|
||||
|
|
|
@ -22,6 +22,7 @@ set(TESTS_SRC
|
|||
Classes/ActionsEaseTest/ActionsEaseTest.cpp
|
||||
Classes/ActionsProgressTest/ActionsProgressTest.cpp
|
||||
Classes/ActionsTest/ActionsTest.cpp
|
||||
Classes/AllocatorTest/AllocatorTest.cpp
|
||||
Classes/BillBoardTest/BillBoardTest.cpp
|
||||
Classes/BugsTest/Bug-1159.cpp
|
||||
Classes/BugsTest/Bug-1174.cpp
|
||||
|
|
|
@ -35,6 +35,7 @@ static std::function<Layer*()> createFunctions[] = {
|
|||
|
||||
CL(ActionManual),
|
||||
CL(ActionMove),
|
||||
CL(ActionMove3D),
|
||||
CL(ActionRotate),
|
||||
CL(ActionRotateBy3D),
|
||||
CL(ActionScale),
|
||||
|
@ -299,6 +300,36 @@ std::string ActionMove::subtitle() const
|
|||
return "MoveTo / MoveBy";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// ActionMove3D
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
void ActionMove3D::onEnter()
|
||||
{
|
||||
ActionsDemo::onEnter();
|
||||
|
||||
centerSprites(3);
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
_tamara->setPosition3D(Vec3(s.width-40, s.height-40, 0));
|
||||
_kathia->setPosition3D(Vec3(40, 40, 0));
|
||||
|
||||
auto actionTo = MoveTo::create(2, Vec3(s.width-40, s.height-40, -100));
|
||||
auto actionBy = MoveBy::create(2, Vec3(80, 80, -100));
|
||||
auto actionByBack = actionBy->reverse();
|
||||
|
||||
_tamara->runAction(actionTo);
|
||||
_grossini->runAction(Sequence::create(actionBy, actionByBack, nullptr));
|
||||
_kathia->runAction(MoveTo::create(1, Vec3(40, 40, -100)));
|
||||
}
|
||||
|
||||
std::string ActionMove3D::subtitle() const
|
||||
{
|
||||
return "MoveTo / MoveBy 3D";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// ActionScale
|
||||
|
|
|
@ -80,6 +80,15 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class ActionMove3D : public ActionsDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(ActionMove3D);
|
||||
|
||||
virtual void onEnter() override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class ActionScale : public ActionsDemo
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INAN 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.
|
||||
****************************************************************************/
|
||||
|
||||
#include "AllocatorTest.h"
|
||||
#include "cocos2d.h"
|
||||
#include <chrono>
|
||||
|
||||
namespace AllocatorTestNS
|
||||
{
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR
|
||||
Test1::tAllocator Test1::_allocator("Test1", kNumberOfInstances);
|
||||
#endif // CC_ENABLE_ALLOCATOR
|
||||
|
||||
static int sceneIdx = -1;
|
||||
|
||||
static std::function<Layer*()> createFunctions[] =
|
||||
{
|
||||
CL(AllocatorTest)
|
||||
};
|
||||
|
||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||
|
||||
static Layer* nextAllocatorTestAction()
|
||||
{
|
||||
sceneIdx++;
|
||||
sceneIdx = sceneIdx % MAX_LAYER;
|
||||
|
||||
auto layer = (createFunctions[sceneIdx])();
|
||||
return layer;
|
||||
}
|
||||
|
||||
static Layer* backAllocatorTestAction()
|
||||
{
|
||||
sceneIdx--;
|
||||
int total = MAX_LAYER;
|
||||
if( sceneIdx < 0 )
|
||||
sceneIdx += total;
|
||||
|
||||
auto layer = (createFunctions[sceneIdx])();
|
||||
return layer;
|
||||
}
|
||||
|
||||
static Layer* restartAllocatorTestAction()
|
||||
{
|
||||
auto layer = (createFunctions[sceneIdx])();
|
||||
return layer;
|
||||
}
|
||||
|
||||
//
|
||||
// AllocatorTest
|
||||
//
|
||||
|
||||
AllocatorTest::AllocatorTest()
|
||||
{
|
||||
typedef std::vector<Test1*> tTest1Container;
|
||||
typedef std::vector<Test2*> tTest2Container;
|
||||
|
||||
tTest1Container test1Container;
|
||||
test1Container.reserve(kNumberOfInstances);
|
||||
|
||||
tTest2Container test2Container;
|
||||
test2Container.reserve(kNumberOfInstances);
|
||||
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> alloc1Start, alloc1End, alloc2Start, alloc2End;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> free1Start, free1End, free2Start, free2End;
|
||||
|
||||
alloc1Start = std::chrono::high_resolution_clock::now();
|
||||
for (int i = 0; i < kNumberOfInstances; ++i)
|
||||
test1Container.push_back(new Test1);
|
||||
alloc1End = std::chrono::high_resolution_clock::now();
|
||||
|
||||
alloc2Start = std::chrono::high_resolution_clock::now();
|
||||
for (int i = 0; i < kNumberOfInstances; ++i)
|
||||
test2Container.push_back(new Test2);
|
||||
alloc2End = std::chrono::high_resolution_clock::now();
|
||||
|
||||
free1Start = std::chrono::high_resolution_clock::now();
|
||||
for (int i = 0; i < kNumberOfInstances; ++i)
|
||||
delete test1Container[i];
|
||||
free1End = std::chrono::high_resolution_clock::now();
|
||||
|
||||
free2Start = std::chrono::high_resolution_clock::now();
|
||||
for (int i = 0; i < kNumberOfInstances; ++i)
|
||||
delete test2Container[i];
|
||||
free2End = std::chrono::high_resolution_clock::now();
|
||||
|
||||
test1Container.clear();
|
||||
test2Container.clear();
|
||||
|
||||
std::chrono::duration<double> elapsed_seconds_alloc1 = alloc1End - alloc1Start;
|
||||
std::chrono::duration<double> elapsed_seconds_alloc2 = alloc2End - alloc2Start;
|
||||
std::chrono::duration<double> elapsed_seconds_free1 = free1End - free1Start;
|
||||
std::chrono::duration<double> elapsed_seconds_free2 = free2End - free2Start;
|
||||
|
||||
char buf[1000];
|
||||
|
||||
const float x_start = 240;
|
||||
const float y_start = 100;
|
||||
const float y_delta = 20;
|
||||
float y = 0;
|
||||
|
||||
sprintf(buf, "alloc1 %f", elapsed_seconds_alloc1.count());
|
||||
auto alloc1 = Label::createWithSystemFont(buf, "Helvetica", 12);
|
||||
alloc1->setPosition(x_start, y++ * y_delta + y_start);
|
||||
addChild(alloc1);
|
||||
|
||||
sprintf(buf, "alloc2 %f", elapsed_seconds_alloc2.count());
|
||||
auto alloc2 = Label::createWithSystemFont(buf, "Helvetica", 12);
|
||||
alloc2->setPosition(x_start, y++ * y_delta + y_start);
|
||||
addChild(alloc2);
|
||||
|
||||
sprintf(buf, "free1 %f", elapsed_seconds_free1.count());
|
||||
auto free1 = Label::createWithSystemFont(buf, "Helvetica", 12);
|
||||
free1->setPosition(x_start, y++ * y_delta + y_start);
|
||||
addChild(free1);
|
||||
|
||||
sprintf(buf, "free2 %f", elapsed_seconds_free2.count());
|
||||
auto free2 = Label::createWithSystemFont(buf, "Helvetica", 12);
|
||||
free2->setPosition(x_start, y++ * y_delta + y_start);
|
||||
addChild(free2);
|
||||
}
|
||||
|
||||
AllocatorTest::~AllocatorTest()
|
||||
{
|
||||
}
|
||||
|
||||
std::string AllocatorTest::title() const
|
||||
{
|
||||
return "Allocator Test";
|
||||
}
|
||||
|
||||
std::string AllocatorTest::subtitle() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void AllocatorTest::restartCallback( Ref* sender )
|
||||
{
|
||||
auto s = new AllocatorTestScene();
|
||||
s->addChild(restartAllocatorTestAction());
|
||||
Director::getInstance()->replaceScene(s);
|
||||
s->release();
|
||||
}
|
||||
|
||||
void AllocatorTest::nextCallback( Ref* sender )
|
||||
{
|
||||
auto s = new AllocatorTestScene();
|
||||
s->addChild( nextAllocatorTestAction() );
|
||||
Director::getInstance()->replaceScene(s);
|
||||
s->release();
|
||||
}
|
||||
|
||||
void AllocatorTest::backCallback( Ref* sender )
|
||||
{
|
||||
auto s = new AllocatorTestScene();
|
||||
s->addChild( backAllocatorTestAction() );
|
||||
Director::getInstance()->replaceScene(s);
|
||||
s->release();
|
||||
}
|
||||
|
||||
void AllocatorTest::onEnter()
|
||||
{
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void AllocatorTest::onExit()
|
||||
{
|
||||
BaseTest::onExit();
|
||||
}
|
||||
|
||||
void AllocatorTest::update(float delta)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// AllocatorTestScene
|
||||
//
|
||||
|
||||
AllocatorTestScene::AllocatorTestScene()
|
||||
{
|
||||
}
|
||||
|
||||
void AllocatorTestScene::runThisTest()
|
||||
{
|
||||
auto layer = nextAllocatorTestAction();
|
||||
addChild(layer);
|
||||
Director::getInstance()->replaceScene(this);
|
||||
}
|
||||
|
||||
} // AllocatorTestNS
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2014 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
#include "base/allocator/CCAllocatorStrategyPool.h"
|
||||
|
||||
namespace AllocatorTestNS
|
||||
{
|
||||
|
||||
//
|
||||
// Test Classes
|
||||
//
|
||||
|
||||
#define kNumberOfInstances 100000
|
||||
#define kObjectSize 952 // sizeof(Sprite)
|
||||
|
||||
class Test1;
|
||||
|
||||
class Test1
|
||||
{
|
||||
public:
|
||||
|
||||
Test1()
|
||||
{
|
||||
memset(bytes, 0, sizeof(bytes));
|
||||
}
|
||||
uint8_t bytes[kObjectSize];
|
||||
|
||||
#if CC_ENABLE_ALLOCATOR
|
||||
typedef cocos2d::allocator::AllocatorStrategyPool<Test1> tAllocator;
|
||||
static tAllocator _allocator;
|
||||
#endif // CC_ENABLE_ALLOCATOR
|
||||
CC_USE_ALLOCATOR_POOL(Test1, _allocator);
|
||||
};
|
||||
|
||||
class Test2
|
||||
{
|
||||
public:
|
||||
|
||||
Test2()
|
||||
{
|
||||
memset(bytes, 0, sizeof(bytes));
|
||||
}
|
||||
uint8_t bytes[kObjectSize];
|
||||
};
|
||||
|
||||
class AllocatorTest : public BaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(AllocatorTest);
|
||||
AllocatorTest();
|
||||
virtual ~AllocatorTest();
|
||||
|
||||
virtual std::string title() const;
|
||||
virtual std::string subtitle() const;
|
||||
|
||||
virtual void restartCallback(Ref* sender);
|
||||
virtual void nextCallback(Ref* sender);
|
||||
virtual void backCallback(Ref* sender);
|
||||
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
|
||||
virtual void update(float delta);
|
||||
};
|
||||
|
||||
class AllocatorTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
AllocatorTestScene();
|
||||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
} // AllocatorTestNS
|
|
@ -55,6 +55,9 @@ static std::function<Layer*()> createFunctions[] =
|
|||
// 3DEffect use custom shader which is not supported on WP8/WinRT yet.
|
||||
CL(Sprite3DEffectTest),
|
||||
CL(Sprite3DUVAnimationTest),
|
||||
CL(Sprite3DFakeShadowTest),
|
||||
CL(Sprite3DBasicToonShaderTest),
|
||||
CL(Sprite3DLightMapTest),
|
||||
#endif
|
||||
CL(Sprite3DWithSkinTest),
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
|
@ -325,6 +328,352 @@ void Sprite3DUVAnimationTest::cylinderUpdate(float dt)
|
|||
_state->setUniformFloat("duration",_shining_duraion);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Sprite3DFakeShadowTest
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
Sprite3DFakeShadowTest::Sprite3DFakeShadowTest()
|
||||
{
|
||||
Size visibleSize = Director::getInstance()->getVisibleSize();
|
||||
|
||||
auto listener = EventListenerTouchAllAtOnce::create();
|
||||
listener->onTouchesBegan = CC_CALLBACK_2(Sprite3DFakeShadowTest::onTouchesBegan, this);
|
||||
listener->onTouchesMoved = CC_CALLBACK_2(Sprite3DFakeShadowTest::onTouchesMoved, this);
|
||||
listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DFakeShadowTest::onTouchesEnded, this);
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
auto layer = Layer::create();
|
||||
addChild(layer,0);
|
||||
//create Camera
|
||||
_camera = Camera::createPerspective(60,visibleSize.width/visibleSize.height,0.1,200);
|
||||
_camera->setCameraFlag(CameraFlag::USER1);
|
||||
_camera->setPosition3D(Vec3(0,20,25));
|
||||
_camera->setRotation3D(Vec3(-60,0,0));
|
||||
|
||||
//create a plane
|
||||
_plane = Sprite3D::create("Sprite3DTest/plane.c3t");
|
||||
_plane->setRotation3D(Vec3(90,0,0));
|
||||
|
||||
// use custom shader
|
||||
auto shader =GLProgram::createWithFilenames("Sprite3DTest/simple_shadow.vert","Sprite3DTest/simple_shadow.frag");
|
||||
auto state = GLProgramState::create(shader);
|
||||
_plane->setGLProgramState(state);
|
||||
|
||||
//pass mesh's attribute to shader
|
||||
long offset = 0;
|
||||
auto attributeCount = _plane->getMesh()->getMeshVertexAttribCount();
|
||||
for (auto i = 0; i < attributeCount; i++) {
|
||||
auto meshattribute = _plane->getMesh()->getMeshVertexAttribute(i);
|
||||
state->setVertexAttribPointer(s_attributeNames[meshattribute.vertexAttrib],
|
||||
meshattribute.size,
|
||||
meshattribute.type,
|
||||
GL_FALSE,
|
||||
_plane->getMesh()->getVertexSizeInBytes(),
|
||||
(GLvoid*)offset);
|
||||
offset += meshattribute.attribSizeBytes;
|
||||
}
|
||||
state->setUniformMat4("u_model_matrix",_plane->getNodeToWorldTransform());
|
||||
|
||||
//create shadow texture
|
||||
auto shadowTexture = Director::getInstance()->getTextureCache()->addImage("Sprite3DTest/shadowCircle.png");
|
||||
Texture2D::TexParams tRepeatParams;//set texture parameters
|
||||
tRepeatParams.magFilter = GL_LINEAR;
|
||||
tRepeatParams.minFilter = GL_LINEAR;
|
||||
tRepeatParams.wrapS = GL_CLAMP_TO_EDGE;
|
||||
tRepeatParams.wrapT = GL_CLAMP_TO_EDGE;
|
||||
shadowTexture->setTexParameters(tRepeatParams);
|
||||
state->setUniformTexture("u_shadowTexture",shadowTexture);
|
||||
layer->addChild(_plane);
|
||||
|
||||
//create the orc
|
||||
_orc = Sprite3D::create("Sprite3DTest/orc.c3b");
|
||||
_orc->setScale(0.2);
|
||||
_orc->setRotation3D(Vec3(0,180,0));
|
||||
_orc->setPosition3D(Vec3(0,0,10));
|
||||
_targetPos = _orc->getPosition3D();
|
||||
_plane->getGLProgramState()->setUniformVec3("u_target_pos",_orc->getPosition3D());
|
||||
layer->addChild(_orc);
|
||||
layer->addChild(_camera);
|
||||
layer->setCameraMask(2);
|
||||
|
||||
schedule(CC_SCHEDULE_SELECTOR(Sprite3DFakeShadowTest::updateCamera), 0.0f);
|
||||
}
|
||||
|
||||
std::string Sprite3DFakeShadowTest::title() const
|
||||
{
|
||||
return "fake shadow effect";
|
||||
}
|
||||
|
||||
std::string Sprite3DFakeShadowTest::subtitle() const
|
||||
{
|
||||
return "touch the screen to move around";
|
||||
}
|
||||
|
||||
void Sprite3DFakeShadowTest::Move(cocos2d::Ref* sender,int value)
|
||||
{
|
||||
_orc->setPositionX(_orc->getPositionX()+value);
|
||||
|
||||
}
|
||||
|
||||
void Sprite3DFakeShadowTest::updateCamera(float fDelta)
|
||||
{
|
||||
updateState(fDelta);
|
||||
if(isState(_curState,State_Move))
|
||||
{
|
||||
move3D(fDelta);
|
||||
if(isState(_curState,State_Rotate))
|
||||
{
|
||||
Vec3 curPos = _orc->getPosition3D();
|
||||
|
||||
Vec3 newFaceDir = _targetPos - curPos;
|
||||
newFaceDir.y = 0;
|
||||
newFaceDir.normalize();
|
||||
Vec3 up;
|
||||
_orc->getNodeToWorldTransform().getUpVector(&up);
|
||||
up.normalize();
|
||||
Vec3 right;
|
||||
Vec3::cross(-newFaceDir,up,&right);
|
||||
right.normalize();
|
||||
Vec3 pos = Vec3(0,0,0);
|
||||
Mat4 mat;
|
||||
mat.m[0] = right.x;
|
||||
mat.m[1] = right.y;
|
||||
mat.m[2] = right.z;
|
||||
mat.m[3] = 0.0f;
|
||||
|
||||
mat.m[4] = up.x;
|
||||
mat.m[5] = up.y;
|
||||
mat.m[6] = up.z;
|
||||
mat.m[7] = 0.0f;
|
||||
|
||||
mat.m[8] = newFaceDir.x;
|
||||
mat.m[9] = newFaceDir.y;
|
||||
mat.m[10] = newFaceDir.z;
|
||||
mat.m[11] = 0.0f;
|
||||
|
||||
mat.m[12] = pos.x;
|
||||
mat.m[13] = pos.y;
|
||||
mat.m[14] = pos.z;
|
||||
mat.m[15] = 1.0f;
|
||||
_orc->setAdditionalTransform(&mat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Sprite3DFakeShadowTest::move3D(float elapsedTime)
|
||||
{
|
||||
Vec3 curPos= _orc->getPosition3D();
|
||||
Vec3 newFaceDir = _targetPos - curPos;
|
||||
newFaceDir.y = 0.0f;
|
||||
newFaceDir.normalize();
|
||||
Vec3 offset = newFaceDir * 25.0f * elapsedTime;
|
||||
curPos+=offset;
|
||||
_orc->setPosition3D(curPos);
|
||||
offset.x=offset.x;
|
||||
offset.z=offset.z;
|
||||
//pass the newest orc position
|
||||
_plane->getGLProgramState()->setUniformVec3("u_target_pos",_orc->getPosition3D());
|
||||
}
|
||||
|
||||
void Sprite3DFakeShadowTest::updateState(float elapsedTime)
|
||||
{
|
||||
Vec3 curPos= _orc->getPosition3D();
|
||||
Vec3 curFaceDir;
|
||||
_orc->getNodeToWorldTransform().getForwardVector(&curFaceDir);
|
||||
curFaceDir=-curFaceDir;
|
||||
curFaceDir.normalize();
|
||||
Vec3 newFaceDir = _targetPos - curPos;
|
||||
newFaceDir.y = 0.0f;
|
||||
newFaceDir.normalize();
|
||||
float cosAngle = std::fabs(Vec3::dot(curFaceDir,newFaceDir) - 1.0f);
|
||||
float dist = curPos.distanceSquared(_targetPos);
|
||||
if(dist<=4.0f)
|
||||
{
|
||||
if(cosAngle<=0.01f)
|
||||
_curState = State_Idle;
|
||||
else
|
||||
_curState = State_Rotate;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cosAngle>0.01f)
|
||||
_curState = State_Rotate | State_Move;
|
||||
else
|
||||
_curState = State_Move;
|
||||
}
|
||||
}
|
||||
|
||||
bool Sprite3DFakeShadowTest::isState(unsigned int state,unsigned int bit) const
|
||||
{
|
||||
return (state & bit) == bit;
|
||||
}
|
||||
|
||||
void Sprite3DFakeShadowTest::onTouchesBegan(const std::vector<Touch*>& touches, cocos2d::Event *event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Sprite3DFakeShadowTest::onTouchesMoved(const std::vector<Touch*>& touches, cocos2d::Event *event)
|
||||
{
|
||||
}
|
||||
|
||||
void Sprite3DFakeShadowTest::onTouchesEnded(const std::vector<Touch*>& touches, cocos2d::Event *event)
|
||||
{
|
||||
for ( auto &item: touches )
|
||||
{
|
||||
auto touch = item;
|
||||
auto location = touch->getLocationInView();
|
||||
if(_camera)
|
||||
{
|
||||
if(_orc )
|
||||
{
|
||||
Vec3 nearP(location.x, location.y, -1.0f), farP(location.x, location.y, 1.0f);
|
||||
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
_camera->unproject(size, &nearP, &nearP);
|
||||
_camera->unproject(size, &farP, &farP);
|
||||
Vec3 dir(farP - nearP);
|
||||
float dist=0.0f;
|
||||
float ndd = Vec3::dot(Vec3(0,1,0),dir);
|
||||
if(ndd == 0)
|
||||
dist=0.0f;
|
||||
float ndo = Vec3::dot(Vec3(0,1,0),nearP);
|
||||
dist= (0 - ndo) / ndd;
|
||||
Vec3 p = nearP + dist * dir;
|
||||
|
||||
if( p.x > 100)
|
||||
p.x = 100;
|
||||
if( p.x < -100)
|
||||
p.x = -100;
|
||||
if( p.z > 100)
|
||||
p.z = 100;
|
||||
if( p.z < -100)
|
||||
p.z = -100;
|
||||
|
||||
_targetPos=p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Sprite3DBasicToonShaderTest
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
Sprite3DBasicToonShaderTest::Sprite3DBasicToonShaderTest()
|
||||
{
|
||||
Size visibleSize = Director::getInstance()->getVisibleSize();
|
||||
auto _camera = Camera::createPerspective(60,visibleSize.width/visibleSize.height,0.1,200);
|
||||
_camera->setCameraFlag(CameraFlag::USER1);
|
||||
// create a teapot
|
||||
auto teapot = Sprite3D::create("Sprite3DTest/teapot.c3b");
|
||||
//create and set our custom shader
|
||||
auto shader =GLProgram::createWithFilenames("Sprite3DTest/toon.vert","Sprite3DTest/toon.frag");
|
||||
auto state = GLProgramState::create(shader);
|
||||
teapot->setGLProgramState(state);
|
||||
teapot->setPosition3D(Vec3(0,-5,-20));
|
||||
teapot->setRotation3D(Vec3(-90,180,0));
|
||||
auto rotate_action = RotateBy::create(1.5,Vec3(0,30,0));
|
||||
teapot->runAction(RepeatForever::create(rotate_action));
|
||||
//pass mesh's attribute to shader
|
||||
long offset = 0;
|
||||
auto attributeCount = teapot->getMesh()->getMeshVertexAttribCount();
|
||||
for (auto i = 0; i < attributeCount; i++) {
|
||||
auto meshattribute = teapot->getMesh()->getMeshVertexAttribute(i);
|
||||
state->setVertexAttribPointer(s_attributeNames[meshattribute.vertexAttrib],
|
||||
meshattribute.size,
|
||||
meshattribute.type,
|
||||
GL_FALSE,
|
||||
teapot->getMesh()->getVertexSizeInBytes(),
|
||||
(GLvoid*)offset);
|
||||
offset += meshattribute.attribSizeBytes;
|
||||
}
|
||||
addChild(teapot);
|
||||
addChild(_camera);
|
||||
setCameraMask(2);
|
||||
}
|
||||
|
||||
std::string Sprite3DBasicToonShaderTest::title() const
|
||||
{
|
||||
return "basic toon shader test";
|
||||
}
|
||||
|
||||
std::string Sprite3DBasicToonShaderTest::subtitle() const
|
||||
{
|
||||
return " ";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Sprite3DLightMapTest
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
Sprite3DLightMapTest::Sprite3DLightMapTest()
|
||||
{
|
||||
//the assets are from the OpenVR demo
|
||||
//get the visible size.
|
||||
Size visibleSize = Director::getInstance()->getVisibleSize();
|
||||
_camera = Camera::createPerspective(60,visibleSize.width/visibleSize.height,0.1,200);
|
||||
_camera->setCameraFlag(CameraFlag::USER1);
|
||||
_camera->setPosition3D(Vec3(0,25,15));
|
||||
_camera->setRotation3D(Vec3(-35,0,0));
|
||||
auto LightMapScene = Sprite3D::create("Sprite3DTest/LightMapScene.c3b");
|
||||
LightMapScene->setScale(0.1);
|
||||
addChild(LightMapScene);
|
||||
addChild(_camera);
|
||||
setCameraMask(2);
|
||||
|
||||
//add a point light
|
||||
auto light = PointLight::create(Vec3(35,75,-20.5),Color3B(255,255,255),150);
|
||||
addChild(light);
|
||||
//set the ambient light
|
||||
auto ambient = AmbientLight::create(Color3B(55,55,55));
|
||||
addChild(ambient);
|
||||
|
||||
//create a listener
|
||||
auto listener = EventListenerTouchAllAtOnce::create();
|
||||
listener->onTouchesMoved = CC_CALLBACK_2(Sprite3DLightMapTest::onTouchesMoved, this);
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
}
|
||||
|
||||
std::string Sprite3DLightMapTest::title() const
|
||||
{
|
||||
return "light map test";
|
||||
}
|
||||
|
||||
std::string Sprite3DLightMapTest::subtitle() const
|
||||
{
|
||||
return "drag the screen to move around";
|
||||
}
|
||||
|
||||
void Sprite3DLightMapTest::onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event)
|
||||
{
|
||||
if(touches.size()==1)
|
||||
{
|
||||
float delta = Director::getInstance()->getDeltaTime();
|
||||
auto touch = touches[0];
|
||||
auto location = touch->getLocation();
|
||||
auto PreviousLocation = touch->getPreviousLocation();
|
||||
Point newPos = PreviousLocation - location;
|
||||
|
||||
Vec3 cameraDir;
|
||||
Vec3 cameraRightDir;
|
||||
_camera->getNodeToWorldTransform().getForwardVector(&cameraDir);
|
||||
cameraDir.normalize();
|
||||
cameraDir.y=0;
|
||||
_camera->getNodeToWorldTransform().getRightVector(&cameraRightDir);
|
||||
cameraRightDir.normalize();
|
||||
cameraRightDir.y=0;
|
||||
Vec3 cameraPos= _camera->getPosition3D();
|
||||
cameraPos+=cameraDir*newPos.y*delta;
|
||||
cameraPos+=cameraRightDir*newPos.x*delta;
|
||||
_camera->setPosition3D(cameraPos);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Sprite3DHitTest
|
||||
|
|
|
@ -81,6 +81,58 @@ protected:
|
|||
float _shining_duraion;
|
||||
GLProgramState * _state;
|
||||
};
|
||||
|
||||
class Sprite3DFakeShadowTest : public Sprite3DTestDemo
|
||||
{
|
||||
public:
|
||||
enum State
|
||||
{
|
||||
State_None = 0,
|
||||
State_Idle = 0x01,
|
||||
State_Move = 0x02,
|
||||
State_Rotate = 0x04
|
||||
};
|
||||
CREATE_FUNC(Sprite3DFakeShadowTest);
|
||||
Sprite3DFakeShadowTest();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
void Move(cocos2d::Ref* sender,int value);
|
||||
void updateCamera(float fDelta);
|
||||
void move3D(float elapsedTime);
|
||||
void updateState(float elapsedTime);
|
||||
bool isState(unsigned int state,unsigned int bit) const;
|
||||
void onTouchesBegan(const std::vector<Touch*>& touches, cocos2d::Event *event);
|
||||
void onTouchesMoved(const std::vector<Touch*>& touches, cocos2d::Event *event);
|
||||
void onTouchesEnded(const std::vector<Touch*>& touches, cocos2d::Event *event);
|
||||
private:
|
||||
cocos2d::Camera * _camera;
|
||||
Vec3 _targetPos;
|
||||
unsigned int _curState;
|
||||
cocos2d::Sprite3D * _plane;
|
||||
cocos2d::Sprite3D * _orc;
|
||||
};
|
||||
|
||||
class Sprite3DLightMapTest : public Sprite3DTestDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Sprite3DLightMapTest);
|
||||
Sprite3DLightMapTest();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
||||
private:
|
||||
Camera * _camera;
|
||||
};
|
||||
|
||||
class Sprite3DBasicToonShaderTest : public Sprite3DTestDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Sprite3DBasicToonShaderTest);
|
||||
Sprite3DBasicToonShaderTest();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
};
|
||||
class EffectSprite3D;
|
||||
|
||||
class Effect3D : public Ref
|
||||
|
|
|
@ -38,7 +38,8 @@ Controller g_aTestNames[] = {
|
|||
{ "Actions - Basic", [](){ return new ActionsTestScene(); } },
|
||||
{ "Actions - Ease", [](){return new ActionsEaseTestScene();} },
|
||||
{ "Actions - Progress", [](){return new ProgressActionsTestScene(); } },
|
||||
{ "Audio - CocosDenshion", []() { return new CocosDenshionTestScene(); } },
|
||||
{ "Allocator - Basic", [](){return new AllocatorTestNS::AllocatorTestScene(); } },
|
||||
{ "Audio - CocosDenshion", []() { return new CocosDenshionTestScene(); } },
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
{ "Audio - NewAudioEngine", []() { return new AudioEngineTestScene(); } },
|
||||
#endif
|
||||
|
|
|
@ -79,5 +79,6 @@
|
|||
#include "LightTest/LightTest.h"
|
||||
|
||||
#include "OpenURLTest/OpenURLTest.h"
|
||||
#include "AllocatorTest/AllocatorTest.h"
|
||||
|
||||
#endif
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
#ifdef GL_ES
|
||||
varying mediump vec2 TextureCoordOut;
|
||||
varying mediump vec2 v_texture_coord;
|
||||
#else
|
||||
varying vec2 TextureCoordOut;
|
||||
varying vec2 v_texture_coord;
|
||||
#endif
|
||||
|
||||
uniform vec4 u_color;
|
||||
|
@ -10,7 +10,7 @@ uniform float duration;
|
|||
uniform sampler2D caustics;
|
||||
void main(void)
|
||||
{
|
||||
vec4 golden = duration*vec4(0,0.8,0.4,1.0);
|
||||
vec4 color = duration*vec4(0,0.8,0.4,1.0);
|
||||
//blend two texture
|
||||
gl_FragColor = texture2D(CC_Texture0, vec2(TextureCoordOut.x- 2.0 * offset,TextureCoordOut.y)) * vec4(0.3,0.3,0.3,1)+texture2D(caustics,vec2(TextureCoordOut.x-offset,TextureCoordOut.y)).r*golden;
|
||||
gl_FragColor = u_color*texture2D(CC_Texture0, vec2(v_texture_coord.x- 2.0 * offset,v_texture_coord.y)) * vec4(0.3,0.3,0.3,1)+texture2D(caustics,vec2(v_texture_coord.x-offset,v_texture_coord.y)).r*color;
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
attribute vec4 a_position;
|
||||
attribute vec2 a_texCoord;
|
||||
uniform float offset;
|
||||
varying vec2 TextureCoordOut;
|
||||
varying vec2 v_texture_coord;
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = CC_MVPMatrix * a_position;
|
||||
TextureCoordOut = a_texCoord;
|
||||
TextureCoordOut.y = (1.0 - TextureCoordOut.y);
|
||||
v_texture_coord = a_texCoord;
|
||||
v_texture_coord.y = (1.0 - v_texture_coord.y);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
{
|
||||
"version": "0.3",
|
||||
"id": "",
|
||||
"meshes": [
|
||||
{
|
||||
"attributes": [{
|
||||
"size": 3,
|
||||
"type": "GL_FLOAT",
|
||||
"attribute": "VERTEX_ATTRIB_POSITION"
|
||||
}, {
|
||||
"size": 3,
|
||||
"type": "GL_FLOAT",
|
||||
"attribute": "VERTEX_ATTRIB_NORMAL"
|
||||
}, {
|
||||
"size": 2,
|
||||
"type": "GL_FLOAT",
|
||||
"attribute": "VERTEX_ATTRIB_TEX_COORD"
|
||||
}],
|
||||
"vertices": [
|
||||
50.000000, -50.000000, 0.000000, 0.000000, 0.000000, -1.000000, 0.000000, 0.000000,
|
||||
-50.000000, -50.000000, 0.000000, 0.000000, 0.000000, -1.000000, 1.000000, 0.000000,
|
||||
50.000000, 50.000000, 0.000000, 0.000000, 0.000000, -1.000000, 0.000000, 1.000000,
|
||||
-50.000000, 50.000000, 0.000000, 0.000000, 0.000000, -1.000000, 1.000000, 1.000000,
|
||||
50.000000, 50.000000, 3.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000,
|
||||
-50.000000, 50.000000, 3.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000,
|
||||
-50.000000, -50.000000, 3.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000,
|
||||
50.000000, -50.000000, 3.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000,
|
||||
50.000000, -50.000000, 3.000000, 0.000000, -1.000000, 0.000000, 1.000000, 1.000000,
|
||||
-50.000000, -50.000000, 3.000000, 0.000000, -1.000000, 0.000000, 0.000000, 1.000000,
|
||||
-50.000000, -50.000000, 0.000000, 0.000000, -1.000000, 0.000000, 0.000000, 0.000000,
|
||||
50.000000, -50.000000, 0.000000, 0.000000, -1.000000, 0.000000, 1.000000, 0.000000,
|
||||
50.000000, 50.000000, 3.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000,
|
||||
50.000000, -50.000000, 3.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000,
|
||||
50.000000, -50.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
50.000000, 50.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000,
|
||||
-50.000000, 50.000000, 3.000000, 0.000000, 1.000000, 0.000000, 1.000000, 1.000000,
|
||||
50.000000, 50.000000, 3.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000,
|
||||
50.000000, 50.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000,
|
||||
-50.000000, 50.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000,
|
||||
-50.000000, -50.000000, 3.000000, -1.000000, 0.000000, 0.000000, 1.000000, 1.000000,
|
||||
-50.000000, 50.000000, 3.000000, -1.000000, 0.000000, 0.000000, 0.000000, 1.000000,
|
||||
-50.000000, 50.000000, 0.000000, -1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
-50.000000, -50.000000, 0.000000, -1.000000, 0.000000, 0.000000, 1.000000, 0.000000
|
||||
],
|
||||
"parts": [
|
||||
{
|
||||
"id": "shape1_part1",
|
||||
"type": "TRIANGLES",
|
||||
"indices": [
|
||||
0, 1, 2, 1, 3, 2, 4, 5, 6, 4, 6, 7,
|
||||
8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15,
|
||||
16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"materials": [
|
||||
{
|
||||
"id": "01 - Default",
|
||||
"ambient": [ 0.588235, 0.588235, 0.588235],
|
||||
"diffuse": [ 0.588235, 0.588235, 0.588235],
|
||||
"emissive": [ 0.000000, 0.000000, 0.000000],
|
||||
"opacity": 1.000000,
|
||||
"specular": [ 0.900000, 0.900000, 0.900000],
|
||||
"shininess": 2.000000,
|
||||
"textures": [
|
||||
{
|
||||
"id": "Map #1",
|
||||
"filename": "plane.png",
|
||||
"type": "DIFFUSE",
|
||||
"wrapModeU": "REPEAT",
|
||||
"wrapModeV": "REPEAT"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "Box001",
|
||||
"skeleton": false,
|
||||
"transform": [ 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000],
|
||||
"parts": [
|
||||
{
|
||||
"meshpartid": "shape1_part1",
|
||||
"materialid": "01 - Default",
|
||||
"uvMapping": [[ 0]]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"animations": []
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
|
@ -0,0 +1,22 @@
|
|||
#ifdef GL_ES
|
||||
varying mediump vec2 v_texture_coord;
|
||||
varying mediump vec4 v_position;
|
||||
#else
|
||||
varying vec2 v_texture_coord;
|
||||
varying vec4 v_position;
|
||||
#endif
|
||||
uniform sampler2D u_shadowTexture;
|
||||
uniform vec3 u_target_pos;
|
||||
uniform vec4 u_color;
|
||||
void main(void)
|
||||
{
|
||||
|
||||
float Radius = 4.0;//project range
|
||||
vec3 UVector = vec3(1.0, 0.0, 0.0)/(2.0 * Radius);
|
||||
vec3 VVector = vec3(0.0, 0.0, -1.0)/(-2.0 * Radius);
|
||||
vec2 coord;
|
||||
coord.x = dot(v_position.xyz - u_target_pos, UVector) + 0.5;
|
||||
coord.y = dot(v_position.xyz - u_target_pos, VVector) + 0.5;
|
||||
|
||||
gl_FragColor = u_color*texture2D(CC_Texture0,v_texture_coord)*texture2D(u_shadowTexture,coord);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
attribute vec4 a_position;
|
||||
attribute vec2 a_texCoord;
|
||||
varying vec2 v_texture_coord;
|
||||
varying vec4 v_position;
|
||||
uniform mat4 u_model_matrix;
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = CC_PMatrix * CC_MVMatrix * a_position;
|
||||
v_texture_coord = a_texCoord;
|
||||
v_texture_coord.y = (1.0 - v_texture_coord.y);
|
||||
v_position = u_model_matrix * a_position;
|
||||
}
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 141 B |
Binary file not shown.
After Width: | Height: | Size: 177 B |
|
@ -0,0 +1,24 @@
|
|||
#ifdef GL_ES
|
||||
varying mediump vec2 v_texture_coord;
|
||||
#else
|
||||
varying vec2 v_texture_coord;
|
||||
#endif
|
||||
uniform vec4 u_color;
|
||||
varying vec3 v_normal;
|
||||
void main(void)
|
||||
{
|
||||
vec3 light_direction = vec3(1,-1,0);
|
||||
light_direction = normalize(light_direction);
|
||||
vec3 light_color = vec3(1,1,1);
|
||||
vec3 normal = normalize(v_normal);
|
||||
float diffuse_factor = dot(normal,-light_direction);
|
||||
vec4 diffuse_color = texture2D(CC_Texture0,v_texture_coord);
|
||||
|
||||
if (diffuse_factor > 0.95) diffuse_factor=1.0;
|
||||
else if (diffuse_factor > 0.75) diffuse_factor = 0.8;
|
||||
else if (diffuse_factor > 0.50) diffuse_factor = 0.6;
|
||||
else diffuse_factor = 0.4;
|
||||
|
||||
light_color = light_color * diffuse_factor;
|
||||
gl_FragColor = vec4(light_color,1.0) * diffuse_color * u_color;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
attribute vec4 a_position;
|
||||
attribute vec2 a_texCoord;
|
||||
attribute vec3 a_normal;
|
||||
varying vec2 v_texture_coord;
|
||||
varying vec3 v_normal;
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = CC_MVPMatrix * a_position;
|
||||
v_texture_coord = a_texCoord;
|
||||
v_texture_coord.y = (1.0 - v_texture_coord.y);
|
||||
v_normal = CC_NormalMatrix *a_normal;
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
<classpath>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
|
|
|
@ -16,6 +16,7 @@ LOCAL_SRC_FILES := main.cpp \
|
|||
../../Classes/ActionsEaseTest/ActionsEaseTest.cpp \
|
||||
../../Classes/ActionsProgressTest/ActionsProgressTest.cpp \
|
||||
../../Classes/ActionsTest/ActionsTest.cpp \
|
||||
../../Classes/AllocatorTest/AllocatorTest.cpp \
|
||||
../../Classes/BillBoardTest/BillBoardTest.cpp \
|
||||
../../Classes/Box2DTest/Box2dTest.cpp \
|
||||
../../Classes/Box2DTestBed/Box2dView.cpp \
|
||||
|
|
|
@ -136,6 +136,7 @@
|
|||
</PreLinkEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Classes\AllocatorTest\AllocatorTest.cpp" />
|
||||
<ClCompile Include="..\Classes\BaseTest.cpp" />
|
||||
<ClCompile Include="..\Classes\BillBoardTest\BillBoardTest.cpp" />
|
||||
<ClCompile Include="..\Classes\BugsTest\Bug-Child.cpp" />
|
||||
|
@ -324,6 +325,7 @@
|
|||
<ClCompile Include="..\Classes\MutiTouchTest\MutiTouchTest.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Classes\AllocatorTest\AllocatorTest.h" />
|
||||
<ClInclude Include="..\Classes\BaseTest.h" />
|
||||
<ClInclude Include="..\Classes\BillBoardTest\BillBoardTest.h" />
|
||||
<ClInclude Include="..\Classes\Box2DTestBed\Tests\ConvexHull.h" />
|
||||
|
|
|
@ -343,6 +343,9 @@
|
|||
<Filter Include="Classes\UITest\CocostudioGUISceneTest\CustomTest\CustomWidgetCallbackBindTest">
|
||||
<UniqueIdentifier>{65be3b70-58d6-47f4-bc67-fac9ee134c42}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\AllocatorTest">
|
||||
<UniqueIdentifier>{eed1887a-757e-4625-b21c-bbfcfaa5200f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
|
@ -903,6 +906,9 @@
|
|||
<ClCompile Include="..\Classes\UITest\CocoStudioGUITest\CustomTest\CustomWidgetCallbackBindTest\CustomWidgetCallbackBindTest.cpp">
|
||||
<Filter>Classes\UITest\CocostudioGUISceneTest\CustomTest\CustomWidgetCallbackBindTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\AllocatorTest\AllocatorTest.cpp">
|
||||
<Filter>Classes\AllocatorTest</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="main.h">
|
||||
|
@ -1661,5 +1667,8 @@
|
|||
<ClInclude Include="..\Classes\UITest\CocoStudioGUITest\CustomTest\CustomWidgetCallbackBindTest\CustomWidgetCallbackBindTest.h">
|
||||
<Filter>Classes\UITest\CocostudioGUISceneTest\CustomTest\CustomWidgetCallbackBindTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\AllocatorTest\AllocatorTest.h">
|
||||
<Filter>Classes\AllocatorTest</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue