Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Media / RenderCapability.cs / 1 / 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. Can only return true if this is // the version asked for. const short majorVersionRequired = 2; const short minorVersionRequired = 0; if (majorVersionRequested == majorVersionRequired && minorVersionRequested == minorVersionRequired) { // 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 >= majorVersionRequired) { isSupported = true; } else if (majorVersion == majorVersionRequired && minorVersion >= minorVersionRequired) { isSupported = true; } } return isSupported; } ////// Returns whether Effects can be rendered in software on this machine. /// public static bool IsShaderEffectSoftwareRenderingSupported { get { MediaContext mediaContext = MediaContext.CurrentMediaContext; return mediaContext.HasSSE2Support; } } ////// 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; } } } } // 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. Can only return true if this is // the version asked for. const short majorVersionRequired = 2; const short minorVersionRequired = 0; if (majorVersionRequested == majorVersionRequired && minorVersionRequested == minorVersionRequired) { // 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 >= majorVersionRequired) { isSupported = true; } else if (majorVersion == majorVersionRequired && minorVersion >= minorVersionRequired) { isSupported = true; } } return isSupported; } ////// Returns whether Effects can be rendered in software on this machine. /// public static bool IsShaderEffectSoftwareRenderingSupported { get { MediaContext mediaContext = MediaContext.CurrentMediaContext; return mediaContext.HasSSE2Support; } } ////// 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; } } } } // 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
- ObjectToIdCache.cs
- DataBinder.cs
- _UriSyntax.cs
- MonthChangedEventArgs.cs
- Keywords.cs
- compensatingcollection.cs
- InboundActivityHelper.cs
- UdpSocket.cs
- DistributedTransactionPermission.cs
- DictionaryContent.cs
- HttpProtocolImporter.cs
- PrivilegedConfigurationManager.cs
- PictureBox.cs
- ApplicationProxyInternal.cs
- MessageBox.cs
- ServiceDescriptionImporter.cs
- DataViewListener.cs
- DbProviderFactory.cs
- Int16Animation.cs
- SystemInformation.cs
- IriParsingElement.cs
- CompensatableSequenceActivity.cs
- DataGridTemplateColumn.cs
- ScriptManagerProxy.cs
- ProvidePropertyAttribute.cs
- DetailsViewPageEventArgs.cs
- Type.cs
- SchemaInfo.cs
- XmlAttributeOverrides.cs
- WebPartHeaderCloseVerb.cs
- XpsPackagingPolicy.cs
- AlignmentYValidation.cs
- FrameworkRichTextComposition.cs
- SspiSecurityTokenProvider.cs
- AccessorTable.cs
- Graphics.cs
- AsymmetricSignatureDeformatter.cs
- ColorAnimationUsingKeyFrames.cs
- ImageKeyConverter.cs
- OrthographicCamera.cs
- jithelpers.cs
- SiteOfOriginContainer.cs
- DuplicateDetector.cs
- DescendantOverDescendantQuery.cs
- MethodImplAttribute.cs
- BuildResult.cs
- Stream.cs
- TreeNodeEventArgs.cs
- MetadataPropertyCollection.cs
- ProcessHostFactoryHelper.cs
- DropDownList.cs
- SpeechDetectedEventArgs.cs
- OpacityConverter.cs
- Internal.cs
- DataGridAutomationPeer.cs
- SystemIPGlobalProperties.cs
- SmtpCommands.cs
- EFColumnProvider.cs
- ListItemCollection.cs
- TextShapeableCharacters.cs
- XmlSchemaIdentityConstraint.cs
- ChangeBlockUndoRecord.cs
- OuterGlowBitmapEffect.cs
- SettingsSection.cs
- UrlUtility.cs
- ReflectionUtil.cs
- SourceFileBuildProvider.cs
- DBConnectionString.cs
- FormatConvertedBitmap.cs
- SafeFileMappingHandle.cs
- MatrixStack.cs
- AlphabeticalEnumConverter.cs
- SimpleFieldTemplateUserControl.cs
- StylusButton.cs
- LassoHelper.cs
- WinFormsSpinner.cs
- ConnectionStringsExpressionBuilder.cs
- SQLInt64Storage.cs
- SqlInternalConnectionSmi.cs
- WindowHideOrCloseTracker.cs
- HttpException.cs
- SynchronizedDispatch.cs
- ToolStripOverflowButton.cs
- ReservationCollection.cs
- InfoCardSymmetricAlgorithm.cs
- RadioButton.cs
- ControlUtil.cs
- DeviceContexts.cs
- Activator.cs
- CodeEventReferenceExpression.cs
- WmlLabelAdapter.cs
- ButtonField.cs
- FormClosedEvent.cs
- MsmqHostedTransportConfiguration.cs
- XamlStyleSerializer.cs
- TemplateParser.cs
- LingerOption.cs
- LocationUpdates.cs
- ProtocolViolationException.cs
- TdsParserStateObject.cs