Contents

getRectsBeingDrawn(_:count:)

Returns by indirection a list of nonoverlapping rectangles that define the area the view is being asked to draw in Draw(_:).

Declaration

func getRectsBeingDrawn(_ rects: UnsafeMutablePointer<UnsafePointer<NSRect>?>?, count: UnsafeMutablePointer<Int>?)

Parameters

  • rects:

    On return, contains a list of nonoverlapping rectangles defining areas to be drawn in. The rectangles returned in rects are in the coordinate space of the view.

  • count:

    On return, the number of rectangles in the rects list.

Discussion

An implementation of draw(_:) can use this information to test whether objects or regions within the view intersect with the rectangles in the list, and thereby avoid unnecessary drawing that would be completely clipped away.

The needsToDraw(_:) method gives you a convenient way to test individual objects for intersection with the area being drawn in draw(_:). However, you may want to retrieve and directly inspect the rectangle list if this is a more efficient way to perform intersection testing.

You should send this message only from within a draw(_:) implementation. The aRect parameter of draw(_:) is the rectangle enclosing the returned list of rectangles; you can use it in an initial pass to reject objects that are clearly outside the area to be drawn.

See Also

Drawing the View’s Content