小编spu*_*fle的帖子

在不同的屏幕上绘制可可会失去性能

我有一个基于文档的应用程序,其中每个文档都有一个带有NSScrollView的窗口,它只使用Cocoa进行一些(相当连续的)绘图.

要调用绘图,我使用的是CVDisplayLink,如下面的代码所示:

- (void)windowControllerDidLoadNib:(NSWindowController *) aController {
     //other stuff...
     [self prepareDisplayLink]; //For some reason putting this in awakeFromNib crashes
}

//Prep the display link.
- (void)prepareDisplayLink {
    CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
    CVDisplayLinkSetCurrentCGDisplay(displayLink, ((CGDirectDisplayID)[[[[[self windowForSheet]screen]deviceDescription]objectForKey:@"NSScreenNumber"]intValue]));
    CVDisplayLinkSetOutputCallback(displayLink, &MyDisplayLinkCallback, self);
}

//Callback to draw frame
static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext)
{
    NSAutoreleasePool *pool =[[NSAutoreleasePool alloc]init];
    CVReturn result = [(ScrollView*)displayLinkContext getFrameForTime:outputTime];
    [pool drain];
    return result;
}

//Drawing function:
- (CVReturn)getFrameForTime:(const CVTimeStamp*)outputTime
{
    [scrollView lockFocusIfCanDraw];
    [self addToCurrentPostion:(dist/time)*CVDisplayLinkGetActualOutputVideoRefreshPeriod(displayLink)]; …
Run Code Online (Sandbox Code Playgroud)

cocoa screen nsview core-video cadisplaylink

34
推荐指数
1
解决办法
1383
查看次数

64位Quicktime问题

有没有人知道是否有办法从Quicktime .mov文件中提取原始的,仍然压缩的音频和视频样本,使用针对Mac的Apple API/Framework,可以在64位本地编译(IE:QTKit )?我知道这个功能在Apple的QuickTime Framework中可用,它以Mac为目标,但是这个框架只能在32位下编译.

如果有人熟悉这样的框架和任何相关的示例代码,我们将非常感谢您的一些见解.

谢谢,乔希

macos 64-bit quicktime sample objective-c

9
推荐指数
1
解决办法
947
查看次数

在调整视图大小之前,不会显示新的CALayer.contents

我有一个CALayer需要显示视频帧.每次渲染一个帧(作为a CGImageRef)时,都会调用此方法:

- (void)displayFrame:(CGImageRef)frame {
    [view layer].contents = (id)frame;
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是,这首先不会显示任何东西.每次view调整大小时,frame都会显示一个新的,但直到view再次调整大小.

我该如何解决?

cocoa core-animation objective-c calayer cgimage

4
推荐指数
1
解决办法
2751
查看次数

Core Foundation对象和保留/释放消息

假设我们有一些Core Foundation对象,例如CGColorRef,添加到NSArray这样的对象:

CGColorRef color = ...;
NSArray *array = [NSArray arrayWithObject:(id)color];
Run Code Online (Sandbox Code Playgroud)

由于数组保留其内容,因此color收到retain消息(不是CFRetain()吗?).从内存管理的角度来看,在这种情况下会发生什么?

cocoa memory-management objective-c core-foundation

2
推荐指数
1
解决办法
2350
查看次数