Instance Method

cacheImage(in:)

Stores the window’s raster image from a given rectangle expressed in the window’s base coordinate system.

Declaration

func cacheImage(in rect: NSRect)

Parameters

rect

The rectangle representing the image to cache.

Discussion

This method allows the window to perform temporary drawing, such as a band around the selection as the user drags the mouse, and to quickly restore the previous image by invoking restoreCachedImage() and flushIfNeeded(). The next time the window displays, it discards its cached image rectangles. You can also explicitly use discardCachedImage() to free the memory occupied by cached image rectangles. rect is made integral before caching the image to avoid antialiasing artifacts.

Only the last cached rectangle is remembered and can be restored.

See Also

Bracketing Drawing Operations

func restoreCachedImage()

Splices the window’s cached image rectangles, if any, back into its raster image (and buffer if it has one), undoing the effect of any drawing performed within those areas since they were established using cacheImage(in:).

Deprecated
func discardCachedImage()

Discards all of the window’s cached image rectangles.

Deprecated