Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / RenderCapability.cs / 1305600 / RenderCapability.cs
//------------------------------------------------------------------------------ // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // The RenderCapability class allows clients to query for the current // render tier associated with their Dispatcher and to register for // notification on change. // //----------------------------------------------------------------------------- using System; using System.Diagnostics; namespace System.Windows.Media { ////// RenderCapability - /// The RenderCapability class allows clients to query for the current /// render tier associated with their Dispatcher and to register for /// notification on change. /// public static class RenderCapability { ////// Tier Property - returns the current render tier for the Dispatcher associated /// with the current thread. /// public static int Tier { get { MediaContext mediaContext = MediaContext.CurrentMediaContext; // The Dispatcher auto-creates if there is no Dispatcher associated with this // thread, and the MediaContext does the same. Thus, mediaContext should never // be null. Debug.Assert(mediaContext != null); return mediaContext.Tier; } } ////// Returns whether the specified PixelShader major/minor version is /// supported by this version of WPF, and whether Effects using the /// specified major/minor version can run on the GPU. /// public static bool IsPixelShaderVersionSupported(short majorVersionRequested, short minorVersionRequested) { bool isSupported = false; // // For now, we only support PS 2.0 and 3.0. Can only return true if this is // the version asked for. // if (majorVersionRequested == 2 && minorVersionRequested == 0 || majorVersionRequested == 3 && minorVersionRequested == 0) { // Now actually check. MediaContext mediaContext = MediaContext.CurrentMediaContext; byte majorVersion = (byte)((mediaContext.PixelShaderVersion >> 8) & 0xFF); byte minorVersion = (byte)((mediaContext.PixelShaderVersion >> 0) & 0xFF); // We assume here that a higher version does in fact support the // version we're requiring. if (majorVersion >= majorVersionRequested) { isSupported = true; } else if (majorVersion == majorVersionRequested && minorVersion >= minorVersionRequested) { isSupported = true; } } return isSupported; } ////// Returns whether Effects can be rendered in software on this machine. /// public static bool IsPixelShaderVersionSupportedInSoftware(short majorVersionRequested, short minorVersionRequested) { bool isSupported = false; // // Software rendering is only supported for PS 2.0. // if (majorVersionRequested == 2 && minorVersionRequested == 0) { // Now actually check. MediaContext mediaContext = MediaContext.CurrentMediaContext; isSupported = mediaContext.HasSSE2Support; } return isSupported; } ////// Returns whether Effects can be rendered in software on this machine. /// [Obsolete(IsShaderEffectSoftwareRenderingSupported_Deprecated)] public static bool IsShaderEffectSoftwareRenderingSupported { get { MediaContext mediaContext = MediaContext.CurrentMediaContext; return mediaContext.HasSSE2Support; } } ////// Returns the maximum number of instruction slots supported. /// The number of instruction slots supported by PS 3.0 varies, but will be at least 512. /// public static int MaxPixelShaderInstructionSlots(short majorVersionRequested, short minorVersionRequested) { if (majorVersionRequested == 2 && minorVersionRequested == 0) { // ps_2_0 supports 32 texture + 64 arithmetic = 96 instruction slots. return 96; } else if (majorVersionRequested == 3 && minorVersionRequested == 0) { MediaContext mediaContext = MediaContext.CurrentMediaContext; return (int)mediaContext.MaxPixelShader30InstructionSlots; } else { // anything other than ps_2_0 and ps_3_0 are not supported. return 0; } } ////// Returns the maximum width and height for texture creation of the underlying /// hardware device. If there are multiple devices, this returns the minumum size /// among them. /// public static Size MaxHardwareTextureSize { get { MediaContext mediaContext = MediaContext.CurrentMediaContext; return mediaContext.MaxTextureSize; } } ////// TierChanged event - /// This event is raised when the Tier for a given Dispatcher changes. /// public static event EventHandler TierChanged { add { MediaContext mediaContext = MediaContext.CurrentMediaContext; // The Dispatcher auto-creates if there is no Dispatcher associated with this // thread, and the MediaContext does the same. Thus, mediaContext should never // be null. Debug.Assert(mediaContext != null); mediaContext.TierChanged += value; } remove { MediaContext mediaContext = MediaContext.CurrentMediaContext; // The Dispatcher auto-creates if there is no Dispatcher associated with this // thread, and the MediaContext does the same. Thus, mediaContext should never // be null. Debug.Assert(mediaContext != null); mediaContext.TierChanged -= value; } } private const string IsShaderEffectSoftwareRenderingSupported_Deprecated = "IsShaderEffectSoftwareRenderingSupported property is deprecated. Use IsPixelShaderVersionSupportedInSoftware static method instead."; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // The RenderCapability class allows clients to query for the current // render tier associated with their Dispatcher and to register for // notification on change. // //----------------------------------------------------------------------------- using System; using System.Diagnostics; namespace System.Windows.Media { ////// RenderCapability - /// The RenderCapability class allows clients to query for the current /// render tier associated with their Dispatcher and to register for /// notification on change. /// public static class RenderCapability { ////// Tier Property - returns the current render tier for the Dispatcher associated /// with the current thread. /// public static int Tier { get { MediaContext mediaContext = MediaContext.CurrentMediaContext; // The Dispatcher auto-creates if there is no Dispatcher associated with this // thread, and the MediaContext does the same. Thus, mediaContext should never // be null. Debug.Assert(mediaContext != null); return mediaContext.Tier; } } ////// Returns whether the specified PixelShader major/minor version is /// supported by this version of WPF, and whether Effects using the /// specified major/minor version can run on the GPU. /// public static bool IsPixelShaderVersionSupported(short majorVersionRequested, short minorVersionRequested) { bool isSupported = false; // // For now, we only support PS 2.0 and 3.0. Can only return true if this is // the version asked for. // if (majorVersionRequested == 2 && minorVersionRequested == 0 || majorVersionRequested == 3 && minorVersionRequested == 0) { // Now actually check. MediaContext mediaContext = MediaContext.CurrentMediaContext; byte majorVersion = (byte)((mediaContext.PixelShaderVersion >> 8) & 0xFF); byte minorVersion = (byte)((mediaContext.PixelShaderVersion >> 0) & 0xFF); // We assume here that a higher version does in fact support the // version we're requiring. if (majorVersion >= majorVersionRequested) { isSupported = true; } else if (majorVersion == majorVersionRequested && minorVersion >= minorVersionRequested) { isSupported = true; } } return isSupported; } ////// Returns whether Effects can be rendered in software on this machine. /// public static bool IsPixelShaderVersionSupportedInSoftware(short majorVersionRequested, short minorVersionRequested) { bool isSupported = false; // // Software rendering is only supported for PS 2.0. // if (majorVersionRequested == 2 && minorVersionRequested == 0) { // Now actually check. MediaContext mediaContext = MediaContext.CurrentMediaContext; isSupported = mediaContext.HasSSE2Support; } return isSupported; } ////// Returns whether Effects can be rendered in software on this machine. /// [Obsolete(IsShaderEffectSoftwareRenderingSupported_Deprecated)] public static bool IsShaderEffectSoftwareRenderingSupported { get { MediaContext mediaContext = MediaContext.CurrentMediaContext; return mediaContext.HasSSE2Support; } } ////// Returns the maximum number of instruction slots supported. /// The number of instruction slots supported by PS 3.0 varies, but will be at least 512. /// public static int MaxPixelShaderInstructionSlots(short majorVersionRequested, short minorVersionRequested) { if (majorVersionRequested == 2 && minorVersionRequested == 0) { // ps_2_0 supports 32 texture + 64 arithmetic = 96 instruction slots. return 96; } else if (majorVersionRequested == 3 && minorVersionRequested == 0) { MediaContext mediaContext = MediaContext.CurrentMediaContext; return (int)mediaContext.MaxPixelShader30InstructionSlots; } else { // anything other than ps_2_0 and ps_3_0 are not supported. return 0; } } ////// Returns the maximum width and height for texture creation of the underlying /// hardware device. If there are multiple devices, this returns the minumum size /// among them. /// public static Size MaxHardwareTextureSize { get { MediaContext mediaContext = MediaContext.CurrentMediaContext; return mediaContext.MaxTextureSize; } } ////// TierChanged event - /// This event is raised when the Tier for a given Dispatcher changes. /// public static event EventHandler TierChanged { add { MediaContext mediaContext = MediaContext.CurrentMediaContext; // The Dispatcher auto-creates if there is no Dispatcher associated with this // thread, and the MediaContext does the same. Thus, mediaContext should never // be null. Debug.Assert(mediaContext != null); mediaContext.TierChanged += value; } remove { MediaContext mediaContext = MediaContext.CurrentMediaContext; // The Dispatcher auto-creates if there is no Dispatcher associated with this // thread, and the MediaContext does the same. Thus, mediaContext should never // be null. Debug.Assert(mediaContext != null); mediaContext.TierChanged -= value; } } private const string IsShaderEffectSoftwareRenderingSupported_Deprecated = "IsShaderEffectSoftwareRenderingSupported property is deprecated. Use IsPixelShaderVersionSupportedInSoftware static method instead."; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CharacterMetrics.cs
- PersonalizationAdministration.cs
- EntityKeyElement.cs
- ErrorHandlerModule.cs
- VisualSerializer.cs
- EditorPartCollection.cs
- BeginStoryboard.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- SuppressMergeCheckAttribute.cs
- SecureStringHasher.cs
- IndexedString.cs
- BinaryMessageFormatter.cs
- shaperfactory.cs
- XmlNodeChangedEventManager.cs
- WebServiceData.cs
- DBCommandBuilder.cs
- AesManaged.cs
- XmlSchemaAnnotation.cs
- StagingAreaInputItem.cs
- MaterializeFromAtom.cs
- DefinitionBase.cs
- BitmapEffectGeneralTransform.cs
- ToolStripStatusLabel.cs
- SimpleWorkerRequest.cs
- XsltArgumentList.cs
- DataGridColumnCollection.cs
- FlowLayout.cs
- SQLInt64Storage.cs
- RootBrowserWindowAutomationPeer.cs
- OrElse.cs
- AnimationLayer.cs
- XmlSecureResolver.cs
- ProcessExitedException.cs
- SamlAttribute.cs
- FullTextState.cs
- WrappedReader.cs
- BufferedGraphics.cs
- WebConfigurationFileMap.cs
- ProfileGroupSettings.cs
- BindingContext.cs
- MailDefinition.cs
- SqlProviderUtilities.cs
- Positioning.cs
- StylusSystemGestureEventArgs.cs
- DoubleKeyFrameCollection.cs
- Reference.cs
- CacheDependency.cs
- DataGridTableCollection.cs
- XmlSerializableReader.cs
- ToolboxItemFilterAttribute.cs
- ItemCollection.cs
- XpsS0ValidatingLoader.cs
- WindowsFormsSectionHandler.cs
- PropertyNames.cs
- BamlLocalizer.cs
- DataSourceHelper.cs
- XmlLoader.cs
- XsltArgumentList.cs
- PenLineCapValidation.cs
- MouseButton.cs
- MsmqPoisonMessageException.cs
- HtmlImage.cs
- WebPartManager.cs
- DecoderExceptionFallback.cs
- OrderedDictionary.cs
- ReadContentAsBinaryHelper.cs
- DesignerDeviceConfig.cs
- DbParameterHelper.cs
- UserControl.cs
- XmlQueryCardinality.cs
- EnumMemberAttribute.cs
- RecordManager.cs
- SafeLocalMemHandle.cs
- IncrementalReadDecoders.cs
- relpropertyhelper.cs
- JapaneseLunisolarCalendar.cs
- XmlSchemaAnnotated.cs
- DataGridViewLayoutData.cs
- TdsParserHelperClasses.cs
- Pen.cs
- UserPersonalizationStateInfo.cs
- SystemUnicastIPAddressInformation.cs
- EncodingInfo.cs
- MdbDataFileEditor.cs
- EncodingConverter.cs
- XamlWrappingReader.cs
- LineBreakRecord.cs
- PropertyContainer.cs
- XmlSchemaSimpleType.cs
- UIElementHelper.cs
- ProfileModule.cs
- FilterQuery.cs
- XmlSerializerNamespaces.cs
- LoadRetryHandler.cs
- CodeNamespaceCollection.cs
- LineMetrics.cs
- MulticastDelegate.cs
- SimpleMailWebEventProvider.cs
- SqlWriter.cs
- ObjectTag.cs