0

I am drawing a rounded image in the centre of my custom view by creating a rounded NSBezierPath and adding it to the clipping region of the graphics context. This is working well, but I'm wondering if I can improve the performance of drawing the background of the view (the area outside of the rounded centred image) but inverting this clip and performing the background draw (an NSGradient fill).

Can anyone suggest a method of inverting a clip path?

trojanfoe
  • 120,358
  • 21
  • 212
  • 242

2 Answers2

1

You won't improve the drawing performance of the background by doing this. If anything, using a more complex clipping path will slow down drawing.

If you want to draw objects over a background without significant overhead of redrawing the background, you could use Core Animation layers as I explained in my answer to this question.

Community
  • 1
  • 1
Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
  • Thank you - that's good to know. I am restricting the background drawing to times when `dirtyRect` isn't wholly within my image and I will look into `CALayer` as well. – trojanfoe Feb 25 '12 at 09:33
0

Regardless of performance, this question comes first when you try to invert clip.

So if that's what you're looking for: Using NSBezierPath addClip - How to invert clip

Community
  • 1
  • 1
Avishay Cohen
  • 2,418
  • 1
  • 22
  • 40