When developing Flash content, there are a number of considerations and optimizations that should be followed and implemented in order to get the best performance.
Draw primitives (DPs) are 3D mesh objects created by GFx to render 2D Flash elements, such as a group of shapes on the same layer. Each draw primitive is rendered independently, incurring a significant cost. In general, display performance will tend to decrease linearly as more DPs are introduced into the scene; therefore it is a good practice to keep the DP count as low as possible. The number of draw primitives can be determined via the Scaleform Player by pressing the (F) key, which brings up basic performance stats in the title bar. The stats include draw primtive count, framerate, as well as A (Advance) and D (Display) timing in milliseconds.
The following are a few facts to help keep draw primitive count low:
- Gradient fills can increase the number of DPs if several of them are used in a shape at the same time.
- Vector graphics with solid fills and no strokes on the same layer are very cheap. Only one DP is required to represent any amount of these types of shapes on a single layer, even if those shapes use different colors.
- Each vector shape (or group of vector shapes) on its own layer requires one DP.
- Strokes are more expensive than fills, unless all strokes are the same solid color.
- Each dissimilar (different color) solid stroke on a layer adds one DP.
- Empty movie clips do not require a DP; however, a movie clip with objects in it will require the amount of DPs dictated by those objects.
- Alpha, Blends, and Transparency effects do not affect the number of DPs required; however, they will have an impact on rendering performance.
- Each bitmap/texture on the Stage requires one DP.
- Each text field requires at least one DP. Adding a border/background will add one more DP. Although in most cases all of text glyphs will be rendered from texture with one DP, large text may end up being rendered as vector shapes with each glyph using is a separate primitive. If clipping of vector glyphs is necessary then the text field will use a mask, which adds one more DP. Masks currently have a significant performance cost and clipped text fields will compound this penalty.