X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FDarwin.cc;h=068b766b6b54c34cc4702e59a0b79066fa1bcbff;hb=38786988d12f2c48a314ee37c326965ff0bcadb6;hp=b923803543a848eac3b5ad76d96695c0fb055ed8;hpb=4a63a18b271c93fd8214e5f1d56428ba3363f9a6;p=org.ibex.core.git diff --git a/src/org/xwt/plat/Darwin.cc b/src/org/xwt/plat/Darwin.cc index b923803..068b766 100644 --- a/src/org/xwt/plat/Darwin.cc +++ b/src/org/xwt/plat/Darwin.cc @@ -9,8 +9,6 @@ #define __private_extern__ #include -//#include -//#include #include "POSIX.cc" #include "OpenGL.cc" @@ -21,15 +19,16 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #include #include +#include #include "DarwinCarbonHeaders.h" @@ -469,7 +468,7 @@ OSStatus our_windowEventHandler(EventHandlerCallRef handler, EventRef e, void *u switch(eKind) { case kEventWindowUpdate: { - surface->Dirty(0,0,surface->root->width,surface->root->height); + surface->Dirty(0,0,surface->root->width,surface->root->height); return noErr; } case kEventWindowBoundsChanged: { @@ -536,34 +535,22 @@ void Darwin$CarbonSurface::natInit(jboolean framed) { // FIXME: unframed windows should appear in the window menu // This probably needs a hack similar to whats in Cocoa.mm WindowAttributes attr = kWindowStandardHandlerAttribute| - (framed ? kWindowInWindowMenuAttribute|kWindowStandardDocumentAttributes|kWindowLiveResizeAttribute/*|kWindowMetalAttribute*/ : 0); + (framed ? kWindowInWindowMenuAttribute|kWindowStandardDocumentAttributes|kWindowLiveResizeAttribute : 0); OSStatus r; rect.top = 0; rect.left = 0; rect.bottom = 10; rect.right=10; r = CreateNewWindow(wc,attr,&rect,&window); checkStatus(r,"CreateNewWindow"); - /* - // setBackingType - NSString* - Class NSWindowClass = NSClassFromString - NSWindowClass->methodLists - - void *iterator = 0; // Method list (category) iterator - struct objc_method_list* mlist; - Method currMethod; - int j; - while ( mlist = class_nextMethodList( NSWindowClass, &iterator ) ) { - for ( j = 0; j < mlist->method_count; ++j ) { - currMethod = (mlist->method_list + j); - if (strcmp((const char *)currMethod->method_name, "setBackingStore")) { - IMP imp = currMethod->method_imp; - (*imp)(NSWindowInstance, currMethod->method_name, 0); - // do stuff - } - } - } - NSWindow* window = - */ + + id NSWindowClass = objc_getClass("NSWindow"); + printf("nswindowclass is %x\n", NSWindowClass); + SEL selector = sel_registerName("initWithWindowRef"); + printf("selector is %s\n", selector); + objc_method method = class_getClassMethod(NSWindowClass, selector); + printf("method is %x\n", method); + id windowInstance = objc_msgSend(NSWindowClass, selector, window); + printf("instance is %x\n", windowInstance); + GCJ$Retainer::retain(this); // Need to account for the EventHandlers pointer to us EventHandlerUPP upp = NewEventHandlerUPP(our_windowEventHandler); @@ -730,9 +717,9 @@ void Darwin::natSetClipBoard(jstring js) { checkStatus(r,"PutScrapFlavor"); } -Proxy *Darwin::natDetectProxy() { - using org::xwt::Proxy; - Proxy *p=0; +HTTP$Proxy *Darwin::natDetectProxy() { + using org::xwt::HTTP$Proxy; + HTTP$Proxy *p=0; CFStringRef string; CFNumberRef number; SmartCFString smartString; @@ -751,7 +738,7 @@ Proxy *Darwin::natDetectProxy() { number = (CFNumberRef) CFDictionaryGetValue(proxyInfo, kSCPropNetProxies ## proto ## Port); \ if(number != NULL && CFGetTypeID(number) != CFNumberGetTypeID()) number = NULL; \ if(string && number && CFNumberGetValue(number,kCFNumberIntType,&i) && i) { \ - if(!p) p = new Proxy(); \ + if(!p) p = new HTTP$Proxy(); \ p->var ## ProxyHost = cfStringToJString(string); \ p->var ## ProxyPort = i; \ } \ @@ -922,7 +909,7 @@ void Darwin$CarbonOpenGL::initSharedContext() { checkStatus(rawSharedContext,"aglCreateContext"); } -void Darwin$GLCarbonDoubleBuffer::natInit() { +void Darwin$GLCarbonPixelBuffer::natInit() { WindowClass wc = kPlainWindowClass; WindowAttributes attr = 0; WindowRef window; @@ -940,23 +927,21 @@ void Darwin$GLCarbonDoubleBuffer::natInit() { r = CreateNewWindow(wc,attr,&rect,&window); checkStatus(r,"CreateNewWindow"); - + shared = (AGLContext) gl->rawSharedContext; fmt = (AGLPixelFormat) gl->rawPixelFormat; ctx = aglCreateContext(fmt,shared); checkStatus(ctx, "aglCreateContext"); - b = aglSetDrawable(ctx, GetWindowPort(window)); + b = aglSetDrawable(ctx,GetWindowPort(window)); checkStatus(b,"aglSetDrawable"); aglSetCurrentContext(ctx); aglUpdateContext(ctx); - drawableInit(OpenGL::roundToPowerOf2(width), - OpenGL::roundToPowerOf2(height)); + drawableInit(width,height); glClear(GL_COLOR_BUFFER_BIT); aglSetCurrentContext(shared); - target = rectTexture ? GL_TEXTURE_RECTANGLE_EXT : GL_TEXTURE_2D; glEnable(target); glGenTextures(1,&tex); @@ -964,10 +949,6 @@ void Darwin$GLCarbonDoubleBuffer::natInit() { glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); aglSurfaceTexture (shared, target, GL_RGBA, ctx); - /* - glReadBuffer - glCopyTexImage2D(target, 0, GL_RGBA, 0, 0, width, height, 0); - */ checkGLError(); glDisable(target); @@ -977,19 +958,19 @@ void Darwin$GLCarbonDoubleBuffer::natInit() { rawCTX = (RawData*) ctx; } -void Darwin$GLCarbonDoubleBuffer::activateContext() { +void Darwin$GLCarbonPixelBuffer::activateContext() { AGLContext ctx = (AGLContext) rawCTX; aglSetCurrentContext(ctx); } -void Darwin$GLCarbonDoubleBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) { +void Darwin$GLCarbonPixelBuffer::natCleanup(RawData* rawWindowRef, RawData* rawCTX) { WindowRef window = (WindowRef) rawWindowRef; AGLContext ctx = (AGLContext) rawCTX; aglDestroyContext(ctx); DisposeWindow(window); } -void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonDoubleBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) { +void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, jint sy1, jint dx1, jint dy1, jint dx2, jint dy2) { AGLContext ctx = (AGLContext) rawCTX; int sx2 = sx1 + (dx2-dx1); int sy2 = sy1 + (dy2-dy1); @@ -1001,7 +982,7 @@ void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonDoubleBuffer *db, jint sx1, if(db->rectTexture) { glEnable(GL_TEXTURE_RECTANGLE_EXT); checkGLError(); - glBindTexture(GL_TEXTURE_RECTANGLE_EXT, (GLuint)db->textureName); + glBindTexture(GL_TEXTURE_RECTANGLE_EXT, db->textureName); checkGLError(); glBegin(GL_QUADS); glTexCoord2i (sx1, sy1 ); @@ -1025,10 +1006,7 @@ void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonDoubleBuffer *db, jint sx1, glColor4f(1.0f,1.0f,1.0f,1.0f); glEnable(GL_TEXTURE_2D); - GLuint tname; - glGenTextures(1, &tname); - glBindTexture(GL_TEXTURE_2D, tname); - aglSurfaceTexture (ctx, GL_TEXTURE_2D, GL_RGBA, (AGLContext)db->rawCTX); + glBindTexture(GL_TEXTURE_2D, db->textureName); checkGLError(); glBegin(GL_QUADS); glTexCoord2f (tx1, ty1 );