Cached Composition
Massive performance wins are possible with the new Cached
Composition feature in WPF 4, which allows applications to cache arbitrary
content including live and fully-interactive controls, vector geometry, etc. as
bitmaps which persist in video memory. Once cached, these elements can be
arbitrarily transformed, animated, manipulated, and can have Effects applied,
all without having to re-render the cached element.
Figure 3
This spares both the CPU and the GPU the cost of
re-rendering content, and instead allows the GPU to render straight from the
cache. The cache(s) understand dirty regions, so a blinking cursor in a cached textblock,
for example, will only need to re-render the cursor between frames. There’s
even a new Brush which specifically uses these intelligent caches – effectively
a VisualBrush with vastly better performance.
Pixel Shader 3 Support
WPF 4 builds on top of the very popular ShaderEffect support
first introduced in WPF 3.5 SP1 by allowing applications to now write Effects
using Pixel Shader version 3.0. The PS 3.0 shader model is dramatically more
sophisticated than PS 2.0, allowing for even more compelling Effects on
supported hardware.
LayoutRounding
WPF 4 adopts the UseLayoutRounding property, originally introduced in
Silverlight 2. WPF’s layout engine frequently calculates sub-pixel positioning
coordinates. This can lead to rendering artifacts as elements positioned on
sub-pixel boundaries are anti-aliased over multiple physical pixels.
UseLayoutRounding will force the layout engine to place
elements on whole pixel boundaries, thus removing most of the rendering
artifacts caused by this problem – which generates cleaner and crisper UI by
default.
Figure 4
Animation Easing Function
Discrete, linear, and spline animations were supported with
previous versions of WPF. WPF 4 introduces a new concept of Easing Functions –
which allows application authors to create fluid behavior using animations.
This can be used in an infinite number of ways, such as creating a springy
behavior, or adding anticipation to an animation. Easing Functions customize
the manner in which animations progress from start to finish. The
built-in easing functions provide a range of behaviors such as circular,
exponential, elastic, and bouncy animation progress. The extensibility design also
allows application authors to create custom easing functions to define the
manner in which their animations progress. With this easy-to-use feature,
designers can effortlessly create fluid, organic animations.
CleartypeHint
The new CleartypeHint attached property allows application
authors to enable higher-quality Cleartyped text rendering in many situations
where it would have previously been disabled. Such situations include text in
layered windows, text in VisualBrushes, DrawingBrushes, BitmapCacheBrushes, and
anywhere else where the introduction of an intermediate render target would
have previously resulted in grayscale text rendering.