Author: johnmci Date: 2010-08-27 21:28:15 -0700 (Fri, 27 Aug 2010) New Revision: 2264 Modified: trunk/platforms/iOS/plugins/SoundPlugin/sqSqueakSoundCoreAudio.m trunk/platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.m trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.h trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+imageReadWrite.m trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAndWindow.m trunk/platforms/iOS/vm/Info-iPhone.plist trunk/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m trunk/platforms/iOS/vm/OSX/sqMacUnixExternalPrims.m trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+attributes.m trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication.h trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.h trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.m trunk/platforms/iOS/vm/OSX/sqSqueakOSXScreenAndWindow.m trunk/platforms/iOS/vm/SqueakPureObjc-Info 64*64.plist trunk/platforms/iOS/vm/SqueakPureObjc-Info.plist trunk/platforms/iOS/vm/SqueakPureObjc-InfoCOG.plist trunk/platforms/iOS/vm/iPhone/sqMacV2Memory.c trunk/platforms/iOS/vm/iPhone/sqPlatformSpecific.h Log: iOS The two major changes are: (a) We move to open/GL for drawing on os-x, this takes us from 29 to 40 fps . (b) We move to a single thread to avoid issues with FFI & Objective-C plugin calls sqSqueakScreenAndWindow.m sqSqueakOSXScreenAndWindow.m move ioForceDisplayUpdateActual logic to subclasses sqSqueakMainApplication+events..m/h sqSqueakOSXApplication+events.m/h sqSqueakOSXApplication.m/h Add pumpRunLoop by subclass for single threaded model. sqSqueakEventsAPI.m Add pumpRunLoop call sqSqueakOSXNSView.h/m Move to OpenGL fix for CNTRL-ARROW keys left/right sqSqueakOSXApplication+attributes.m version number changes SqueakOSXAppDelegate.m add singleThreadStart sqAllocateMemoryMac.c first two ignored parms were wrong. sqSqueakFileDirectoryInterface.m sqSqueakMainApplication+imageReadWrite.m sqSqueakOSXScreenAndWindow.h sqMacUnixExternalPrims.m SqueakOSXAppDelegate.h cleanup of warning messages Modified: trunk/platforms/iOS/plugins/SoundPlugin/sqSqueakSoundCoreAudio.m =================================================================== --- trunk/platforms/iOS/plugins/SoundPlugin/sqSqueakSoundCoreAudio.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/plugins/SoundPlugin/sqSqueakSoundCoreAudio.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -272,6 +272,7 @@ return; //NSLog(@"%i sound stop force",ioMSecs()); OSStatus result = AudioQueueStop (self.outputAudioQueue,true); //This implicitly invokes AudioQueueReset +#pragma unused(result) } @@ -282,6 +283,7 @@ [self snd_Stop]; OSStatus result = AudioQueueDispose (self.outputAudioQueue,true); +#pragma unused(result) self.outputAudioQueue = nil; self.soundOutQueue = [Queue new]; return 1; Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m =================================================================== --- trunk/platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -56,25 +56,11 @@ if ([getMainWindowDelegate() forceUpdateFlush]) { [getMainWindowDelegate() ioForceDisplayUpdate]; } - /* This the carbon logic model - described by http://developer.apple.com/qa/qa2001/qa1061.html - but fails on device, bug tracking number 5971848 */ - -/* extern struct VirtualMachine* interpreterProxy; + if (interpreterProxy->methodPrimitiveIndex() != 0) { - // limitDateForMode: - - BOOL processedEvent; - // NSDate *now = [[NSDate alloc] init]; - NSDate *now = [[NSDate alloc] initWithTimeIntervalSinceNow: 0.500]; - //processedEvent = [[NSRunLoop mainRunLoop] runMode: NSDefaultRunLoopMode beforeDate: now]; - - //[now release]; - [[NSRunLoop mainRunLoop] runUntilDate: now]; - [now release]; - } */ + [gDelegateApp.squeakApplication pumpRunLoop]; + } - if (gQuitNowRightNow) { ioExit(); //This might not return, might call exittoshell } Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.m =================================================================== --- trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakFileDirectoryInterface.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -62,6 +62,7 @@ isDirectory: (sqInt *) isDirectory sizeIfFile: (squeakFileOffsetType *) sizeIfFile { #warning this is not implementation + return 0; } Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.h =================================================================== --- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.h 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.h 2010-08-28 04:28:15 UTC (rev 2264) @@ -41,4 +41,5 @@ @interface sqSqueakMainApplication (events) - (void) ioGetNextEvent: (sqInputEvent *) evt; - (void) processAsOldEventOrComplexEvent: (id) event placeIn: (sqInputEvent *) evt; +- (void) pumpRunLoop; @end Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m =================================================================== --- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+events.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -40,6 +40,21 @@ @implementation sqSqueakMainApplication (events) +- (void) pumpRunLoop { + + /* This the carbon logic model + described by http://developer.apple.com/qa/qa2001/qa1061.html + but fails on device, bug tracking number 5971848 */ + + NSRunLoop *theRL = [NSRunLoop mainRunLoop]; + BOOL result = [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]; + + // while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource); + + // TEST WHICH IS BETTER? SInt32 what = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true); +#pragma unused(result) +} + - (void) ioGetNextEvent: (sqInputEvent *) evt { ioProcessEvents(); Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+imageReadWrite.m =================================================================== --- trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+imageReadWrite.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication+imageReadWrite.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -52,7 +52,6 @@ return NO; } f = sqImageFileOpen(characterPathForImage, "rb"); - #warning sqGetAvailableMemory returns unsigned but readImageFromFileHeapSizeStartingAt is wrong readImageFromFileHeapSizeStartingAt(f, sqGetAvailableMemory(), (squeakFileOffsetType) 0); //This is a VM Callback sqImageFileClose(f); [pool drain]; Modified: trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAndWindow.m =================================================================== --- trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAndWindow.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/Common/Classes/sqSqueakScreenAndWindow.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -108,8 +108,6 @@ } - (void) ioForceDisplayUpdateActual { - self.forceUpdateFlush = NO; - [[self getMainView] performSelectorOnMainThread: @selector(drawThelayers) withObject: nil waitUntilDone: YES]; } - (void) ioForceDisplayUpdate { Modified: trunk/platforms/iOS/vm/Info-iPhone.plist =================================================================== --- trunk/platforms/iOS/vm/Info-iPhone.plist 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/Info-iPhone.plist 2010-08-28 04:28:15 UTC (rev 2264) @@ -19,11 +19,11 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>2.3.1</string> + <string>2.3.2</string> <key>CFBundleSignature</key> <string>FAST</string> <key>CFBundleVersion</key> - <string>2.3.1</string> + <string>2.3.2</string> <key>LSRequiresIPhoneOS</key> <true/> <key>NSMainNibFile</key> Modified: trunk/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m =================================================================== --- trunk/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -56,21 +56,8 @@ self.checkForFileNameOnFirstParm = YES; } -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - NSAutoreleasePool * pool = [NSAutoreleasePool new]; - gDelegateApp = self; - squeakApplication = [self makeApplicationInstance]; - sqSqueakOSXScreenAndWindow *windowHandler = [sqSqueakOSXScreenAndWindow new]; - windowHandler.mainViewOnWindow = self.mainView; - self.mainView.windowLogic = windowHandler; - windowHandler.windowIndex = 1; - [windowHandler.mainViewOnWindow initializeVariables]; - self.window.delegate = windowHandler; - - [self.squeakApplication setupEventQueue]; - +- (void) workerThreadStart { // Run the squeak process in a worker thread - NSThread* myThread = [[NSThread alloc] initWithTarget: self.squeakApplication selector: @selector(runSqueak) object:nil]; @@ -79,19 +66,34 @@ #endif [myThread start]; +} +- (void) singleThreadStart { /* This the carbon logic model described by http://developer.apple.com/qa/qa2001/qa1061.html */ - -/* [[NSRunLoop mainRunLoop] performSelector: @selector(runSqueak) - target: self.squeakApplication - argument: nil - order: 1 - modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; -*/ + target: self.squeakApplication + argument: nil + order: 1 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; +} + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + NSAutoreleasePool * pool = [NSAutoreleasePool new]; + gDelegateApp = self; + squeakApplication = [self makeApplicationInstance]; + sqSqueakOSXScreenAndWindow *windowHandler = [sqSqueakOSXScreenAndWindow new]; + windowHandler.mainViewOnWindow = self.mainView; + self.mainView.windowLogic = windowHandler; + windowHandler.windowIndex = 1; + [windowHandler.mainViewOnWindow initializeVariables]; + self.window.delegate = windowHandler; + + [self.squeakApplication setupEventQueue]; + [self singleThreadStart]; +// [self workerThreadStart]; [pool drain]; @@ -113,17 +115,16 @@ resetFrame.size.width = width; resetFrame.size.height = height; [gDelegateApp.window setAcceptsMouseMovedEvents: YES]; - [gDelegateApp.window useOptimizedDrawing: YES]; + [gDelegateApp.window useOptimizedDrawing: NO]; [gDelegateApp.window setTitle: [[self.squeakApplication.imageNameURL path] lastPathComponent]]; [gDelegateApp.window setRepresentedURL: self.squeakApplication.imageNameURL]; [gDelegateApp.window setInitialFirstResponder: gDelegateApp.mainView]; [gDelegateApp.window setShowsResizeIndicator: NO]; extern sqInt getFullScreenFlag(void); - #if (SQ_VI_BYTES_PER_WORD == 4) NSPanel *panel; if (sizeof(void*) == 8) { - panel= NSGetAlertPanel(@"About this Alpha Version of Cocoa Squeak 64/32 bits 5.7b2 (20)", + panel= NSGetAlertPanel(@"About this Alpha Version of Cocoa Squeak 64/32 bits 5.7b3 (21)", @"Only use this VM for testing, it lacks mac menu integration.", @"Dismiss", nil, @@ -137,13 +138,13 @@ #endif NSPanel *panel; if (sizeof(long) == 8) { - panel= NSGetAlertPanel(@"About this Alpha Version of Cocoa Squeak 64/64 bits 5.7b2 (20)", + panel= NSGetAlertPanel(@"About this Alpha Version of Cocoa Squeak 64/64 bits 5.7b3 (21)", @"Only use this VM for testing, it lacks mac menu integration.", @"Dismiss", nil, nil); } else { - panel= NSGetAlertPanel(@"About this Alpha Version of Cocoa Squeak 32/64 bits 5.7b2 (20)", + panel= NSGetAlertPanel(@"About this Alpha Version of Cocoa Squeak 32/64 bits 5.7b3 (21)", @"Only use this VM for testing, it lacks mac menu integration.", @"Dismiss", nil, @@ -180,6 +181,7 @@ OSErr err = LSOpenFromURLSpec(&launchSpec, NULL); // NSLog(@"error %i",err); +#pragma unused(err) } } Modified: trunk/platforms/iOS/vm/OSX/sqMacUnixExternalPrims.m =================================================================== --- trunk/platforms/iOS/vm/OSX/sqMacUnixExternalPrims.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/sqMacUnixExternalPrims.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -205,6 +205,7 @@ if (!systemFolder) { struct FSRef frameworksFolderRef; OSErr err = FSFindFolder(kSystemDomain, kFrameworksFolderType, false, &frameworksFolderRef); +#pragma unused(err) NSURL *myURLRef = (NSURL *) CFURLCreateFromFSRef(kCFAllocatorDefault, &frameworksFolderRef); systemFolder = [[myURLRef path] retain]; CFRelease(myURLRef); Modified: trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+attributes.m =================================================================== --- trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+attributes.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+attributes.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -82,11 +82,13 @@ #if (SQ_VI_BYTES_PER_WORD == 4) #if STACKVM - return "Mac Cocoa Cog 5.8b3 21-Aug-10 >5954D562-FB39-4195-9D19-EBB49FAECCF7<"; + return "Mac Cocoa Cog 5.8b4 27-Aug-10 >5954D562-FB39-4195-9D19-EBB49FAECCF7<"; +// return "Mac Cocoa Cog 5.8b3 21-Aug-10 >5954D562-FB39-4195-9D19-EBB49FAECCF7<"; // return "Mac Cocoa Cog 5.8b2 08-Jul-10 >7BCAB029-A835-4D12-946D-4AB7083D2955<"; // return "Mac Cocoa Cog 5.8b1 07-Jul-10 >529F6B5A-DC81-4C1F-81B6-3D99741B954A<"; #else - return "Mac Cocoa 5.7b2 08-Jul-10 >7BCAB029-A835-4D12-946D-4AB7083D2955<"; + return "Mac Cocoa 5.7b3 27-Aug-10 >7BCAB029-A835-4D12-946D-4AB7083D2955<"; +// return "Mac Cocoa 5.7b2 08-Jul-10 >7BCAB029-A835-4D12-946D-4AB7083D2955<"; // return "Mac Cocoa 5.7b1 15-Jun-10 >34286DE5-3BD3-40D8-9700-4C41C772B16B<"; #endif // return "Mac Cocoa 5.7b1 15-Jun-10 >34286DE5-3BD3-40D8-9700-4C41C772B16B<"; Modified: trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h =================================================================== --- trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.h 2010-08-28 04:28:15 UTC (rev 2264) @@ -36,6 +36,7 @@ */ // #import "sqSqueakOSXApplication.h" +#import "sqSqueakMainApplication+events.h" #import "sqSqueakOSXNSView.h" @interface sqSqueakOSXApplication (events) Modified: trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m =================================================================== --- trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication+events.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -106,6 +106,34 @@ @implementation sqSqueakOSXApplication (events) +- (void) pumpRunLoop { + [super pumpRunLoop]; + + NSEvent *event; + while (event = [NSApp nextEventMatchingMask: NSAnyEventMask untilDate: nil inMode: NSEventTrackingRunLoopMode dequeue: YES]) + [NSApp sendEvent: event]; + + + /* + http://www.cocoabuilder.com/archive/cocoa/228473-receiving-user-events-from-within-an-nstimer-callback.html + The reason you have to do this and can't just run the runloop is + because the event loop is actually a separate concept from the + runloop. It's a bit confusing because the event loop is implemented + using the runloop, but if you just run the runloop on the main thread, + events won't get processed. You have to explicitly run this in order + to get them to be processed. + + Note that using the default runloop mode with this is generally a bad + idea. By running in the default mode you allow *everything* else to + run, which means that some other code might decide that *it* wants an + inner event loop as well. If you then want to quit before that other + code has finished, tough cookies. Much better to control things more + tightly by using a different runloop mode. + + */ + +} + - (void ) processAsOldEventOrComplexEvent: (id) event placeIn: (sqInputEvent *) evt { if ([[event objectAtIndex: 0] intValue] == 1) { [(NSData *)[event objectAtIndex: 1] getBytes: evt length: sizeof(sqInputEvent)]; Modified: trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication.h =================================================================== --- trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication.h 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/sqSqueakOSXApplication.h 2010-08-28 04:28:15 UTC (rev 2264) @@ -55,5 +55,5 @@ - (void) printUsage; - (void) printUsageNotes; - (BOOL)isImageFile:(NSString *)filePath; - +- (void) pumpRunLoop; @end Modified: trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.h =================================================================== --- trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.h 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.h 2010-08-28 04:28:15 UTC (rev 2264) @@ -43,7 +43,7 @@ @class sqSqueakOSXScreenAndWindow; #import "sq.h" -@interface sqSqueakOSXNSView : NSView <NSTextInputClient> { +@interface sqSqueakOSXNSView : NSOpenGLView <NSTextInputClient> { sqSqueakOSXScreenAndWindow *windowLogic; NSTrackingRectTag squeakTrackingRectForCursor; NSRange inputMark; @@ -56,11 +56,6 @@ NSMutableArray* dragItems; CGDisplayFadeReservationToken fadeToken; NSRect savedScreenBoundsAtTimeOfFullScreen; - CALayer *myLayer[4][4]; - BOOL dirty[4][4]; - CGRect frameForQuartz[4][4]; - CGFloat dividedWidth; - CGFloat dividedHeight; CGColorSpaceRef colorspace; unsigned int* colorMap32; } @@ -83,6 +78,8 @@ - (NSUInteger) countNumberOfNoneSqueakImageFilesInDraggedFiles: (id<NSDraggingInfo>)info; - (NSMutableArray *) filterOutSqueakImageFilesFromDraggedFiles: (id<NSDraggingInfo>)info; - (NSMutableArray *) filterSqueakImageFilesFromDraggedFiles: (id<NSDraggingInfo>)info; +-(void)setupOpenGL; +- (void) drawThelayers; @end #import "SqViewClut.h" Modified: trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.m =================================================================== --- trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/sqSqueakOSXNSView.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -49,81 +49,40 @@ extern SqueakOSXAppDelegate *gDelegateApp; extern struct VirtualMachine* interpreterProxy; -@implementation sqSqueakOSXNSView -@synthesize squeakTrackingRectForCursor,lastSeenKeyBoardStrokeDetails, -lastSeenKeyBoardModifierDetails,dragInProgress,dragCount,dragItems,windowLogic,savedScreenBoundsAtTimeOfFullScreen; - static NSString *stringWithCharacter(unichar character) { return [NSString stringWithCharacters: &character length: 1]; } +@implementation sqSqueakOSXNSView +@synthesize squeakTrackingRectForCursor,lastSeenKeyBoardStrokeDetails, +lastSeenKeyBoardModifierDetails,dragInProgress,dragCount,dragItems,windowLogic,savedScreenBoundsAtTimeOfFullScreen; -static void MyProviderReleaseData ( - void *info, - const void *data, - size_t size - ) { - free((void*)data); ++ (NSOpenGLPixelFormat *)defaultPixelFormat { + NSOpenGLPixelFormatAttribute attrs[] = + { + NSOpenGLPFAAccelerated, + NSOpenGLPFANoRecovery, + 0 + }; + return[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; } -- (void) initializeVariables { +- (void)awakeFromNib { + self = [self initWithFrame: self.frame pixelFormat: [[self class] defaultPixelFormat] ]; inputMark = NSMakeRange(NSNotFound, 0); inputSelection = NSMakeRange(0, 0); [self registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, nil]]; -// NSLog(@"registerForDraggedTypes"); + // NSLog(@"registerForDraggedTypes"); dragInProgress = NO; dragCount = 0; dragItems = NULL; colorspace = CGColorSpaceCreateDeviceRGB(); - [self setWantsLayer:YES]; [self initializeSqueakColorMap]; } -- (void)setFrameSize:(NSSize)newSize { - [super setFrameSize: newSize]; - - int dividedWidthInteger = dividedWidth = (newSize.width/4.0); - int dividedHeightInteger= dividedHeight = (newSize.height/4.0); - - int lastTileWidth = newSize.width - dividedWidthInteger*3; - int lastTileHeight = newSize.height - dividedHeightInteger*3; - - CALayer *setupLayer = [CALayer layer]; - [setupLayer setOpaque: YES]; - setupLayer.frame = CGRectMake(0.0f,0.0f, newSize.width, newSize.height); - [self setLayer: setupLayer]; - - int h,v; - for (v=0;v<4;v++) { - for (h=0;h<4;h++) { - setupLayer = [CALayer layer]; - [setupLayer setOpaque: YES]; - - CGFloat usableWidth = dividedWidthInteger; - CGFloat usableHeight = dividedHeightInteger; - if (v == 0) - usableHeight = lastTileHeight; - if (h == 3) - usableWidth = lastTileWidth; - - setupLayer.frame = frameForQuartz[v][h] = CGRectMake(dividedWidthInteger*h,dividedHeightInteger*(3-v), usableWidth, usableHeight); -// NSLog(@" vhxywh %i %i %f %f %f %f",v,h,setupLayer.frame.origin.x,setupLayer.frame.origin.y,setupLayer.frame.size.width,setupLayer.frame.size.height); - [self.layer addSublayer: setupLayer]; - myLayer[v][h] = setupLayer; - dirty[v][h] = NO; - } - } +- (void) initializeVariables { } -- (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - if (self) { - // Initialization code here. - [self initializeVariables]; - } - return self; -} - - (void) dealloc { [super dealloc]; free(colorMap32); @@ -165,105 +124,149 @@ [((sqSqueakOSXApplication*) gDelegateApp.squeakApplication).squeakCursor performSelectorOnMainThread: @selector(set) withObject: nil waitUntilDone: NO]; } -/* - if (depth == 32) { - return [super createImageFrom: dispBitsIndex - depth: depth - colorspace: colorspace - pitch: pitch - affectedT: affectedT - affectedB: affectedB - affectedL: affectedL - affectedR: affectedR - height: height - width: width]; - } else { - return [[self getMainView] computeBitmapFromBitsIndex: dispBitsIndex - width:width - height:height - depth:depth - left:affectedL - right:affectedR - top:affectedT - bottom:affectedB]; - } +- (void) drawImageUsingClip: (CGRect) clip { + NSRect what = *(NSRect *) &clip; + [self setNeedsDisplayInRect: what]; +} - */ +- (void) drawThelayers { + if([[self window] viewsNeedDisplay]) { + [self displayIfNeeded]; +// NSLog(@"drawTheLayers flushHappened"); + glFinish(); + } + if (!firstDrawCompleted) { + firstDrawCompleted = YES; + if (getFullScreenFlag() == 0) + [self.window makeKeyAndOrderFront: self]; + } +} - -- (CGImageRef) createImageFrom: (void *) dispBitsIndex affectedT: (int) affectedT affectedB: (int) affectedB affectedL: (int) affectedL - affectedR: (int) affectedR height: (int) height width: (int) width { - const size_t depth = 32; - void *tempMemory; +-(void)setupOpenGL { + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glClearColor(1.0, 1.0, 1.0, 1.0); + glColor4f(1.0, 1.0, 1.0, 1.0); + glDisable(GL_TEXTURE_2D); - size_t pitch = ((((width)*(depth) + 31) >> 5) << 2); + glDisable(GL_DITHER); + glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + glDisable(GL_STENCIL_TEST); + glDisable(GL_FOG); + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glPixelZoom(1.0,1.0); - size_t totalSize = pitch * (affectedB-affectedT)-affectedL*4; - tempMemory = malloc(totalSize); - memcpy(tempMemory,(void*)dispBitsIndex+ pitch*affectedT + affectedL*4,totalSize); - CGDataProviderRef provider = CGDataProviderCreateWithData (NULL,tempMemory,(size_t) totalSize,MyProviderReleaseData); + glEnable(GL_TEXTURE_RECTANGLE_ARB); + glEnable(GL_UNPACK_CLIENT_STORAGE_APPLE); + glEnable(GL_APPLE_texture_range); + glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_PRIORITY, 0.0); + glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); + glTexParameteri(GL_APPLE_texture_range, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE); + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +- (void)loadTexturesFrom: (void*) lastBitsIndex subRectangle: (NSRect) subRect { + static int first=YES; + + NSRect r=[self frame]; + [[self openGLContext] makeCurrentContext]; + [[self openGLContext] update]; + if(!first) { + GLuint dt = 1; + glDeleteTextures(1, &dt); + } + + glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 1); + + glViewport( subRect.origin.x,subRect.origin.y, subRect.size.width,subRect.size.height ); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); - CGImageRef image = CGImageCreate((size_t) affectedR-affectedL,(size_t) affectedB-affectedT, (size_t) 8 /* bitsPerComponent */, - (size_t) depth /* bitsPerPixel */, - (size_t) pitch, colorspace, - (CGBitmapInfo) kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host , - provider, NULL, (bool) 0, kCGRenderingIntentDefault); + glPixelStorei( GL_UNPACK_ROW_LENGTH, r.size.width ); + char *subimg = ((char*)lastBitsIndex) + (unsigned int)(subRect.origin.x + (r.size.height-subRect.origin.y-subRect.size.height)*r.size.width)*4; + glTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, subRect.size.width, subRect.size.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, subimg ); + glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); +// NSLog(@" draw %f %f %f %f",subRect.origin.x,subRect.origin.y,subRect.size.width,subRect.size.height); - CGDataProviderRelease(provider); -// NSLog(@"cif pitch %i T %i L %i B %i R %i h %i w %i",pitch,affectedT,affectedL,affectedB,affectedR,height,width); - return image; } +-(void)defineQuad:(NSRect)r +{ + glBegin(GL_QUADS); + glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, 1.0f); + glTexCoord2f(0.0f, r.size.height); glVertex2f(-1.0f, -1.0f); + glTexCoord2f(r.size.width, r.size.height); glVertex2f(1.0f, -1.0f); + glTexCoord2f(r.size.width, 0.0f); glVertex2f(1.0f, 1.0f); + glEnd(); +} -- (void) drawImageUsingClip: (CGRect) clip { - int h,v; - for (v=0;v<4;v++) { - for (h=0;h<4;h++) { - dirty[v][h] = dirty[v][h] || CGRectIntersectsRect(myLayer[v][h].frame,clip); - } - } +- (void)update // moved or resized +{ + NSRect rect; + + [super update]; + + [[self openGLContext] makeCurrentContext]; + [[self openGLContext] update]; + + rect = [self bounds]; + + glViewport(0, 0, (int) rect.size.width, (int) rect.size.height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + [self setNeedsDisplay:true]; } +- (void)reshape // scrolled, moved or resized +{ + NSRect rect; + + [super reshape]; + + [[self openGLContext] makeCurrentContext]; + [[self openGLContext] update]; + + rect = [self bounds]; + + glViewport(0, 0, (int) rect.size.width, (int) rect.size.height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + [self setNeedsDisplay:true]; +} -- (void) drawThelayers { +-(void)drawRect:(NSRect)rect +{ +// NSLog(@" draw %f %f %f %f",rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); sqInt formObj = interpreterProxy->displayObject(); sqInt formPtrOop = interpreterProxy->fetchPointerofObject(0, formObj); void* dispBitsIndex = interpreterProxy->firstIndexableField(formPtrOop); - CGRect rect; - [CATransaction begin]; - [CATransaction setValue: (id)kCFBooleanTrue forKey: kCATransactionDisableActions]; - int h,v; - for (v=0;v<4;v++) { - for (h=0;h<4;h++) { - if (dirty[v][h]) { - CGRect ff = myLayer[v][h].frame; - - rect.origin.x = myLayer[v][h].frame.origin.x; - rect.origin.y = self.frame.size.height-myLayer[v][h].frame.origin.y-myLayer[v][h].frame.size.height; - rect.size.height = myLayer[v][h].frame.size.height; - rect.size.width = myLayer[v][h].frame.size.width; - -// NSLog(@" dtl vhxywh %i %i %f %f %f %f",v,h,rect.origin.x,rect.origin.y,rect.size.width,rect.size.height); - CGImageRef x= [self createImageFrom: dispBitsIndex - affectedT: rect.origin.y - affectedB: rect.origin.y+rect.size.height - affectedL: rect.origin.x - affectedR: rect.origin.x+rect.size.width - height: (int) self.frame.size.height - width: (int) self.frame.size.width]; - myLayer[v][h].contents = (id)x; - CGImageRelease(x); - dirty[v][h] = NO; - } + static int inited=NO; + if ( dispBitsIndex ) { + [[self openGLContext] makeCurrentContext]; + if (!inited) { + [self setupOpenGL]; + inited=YES; } - } - [CATransaction commit]; - if (!firstDrawCompleted) { - firstDrawCompleted = YES; - if (getFullScreenFlag() == 0) - [self.window makeKeyAndOrderFront: self]; - } - + [self loadTexturesFrom:dispBitsIndex subRectangle: rect]; + [self defineQuad:rect]; + } } - (void)mouseEntered:(NSEvent *)theEvent { @@ -476,7 +479,10 @@ else encode( (isFunctionKey ? 1 : 28), (isFunctionKey ? 115 : 123), moveToLeftEndOfLine:) else encode( (isFunctionKey ? 4 : 29), (isFunctionKey ? 119 : 124), moveToRightEndOfLine:) - + + else encode( (isFunctionKey ? 1 : 28), (isFunctionKey ? 115 : 123), moveToLeftEndOfLineAndModifySelection:) + else encode( (isFunctionKey ? 4 : 29), (isFunctionKey ? 119 : 124), moveToRightEndOfLineAndModifySelection:) + else encode( 1, 115, scrollToBeginningOfDocument:) else encode( 4, 119, scrollToEndOfDocument:) @@ -627,6 +633,7 @@ launchSpec.asyncRefCon = NULL; OSErr err = LSOpenFromURLSpec(&launchSpec, NULL); +#pragma unused(err) } } @@ -711,3 +718,71 @@ } @end + + +/*GL_TEXTURE_RECTANGLE_ARB + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, (int)r.size.width,(int)r.size.height, + 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void*)lastBitsIndex); + */ + +/* glPixelStorei( GL_UNPACK_ROW_LENGTH, r.size.width ); + glPixelStorei( GL_UNPACK_SKIP_PIXELS, subRect.origin.x ); + glPixelStorei( GL_UNPACK_SKIP_ROWS, subRect.origin.y ); + glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, (int)subRect.size.width,(int)subRect.size.height,0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void*)lastBitsIndex ); + + NSLog(@" draw %f %f %f %f",subRect.origin.x,subRect.origin.y,subRect.size.width,subRect.size.height); + + glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); + glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); + */ +/* void glTexImage2D( GLenum target, + GLint level, + GLint internalformat, + GLsizei width, + GLsizei height, + GLint border, + GLenum format, + GLenum type, + const GLvoid *pixels ); + + void glTexSubImage2D( GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid *pixels ) + + + glPixelStorei(GL_UNPACK_ROW_LENGTH, r.size.width); + glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, + 0, + (int) subRect.origin.x, + (int) subRect.origin.y, + (int) subRect.size.width, + (int) subRect.size.height, + GL_BGRA, + GL_UNSIGNED_INT_8_8_8_8_REV, + (void*)lastBitsIndex); + + glPixelStorei( GL_UNPACK_ROW_LENGTH, img_width ); + char *subimg = (char*)m_data + (sub_x + sub_y*img_width)*4; + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, sub_width, sub_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, subimg ); + glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + + GLES for iphone + no GL_UNPACK_ROW_LENGTH. In which case, you could either (a) extract the subimage into a new buffer yourself, or (b)... + + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, sub_width, sub_height, 0, GL_RGBA, GL_UNSIGNED_BYTES, NULL ); + + for( int y = 0; y < sub_height; y++ ) + { + char *row = m_data + ((y + sub_y)*img_width + sub_x) * 4; + glTexSubImage2D( GL_TEXTURE_2D, 0, 0, y, sub_width, 1, GL_RGBA, GL_UNSIGNED_BYTE, row ); + } + + */ Modified: trunk/platforms/iOS/vm/OSX/sqSqueakOSXScreenAndWindow.m =================================================================== --- trunk/platforms/iOS/vm/OSX/sqSqueakOSXScreenAndWindow.m 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/OSX/sqSqueakOSXScreenAndWindow.m 2010-08-28 04:28:15 UTC (rev 2264) @@ -57,12 +57,6 @@ [super dealloc]; } -- (void) postIoForceDisplayUpdateUsingRectangle: (CGRect) retanglePending { - NSRect r; - memcpy(&r,&retanglePending,sizeof(NSRect)); - [[self getMainView] setNeedsDisplayInRect: r]; -} - - (void) ioSetFullScreen: (sqInt) fullScreen { [[self getMainView] ioSetFullScreen: fullScreen]; } @@ -73,5 +67,9 @@ return false; } +- (void) ioForceDisplayUpdateActual { + self.forceUpdateFlush = NO; + [[self getMainView] drawThelayers]; +} @end Modified: trunk/platforms/iOS/vm/SqueakPureObjc-Info 64*64.plist =================================================================== --- trunk/platforms/iOS/vm/SqueakPureObjc-Info 64*64.plist 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/SqueakPureObjc-Info 64*64.plist 2010-08-28 04:28:15 UTC (rev 2264) @@ -460,7 +460,7 @@ <key>CFBundleName</key> <string>Squeak VM Host 64/64bits</string> <key>CFBundleGetInfoString</key> - <string>Squeak VM 5.7b1 64/64 bits http://www.squeak.org</string> + <string>Squeak VM 5.7b3 64/64 bits http://www.squeak.org</string> <key>CFBundleIconFile</key> <string>Squeak.icns</string> <key>CFBundleIdentifier</key> @@ -470,11 +470,11 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>5.7b1</string> + <string>5.7b3</string> <key>CFBundleSignature</key> <string>FAST</string> <key>CFBundleVersion</key> - <string>19.0</string> + <string>21.0</string> <key>LSBackgroundOnly</key> <false/> <key>LSMinimumSystemVersion</key> Modified: trunk/platforms/iOS/vm/SqueakPureObjc-Info.plist =================================================================== --- trunk/platforms/iOS/vm/SqueakPureObjc-Info.plist 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/SqueakPureObjc-Info.plist 2010-08-28 04:28:15 UTC (rev 2264) @@ -350,7 +350,7 @@ <key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string> <key>CFBundleGetInfoString</key> - <string>Squeak VM 5.7b2 http://www.squeak.org</string> + <string>Squeak VM 5.7b3 http://www.squeak.org</string> <key>CFBundleIconFile</key> <string>Squeak.icns</string> <key>CFBundleIdentifier</key> @@ -362,11 +362,11 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>5.7b2</string> + <string>5.7b3</string> <key>CFBundleSignature</key> <string>FAST</string> <key>CFBundleVersion</key> - <string>20.0</string> + <string>21.0</string> <key>LSBackgroundOnly</key> <false/> <key>LSMinimumSystemVersion</key> Modified: trunk/platforms/iOS/vm/SqueakPureObjc-InfoCOG.plist =================================================================== --- trunk/platforms/iOS/vm/SqueakPureObjc-InfoCOG.plist 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/SqueakPureObjc-InfoCOG.plist 2010-08-28 04:28:15 UTC (rev 2264) @@ -350,7 +350,7 @@ <key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string> <key>CFBundleGetInfoString</key> - <string>Squeak VM 5.8b3 http://www.squeak.org</string> + <string>Squeak VM 5.8b4 http://www.squeak.org</string> <key>CFBundleIconFile</key> <string>Squeak.icns</string> <key>CFBundleIdentifier</key> @@ -362,11 +362,11 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>5.8b3</string> + <string>5.8b4</string> <key>CFBundleSignature</key> <string>FAST</string> <key>CFBundleVersion</key> - <string>21.0</string> + <string>22.0</string> <key>LSBackgroundOnly</key> <false/> <key>LSMinimumSystemVersion</key> Modified: trunk/platforms/iOS/vm/iPhone/sqMacV2Memory.c =================================================================== --- trunk/platforms/iOS/vm/iPhone/sqMacV2Memory.c 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/iPhone/sqMacV2Memory.c 2010-08-28 04:28:15 UTC (rev 2264) @@ -80,7 +80,7 @@ static size_t pageSize; static size_t pageMask; - usqInt sqAllocateMemoryMac(sqInt minHeapSize, sqInt *desiredHeapSize, FILE * f,usqInt headersize) { + usqInt sqAllocateMemoryMac(usqInt desiredHeapSize, sqInt minHeapSize, FILE * f,usqInt headersize) { void *possibleLocation,*startOfAnonymousMemory; off_t fileSize; struct stat sb; Modified: trunk/platforms/iOS/vm/iPhone/sqPlatformSpecific.h =================================================================== --- trunk/platforms/iOS/vm/iPhone/sqPlatformSpecific.h 2010-08-25 21:48:56 UTC (rev 2263) +++ trunk/platforms/iOS/vm/iPhone/sqPlatformSpecific.h 2010-08-28 04:28:15 UTC (rev 2264) @@ -79,7 +79,7 @@ void sqFilenameFromString(char *buffer,sqInt fileIndex, long fileLength); #undef allocateMemoryMinimumImageFileHeaderSize #undef sqImageFileReadEntireImage -usqInt sqAllocateMemoryMac(sqInt minHeapSize, sqInt *desiredHeapSize, FILE * f,usqInt headersize); +usqInt sqAllocateMemoryMac(usqInt desiredHeapSize,sqInt minHeapSize, FILE * f,usqInt headersize); #define allocateMemoryMinimumImageFileHeaderSize(heapSize, minimumMemory, fileStream, headerSize) \ sqAllocateMemoryMac(heapSize, minimumMemory, fileStream, headerSize) |
Free forum by Nabble | Edit this page |