Note that there are some explanatory texts on larger screens.

plurals
  1. PO-(void) drawRect:(CGRect)rect; is using up nearly all of iPhone CPU
    primarykey
    data
    text
    <pre><code>- (void)drawRect:(CGRect)rect{ float sliceSize = rect.size.width / imagesShownAtOnce; //Apply our clipping region and fill it with black [clippingRegion addClip]; [clippingRegion fill]; //Draw the 3 images (+1 for inbetween), with our scroll amount. CGPoint loc; for (int i=0;i&lt;imagesShownAtOnce+1;i++){ loc = CGPointMake(rect.origin.x+(i*sliceSize)-imageScroll, rect.origin.y); [[buttonImages objectAtIndex:i] drawAtPoint:loc]; } //Draw the text region background [[UIColor blackColor] setFill]; [textRegion fillWithBlendMode:kCGBlendModeNormal alpha:0.4f]; //Draw the actual text. CGRect textRectangle = CGRectMake(rect.origin.x+16,rect.origin.y+rect.size.height*4/5.6,rect.size.width/1.5,rect.size.height/3); [[UIColor whiteColor] setFill]; [buttonText drawInRect:textRectangle withFont:[UIFont fontWithName:@"Avenir-HeavyOblique" size:22]]; } </code></pre> <p><code>clippingRegion</code> and <code>textRegion</code> are <code>UIBezierPaths</code> to give me the rounded rectangles I want (First for a clipping region, 2nd as an overlay for my text)</p> <p>The middle section is drawing 3 images and letting them scroll along, which im updating every 2 refreshes from a <code>CADisplayLink</code>, and that invalidates the draw region by calling <code>[self setNeedsDisplay]</code>, and also increasing my imageScroll variable.</p> <hr> <p>Now that that background information is done, here is my issue:</p> <p>It runs, and even runs smoothly. But it is using up an absolutely high amount of CPU time (80%+)!! How do I push this off to the GPU on the phone instead? Someone told me about CALayers but I've never dealt with them before</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload