How does DrawPdfPage() know which parts to draw when used in CATiledLayer?
In my CATiledLayerDelegate I have the following code to draw a PDF page. This works but I don't understand why! CATiledLayer is supposed to ask me whick tile to draw. The code below always draws the complete PDF page. Nevertheless I can see the tiles appearing one by one. How does that work?
If I subclass CATiledLayer, I can override drawRect: which asks me for a specific rectangle to draw, but using the delegate this is not the case. So how does that magic work?
public override void DrawLayer (CALayer layer, CGContext context)
{
context.SaveState ();
context.SetRGBFillColor (1.0f, 1.0f, 1.0f, 1.0f);
context.FillRect (context.GetClipBoundingBox ());
context.TranslateCTM (0.0f, layer.Bounds.Size.Height);
context.ScaleCTM (1.0f, -1.0f);
context.ConcatCTM (this.oParentController.oPdfPage.GetDrawingTransform (CGPDFBox.Media, layer.Bounds, 0, true));
context.DrawPDFPage (this.oParentController.oPdfPage);
开发者_如何学JAVA context.RestoreState ();
}
Figured out after more research. DrawLayer() is really drawing the whole layer. CATiledLayer is then taking care of passing on only the required tiles to the scrollview for instance. This means: if the PDF page being drawn s big enough (memory wise), iOS will run OOM even though tiling is used. One would have to write the tiling from scratch like the guys of Goodreader probably did.
精彩评论