Screen Surfaces
A screen surface is a Core Surface object used to access a raw pixel buffer that is rendered directly to a layer. This allows advanced games or applications to write pixel data directly to a surface on the screen. Core Surface supports many different color value configurations to host different types of pixel data.
Screen surfaces are attached to a layer, which is how the surface can eventually be displayed in a view. The surface is glued to the layer, and the layer is added to a view class, which renders it. This also means that the image rendered on a screen surface can be manipulated using the layer's methods.
Creating a Screen Surface
A screen surface is an object containing a raw video buffer. It supports a specific resolution, pitch, and pixel format. To create a new screen surface, a buffer is initialized using a dynamic dictionary class named CFMutableDictionary. This is used to provide information about the desired makeup and behavior of the surface. CFMutableDictionary is a class used on both the desktop and mobile platforms of Mac OS X and is part of the Core Foundation framework. Full documentation for this class can be found on the Apple Developer Connection web site.
The following example builds a dictionary object specifying a 320×480 video buffer. It uses RGBA, a four-byte pixel format containing one byte each for red, green, blue, and alpha blending channels. The last method called in the example allocates enough space in the dictionary for all the four-byte ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access