Note that there are some explanatory texts on larger screens.

plurals
  1. POQuartz2D and Clipping - Optimize this drawing routine?
    primarykey
    data
    text
    <p>I'm new to Quartz2d so I hope this is an easy question to answer. </p> <p>I have a scrollview whose content frame is 1024x768. Within this I push a custom view (with frame 1024x768) that uses Quartz2d to do some drawing. The idea is, I have a large area that the user can scroll around to see different parts.</p> <p>The problem I'm having is, when I scroll on the device I get memory warning errors or terrible scrolling performance. This is no doubt because I am re-drawing the entire 1024x768 field. I thought that setting the clipping path to the UIScrollView offset would help.. and it does.. until i scroll.. in which case the view does not redraw until scrolling stops. telling the view to draw during scrollViewDidScroll also results in bad performance</p> <p>can anyone tell me how i can optimize my drawing routine?</p> <p>i have two images.. one of which is getting masked, and both being painted to the screen (one on top of the other)</p> <p><code> - (void)drawRect:(CGRect)dirtyRect {</p> <pre><code>CGContextRef myContext = UIGraphicsGetCurrentContext(); // get our offset (where we've scrolled to) CGPoint offset = scrollView.contentOffset; // clip to our offset.. uncomment for good performance but terrible scrolling //CGContextClipToRect(myContext, CGRectMake(offset.x, offset.y, 480, 320)); // make an image from the mask context CGImageRef aMaskImage = CGBitmapContextCreateImage (myMaskContext); // mask the first image CGImageRef aImage = CGImageCreateWithMask(myImageRef1, aMaskImage); CGContextDrawImage(myContext, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), myImageRef1); CGContextDrawImage(myContext, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), aImage); CGImageRelease(aImage); CGImageRelease(aMaskImage); </code></pre> <p>}</p> <p></code></p> <p>thanks in advance for any help you can provide!</p>
    singulars
    1. This table or related slice is empty.
    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