Skip to content

Commit 677a8cd

Browse files
committed
Merge branch 'headless-develop' of github.com:spritebuilder/cocos2d-swift into headless-develop
2 parents 820c6c1 + 2c7acd0 commit 677a8cd

File tree

7 files changed

+36
-26
lines changed

7 files changed

+36
-26
lines changed

cocos2d-osx.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@
169169
D216F92D1970A35A000DEF7C /* ALWeakDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = D216F9271970A35A000DEF7C /* ALWeakDictionary.m */; };
170170
D216F92E1970A35A000DEF7C /* ALWeakElement.h in Headers */ = {isa = PBXBuildFile; fileRef = D216F9281970A35A000DEF7C /* ALWeakElement.h */; };
171171
D216F92F1970A35A000DEF7C /* ALWeakElement.m in Sources */ = {isa = PBXBuildFile; fileRef = D216F9291970A35A000DEF7C /* ALWeakElement.m */; };
172+
D2342007199AD36D00DF8FCD /* CCNoARC.m in Sources */ = {isa = PBXBuildFile; fileRef = D2342004199AD36D00DF8FCD /* CCNoARC.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
173+
D2342008199AD36D00DF8FCD /* CCRenderDispatch.h in Headers */ = {isa = PBXBuildFile; fileRef = D2342005199AD36D00DF8FCD /* CCRenderDispatch.h */; };
174+
D2342009199AD36D00DF8FCD /* CCRenderDispatch.m in Sources */ = {isa = PBXBuildFile; fileRef = D2342006199AD36D00DF8FCD /* CCRenderDispatch.m */; };
172175
D2D598641987132700BDAF25 /* CCEffect_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D2D598421987132700BDAF25 /* CCEffect_Private.h */; };
173176
D2D598651987132700BDAF25 /* CCEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = D2D598431987132700BDAF25 /* CCEffect.h */; };
174177
D2D598661987132700BDAF25 /* CCEffect.m in Sources */ = {isa = PBXBuildFile; fileRef = D2D598441987132700BDAF25 /* CCEffect.m */; };
@@ -540,6 +543,9 @@
540543
D216F9271970A35A000DEF7C /* ALWeakDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ALWeakDictionary.m; sourceTree = "<group>"; };
541544
D216F9281970A35A000DEF7C /* ALWeakElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ALWeakElement.h; sourceTree = "<group>"; };
542545
D216F9291970A35A000DEF7C /* ALWeakElement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ALWeakElement.m; sourceTree = "<group>"; };
546+
D2342004199AD36D00DF8FCD /* CCNoARC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCNoARC.m; sourceTree = "<group>"; };
547+
D2342005199AD36D00DF8FCD /* CCRenderDispatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRenderDispatch.h; sourceTree = "<group>"; };
548+
D2342006199AD36D00DF8FCD /* CCRenderDispatch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCRenderDispatch.m; sourceTree = "<group>"; };
543549
D2D598421987132700BDAF25 /* CCEffect_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffect_Private.h; sourceTree = "<group>"; };
544550
D2D598431987132700BDAF25 /* CCEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffect.h; sourceTree = "<group>"; };
545551
D2D598441987132700BDAF25 /* CCEffect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCEffect.m; sourceTree = "<group>"; };
@@ -1342,6 +1348,9 @@
13421348
D3AD531F18C84FC9005B6CF3 /* CCRenderer_private.h */,
13431349
D3AD532018C84FC9005B6CF3 /* CCRenderer.h */,
13441350
D3AD532118C84FC9005B6CF3 /* CCRenderer.m */,
1351+
D2342004199AD36D00DF8FCD /* CCNoARC.m */,
1352+
D2342005199AD36D00DF8FCD /* CCRenderDispatch.h */,
1353+
D2342006199AD36D00DF8FCD /* CCRenderDispatch.m */,
13451354
);
13461355
path = cocos2d;
13471356
sourceTree = "<group>";
@@ -1748,6 +1757,7 @@
17481757
B7E2603517E7C774007067F0 /* NSEvent+CC.h in Headers */,
17491758
B77060961831B0C40043CC67 /* OALAudioFile.h in Headers */,
17501759
B7E2603917E7C786007067F0 /* UITouch+CC.h in Headers */,
1760+
D2342008199AD36D00DF8FCD /* CCRenderDispatch.h in Headers */,
17511761
D2D5987E1987132700BDAF25 /* CCEffectSaturation.h in Headers */,
17521762
);
17531763
runOnlyForDeploymentPostprocessing = 0;
@@ -1870,6 +1880,7 @@
18701880
E076E6DA1225EC7400DE0DA2 /* CCActionInstant.m in Sources */,
18711881
E076E6DC1225EC7400DE0DA2 /* CCActionInterval.m in Sources */,
18721882
B77060901831B0C40043CC67 /* mach_timing.c in Sources */,
1883+
D2342009199AD36D00DF8FCD /* CCRenderDispatch.m in Sources */,
18731884
E076E6DE1225EC7400DE0DA2 /* CCActionManager.m in Sources */,
18741885
B791E851182065BD00DAE1D7 /* CCTiledMapLayer.m in Sources */,
18751886
E076E6E21225EC7400DE0DA2 /* CCActionProgressTimer.m in Sources */,
@@ -1897,6 +1908,7 @@
18971908
B770606C1831B0C40043CC67 /* OALAudioTrackNotifications.m in Sources */,
18981909
E076E7161225EC7400DE0DA2 /* CCProgressNode.m in Sources */,
18991910
D2D598851987132700BDAF25 /* CCEffectUtils.m in Sources */,
1911+
D2342007199AD36D00DF8FCD /* CCNoARC.m in Sources */,
19001912
B77060831831B0C40043CC67 /* ALSource.m in Sources */,
19011913
E076E7191225EC7400DE0DA2 /* CCRenderTexture.m in Sources */,
19021914
E076E71D1225EC7400DE0DA2 /* CCScene.m in Sources */,

cocos2d-tests-android/Headless.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,8 @@
10441044
OTHER_LDFLAGS = (
10451045
"-landroid",
10461046
"-lgles_apportable",
1047-
"-ObjC",
10481047
"-all_load",
1048+
"-ObjC",
10491049
);
10501050
PRODUCT_NAME = "$(TARGET_NAME)";
10511051
WRAPPER_EXTENSION = app;

cocos2d-ui/CCScrollView.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ - (void) onExitTransitionDidStart
775775
[recognizers removeObject:_tapRecognizer];
776776

777777
view.gestureRecognizers = recognizers;
778+
778779
[super onExitTransitionDidStart];
779780
}
780781

cocos2d/Platforms/Android/CCActivity.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ - (void)startGL:(JavaObject<AndroidSurfaceHolder> *)holder
226226

227227
_gameLoop = [NSRunLoop currentRunLoop];
228228

229+
[_gameLoop addPort:[NSPort port] forMode:NSDefaultRunLoopMode]; // Ensure that _gameLoop always has a source.
230+
229231
[self setupView:holder];
230232

231233
[self setupPaths];
@@ -310,12 +312,17 @@ - (void)surfaceCreated:(JavaObject<AndroidSurfaceHolder> *)holder
310312
- (void)surfaceDestroyed:(JavaObject<AndroidSurfaceHolder> *)holder
311313
{
312314
#if USE_MAIN_THREAD
313-
[self finish];
315+
[self handleDestroy];
314316
#else
315-
[self performSelector:@selector(finish) onThread:_thread withObject:nil waitUntilDone:NO modes:@[NSDefaultRunLoopMode]];
317+
[self performSelector:@selector(handleDestroy) onThread:_thread withObject:nil waitUntilDone:NO modes:@[NSDefaultRunLoopMode]];
316318
#endif
317319
}
318320

321+
- (void)handleDestroy
322+
{
323+
[[CCDirector sharedDirector] stopAnimation];
324+
}
325+
319326
- (BOOL)onKeyDown:(int32_t)keyCode keyEvent:(AndroidKeyEvent *)event
320327
{
321328
return NO;

cocos2d/Platforms/Android/CCGLView.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,14 @@ - (BOOL)setupView:(ANativeWindow*)window
491491

492492
if(eglGetError() != EGL_SUCCESS) { NSLog(@"EGL ERROR: %i", eglGetError()); };
493493

494-
if(!(_eglContext = eglCreateContext(_eglDisplay, _eglConfiguration, 0, contextAttribs)))
494+
if(_eglContext == nil)
495495
{
496-
NSLog(@"eglCreateContext() returned error %d", eglGetError());
497-
return NO;
496+
if(!(_eglContext = eglCreateContext(_eglDisplay, _eglConfiguration, 0, contextAttribs)))
497+
{
498+
NSLog(@"eglCreateContext() returned error %d", eglGetError());
499+
return NO;
500+
501+
}
498502
}
499503

500504
if(eglGetError() != EGL_SUCCESS) { NSLog(@"EGL ERROR: %i", eglGetError()); };

cocos2d/Platforms/CCDirectorView.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@
3535
/// The block may not be invoked from the main thread.
3636
-(void)addFrameCompletionHandler:(dispatch_block_t)handler;
3737

38+
/** uses and locks the OpenGL context */
39+
-(void) lockOpenGLContext;
40+
41+
/** unlocks the openGL context */
42+
-(void) unlockOpenGLContext;
43+
3844
@end

external/ObjectAL/OALSimpleAudio.m

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -659,31 +659,11 @@ - (void) unloadAllEffects
659659
return nil;
660660
}
661661

662-
#if 0 // __CC_PLATFORM_ANDROID
663-
// TODO: we are creating a player and throwing it away each time, and not taking into account if it was preloaded.
664-
// think about checking for preload and implement the player's asyncPrepare finish listener
665-
AndroidAssetFileDescriptor *assetFd = [[[CCActivity currentActivity] assets] openFdWithFileName:filePath];
666-
667-
if (assetFd.fileDescriptor && [assetFd.fileDescriptor valid]) {
668-
AndroidMediaPlayer *player = [[AndroidMediaPlayer alloc] init];
669-
[player reset];
670-
[player setDataSource:assetFd.fileDescriptor offset:assetFd.startOffset length:assetFd.length];
671-
#warning TODO: note sure how to set on finished listener for player and call the player's release() (not objc release) in the callback to close fd
672-
[player prepare];
673-
[player start];
674-
}
675-
676-
if (assetFd) {
677-
[assetFd close];
678-
}
679-
// TODO: convert to ALSoundSource and return
680-
#else
681662
ALBuffer* buffer = [self internalPreloadEffect:filePath reduceToMono:NO];
682663
if(nil != buffer)
683664
{
684665
return [channel play:buffer gain:volume pitch:pitch pan:pan loop:loop];
685666
}
686-
#endif
687667
return nil;
688668
}
689669

0 commit comments

Comments
 (0)