4

Because of various reasons, I am considering to make my own implementation of CATiledLayer. I have done some investigation, but I don't seem to be able to figure out how CATiledLayer knows which tile to provide. For example, when you scroll the layer, setPosition: or setBounds: are never called. It looks like the background thread just calls drawLayer:inContext: of the delegate out of the blue without any triggers. I have found out that CATiledLayer calls setContent: with an instance of "CAImageProvider", and the all calls to drawLayer:inContext: originate from that class. So probably that one is the key in determining what tile to draw. But I cannot find any documentation on that class.

So... does anybody know how this is working, and how I might be able to override it?

As for the disadvantages of CATiledLayer:

  • it always uses screen resolution (or x2, x4, etc); you cannot set it to the native resolution of your source images
  • you cannot specify any other scaling factor than 2
  • you have to specify the levelsOfDetail and levelsOfDetailBias, for which I see no implementation reason at all. If you have content that is infinitely scalable, like fractals, then this is very limiting.
  • most importantly: if you restrict it to zooming in only one direction (I do that by forcing the scale factor of one direction to 1 in setTransform:), it acts all weird
fishinear
  • 6,101
  • 3
  • 36
  • 84
  • @fishiear: it's been a while since your question? I really do have the same problem. Did you solve it? I have to accomplish a zoom factor of 3 and am also looking for my own solution. But I don't know if it's good. What did you do finally? I would like to get in contact with you. You can write me a mail. It is very important for me. – Fab1n Feb 23 '13 at 08:41
  • @Fab1n I did not solve this particular problem. What I did in the end, is to inform my tiled layer implementation explicitly every time I knew the displayed content would change (after zoom and scroll and when new content was available). I can share the code with you, leave me your email address. – fishinear Feb 23 '13 at 10:26
  • thanks for your quick response. My email address is renneronline at me dot com. Wow appreciate the code. Think that saves me a lot of time. – Fab1n Feb 24 '13 at 10:31

1 Answers1

1

In drawLayer:inContext:, you can get the bounding box using CGContextGetClipBoundingBox. CGContextGetCTM should give you information about the current resolution.

Jilouc
  • 12,684
  • 4
  • 46
  • 43
  • thanks, but i know. I am looking information on how catiledlayer knows when to send me the drawlayer:incontext message. – fishinear Sep 12 '11 at 07:24