CIContext drawImage非常慢

时间:2013-08-12 21:25:06

标签: ios opengl-es core-image glkit

我试图在GLKView的drawRect中使用CIContext drawImage绘制静态CIImage,但是我每秒大约需要4帧。建议改进?

// init code
self.backgroundColor = UIColor.black;
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
self.ciContext = [CIContext contextWithEAGLContext:self.context options:@{ kCIContextOutputColorSpace: (__bridge id)cs, kCIContextWorkingColorSpace: (__bridge id)cs }];
self.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
self.drawableDepthFormat = GLKViewDrawableDepthFormatNone;
self.drawableMultisample = GLKViewDrawableMultisampleNone;
self.drawableStencilFormat = GLKViewDrawableStencilFormatNone;

// draw code    
- (void) drawRect:(CGRect)r
{
    // Clears the screen to a black color
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);

    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

    [self.ciContext drawImage:self.ciImage
                       inRect:self.bounds
                     fromRect:self.bounds];
}

0 个答案:

没有答案