CachingHint 列舉

定義

指定是否快取並排顯示筆刷物件。Specifies whether to cache tiled brush objects.

public enum class CachingHint
public enum CachingHint
type CachingHint = 
Public Enum CachingHint
繼承
CachingHint

欄位

Cache 1

使用RenderOptions 設定所指定的快取提示,快取螢幕外緩衝區的並排顯示筆刷物件。Cache the tiled brush objects in an off-screen buffer, using the caching hints specified by the RenderOptions settings.

Unspecified 0

未指定任何的快取提示。No caching hints are specified.

範例

下列範例顯示如何使用的快取提示選項 DrawingBrushThe following example shows how to use the caching hint option for a DrawingBrush.

DrawingBrush drawingBrush = new DrawingBrush();
            
// Set the caching hint option for the brush.
RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache);

// Set the minimum and maximum relative sizes for regenerating the tiled brush.
// The tiled brush will be regenerated and re-cached when its size is
// 0.5x or 2x of the current cached size.
RenderOptions.SetCacheInvalidationThresholdMinimum(drawingBrush, 0.5);
RenderOptions.SetCacheInvalidationThresholdMaximum(drawingBrush, 2.0);
Dim drawingBrush As New DrawingBrush()

' Set the caching hint option for the brush.
RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache)

' Set the minimum and maximum relative sizes for regenerating the tiled brush.
' The tiled brush will be regenerated and re-cached when its size is
' 0.5x or 2x of the current cached size.
RenderOptions.SetCacheInvalidationThresholdMinimum(drawingBrush, 0.5)
RenderOptions.SetCacheInvalidationThresholdMaximum(drawingBrush, 2.0)

備註

根據預設,不會快取 WPFWPF 和物件的呈現內容 DrawingBrush VisualBrushBy default, WPFWPF does not cache the rendered contents of DrawingBrush and VisualBrush objects. 在不會變更影像中的筆刷內容或使用的靜態案例中,因為快取會節省視訊記憶體,所以不會提供好處。In static scenarios where neither the contents nor the use of the brush in the scene is changing, not caching provides a benefit because it conserves video memory. 當使用靜態內容的筆刷以非靜態方式使用時,的預設行為是在 WPFWPF 每個框架中重新轉譯筆刷的全部內容,即使內容不變也一樣。When a brush with static content is used in a non-static way, the default behavior of WPFWPF is to re-render the entire content of the brush every frame, even though the content is unchanging. 例如,當靜態 DrawingBrushVisualBrush 對應至旋轉3d 物件的介面時,就會發生這種情況。For example, this will happen when a static DrawingBrush or VisualBrush is mapped to the surface of a rotating 3D object. 重新呈現靜態內容可能會對效能造成負面影響。Re-rendering the static content can have a negative impact on performance.

藉由將 CachingHint 筆刷上的附加屬性設定為 [快取],您可以使用已並排顯示的筆刷物件的快取版本來增加效能。By setting the CachingHint attached property on the brush to Cache, you can increase performance by using cached versions of the tiled brush objects.

CacheInvalidationThresholdMinimumCacheInvalidationThresholdMaximum 屬性值是相對大小的值,可決定 TileBrush 物件因規模變更而應重新產生的時間。The CacheInvalidationThresholdMinimum and CacheInvalidationThresholdMaximum property values are relative size values that determine when the TileBrush object should be regenerated due to changes in scale. 例如,藉由將 CacheInvalidationThresholdMaximum 屬性設定為2.0, TileBrush 只有當其大小超過目前快取大小的兩倍時,才需要重新產生的快取。For example, by setting the CacheInvalidationThresholdMaximum property to 2.0, the cache for the TileBrush only needs to be regenerated when its size exceeds twice the size of the current cache.

適用於

另請參閱