2015-07-21 1 views
0

Edit: J'ai reçu un downvote, et je voulais juste m'assurer que c'était parce que je n'ai pas demandé aux forums de développement (ce que j'ai fait, https://forums.developer.apple.com/thread/11593, mais je n'ai reçu aucune réponse). C'est un très gros problème pour nous, alors j'ai pensé qu'il serait préférable de lancer une ligne large, peut-être que quelqu'un peut aider.`-drawInRect` semble être différent dans 10.11? Qu'est-ce qui aurait pu changer?

Nous avons une application qui fonctionne en 10.10, mais a ce problème en 10.11. Nous appelons -drawRect dans un NSGraphicsContext sur un NSImage qui est réglé correctement dans les deux OS

Mais cette 10,11 NSImage ne pas drainée. Je suis assez novice, mais j'ai débogué pendant un bon moment pour arriver là où je suis maintenant, et je suis simplement bloqué. Était voir si quelqu'un a déjà rencontré cela, ou a une idée de pourquoi cela pourrait être.

Voici le code pertinent: (l'objet layer est un CGLayerRef qui est passé dans ce procédé, à partir de la méthode -drawRect) Voici comment la couche est instancié:

NSRect scaledRect = [Helpers scaleRect:rect byScale:[self backingScaleFactorRelativeToZoom]]; 

    CGSize size = NSSizeToCGSize(rect.size); 
size_t width = size.width; 
size_t height = size.height; 
size_t bitsPerComponent = 8; 
size_t bytesPerRow = (width * 4+ 0x0000000F) & ~0x0000000F;/ 
size_t dataSize = bytesPerRow * height; 
    void* data = calloc(1, dataSize); 

CGColorSpaceRef colorspace = [[[_imageController document] captureColorSpace] CGColorSpace]; 
CGContextRef bitmapContext = CGBitmapContextCreate(data, width, height, bitsPerComponent, bytesPerRow, colorspace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host); 
    CGLayerRef canvasLayer = CGLayerCreateWithContext(bitmapContext, scaledRect.size, NULL); 

Voici la méthode qui dessine l'image:

CGContextRef mainLayerContext = CGLayerGetContext(layer); 
    NSRect scaledBounds = [contextInfo[kContextInfoBounds] rectValue]; 
    if(!_flatCache) 
    {  
     _flatCache = CGLayerCreateWithContext(mainLayerContext, scaledBounds.size, NULL); 
     CGContextRef flatCacheCtx = CGLayerGetContext(_flatCache); 

     CGLayerRef tempLayer = CGLayerCreateWithContext(flatCacheCtx, scaledBounds.size, NULL); 
     CIImage *tempImage = [CIImage imageWithCGLayer:tempLayer]; 
     NSLog(@"%@",tempImage); 
     CGContextRef tempLayerCtx = CGLayerGetContext(tempLayer); 

     CGContextTranslateCTM(tempLayerCtx, -scaledBounds.origin.x, -scaledBounds.origin.y); 

     [NSGraphicsContext saveGraphicsState]; 
     NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:tempLayerCtx flipped:NO]; 
     [NSGraphicsContext setCurrentContext:newContext]; 

     if ([_imageController background]) 
     { 
     NSRect bgRect = { [_imageController backgroundPosition], [_imageController backgroundSize] }; 
     bgRect = [Helpers scaleRect:bgRect byScale:[self backingScaleFactorRelativeToZoom]]; 
     [[_imageController background] drawInRect:bgRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; 
     } 

     CIImage *tempImage2 = [CIImage imageWithCGLayer:tempLayer]; 
     NSLog(@"%@",tempImage2); 

En 10,10 et 10,11, tempImage est une image vide en poids/la taille correcte.
Dans 10,10 tempImage2 a maintenant [_imageController background] correctement tiré
Dans 10,11 tempImage2 est le même que tempImage, une image vierge w/la taille correcte

Malheureusement, la personne qui a écrit à l'origine, ce code est maintenant disparu , et je suis trop novice pour aller creuser plus bas sans trouver un livre et le lire.

bgRect n'est pas le problème, déjà essayé de modifier cela autour. J'ai également joué avec les arguments -translate, mais ne pouvait toujours rien apprendre.

Est-ce que quelqu'un sait comment je pourrais déboguer cela pour trouver le problème? Ou mieux encore, est-ce que quelqu'un a vu ce problème et sait quel est mon problème?

+0

Arrêtez de demander que ici, idiot. –

+0

J'ai demandé aux forums de développement, aucune réponse pour le moment. Assez désespéré, a frappé un mur de briques: \ Figured il ne ferait pas mal au cas où le hasard quelqu'un a vu cela aussi. Je ne pense pas que je viole toutes les règles de SO, même si la question ne répond pas –

Répondre

0

Juste besoin d'ajouter cette ligne:

//`bounds` calculated from the size of the image 
//mainLayerContext and flatCache defined above in question ^^ 
CGContextDrawLayerInRect(mainLayerContext, bounds, _flatCache); 

tout à la fin