The next day (11/16/2010)
Step 2: abstract
1. RenderCapability class:
Enables WPF applications to query for the current rendering tier for their associated Dispatcher object and to register for notification of changes.
RenderCapability. Tier attribute: Gets a value that indicates the rendering tier for the current thread
Return Value |
Presentation Layer |
Description |
Zero x 00000000 |
0 |
No graphical hardware acceleration is available for applications on the device. |
Zero x 00010000 |
1 |
Some graphics and hardware acceleration are available on the video card. This corresponds to DirectX Versions later than or equal to 7.0 and lower than 9.0. |
Zero x 00020000 |
2 |
The value of 2 in the rendering layer means that if necessary system resources are not exhausted, most of the graphic functions of WPF should use hardware acceleration. This corresponds to a DirectX version later than or equal to 9.0. |
2. RenderOptions class:
Provides options for controlling the rendering behavior of objects. RenderOptions. ProcessRenderMode attribute: Specifies the render mode preference for the current process. Description:
Please useProcessRenderModeAttribute to force the current process to perform software rendering. If you change the software rendering preferences, you can avoid many rendering problems that occur in WPF applications and are caused by external problems.
During application startup, if your application detects a rendering problem, such as a slow frame rate, you can set the rendering mode to software only. In addition, you may want to enable user settings when the application is running.
The existence of SoftwareOnly overwrites the RenderMode setting. The priority of software presentation is:
- DisableHWAcceleration registry key
- ProcessRenderMode
- RenderMode (each target)
Note: ProcessRenderMode specifies a preference and does not necessarily change the actual rendering mode. Other parts of the system may override this preference and force the system to use software rendering.
3. HwndTarget class:
Indicates the binding of window handles that support visual writing.
HwndTarget. RenderMode attribute: gets or sets the rendering mode of the window referenced by this HwndTarget. One of the RenderMode values is used to specify the current rendering mode. The Default value is RenderMode. Default.
Example:
HwndSource hwndSource = PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource;
HwndTarget hwndTarget = hwndSource.CompositionTarget;
hwndTarget.RenderMode = renderMode;
Summary:
- You can change the rendering mode in three ways. Their order is
- DisableHWAcceleration registry key
HKEY_CURRENT_USER \ SOFTWARE \ Microsoft \ aveon. Graphics \ DisableHWAcceleration. 0 indicates hardware acceleration is enabled, and 1 indicates hardware acceleration is disabled.
- ProcessRenderMode(Static attribute, corresponding to each process)
RenderOptions. ProcessRenderMode = RenderMode. Default;
RenderOptions. ProcessRenderMode = RenderMode. SoftwareOnly;
- RenderMode (non-static attribute, for each target, window)
HwndSource hwndSource = PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource;
HwndTarget hwndTarget = hwndSource.CompositionTarget;
hwndTarget.RenderMode = renderMode;
- RenderCapability. Tier only indicates how powerful the current machine can achieve hardware acceleration. It changes when the current actual content changes the display reality, or when it is dragged from this display to another display reality.
RenderCapability. TierChanged event will be triggered when RenderCapability. Tier changes