Re: CompositeToPoint - avoid its use?
Re: CompositeToPoint - avoid its use?
- Subject: Re: CompositeToPoint - avoid its use?
- From: "Ken Ferry" <email@hidden>
- Date: Fri, 17 Oct 2008 21:27:04 -0700
The composite methods are not more efficient. It isn't possible to 'ignore'
the current transform matrix - it's possible to do further calculation to
undo (parts of) its effects. This is what the composite methods do.
The primary reason to avoid the composite methods is that they have
surprising semantics. Normally, all drawing is with respect to the
coordinate system set up in -[NSGraphicsContext currentContext]. Unlike
everything else, before drawing, the composite methods manipulate the
current transformation matrix to be the identity matrix (or more accurately,
the identity scaled up by the default user space scale factor – think
default window scaling with resolution independence). That basically means
that in a scaled or rotated view, composite methods draw as if the view is
not scaled or rotated, though it can means something different if drawing to
something other than the window itself.
This isn't usually what one is really after. In fact, if anyone is using
the composite methods intentionally to get this effect, I'd like to hear
about it!
Often people use these methods because they seem to produce right-side-up
drawing in flipped views (though you still branch your layout on the
flippedness, since the point you pass to compositeToPoint: becomes the
visual bottom of the image). I gave a less surprising method of doing that
in <http://lists.apple.com/archives/cocoa-dev/2008/Oct/msg01266.html>.
This reply is a little bit complicated. That's because the methods are,
which is the point. :-)
-Ken
Cocoa Frameworks
On Fri, Oct 17, 2008 at 9:04 PM, Matt <email@hidden> wrote:
> Recently found this in the Apple NSImage docs re: CompositeToPoint method:
>
> "Important: If you are writing new code, or updating old code, you
> should avoid using this method. Instead, you should use the
> drawAtPoint:fromRect:operation:fraction: or
> drawInRect:fromRect:operation:fraction: method to draw the image.
> Although the method itself is not deprecated, the behavior it provides
> is not recommended for general use."
>
> I am currently using compositeToPoint extensively in one of my
> projects because I read in the apple drawing guide that it is more
> efficient since it ignores some extra checks like bounds and view
> rotation, etc.
>
> I have had trouble finding any other details on the above warning in
> the docs. Does anyone have any information they might be able to share
> on why 'compositeToPoint' is 'not recommended for general use'?
>
> Thanks in advance,
> -Matt
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden