WPF Rendering 2 (hardware acceleration and Software Acceleration)

Source: Internet
Author: User
  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:

  1. DisableHWAcceleration registry key
  2. ProcessRenderMode
  3. 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
  1. DisableHWAcceleration registry key
    HKEY_CURRENT_USER \ SOFTWARE \ Microsoft \ aveon. Graphics \ DisableHWAcceleration. 0 indicates hardware acceleration is enabled, and 1 indicates hardware acceleration is disabled.
  2. ProcessRenderMode(Static attribute, corresponding to each process)
    RenderOptions. ProcessRenderMode = RenderMode. Default;
    RenderOptions. ProcessRenderMode = RenderMode. SoftwareOnly;
  3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.