On 9 Dec 2013, at 7:03 pm, Seth Willits <sli...@araelium.com> wrote:
> If all the drawRect is doing is making a single call to CGContextDrawImage > then it should rightly be 100% of the time, so that measure isn’t interesting > on its own. :) Yes, that’s true. It’s hard to be totally objective, because running Instruments against the app involves some manual input like scrolling, which is hard to reproduce accurately each time without writing a complicated test, but it looks as if it’s roughly 4 times slower when I enable the threaded code (and there I was hoping it would be 4x faster, being the number of cores I have ;-). > You must be passing in incorrect values. It will work. I’ve done this before > and I just tested it now and I’m not getting any assertions like you are. > > If your backing is 1600 x 800, and you want a context for the left half and > another for the right half both have bytesPerRow values of 1600 * 4, a width > of 800, and heigh of 800. The only thing that is different is the buffer > offset. The first one is at 0 and the second at 800 * 4. It may feel odd > because the second context specifies that the last row is 1600 * 4 bytes > wide, but thanks to initial offset and real buffer size is only 800 * 4 wide, > but CG won't try to read or write to those bytes in rows that are after width > * bytesPerPixel, so it really is safe. This sounds like what I was doing, so I’ll check again and make sure my values are really correct - I may well have made a mistake. > The single CGContextDrawImage in drawRect: should end up essentially being a > memcpy which will be ridiculously fast, as long as your contexts/backing all > use the same color space and bitmap layout as the view’s context’s backing. > Definitely make sure they’re using the same color space because converting is > really slow. But how can you do that? There’s no CGContextGetColorspace function, except for a bitmap context, and the context that’s current when drawRect: is entered does not seem to be a bitmap context. I would have expected it to be, but it returns nil for all of the CGBitmapContextxxx functions, so my assumption is it’s a private variant. Same goes for the format, even if it has one. I’m using the genericRGB colourspace and premultiplied alpha first for my own contexts. —Graham _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com