4

I am trying to draw a static CIImage using CIContext drawImage in the drawRect of a GLKView, however I am getting about 4 frames per second. Suggestions for improvement?

// 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];
}
jjxtra
  • 20,415
  • 16
  • 100
  • 140
  • I am having the same issue. What surprised me was the amount of CPU that the drawImage:inRect:fromRect: method takes. If you found a solution, please let me know! – Jorge Sep 09 '13 at 20:52
  • @Jorge no luck, we ended up scrapping the animated image and just using a static UIImageView with one image. – jjxtra Sep 09 '13 at 21:04
  • Are you testing this in the simulator when monitoring FPS? – joelg Mar 20 '15 at 22:05
  • It shouldn't be hitting the CPU at all. Did you run Instruments' Time Profiler to see what the issue was? – SushiGrass Jacob May 22 '15 at 18:55
  • @SushiGrassJacob I never did and I no longer work for the company this project was done at. – jjxtra May 22 '15 at 22:13

0 Answers0