未验证 提交 16f75cd6 编写于 作者: A Ashish Kumar Singh 提交者: GitHub

Port dirty-rectangle opt-out from 4.8 (#5837) (#6062)

* disable d3d dirty rectangle optimization

* fix build break - 'processed' file needs to be copied from .NETFx, where it is generated during the build
Co-authored-by: NSam Bent <sambent@microsoft.com>
上级 81508c8c
......@@ -245,7 +245,7 @@ WindowMessage message
IntPtr pChannel,
DUCE.ResourceHandle hResource,
out uint refCount
);
);
}
/// <summary>
......@@ -489,7 +489,7 @@ ref handle
if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW))
{
EventTrace.EventProvider.TraceEvent(EventTrace.Event.CreateOrAddResourceOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, PerfService.GetPerfElementID(instance), _hChannel, (uint) handle, (uint) resourceType);
EventTrace.EventProvider.TraceEvent(EventTrace.Event.CreateOrAddResourceOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, PerfService.GetPerfElementID(instance), _hChannel, (uint) handle, (uint) resourceType);
}
return handleNeedsCreation;
......@@ -553,14 +553,14 @@ out releasedOnChannel
if ((releasedOnChannel != 0) && EventTrace.IsEnabled(EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW))
{
EventTrace.EventProvider.TraceEvent(EventTrace.Event.ReleaseOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, _hChannel, (uint) handle);
EventTrace.EventProvider.TraceEvent(EventTrace.Event.ReleaseOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, _hChannel, (uint) handle);
}
return (releasedOnChannel != 0);
}
/// <summary>
/// Internal only: GetRefCount returns the reference count of a resource
/// Internal only: GetRefCount returns the reference count of a resource
/// corresponding to the specified handle on the channel.
/// </summary>
/// <return>
......@@ -972,7 +972,7 @@ public bool IsOnChannel(Channel channel)
/// <summary>
/// Returns the real UInt32 handle.
/// Returns the real UInt32 handle.
/// </summary>
/// <remarks>
/// Consider moving to an abstract handle type in the future.
......@@ -1522,7 +1522,7 @@ public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.Resou
bool inmap = _map.Get(channel, out handle);
bool created = channel.CreateOrAddRefOnChannel(instance, ref handle, type);
if (!inmap)
{
_map.Set(channel, handle);
......@@ -1690,7 +1690,7 @@ internal static class CompositionNode
DUCE.ResourceHandle hEffect,
Channel channel)
{
DUCE.MILCMD_VISUAL_SETEFFECT command;
DUCE.MILCMD_VISUAL_SETEFFECT command;
command.Type = MILCMD.MilCmdVisualSetEffect;
command.Handle = hCompositionNode;
......@@ -1704,14 +1704,14 @@ internal static class CompositionNode
);
}
}
internal static void SetCacheMode(
DUCE.ResourceHandle hCompositionNode,
DUCE.ResourceHandle hCacheMode,
Channel channel)
{
DUCE.MILCMD_VISUAL_SETCACHEMODE command;
DUCE.MILCMD_VISUAL_SETCACHEMODE command;
command.Type = MILCMD.MilCmdVisualSetCacheMode;
command.Handle = hCompositionNode;
......@@ -1834,7 +1834,7 @@ internal static class CompositionNode
sizeof(DUCE.MILCMD_VISUAL_SETSCROLLABLEAREACLIP)
);
}
}
}
internal static void SetClip(
DUCE.ResourceHandle hCompositionNode,
......@@ -2239,7 +2239,7 @@ Channel channel
command.flags |= (UInt32)MILRTInitializationFlags.MIL_RT_SOFTWARE_ONLY;
}
bool? enableMultiMonitorDisplayClipping =
bool? enableMultiMonitorDisplayClipping =
System.Windows.CoreCompatibilityPreferences.EnableMultiMonitorDisplayClipping;
if (enableMultiMonitorDisplayClipping != null)
......@@ -2253,6 +2253,11 @@ Channel channel
}
}
if (CoreAppContextSwitches.DisableDirtyRectangles)
{
command.flags |= (UInt32)MILRTInitializationFlags.MIL_RT_DISABLE_DIRTY_RECTANGLES;
}
command.hBitmap = DUCE.ResourceHandle.Null;
command.stride = 0;
command.ePixelFormat = 0;
......@@ -2465,11 +2470,11 @@ Channel channel
}
/// <summary>
/// See <see cref="MediaContext.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable"/> for
/// See <see cref="MediaContext.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable"/> for
/// details.
/// </summary>
internal static void NotifyPolicyChangeForNonInteractiveMode(
bool forceRender,
bool forceRender,
Channel channel
)
{
......@@ -2482,8 +2487,8 @@ Channel channel
unsafe
{
channel.SendCommand(
(byte*)&command,
sizeof(DUCE.MILCMD_PARTITION_NOTIFYPOLICYCHANGEFORNONINTERACTIVEMODE),
(byte*)&command,
sizeof(DUCE.MILCMD_PARTITION_NOTIFYPOLICYCHANGEFORNONINTERACTIVEMODE),
sendInSeparateBatch: false
);
}
......
......@@ -17,7 +17,7 @@ internal enum MIL_SEGMENT_TYPE {
MilSegmentPolyLine,
MilSegmentPolyBezier,
MilSegmentPolyQuadraticBezier,
MIL_SEGMENT_TYPE_FORCE_DWORD = unchecked((int)0xffffffff)
};
......@@ -27,121 +27,121 @@ internal enum MILCoreSegFlags
SegTypeLine = 0x00000001,
SegTypeBezier = 0x00000002,
SegTypeMask = 0x00000003,
// When this bit is set then this segment is not to be stroked
SegIsAGap = 0x00000004,
// When this bit is set then the join between this segment and the PREVIOUS segment
// will be rounded upon widening, regardless of the pen line join property.
SegSmoothJoin = 0x00000008,
// When this bit is set on the first type then the figure should be closed.
SegClosed = 0x00000010,
// This bit indicates whether the segment is curved.
SegIsCurved = 0x00000020,
FORCE_DWORD = unchecked((int)0xffffffff)
};
internal enum MIL_PEN_CAP {
MilPenCapFlat = 0,
MilPenCapSquare = 1,
MilPenCapRound = 2,
MilPenCapTriangle = 3,
MIL_PEN_CAP_FORCE_DWORD = unchecked((int)0xffffffff)
};
internal enum MIL_PEN_JOIN {
MilPenJoinMiter = 0,
MilPenJoinBevel = 1,
MilPenJoinRound = 2,
MIL_PEN_JOIN_FORCE_DWORD = unchecked((int)0xffffffff)
};
[System.Flags]
internal enum MILRTInitializationFlags
{
// Default initialization flags (0) imply hardware with software fallback,
// synchronized to reduce tearing for hw RTs, and no retention of contents
// between scenes.
MIL_RT_INITIALIZE_DEFAULT = 0x00000000,
// This flag disables the hardware accelerated RT. Use only software.
MIL_RT_SOFTWARE_ONLY = 0x00000001,
// This flag disables the software RT. Use only hardware.
MIL_RT_HARDWARE_ONLY = 0x00000002,
// Creates a dummy render target that consumes all calls
MIL_RT_NULL = 0x00000003,
// Mask for choice of render target
MIL_RT_TYPE_MASK = 0x00000003,
// This flag indicates that presentation should not wait for any specific
// time to promote the results to the display. This may result in display
// tearing.
MIL_RT_PRESENT_IMMEDIATELY = 0x00000004,
// This flag makes the RT reatin the contents from one frame to the next.
// Retaining the contents has performance implications. For scene changes
// with little to update retaining contents may help, but if most of the
// scene will be repainted anyway, retention may hurt some hw scenarios.
MIL_RT_PRESENT_RETAIN_CONTENTS = 0x00000008,
// This flag indicates that we should create a full screen RT.
MIL_RT_FULLSCREEN = 0x00000010,
// This flag indicates that the render target backbuffer will have
// linear gamma.
MIL_RT_LINEAR_GAMMA = 0x00000020,
// This flag indicates that the render target backbuffer will have
// an alpha channel that is at least 8 bits wide.
MIL_RT_NEED_DESTINATION_ALPHA = 0x00000040,
// This flag allows the render target backbuffer to contain
// 10 bits per channel rather than 32. This flag only has
// meaning when linear gamma is also present.
MIL_RT_ALLOW_LOW_PRECISION = 0x00000080,
// This flag assumes that all resources (such as bitmaps and render
// targets) are released on the same thread as the rendering device. This
// flag enables us to use a single threaded dx device instead of a
// multi-threaded one.
MIL_RT_SINGLE_THREADED_USAGE = 0x00000100,
// This flag directs the render target to extend its presentation area
// to include the non-client area. The origin of the render target space
// will be equal to the origin of the window.
MIL_RT_RENDER_NONCLIENT = 0x00000200,
// This flag enables tear free composition by using the SWAPEFFECT D3D_FLIP.
MIL_RT_PRESENT_FLIP = 0x00000400,
// Setting this flag results in the DX device instructing the driver not to
// autorotate if the monitor is in a rotated mode. Only makes sense for
// fullscreen RTs
MIL_RT_FULLSCREEN_NO_AUTOROTATE = 0x00000800,
// This flag directed the render target not to restrict its rendering and
// presentation to the visible portion of window on the desktop. This is
// useful for when the window position may be faked or the system may try
......@@ -149,62 +149,68 @@ internal enum MILRTInitializationFlags
// example DWM thumbnails expect a fully rendered and presented window.
//
// Note: This does not guarantee that some clipping will not be used. See
MIL_RT_DISABLE_DISPLAY_CLIPPING = 0x00001000,
//
// This flag is the same as MIL_RT_DISABLE_DISPLAY_CLIPPING except that it disables
// display clipping on multi-monitor configurations in all OS'. This flag is automatically
// set on Windows 8 and newer systems. If WPF decides to unset
// This flag is the same as MIL_RT_DISABLE_DISPLAY_CLIPPING except that it disables
// display clipping on multi-monitor configurations in all OS'. This flag is automatically
// set on Windows 8 and newer systems. If WPF decides to unset
// MIL_RT_DISABLE_DISPLAY_CLIPPING, then MIL_RT_DISABLE_MULTIMON_DISPLAY_CLIPPING flag
// will not be respected even if set by an applicaiton via its manifest
//
MIL_RT_DISABLE_MULTIMON_DISPLAY_CLIPPING = 0x00004000,
//
// This flag is passed down by PresentationCore to tell wpfgfx that
// the DisableMultimonDisplayClipping compatibity flag is set by the user. This
// This flag is passed down by PresentationCore to tell wpfgfx that
// the DisableMultimonDisplayClipping compatibity flag is set by the user. This
// allows us to distinguish between when DisableMultimonDisplayClipping == 0 means
// that the user set it to false explicitly, versus when the user didn't set it
// that the user set it to false explicitly, versus when the user didn't set it
// and the DisableMultimonDisplayClipping bit happens to be implicitly set to 0
//
MIL_RT_IS_DISABLE_MULTIMON_DISPLAY_CLIPPING_VALID = 0x00008000,
//
//
// This flag directs the render target to render the full scene,
// bypassing D3D's dirty-rectangle optimizations.
//
MIL_RT_DISABLE_DIRTY_RECTANGLES = 0x00010000,
//
// UCE only flags
//
// This flag directs the composition rendertarget to enable the occlusion
// culling optimization.
MIL_UCE_RT_ENABLE_OCCLUSION = 0x00010000,
//
// Test only / internal flags
//
// This flag forces the render target to use the d3d9 reference raster
// when using d3d. (Should be combined with MIL_RT_INITIALIZE_DEFAULT or
// MIL_RT_HARDWARE_ONLY)
// This is designed for test apps only
MIL_RT_USE_REF_RAST = 0x01000000,
// This flag forces the render target to use the rgb reference raster
// when using d3d.( Should be combined with MIL_RT_INITIALIZE_DEFAULT or
// MIL_RT_HARDWARE_ONLY )
// This is designed for test apps only
MIL_RT_USE_RGB_RAST = 0x02000000,
// MIL Core Rendering Internal flag (=Do NOT pass to RT Create methods)
// This flag enables the buffer to be set up in a transposed mode
// in order to manage our own rotation for 90 and 270 degree rotations.
MIL_RT_FULLSCREEN_TRANSPOSE_XY = unchecked((int)0x10000000),
// We support 4 primary present modes:
//
// 1) Present using D3D
......@@ -217,11 +223,11 @@ internal enum MILRTInitializationFlags
MIL_RT_PRESENT_USING_BITBLT = unchecked((int)0x40000000),
MIL_RT_PRESENT_USING_ALPHABLEND = unchecked((int)0x80000000),
MIL_RT_PRESENT_USING_ULW = unchecked((int)0xC0000000),
FORCE_DWORD = unchecked((int)0xffffffff)
};
internal enum MIL_PRESENTATION_RESULTS {
MIL_PRESENTATION_VSYNC,
MIL_PRESENTATION_NOPRESENT,
......@@ -229,7 +235,7 @@ internal enum MIL_PRESENTATION_RESULTS {
MIL_PRESENTATION_DWM,
MIL_PRESENTATION_FORCE_DWORD = unchecked((int)0xffffffff)
};
[StructLayout(LayoutKind.Sequential, Pack=1)]
internal struct MIL_PEN_DATA {
internal double Thickness;
......@@ -241,7 +247,7 @@ internal struct MIL_PEN_DATA {
internal MIL_PEN_JOIN LineJoin;
internal UInt32 DashArraySize;
};
[System.Flags]
internal enum MILTransparencyFlags
{
......@@ -249,34 +255,34 @@ internal enum MILTransparencyFlags
ConstantAlpha = 0x1,
PerPixelAlpha = 0x2,
ColorKey = 0x4,
FORCE_DWORD = unchecked((int)0xffffffff)
};
internal enum MILWindowLayerType
{
NotLayered = 0,
SystemManagedLayer = 1,
ApplicationManagedLayer = 2,
FORCE_DWORD = unchecked((int)0xffffffff)
};
//
// Enum which describes whether certain values should be considered as absolute
// local coordinates or whether they should be considered multiples of a bounding
// Enum which describes whether certain values should be considered as absolute
// local coordinates or whether they should be considered multiples of a bounding
// box's size.
//
internal enum MilBrushMappingMode
{
//
// Absolute means that the values in question will be interpreted directly in
// Absolute means that the values in question will be interpreted directly in
// local space.
//
Absolute = 0,
//
// RelativeToBoundingBox means that the values will be interpreted as a multiples
// RelativeToBoundingBox means that the values will be interpreted as a multiples
// of a bounding box, where 1.0 is considered 100% of the bounding box measure.
//
RelativeToBoundingBox = 1,
......@@ -285,7 +291,7 @@ internal enum MilBrushMappingMode
}
//
// The AlignmentX enum is used to describe how content is positioned horizontally
// The AlignmentX enum is used to describe how content is positioned horizontally
// within a container.
//
internal enum MilHorizontalAlignment
......@@ -309,7 +315,7 @@ internal enum MilHorizontalAlignment
}
//
// The AlignmentY enum is used to describe how content is positioned vertically
// The AlignmentY enum is used to describe how content is positioned vertically
// within a container.
//
internal enum MilVerticalAlignment
......@@ -374,7 +380,7 @@ internal enum MilMessageClass
//
// Not a real message. This value is one more than message with the greatest
// Not a real message. This value is one more than message with the greatest
// numerical value.
//
Last,
......@@ -555,8 +561,8 @@ internal struct MilGraphicsAccelerationCaps
/// <summary>
/// MilGraphicsAccelerationAssessment
/// Assessment of the video memory bandwidth and total video memory as set by
/// WinSAT. Used by the DWM to determine glass and opaque glass capability of the
/// Assessment of the video memory bandwidth and total video memory as set by
/// WinSAT. Used by the DWM to determine glass and opaque glass capability of the
/// display machine.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack=1)]
......@@ -595,7 +601,7 @@ internal struct MilMatrix3x2D
internal double DY;
};
internal enum MILCMD
{
{
/* 0x00 */ MilCmdInvalid = 0x00,
//--------------------------------------------------------------------------
......
......@@ -337,6 +337,49 @@ public static bool AllowExternalProcessToBlockAccessToTemporaryFiles
#endregion
#region DisableDirtyRectangles
internal const string DisableDirtyRectanglesSwitchName = "Switch.System.Windows.Media.MediaContext.DisableDirtyRectangles";
private static int _DisableDirtyRectangles;
public static bool DisableDirtyRectangles
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
/// <summary>
/// Due to a limitation of D3D's implementation of
/// dirty-rectangle processing, images occasionally render incorrectly.
/// An app can disable dirty-rectangle processing by setting this switch to true.
/// This will cause more work for the GPU, but the results will be better.
/// </summary>
if (EnableDynamicDirtyRectangles)
{
bool disableDirtyRectangles;
AppContext.TryGetSwitch(DisableDirtyRectanglesSwitchName, out disableDirtyRectangles);
return disableDirtyRectangles;
}
return LocalAppContext.GetCachedSwitchValue(DisableDirtyRectanglesSwitchName, ref _DisableDirtyRectangles);
}
}
internal const string EnableDynamicDirtyRectanglesSwitchName = "Switch.System.Windows.Media.MediaContext.EnableDynamicDirtyRectangles";
private static int _EnableDynamicDirtyRectangles;
public static bool EnableDynamicDirtyRectangles
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
/// <summary>
/// Setting this switch to true causes the DisableDirtyRectangles
/// switch to be re-evaluated before each render.
/// </summary>
return LocalAppContext.GetCachedSwitchValue(EnableDynamicDirtyRectanglesSwitchName, ref _EnableDynamicDirtyRectangles);
}
}
#endregion
}
#pragma warning restore 436
}
......@@ -48,6 +48,7 @@ internal enum RenderingMode
HardwareReference = MILRTInitializationFlags.MIL_RT_HARDWARE_ONLY | MILRTInitializationFlags.MIL_RT_USE_REF_RAST,
DisableMultimonDisplayClipping = MILRTInitializationFlags.MIL_RT_DISABLE_MULTIMON_DISPLAY_CLIPPING,
IsDisableMultimonDisplayClippingValid = MILRTInitializationFlags.MIL_RT_IS_DISABLE_MULTIMON_DISPLAY_CLIPPING_VALID,
DisableDirtyRectangles = MILRTInitializationFlags.MIL_RT_DISABLE_DIRTY_RECTANGLES,
}
// This is the public, more limited, enum exposed for use with the RenderMode property.
......@@ -621,6 +622,11 @@ internal void InvalidateRenderMode()
}
}
if (MediaSystem.DisableDirtyRectangles)
{
mode |= RenderingMode.DisableDirtyRectangles;
}
// Select the render target initialization flags based on the requested
// rendering mode.
......@@ -1075,8 +1081,8 @@ internal IntPtr HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
// pollute the measure data based on the Minized window size.
if (NativeMethods.IntPtrToInt32(wparam) != NativeMethods.SIZE_MINIMIZED)
{
// Rendering sometimes does not refresh propertly,and results in
// rendering artifacts that look like a patchwork of black unpainted squares.
// Rendering sometimes does not refresh propertly,and results in
// rendering artifacts that look like a patchwork of black unpainted squares.
// This is is caused by a race condition in Windows 7 (and possibly
// Windows Vista, though we haven't observed the effect there).
// Sometimes when we restore from minimized, when we present into the newly
......@@ -1122,7 +1128,7 @@ internal IntPtr HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
bool enableRenderTarget = (wparam != IntPtr.Zero);
OnShowWindow(enableRenderTarget);
//
//
//
// When locked on downlevel, MIL stops rendering and invalidates the
// window causing WM_PAINT. When the window is layered and hidden
// before the lock, it won't get the WM_PAINT on unlock and the MIL will
......@@ -2018,7 +2024,7 @@ private void OnShowWindow(bool enableRenderTarget)
private DpiAwarenessContextValue DpiAwarenessContext { get; set; }
internal DpiScale2 CurrentDpiScale { get; private set; }
internal static bool IsPerMonitorDpiScalingSupportedOnCurrentPlatform
{
get
......@@ -2311,7 +2317,7 @@ public override Visual RootVisual
// UIAutomation listens for the EventObjectUIFragmentCreate WinEvent to
// understand when UI that natively implements UIAutomation comes up
// Need to figure out how to handle when _rootVisual is replaced above (is there some
// event when this happens?); MS.Internal.Automation.NativeEventListener may have a context
// monitor that is holding onto the old _rootVisual and that would need to be cleaned up.
......
......@@ -146,56 +146,56 @@ private static int FindNextPrime(int number)
#region Compat support for rendering in a Non-interactive Window Station
/// <summary>
/// General case:
/// True if our window station is interactive (WinSta0), otherwise false.
/// In addition to this, two compatibility switches are provided to opt-in
/// General case:
/// True if our window station is interactive (WinSta0), otherwise false.
/// In addition to this, two compatibility switches are provided to opt-in
/// or opt-out of this behavior
///
///
/// Compatibility switches
/// i. <see cref=" MS.Internal.CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable"/>
/// i. <see cref=" MS.Internal.CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable"/>
/// ii. <see cref="MS.Internal.CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation"/>
///
///
/// How this will work:
/// Desktop/Interactive Window Stations:
/// Rendering will be throttled back/stopped when no display devices are available. For e.g., when a TS
/// Rendering will be throttled back/stopped when no display devices are available. For e.g., when a TS
/// session is in WTSDisconnected state, the OS may not provide any display devices in response to our enumeration.
/// If an application would like to continue rendering in the absence of display devices (accepting that
/// it can lead to a CPU spike), it can set <see cref=" MS.Internal.CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable"/>
/// If an application would like to continue rendering in the absence of display devices (accepting that
/// it can lead to a CPU spike), it can set <see cref=" MS.Internal.CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable"/>
/// to true.
/// Service/Non-interactive Window Stations
/// Rendering will continue by default, irrespective of the presence of display devices.Unless the WPF
/// API's being used are shortlived (like rendering to a bitmap), it can lead to a CPU spike.
/// If an application running inside a service would like to receive the 'default' WPF behavior,
/// API's being used are shortlived (like rendering to a bitmap), it can lead to a CPU spike.
/// If an application running inside a service would like to receive the 'default' WPF behavior,
/// i.e., no rendering in the absence of display devices, then it should set
/// <see cref="MS.Internal.CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation"/> to true
/// In pseudocode,
/// In pseudocode,
/// IsNonInteractiveWindowStation = !Environment.UserInteractive
/// IF DisplayDevicesNotFound() THEN
/// IF IsNonInteractiveWindowStation THEN
/// IF IsNonInteractiveWindowStation THEN
/// // We are inside a SCM service
/// // Default = True, AppContext switch can override it to False
/// ShouldRender = !CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation
/// ELSE
/// ELSE
/// // Desktop/interactive mode, including WTSDisconnected scenarios
/// // Default = False, AppContext switch can override it to True
/// ShouldRender = CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable
/// END IF
/// END IF
///
///
/// </summary>
/// <remarks>
/// i. <see cref=">Environment.UserInteractive"/> calls into Window Station related
/// Win32 API's to identify whether the current Window Station has WSF_VISIBLE
/// flag set.
///
/// Win32 API's to identify whether the current Window Station has WSF_VISIBLE
/// flag set.
///
/// ii. Field is internal to allow <see cref="HwndTarget"/> to consume its value
///
/// iii. This field is named to reflect the general use-case, namely to force rendering
/// when inside a SCM service.
///
/// iii. This field is named to reflect the general use-case, namely to force rendering
/// when inside a SCM service.
/// </remarks>
internal static bool ShouldRenderEvenWhenNoDisplayDevicesAreAvailable { get; } =
!Environment.UserInteractive ? // IF DisplayDevicesNotAvailable && IsNonInteractiveWindowStation/IsService...
!CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation : // THEN render by default, allow ShouldNotRender AppContext override
!Environment.UserInteractive ? // IF DisplayDevicesNotAvailable && IsNonInteractiveWindowStation/IsService...
!CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation : // THEN render by default, allow ShouldNotRender AppContext override
CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable; // ELSE do not render by default, allow ShouldRender AppContext override
......@@ -353,7 +353,7 @@ internal void NotifyChannelMessage()
}
}
// MediaSystem is per-AppDomain and so it uses this to ensure that InvalidateRenderMode()
// MediaSystem is per-AppDomain and so it uses this to ensure that InvalidateRenderMode()
// is called by the right thread.
internal void PostInvalidateRenderMode()
{
......@@ -366,7 +366,7 @@ internal void PostInvalidateRenderMode()
private object InvalidateRenderMode(object dontCare)
{
Debug.Assert(CheckAccess());
foreach (ICompositionTarget target in _registeredICompositionTargets)
{
HwndTarget hwndTarget = target as HwndTarget;
......@@ -518,7 +518,7 @@ internal Size MaxTextureSize
get;
private set;
}
/// <summary>
/// Internal event which is raised when the Tier changes on this MediaContext.
/// </summary>
......@@ -1000,7 +1000,7 @@ private void NotifySyncModeStatus(int enabledResult)
{
CommittingBatch(Channel, new EventArgs());
}
Channel.SyncFlush();
}
}
......@@ -1217,12 +1217,12 @@ internal void CreateChannels()
{
_channelManager.CreateChannels();
// Notify renderer how it should behave when no valid displays are available,
// or when this process is running in a non-interactive Window Station, or when
// Notify renderer how it should behave when no valid displays are available,
// or when this process is running in a non-interactive Window Station, or when
// an application has opted into behavior that requests WPF to continue rendering
// even when no valid displays are detected.
//
// Do this immediately after creating channels.
//
// Do this immediately after creating channels.
DUCE.NotifyPolicyChangeForNonInteractiveMode(
ShouldRenderEvenWhenNoDisplayDevicesAreAvailable,
Channel);
......@@ -1860,6 +1860,8 @@ private object InputMarkerMessageHandler(object arg)
_timeManager.UnlockTickTime();
MediaSystem.PropagateDirtyRectangleSettings();
// Invalidate the input devices on the InputManager
InputManager.UnsecureCurrent.InvalidateInputDevices();
......@@ -1921,7 +1923,7 @@ private object InputMarkerMessageHandler(object arg)
// Reset current operation so it can be re-queued by layout
// This is needed when exception happens in the midst of layout/TemplateExpansion
// and it unwinds from the stack. If we don't clean this field here, the subsequent
// PostRender won't queue new render operation and the window gets stuck.
// PostRender won't queue new render operation and the window gets stuck.
if (gotException
&& _currentRenderOp != null)
{
......@@ -2268,7 +2270,7 @@ internal void CompleteRender()
{
CommittingBatch(Channel, new EventArgs());
}
Channel.WaitForNextMessage();
NotifyChannelMessage();
} while (_interlockState == InterlockState.WaitingForResponse);
......@@ -2311,7 +2313,7 @@ internal void CompleteRender()
{
CommittingBatch(Channel, new EventArgs());
}
//
// Issue a sync flush, which will only return after
// the last frame is presented
......
......@@ -6,9 +6,9 @@
//
//
// Abstract:
// Media system holds the relation between an application
// domain and the underlying transport system.
//
// Media system holds the relation between an application
// domain and the underlying transport system.
//
using System;
using System.Windows.Threading;
......@@ -51,23 +51,23 @@ public static bool Startup(MediaContext mc)
//
// This call will fail if PresentationCore.dll and milcore.dll have mismatched
// versions -- please make sure that both binaries have been properly built
// and deployed.
// and deployed.
//
// *** Failure here does NOT indicate a bug in MediaContext.Startup! ***
//
HRESULT.Check(UnsafeNativeMethods.MilVersionCheck(MS.Internal.Composition.Version.MilSdkVersion));
using (CompositionEngineLock.Acquire())
{
_mediaContexts.Add(mc);
//Is this the first startup?
if (0 == s_refCount)
{
HRESULT.Check(SafeNativeMethods.MilCompositionEngine_InitializePartitionManager(
0 // THREAD_PRIORITY_NORMAL
));
));
s_forceSoftareForGraphicsStreamMagnifier =
UnsafeNativeMethods.WgxConnection_ShouldForceSoftwareForGraphicsStreamClient();
......@@ -80,7 +80,7 @@ public static bool Startup(MediaContext mc)
}
s_refCount++;
}
// Consider making MediaSystem.ConnectTransport return the state of transport connectedness so
// Consider making MediaSystem.ConnectTransport return the state of transport connectedness so
// that we can initialize the media system to a disconnected state.
return true;
......@@ -138,7 +138,7 @@ internal static void Shutdown(MediaContext mc)
{
// We can shut-down.
// Debug.WriteLine("MediSystem::NotifyDisconnect Stop Transport\n");
if (IsTransportConnected)
{
DisconnectTransport();
......@@ -149,6 +149,28 @@ internal static void Shutdown(MediaContext mc)
}
}
/// <summary>
/// If the app has asked to disable dirty-rect processing, notify the graphics engine
/// </summary>
internal static void PropagateDirtyRectangleSettings()
{
int oldValue = s_DisableDirtyRectangles;
int disableDirtyRectangles = CoreAppContextSwitches.DisableDirtyRectangles ? 1 : 0;
if (disableDirtyRectangles != oldValue)
{
if (System.Threading.Interlocked.CompareExchange(ref s_DisableDirtyRectangles, disableDirtyRectangles, oldValue) == oldValue)
{
NotifyRedirectionEnvironmentChanged();
}
}
}
internal static bool DisableDirtyRectangles
{
get { return (s_DisableDirtyRectangles != 0); }
}
/// <summary>
/// Handle DWM messages that indicate that the state of the connection needs to change.
/// </summary>
......@@ -157,7 +179,7 @@ internal static void NotifyRedirectionEnvironmentChanged()
using (CompositionEngineLock.Acquire())
{
// Check to see if we need to force software for the Vista Magnifier
s_forceSoftareForGraphicsStreamMagnifier =
s_forceSoftareForGraphicsStreamMagnifier =
UnsafeNativeMethods.WgxConnection_ShouldForceSoftwareForGraphicsStreamClient();
foreach (MediaContext mc in _mediaContexts)
......@@ -166,7 +188,7 @@ internal static void NotifyRedirectionEnvironmentChanged()
}
}
}
/// <summary>
/// Connect the transport.
/// </summary>
......@@ -178,7 +200,7 @@ private static void ConnectTransport()
}
//
// Create a default transport to be used by this media system.
// Create a default transport to be used by this media system.
// If creation fails, fall back to a local transport.
//
......@@ -198,7 +220,7 @@ private static void ConnectTransport()
false);
IsTransportConnected = true;
}
}
/// <summary>
/// Disconnect the transport. If we are calling this function from a disconnect
......@@ -284,7 +306,7 @@ internal static bool IsTransportConnected
/// </summary>
internal static bool ForceSoftwareRendering
{
get
get
{
using (CompositionEngineLock.Acquire())
{
......@@ -294,7 +316,7 @@ internal static bool ForceSoftwareRendering
}
/// <summary>
/// Returns the service channel for the current media system. This channel
/// Returns the service channel for the current media system. This channel
/// is used by the glyph cache infrastructure.
/// </summary>
internal static DUCE.Channel ServiceChannel
......@@ -339,9 +361,13 @@ internal static bool AnimationSmoothing
/// <summary>
/// Indicates if a graphics stream client is present. If a graphics stream client is present,
/// we drop back to sw rendering to enable the Vista magnifier.
/// we drop back to sw rendering to enable the Vista magnifier.
/// </summary>
private static bool s_forceSoftareForGraphicsStreamMagnifier;
// 1 if app is requesting to disable D3D dirty rectangle work, 0 otherwise.
// We use Interlocked.CompareExchange to change this, which supports int but not bool.
private static int s_DisableDirtyRectangles = 0;
}
}
......@@ -351,7 +351,7 @@
<Field Name="Enabled" Value="1"
Comment="Rendering engine will enable ClearType for this element subtree. Where an intermediate render target is introduced in this subtree, ClearType will once again be disabled." />
<Field Name="Last" UnmanagedOnly="true" />
</Enum>
</Enum>
<Enum Name="CachingHint" UnmanagedName="MilCachingHint" NeedsValidateValueCallback="true"
Comment="Enum used for hinting the rendering engine that rendered content can be cached">
......@@ -373,7 +373,7 @@
<Field Name="ClearType" Value="3"
Comment="Rendering engine will render text with ClearType filtering when possible" />
<Field Name="Last" UnmanagedOnly="true" />
</Enum>
</Enum>
<Enum Name="TextHintingMode" UnmanagedName="MilTextHintingMode" NeedsValidateValueCallback="true"
Comment="Enum used for specifying how text should be rendered with respect to animated or static text">
......@@ -384,7 +384,7 @@
<Field Name="Animated" Value="2"
Comment="Rendering engine will render text for highest animated quality" />
<Field Name="Last" UnmanagedOnly="true" />
</Enum>
</Enum>
<!--
<Enum Name="PixelFormatEnum"
......@@ -458,7 +458,7 @@
<Field Name="BulgedUp" Value="3" Comment="Use a bulged up edge profile" />
</Enum>
<Enum Name="ShaderRenderMode" UnmanagedName="ShaderEffectShaderRenderMode"
<Enum Name="ShaderRenderMode" UnmanagedName="ShaderEffectShaderRenderMode"
Comment="Policy for rendering the shader in software.">
<Field Name="Auto" Value="0" Comment="Allow hardware and software" />
<Field Name="SoftwareOnly" Value="1" Comment="Force software rendering" />
......@@ -470,7 +470,7 @@
<Field Name="Performance" Value="0" Comment="Bias towards performance" />
<Field Name="Quality" Value="1" Comment="Bias towards quality" />
</Enum>
</Enums>
<Enums ManagedNamespace="System.Windows">
......@@ -635,25 +635,29 @@
<Field Name="ForceCompatible" Value="0x00002000"
Comment="This flag forces the creation of a render target bitmap to match its
parent's type, so a software surface only creates software RTs and a
hardware surface only creates hardware RTs. This is necessary for the
hardware surface only creates hardware RTs. This is necessary for the
hardware-accelerated bitmap effects pipeline to guarantee that we do
not encounter a situation where we're trying to run shaders sampling
not encounter a situation where we're trying to run shaders sampling
from a hardware texture to render into a software intermediate." />
<Field Name="DisableMultimonDisplayClipping" Value="0x00004000"
Comment="This flag is the same as DisableDisplayClipping except that it disables
display clipping on multi-monitor configurations in all OS'. This flag is automatically
set on Windows 8 and newer systems. If WPF decides to unset
DisableDisplayClipping, then DisableMultimonDisplayClipping flag will not be
Comment="This flag is the same as DisableDisplayClipping except that it disables
display clipping on multi-monitor configurations in all OS'. This flag is automatically
set on Windows 8 and newer systems. If WPF decides to unset
DisableDisplayClipping, then DisableMultimonDisplayClipping flag will not be
respected even if set by an applicaiton via its manifest" />
<Field Name="IsDisableMultimonDisplayClippingValid" Value="0x00008000"
Comment ="This flag is passed down by PresentationCore to tell wpfgfx that
the DisableMultimonDisplayClipping compatibity flag is set by the user. This
Comment ="This flag is passed down by PresentationCore to tell wpfgfx that
the DisableMultimonDisplayClipping compatibity flag is set by the user. This
allows us to distinguish between when DisableMultimonDisplayClipping == 0 means
that the user set it to false explicitly, versus when the user didn't set it
that the user set it to false explicitly, versus when the user didn't set it
and the DisableMultimonDisplayClipping bit happens to be implicitly set to 0" />
<Field Name="DisableDirtyRectangles" Value="0x00010000"
Comment ="This flag directs the render target to render the full scene,
bypassing D3D's dirty-rectangle optimizations." />
<BlockCommentedFields Comment="Test only / internal flags">
<Field Name="UseRefRast" Value="0x01000000"
Comment="This flag forces the render target to use the d3d9 reference raster
......@@ -2740,7 +2744,7 @@
<Resource Name="ImplicitInputBrush" Extends="Brush" SkipToString="true" CanIntroduceCycles="false">
</Resource>
<Resource Name="Effect" SkipToString="true" IsAbstract="true">
</Resource>
......@@ -2764,7 +2768,7 @@
</Fields>
</Resource>
<Resource Name="ShaderEffect" Extends="Effect" LeaveUnsealed="true" SkipUpdate="true" UseProcessUpdateWrapper="true" SkipToString="true"
<Resource Name="ShaderEffect" Extends="Effect" LeaveUnsealed="true" SkipUpdate="true" UseProcessUpdateWrapper="true" SkipToString="true"
UseOnChannelCoreWrapper="true" CreateInstanceCoreViaActivator="true" CanIntroduceCycles="false">
<Fields>
<Field Name="PixelShader" Type="PixelShader" IsProtected="true" PropertyChangedHook="true"/>
......@@ -3358,7 +3362,7 @@
Comment="If true, this Brush wrap its Target visual in a ContainerVisual, which will allow the brush to support rendering all properties on the visual above the cache to match VisualBrush's behavior."/>
</Fields>
</Resource>
<Resource Name="DashStyle" SkipToString="true" CanIntroduceCycles="false">
<Fields>
<Field Name="Offset" Type="Double" Default="0.0" Animate="true" />
......@@ -3398,7 +3402,7 @@
Comment="The glyph or codepoint count, based on the graunularity" />
</Fields>
</Resource>
<!--
Drawing Classes
-->
......@@ -3466,7 +3470,7 @@
<Field Name="IsDynamic" Type="Boolean" Default="false" IsInternal="true"/>
</Fields>
</Resource>
<!-- Caching -->
<Resource Name="CacheMode" SkipToString="true" IsAbstract="true" />
<Resource Name="BitmapCache" Extends="CacheMode" SkipToString="true" CanIntroduceCycles="false">
......@@ -3686,7 +3690,7 @@
<Namespace Name="System.Windows.Media.Media3D"/>
<Namespace Name="System.Diagnostics"/>
</Namespaces>
<Resource Name="D3DImage" Extends="ImageSource" LeaveUnsealed="true" IsAnimatable="true" SkipToString="true" CanIntroduceCycles="false" />
</Resources>
......@@ -4082,7 +4086,7 @@
ManagedSharedDestinationDir="src\Shared\Ms\Internal\Generated">
<Generate Name="BlurBitmapEffect" ManagedClass="true"/>
<Generate Name="DropShadowBitmapEffect" ManagedClass="true"/>
<Generate Name="DropShadowBitmapEffect" ManagedClass="true"/>
<Generate Name="EmbossBitmapEffect" ManagedClass="true"/>
<Generate Name="OuterGlowBitmapEffect" ManagedClass="true"/>
<Generate Name="BevelBitmapEffect" ManagedClass="true"/>
......@@ -4621,7 +4625,7 @@
<TemplateInstance ModuleName="Core\CSharp" TypeName="Vector3D" />
<TemplateInstance ModuleName="Framework" TypeName="Thickness" />
</Template>
<Template Name="MS.Internal.MilCodeGen.ResourceModel.EasingKeyFrameTemplate">
<TemplateInstance ModuleName="Core\CSharp" TypeName="Byte"/>
<TemplateInstance ModuleName="Core\CSharp" TypeName="Color"/>
......
......@@ -70,6 +70,7 @@ HRESULT HrValidateInitializeCall(
MilRTInitialization::DisableDisplayClipping |
MilRTInitialization::DisableMultimonDisplayClipping |
MilRTInitialization::IsDisableMultimonDisplayClippingValid |
MilRTInitialization::DisableDirtyRectangles |
MilRTInitialization::UseRefRast |
MilRTInitialization::UseRgbRast |
MilRTInitialization::PresentUsingMask
......
......@@ -113,7 +113,7 @@ CHwDisplayRenderTarget::Create(
associatedDisplay,
eWindowLayerType
);
IFCOOM(*ppRenderTarget);
(*ppRenderTarget)->AddRef(); // CHwDisplayRenderTarget::ctor sets ref count == 0
}
......@@ -164,6 +164,8 @@ CHwDisplayRenderTarget::Init(
dwFlags
);
m_fDisableDirtyRectangles = (dwFlags & MilRTInitialization::DisableDirtyRectangles) != 0;
#if DBG_STEP_RENDERING
m_fDbgClearOnPresent = !(dwFlags & MilRTInitialization::PresentRetainContents);
#endif DBG_STEP_RENDERING
......@@ -378,6 +380,12 @@ CHwDisplayRenderTarget::Present(
goto Cleanup;
}
if (m_fDisableDirtyRectangles)
{
// invalidating the empty rect tells ShouldPresent to present everything
InvalidateRect(reinterpret_cast<const CMILSurfaceRect *>(&CMILSurfaceRect::sc_rcEmpty));
}
bool fPresent = false;
RGNDATA *pDirtyRegion = NULL;
IFC(ShouldPresent(
......@@ -417,8 +425,8 @@ CHwDisplayRenderTarget::Present(
// Note that WGXERR_DISPLAYSTATEINVALID is bubbled up here so the caller is
// responsible for recreating this object
if (m_D3DPresentParams.SwapEffect == D3DSWAPEFFECT_COPY)
{
AssertConstMsgW( ( m_MILDC.GetRTInitializationFlags()
{
AssertConstMsgW( ( m_MILDC.GetRTInitializationFlags()
& MilRTInitialization::PresentRetainContents
)
|| IsTagEnabled(tagMILStepRendering),
......@@ -497,11 +505,11 @@ Cleanup:
//
// Member: CHwDisplayRenderTarget::InvalidateRect
//
// Synopsis: Check for enabled rendering and retain contents before
// Synopsis: Check for enabled rendering and retain contents before
// delegating to base class.
//
HRESULT
HRESULT
CHwDisplayRenderTarget::InvalidateRect(
__in_ecount(1) CMILSurfaceRect const *pRect
)
......@@ -525,7 +533,7 @@ Cleanup:
// layout, and desired swap effect.
//
HRESULT
HRESULT
CHwDisplayRenderTarget::PresentInternal(
__in_ecount(1) CMILSurfaceRect const *prcSource,
__in_ecount(1) CMILSurfaceRect const *prcDest,
......@@ -602,7 +610,7 @@ volatile BOOL g_fStepHWRendering = false;
volatile BOOL g_fStepHWRenderingLock = false;
#endif
void
void
CHwDisplayRenderTarget::ShowSteppedRendering(
__in LPCTSTR pszRenderDesc,
__in_ecount(1) const ISteppedRenderingSurfaceRT *pRT
......@@ -628,8 +636,8 @@ CHwDisplayRenderTarget::ShowSteppedRendering(
CMILSurfaceRect rcPresentSource;
CMILSurfaceRect rcPresentDest(
0,
0,
m_uWidth,
0,
m_uWidth,
m_uHeight,
XYWH_Parameters
);
......@@ -975,10 +983,10 @@ Cleanup:
//+----------------------------------------------------------------------------
//
// Member:
// Member:
// CHwDisplayRenderTarget::DbgStepCreateD3DSurfaceFromBitmapSource
//
// Synopsis:
// Synopsis:
// Creates a CD3DSurface in video memory from an IWGXBitmapSource. This
// method was written for stepped rendering, so it is named as such.
// Before renaming this function and using it retail, investigate whether
......@@ -1009,7 +1017,7 @@ CHwDisplayRenderTarget::DbgStepCreateD3DSurfaceFromBitmapSource(
IFC(pBitmap->GetPixelFormat(
&fmtBitmap
));
Assert(fmtBitmap == MilPixelFormat::PBGRA32bpp);
hwVidMemManager.SetRealizationParameters(
......@@ -1310,7 +1318,7 @@ CHwDisplayRenderTarget::AdvanceFrame(
if (SUCCEEDED(m_hrDisplayInvalid) && m_pD3DDevice)
{
ENTER_DEVICE_FOR_SCOPE(*m_pD3DDevice);
m_pD3DDevice->AdvanceFrame(uFrameNumber);
}
}
......
......@@ -147,7 +147,7 @@ public:
THIS_
__in_ecount(1) const RECT *prcSource,
__in_ecount(1) const RECT *prcDest
) PURE;
) PURE;
STDMETHOD(InvalidateRect)(
__in_ecount(1) CMILSurfaceRect const *pRect
......@@ -158,7 +158,7 @@ public:
{
return CBaseSurfaceRenderTarget<CHwRenderTargetLayerData>::ClearInvalidatedRects();
}
STDMETHOD(WaitForVBlank)();
STDMETHOD_(VOID, AdvanceFrame)(
......@@ -186,6 +186,7 @@ protected:
protected:
BOOL m_fEnableRendering; // Rendering is disabled during resize
BOOL m_fDisableDirtyRectangles; // app wants to skip D3D dirty-rect optimization
CD3DSwapChain *m_pD3DSwapChain;
D3DPRESENT_PARAMETERS m_D3DPresentParams;
UINT const m_AdapterOrdinalInGroup;
......@@ -230,7 +231,7 @@ private:
__in_ecount(1) IWGXBitmapSource *pBitmap,
__deref_out_ecount(1) CD3DSurface **ppD3DSurface
);
BOOL m_fDbgClearOnPresent;
#endif DBG_STEP_RENDERING
};
......
......@@ -35,13 +35,13 @@ MtExtern(CSwPresenter32bppGDI);
**************************************************************************/
//
// There is only one presenter, CSwPresenter32bppGDI. Having a separate
// There is only one presenter, CSwPresenter32bppGDI. Having a separate
// CSwPresenterBase is probably redundant and unnecessary
//
class CSwPresenterBase :
// This needs to be an IWGXBitmap so it can be used in SetSurface but
// a lock operates on it and our lock implementation, CWGXBitmapLock,
// a lock operates on it and our lock implementation, CWGXBitmapLock,
// requires a CWGXBitmap because of the Unlock() method
public CWGXBitmap
{
......@@ -166,7 +166,7 @@ public:
THIS_
__in_ecount(1) const RECT *prcSource,
__in_ecount(1) const RECT *prcDest
);
);
STDMETHOD(InvalidateRect)(
__in_ecount(1) CMILSurfaceRect const *prc
......@@ -180,7 +180,7 @@ public:
{
RRETURN(CBaseSurfaceRenderTarget<CSwRenderTargetLayerData>::ClearInvalidatedRects());
}
STDMETHOD(Resize)(
UINT uWidth,
UINT uHeight
......@@ -219,6 +219,7 @@ private:
HWND m_hwnd;
CSwPresenter32bppGDI *m_pPresenter;
BOOL m_fDisableDirtyRectangles; // app wants to skip dirty-rect optimization
};
......
......@@ -60,7 +60,7 @@ HRESULT CSwPresenterBase::GetSize(
{
*puiWidth = m_nWidth;
*puiHeight = m_nHeight;
return S_OK;
}
......@@ -75,7 +75,7 @@ HRESULT CSwPresenterBase::GetSize(
HRESULT CSwPresenterBase::GetPixelFormat(
__out_ecount(1) MilPixelFormat::Enum *pPixelFormat
)
{
{
*pPixelFormat = m_RenderPixelFormat;
return S_OK;
......@@ -97,7 +97,7 @@ HRESULT CSwPresenterBase::GetResolution(
*pDpiX = primaryDisplayDpi.DpiScaleX;
*pDpiY = primaryDisplayDpi.DpiScaleY;
return S_OK;
}
......@@ -336,6 +336,7 @@ HRESULT CSwRenderTargetHWND::Init(
);
m_hwnd = hwnd;
m_fDisableDirtyRectangles = (nFlags & MilRTInitialization::DisableDirtyRectangles) != 0;
#if DBG_STEP_RENDERING
m_fDbgClearOnPresent = !(nFlags & MilRTInitialization::PresentRetainContents);
......@@ -368,16 +369,22 @@ STDMETHODIMP CSwRenderTargetHWND::Present(
CMILSurfaceRect presentRect;
bool fPresent = false;
RGNDATA *pDirtyRegion = NULL;
if (m_fDisableDirtyRectangles)
{
// invalidating the empty rect tells ShouldPresent to present everything
InvalidateRect(reinterpret_cast<const CMILSurfaceRect *>(&CMILSurfaceRect::sc_rcEmpty));
}
IFC(ShouldPresent(
pRect,
&presentRect,
&pDirtyRegion,
&fPresent
));
if (fPresent)
{
IFC(m_pPresenter->Present(
......@@ -441,7 +448,7 @@ CSwRenderTargetHWND::ScrollBlt (
IFC(m_pPresenter->ScrollBlt(&source, &dest, true, true));
Cleanup:
RRETURN(hr);
RRETURN(hr);
}
......
......@@ -745,32 +745,38 @@ BEGIN_MILFLAGENUM( MilRTInitialization )
//
// This flag forces the creation of a render target bitmap to match its
// parent's type, so a software surface only creates software RTs and a
// hardware surface only creates hardware RTs. This is necessary for the
// hardware surface only creates hardware RTs. This is necessary for the
// hardware-accelerated bitmap effects pipeline to guarantee that we do
// not encounter a situation where we're trying to run shaders sampling
// not encounter a situation where we're trying to run shaders sampling
// from a hardware texture to render into a software intermediate.
//
ForceCompatible = 0x00002000,
//
// This flag is the same as DisableDisplayClipping except that it disables
// This flag is the same as DisableDisplayClipping except that it disables
// display clipping on multi-monitor configurations in all OS'. This flag is
// automatically
// set on Windows 8 and newer systems. If WPF decides to unset
// DisableDisplayClipping, then DisableMultimonDisplayClipping flag will not be
// automatically
// set on Windows 8 and newer systems. If WPF decides to unset
// DisableDisplayClipping, then DisableMultimonDisplayClipping flag will not be
// respected even if set by an applicaiton via its manifest
//
DisableMultimonDisplayClipping = 0x00004000,
//
// This flag is passed down by PresentationCore to tell wpfgfx that
// the DisableMultimonDisplayClipping compatibity flag is set by the user. This
// This flag is passed down by PresentationCore to tell wpfgfx that
// the DisableMultimonDisplayClipping compatibity flag is set by the user. This
// allows us to distinguish between when DisableMultimonDisplayClipping == 0 means
// that the user set it to false explicitly, versus when the user didn't set it
// that the user set it to false explicitly, versus when the user didn't set it
// and the DisableMultimonDisplayClipping bit happens to be implicitly set to 0
//
IsDisableMultimonDisplayClippingValid = 0x00008000,
//
// This flag directs the render target to render the full scene,
// bypassing D3D's dirty-rectangle optimizations.
//
DisableDirtyRectangles = 0x00010000,
//
// Test only / internal flags
......
......@@ -273,7 +273,7 @@ WindowMessage message
IntPtr pChannel,
DUCE.ResourceHandle hResource,
out uint refCount
);
);
}
/// <summary>
......@@ -452,7 +452,7 @@ internal void Commit()
/// </summary>
/// <SecurityNote>
/// Critical: This code calls into MilConnection_CloseBatch which causes an elevation
/// TreatAsSafe: Closing a batch is safe and nothing is exposed. Batches are in the
/// TreatAsSafe: Closing a batch is safe and nothing is exposed. Batches are in the
/// render thread, and can only be written to from the UI thread while
/// they're open using other SC/STAS methods on DUCE.Channel. Once closed,
/// the only operation that can be done on a batch is Channel.Commit.
......@@ -574,7 +574,7 @@ ref handle
if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW))
{
EventTrace.EventProvider.TraceEvent(EventTrace.Event.CreateOrAddResourceOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, PerfService.GetPerfElementID(instance), _hChannel, (uint) handle, (uint) resourceType);
EventTrace.EventProvider.TraceEvent(EventTrace.Event.CreateOrAddResourceOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, PerfService.GetPerfElementID(instance), _hChannel, (uint) handle, (uint) resourceType);
}
return handleNeedsCreation;
......@@ -650,14 +650,14 @@ out releasedOnChannel
if ((releasedOnChannel != 0) && EventTrace.IsEnabled(EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW))
{
EventTrace.EventProvider.TraceEvent(EventTrace.Event.ReleaseOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, _hChannel, (uint) handle);
EventTrace.EventProvider.TraceEvent(EventTrace.Event.ReleaseOnChannel, EventTrace.Keyword.KeywordGraphics | EventTrace.Keyword.KeywordPerf, EventTrace.Level.PERF_LOW, _hChannel, (uint) handle);
}
return (releasedOnChannel != 0);
}
/// <summary>
/// Internal only: GetRefCount returns the reference count of a resource
/// Internal only: GetRefCount returns the reference count of a resource
/// corresponding to the specified handle on the channel.
/// </summary>
/// <return>
......@@ -1152,7 +1152,7 @@ public bool IsOnChannel(Channel channel)
/// <summary>
/// Returns the real UInt32 handle.
/// Returns the real UInt32 handle.
/// </summary>
public DUCE.ResourceHandle Handle { get { return _handle; } }
}
......@@ -1702,7 +1702,7 @@ public bool CreateOrAddRefOnChannel(object instance, Channel channel, DUCE.Resou
bool inmap = _map.Get(channel, out handle);
bool created = channel.CreateOrAddRefOnChannel(instance, ref handle, type);
if (!inmap)
{
_map.Set(channel, handle);
......@@ -1880,7 +1880,7 @@ internal static class CompositionNode
DUCE.ResourceHandle hEffect,
Channel channel)
{
DUCE.MILCMD_VISUAL_SETEFFECT command;
DUCE.MILCMD_VISUAL_SETEFFECT command;
command.Type = MILCMD.MilCmdVisualSetEffect;
command.Handle = hCompositionNode;
......@@ -1894,7 +1894,7 @@ internal static class CompositionNode
);
}
}
/// <SecurityNote>
/// Critical: This code accesses an unsafe code block
......@@ -1906,7 +1906,7 @@ internal static class CompositionNode
DUCE.ResourceHandle hCacheMode,
Channel channel)
{
DUCE.MILCMD_VISUAL_SETCACHEMODE command;
DUCE.MILCMD_VISUAL_SETCACHEMODE command;
command.Type = MILCMD.MilCmdVisualSetCacheMode;
command.Handle = hCompositionNode;
......@@ -2054,7 +2054,7 @@ internal static class CompositionNode
sizeof(DUCE.MILCMD_VISUAL_SETSCROLLABLEAREACLIP)
);
}
}
}
/// <SecurityNote>
/// Critical: This code accesses an unsafe code block
......@@ -2534,7 +2534,7 @@ Channel channel
command.flags |= (UInt32)MILRTInitializationFlags.MIL_RT_SOFTWARE_ONLY;
}
bool? enableMultiMonitorDisplayClipping =
bool? enableMultiMonitorDisplayClipping =
System.Windows.CoreCompatibilityPreferences.EnableMultiMonitorDisplayClipping;
if (enableMultiMonitorDisplayClipping != null)
......@@ -2548,6 +2548,11 @@ Channel channel
}
}
if (CoreAppContextSwitches.DisableDirtyRectangles)
{
command.flags |= (UInt32)MILRTInitializationFlags.MIL_RT_DISABLE_DIRTY_RECTANGLES;
}
command.hBitmap = DUCE.ResourceHandle.Null;
command.stride = 0;
command.ePixelFormat = 0;
......@@ -2791,17 +2796,17 @@ Channel channel
}
/// <summary>
/// See <see cref="MediaContext.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable"/> for
/// See <see cref="MediaContext.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable"/> for
/// details.
/// </summary>
/// <SecurityNote>
/// Critical: This code accesses an unsafe code block
/// Safe: Operation is ok to call, sending a pointer to a channel is safe,
/// Safe: Operation is ok to call, sending a pointer to a channel is safe,
/// and this does not return any Critical data to the caller
/// </SecurityNote>
[SecuritySafeCritical]
internal static void NotifyPolicyChangeForNonInteractiveMode(
bool forceRender,
bool forceRender,
Channel channel
)
{
......@@ -2814,8 +2819,8 @@ Channel channel
unsafe
{
channel.SendCommand(
(byte*)&command,
sizeof(DUCE.MILCMD_PARTITION_NOTIFYPOLICYCHANGEFORNONINTERACTIVEMODE),
(byte*)&command,
sizeof(DUCE.MILCMD_PARTITION_NOTIFYPOLICYCHANGEFORNONINTERACTIVEMODE),
sendInSeparateBatch: false
);
}
......
......@@ -858,6 +858,12 @@ BEGIN_MILFLAGENUM( MilRTInitialization )
//
IsDisableMultimonDisplayClippingValid = 0x00008000,
//
// This flag directs the render target to render the full scene,
// bypassing D3D's dirty-rectangle optimizations.
//
DisableDirtyRectangles = 0x00010000,
//
// Test only / internal flags
......
......@@ -25,133 +25,133 @@ internal enum MIL_SEGMENT_TYPE {
MilSegmentPolyLine,
MilSegmentPolyBezier,
MilSegmentPolyQuadraticBezier,
MIL_SEGMENT_TYPE_FORCE_DWORD = unchecked((int)0xffffffff)
};
[System.Flags]
internal enum MILCoreSegFlags
{
SegTypeLine = 0x00000001,
SegTypeBezier = 0x00000002,
SegTypeMask = 0x00000003,
// When this bit is set then this segment is not to be stroked
SegIsAGap = 0x00000004,
// When this bit is set then the join between this segment and the PREVIOUS segment
// will be rounded upon widening, regardless of the pen line join property.
SegSmoothJoin = 0x00000008,
// When this bit is set on the first type then the figure should be closed.
SegClosed = 0x00000010,
// This bit indicates whether the segment is curved.
SegIsCurved = 0x00000020,
FORCE_DWORD = unchecked((int)0xffffffff)
};
internal enum MIL_PEN_CAP {
MilPenCapFlat = 0,
MilPenCapSquare = 1,
MilPenCapRound = 2,
MilPenCapTriangle = 3,
MIL_PEN_CAP_FORCE_DWORD = unchecked((int)0xffffffff)
};
internal enum MIL_PEN_JOIN {
MilPenJoinMiter = 0,
MilPenJoinBevel = 1,
MilPenJoinRound = 2,
MIL_PEN_JOIN_FORCE_DWORD = unchecked((int)0xffffffff)
};
[System.Flags]
internal enum MILRTInitializationFlags
{
// Default initialization flags (0) imply hardware with software fallback,
// synchronized to reduce tearing for hw RTs, and no retention of contents
// between scenes.
MIL_RT_INITIALIZE_DEFAULT = 0x00000000,
// This flag disables the hardware accelerated RT. Use only software.
MIL_RT_SOFTWARE_ONLY = 0x00000001,
// This flag disables the software RT. Use only hardware.
MIL_RT_HARDWARE_ONLY = 0x00000002,
// Creates a dummy render target that consumes all calls
MIL_RT_NULL = 0x00000003,
// Mask for choice of render target
MIL_RT_TYPE_MASK = 0x00000003,
// This flag indicates that presentation should not wait for any specific
// time to promote the results to the display. This may result in display
// tearing.
MIL_RT_PRESENT_IMMEDIATELY = 0x00000004,
// This flag makes the RT reatin the contents from one frame to the next.
// Retaining the contents has performance implications. For scene changes
// with little to update retaining contents may help, but if most of the
// scene will be repainted anyway, retention may hurt some hw scenarios.
MIL_RT_PRESENT_RETAIN_CONTENTS = 0x00000008,
// This flag indicates that we should create a full screen RT.
MIL_RT_FULLSCREEN = 0x00000010,
// This flag indicates that the render target backbuffer will have
// linear gamma.
MIL_RT_LINEAR_GAMMA = 0x00000020,
// This flag indicates that the render target backbuffer will have
// an alpha channel that is at least 8 bits wide.
MIL_RT_NEED_DESTINATION_ALPHA = 0x00000040,
// This flag allows the render target backbuffer to contain
// 10 bits per channel rather than 32. This flag only has
// meaning when linear gamma is also present.
MIL_RT_ALLOW_LOW_PRECISION = 0x00000080,
// This flag assumes that all resources (such as bitmaps and render
// targets) are released on the same thread as the rendering device. This
// flag enables us to use a single threaded dx device instead of a
// multi-threaded one.
MIL_RT_SINGLE_THREADED_USAGE = 0x00000100,
// This flag directs the render target to extend its presentation area
// to include the non-client area. The origin of the render target space
// will be equal to the origin of the window.
MIL_RT_RENDER_NONCLIENT = 0x00000200,
// This flag enables tear free composition by using the SWAPEFFECT D3D_FLIP.
MIL_RT_PRESENT_FLIP = 0x00000400,
// Setting this flag results in the DX device instructing the driver not to
// autorotate if the monitor is in a rotated mode. Only makes sense for
// fullscreen RTs
MIL_RT_FULLSCREEN_NO_AUTOROTATE = 0x00000800,
// This flag directed the render target not to restrict its rendering and
// presentation to the visible portion of window on the desktop. This is
// useful for when the window position may be faked or the system may try
......@@ -163,58 +163,64 @@ internal enum MILRTInitializationFlags
MIL_RT_DISABLE_DISPLAY_CLIPPING = 0x00001000,
//
// This flag is the same as MIL_RT_DISABLE_DISPLAY_CLIPPING except that it disables
// display clipping on multi-monitor configurations in all OS'. This flag is automatically
// set on Windows 8 and newer systems. If WPF decides to unset
// This flag is the same as MIL_RT_DISABLE_DISPLAY_CLIPPING except that it disables
// display clipping on multi-monitor configurations in all OS'. This flag is automatically
// set on Windows 8 and newer systems. If WPF decides to unset
// MIL_RT_DISABLE_DISPLAY_CLIPPING, then MIL_RT_DISABLE_MULTIMON_DISPLAY_CLIPPING flag
// will not be respected even if set by an applicaiton via its manifest
//
MIL_RT_DISABLE_MULTIMON_DISPLAY_CLIPPING = 0x00004000,
//
// This flag is passed down by PresentationCore to tell wpfgfx that
// the DisableMultimonDisplayClipping compatibity flag is set by the user. This
// This flag is passed down by PresentationCore to tell wpfgfx that
// the DisableMultimonDisplayClipping compatibity flag is set by the user. This
// allows us to distinguish between when DisableMultimonDisplayClipping == 0 means
// that the user set it to false explicitly, versus when the user didn't set it
// that the user set it to false explicitly, versus when the user didn't set it
// and the DisableMultimonDisplayClipping bit happens to be implicitly set to 0
//
MIL_RT_IS_DISABLE_MULTIMON_DISPLAY_CLIPPING_VALID = 0x00008000,
//
//
// This flag directs the render target to render the full scene,
// bypassing D3D's dirty-rectangle optimizations.
//
MIL_RT_DISABLE_DIRTY_RECTANGLES = 0x00010000,
//
// UCE only flags
//
// This flag directs the composition rendertarget to enable the occlusion
// culling optimization.
MIL_UCE_RT_ENABLE_OCCLUSION = 0x00010000,
//
// Test only / internal flags
//
// This flag forces the render target to use the d3d9 reference raster
// when using d3d. (Should be combined with MIL_RT_INITIALIZE_DEFAULT or
// MIL_RT_HARDWARE_ONLY)
// This is designed for test apps only
MIL_RT_USE_REF_RAST = 0x01000000,
// This flag forces the render target to use the rgb reference raster
// when using d3d.( Should be combined with MIL_RT_INITIALIZE_DEFAULT or
// MIL_RT_HARDWARE_ONLY )
// This is designed for test apps only
MIL_RT_USE_RGB_RAST = 0x02000000,
// MIL Core Rendering Internal flag (=Do NOT pass to RT Create methods)
// This flag enables the buffer to be set up in a transposed mode
// in order to manage our own rotation for 90 and 270 degree rotations.
MIL_RT_FULLSCREEN_TRANSPOSE_XY = unchecked((int)0x10000000),
// We support 4 primary present modes:
//
// 1) Present using D3D
......@@ -227,11 +233,11 @@ internal enum MILRTInitializationFlags
MIL_RT_PRESENT_USING_BITBLT = unchecked((int)0x40000000),
MIL_RT_PRESENT_USING_ALPHABLEND = unchecked((int)0x80000000),
MIL_RT_PRESENT_USING_ULW = unchecked((int)0xC0000000),
FORCE_DWORD = unchecked((int)0xffffffff)
};
internal enum MIL_PRESENTATION_RESULTS {
MIL_PRESENTATION_VSYNC,
MIL_PRESENTATION_NOPRESENT,
......@@ -239,7 +245,7 @@ internal enum MIL_PRESENTATION_RESULTS {
MIL_PRESENTATION_DWM,
MIL_PRESENTATION_FORCE_DWORD = unchecked((int)0xffffffff)
};
[StructLayout(LayoutKind.Sequential, Pack=1)]
internal struct MIL_PEN_DATA {
internal double Thickness;
......@@ -251,29 +257,28 @@ internal struct MIL_PEN_DATA {
internal MIL_PEN_JOIN LineJoin;
internal UInt32 DashArraySize;
};
[System.Flags]
internal enum MILTransparencyFlags
{
Opaque = 0x0,
ConstantAlpha = 0x1,
PerPixelAlpha = 0x2,
ColorKey = 0x4,
FORCE_DWORD = unchecked((int)0xffffffff)
};
internal enum MILWindowLayerType
{
NotLayered = 0,
SystemManagedLayer = 1,
ApplicationManagedLayer = 2,
FORCE_DWORD = unchecked((int)0xffffffff)
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册