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 / GlyphCache.cs / 1 / GlyphCache.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Security; using System.Text; using System.Windows; using System.Windows.Media; using System.Windows.Media.Composition; using System.Runtime.InteropServices; using MS.Internal; using MS.Internal.FontCache; using SR = MS.Internal.PresentationCore.SR; using SRID = MS.Internal.PresentationCore.SRID; using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods; namespace System.Windows.Media { ////// Master Glyph Cache class /// internal class GlyphCache { ////// Callback delegate. /// public delegate int CreateGlyphsCallbackDelegate( IntPtr /*CMilSlaveGlyphCache | CMilSlaveGlyphRun* */ nativeObject, IntPtr /*GLYPH_BITMAP_CREATE_REQUEST | GLYPH_GEOMETRY_CREATE_REQUEST* */ request, ushort isGeometryRequest); private DUCE.Resource _duceResource = new DUCE.Resource(); private SafeReversePInvokeWrapper _reversePInvokeWrapper; internal DUCE.ResourceHandle Handle { get { return _duceResource.Handle; } } // Service channel that serves for both // pre-commit and post-commit actions internal DUCE.Channel _channel; internal void RemoveFromChannel() { if (_channel != null) { _duceResource.ReleaseOnChannel(_channel); } } ////// /// /// ////// Critical - calls critical code /// [SecurityCritical] internal GlyphCache(DUCE.Channel channel) { _channel = channel; Debug.Assert(_channel != null); _duceResource.CreateOrAddRefOnChannel(_channel, DUCE.ResourceType.TYPE_GLYPHCACHE); SendCallbackEntryPoint(); } ////// Sends a callback pointer to this glyphcache for glyph generation requests. /// ////// Critical - This code sends a pointer to unmanaged code /// [SecurityCritical] private unsafe void SendCallbackEntryPoint() { _createGlyphBitmapsCallbackDelegate = new CreateGlyphsCallbackDelegate(FontCacheAccessor.CreateGlyphsCallback); IntPtr fcn = Marshal.GetFunctionPointerForDelegate(_createGlyphBitmapsCallbackDelegate); _reversePInvokeWrapper = new SafeReversePInvokeWrapper(fcn); DUCE.MILCMD_GLYPHCACHE_SETCALLBACK cmd; cmd.Type = MILCMD.MilCmdGlyphCacheSetCallback; cmd.Handle = Handle; // AddRef the reverse p-invoke wrapper while it is being transferred across the channel. There is a // small chance we would leak the wrapper. More specifically, if the app domain is shut down before // the wrapper is picked up by the composition engine. UnsafeNativeMethods.MILUnknown.AddRef(_reversePInvokeWrapper); cmd.CallbackPointer = (UInt64)_reversePInvokeWrapper.DangerousGetHandle(); _channel.SendSecurityCriticalCommand((byte*)&cmd, sizeof(DUCE.MILCMD_GLYPHCACHE_SETCALLBACK)); } private CreateGlyphsCallbackDelegate _createGlyphBitmapsCallbackDelegate; } } // 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. // // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Security; using System.Text; using System.Windows; using System.Windows.Media; using System.Windows.Media.Composition; using System.Runtime.InteropServices; using MS.Internal; using MS.Internal.FontCache; using SR = MS.Internal.PresentationCore.SR; using SRID = MS.Internal.PresentationCore.SRID; using UnsafeNativeMethods = MS.Win32.PresentationCore.UnsafeNativeMethods; namespace System.Windows.Media { ////// Master Glyph Cache class /// internal class GlyphCache { ////// Callback delegate. /// public delegate int CreateGlyphsCallbackDelegate( IntPtr /*CMilSlaveGlyphCache | CMilSlaveGlyphRun* */ nativeObject, IntPtr /*GLYPH_BITMAP_CREATE_REQUEST | GLYPH_GEOMETRY_CREATE_REQUEST* */ request, ushort isGeometryRequest); private DUCE.Resource _duceResource = new DUCE.Resource(); private SafeReversePInvokeWrapper _reversePInvokeWrapper; internal DUCE.ResourceHandle Handle { get { return _duceResource.Handle; } } // Service channel that serves for both // pre-commit and post-commit actions internal DUCE.Channel _channel; internal void RemoveFromChannel() { if (_channel != null) { _duceResource.ReleaseOnChannel(_channel); } } ////// /// /// ////// Critical - calls critical code /// [SecurityCritical] internal GlyphCache(DUCE.Channel channel) { _channel = channel; Debug.Assert(_channel != null); _duceResource.CreateOrAddRefOnChannel(_channel, DUCE.ResourceType.TYPE_GLYPHCACHE); SendCallbackEntryPoint(); } ////// Sends a callback pointer to this glyphcache for glyph generation requests. /// ////// Critical - This code sends a pointer to unmanaged code /// [SecurityCritical] private unsafe void SendCallbackEntryPoint() { _createGlyphBitmapsCallbackDelegate = new CreateGlyphsCallbackDelegate(FontCacheAccessor.CreateGlyphsCallback); IntPtr fcn = Marshal.GetFunctionPointerForDelegate(_createGlyphBitmapsCallbackDelegate); _reversePInvokeWrapper = new SafeReversePInvokeWrapper(fcn); DUCE.MILCMD_GLYPHCACHE_SETCALLBACK cmd; cmd.Type = MILCMD.MilCmdGlyphCacheSetCallback; cmd.Handle = Handle; // AddRef the reverse p-invoke wrapper while it is being transferred across the channel. There is a // small chance we would leak the wrapper. More specifically, if the app domain is shut down before // the wrapper is picked up by the composition engine. UnsafeNativeMethods.MILUnknown.AddRef(_reversePInvokeWrapper); cmd.CallbackPointer = (UInt64)_reversePInvokeWrapper.DangerousGetHandle(); _channel.SendSecurityCriticalCommand((byte*)&cmd, sizeof(DUCE.MILCMD_GLYPHCACHE_SETCALLBACK)); } private CreateGlyphsCallbackDelegate _createGlyphBitmapsCallbackDelegate; } } // 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
- HttpCacheParams.cs
- BitmapEffectInput.cs
- AccessViolationException.cs
- ScrollChrome.cs
- State.cs
- MobileControl.cs
- MetadataArtifactLoader.cs
- TargetPerspective.cs
- PropertyInformation.cs
- OleDbInfoMessageEvent.cs
- XsltSettings.cs
- DbTransaction.cs
- ClientBuildManagerTypeDescriptionProviderBridge.cs
- DataPagerField.cs
- JapaneseCalendar.cs
- UIPermission.cs
- MailWebEventProvider.cs
- FrameworkElementAutomationPeer.cs
- XsltSettings.cs
- BinaryExpression.cs
- LoginName.cs
- Cursor.cs
- DrawingContext.cs
- MemoryRecordBuffer.cs
- PropertySourceInfo.cs
- HostingEnvironmentWrapper.cs
- ServicesExceptionNotHandledEventArgs.cs
- EntityDataSourceSelectedEventArgs.cs
- PropertyChangeTracker.cs
- TransformFinalBlockRequest.cs
- TreeNodeCollectionEditor.cs
- AllMembershipCondition.cs
- IndexedEnumerable.cs
- IIS7UserPrincipal.cs
- SchemaSetCompiler.cs
- SystemIPAddressInformation.cs
- HyperLinkStyle.cs
- OleDbConnectionFactory.cs
- FieldToken.cs
- EditorPartChrome.cs
- TraversalRequest.cs
- RoleServiceManager.cs
- EditingMode.cs
- DetailsViewUpdatedEventArgs.cs
- RenameRuleObjectDialog.cs
- EntityWithKeyStrategy.cs
- PageContent.cs
- StrokeNodeEnumerator.cs
- ResourcesBuildProvider.cs
- CompositeControl.cs
- SemanticBasicElement.cs
- SafeLibraryHandle.cs
- TcpWorkerProcess.cs
- CmsInterop.cs
- InfocardClientCredentials.cs
- CodeNamespace.cs
- SoapTypeAttribute.cs
- DataGridViewSelectedColumnCollection.cs
- OverlappedAsyncResult.cs
- HtmlGenericControl.cs
- MarshalByRefObject.cs
- SqlTriggerAttribute.cs
- ExpressionConverter.cs
- UITypeEditor.cs
- TemplateControl.cs
- ZoomPercentageConverter.cs
- ECDiffieHellmanCngPublicKey.cs
- MediaContextNotificationWindow.cs
- ToolStripItemBehavior.cs
- CodeTypeOfExpression.cs
- PauseStoryboard.cs
- NetTcpSectionData.cs
- CorrelationTokenTypeConvertor.cs
- TagNameToTypeMapper.cs
- DynamicValueConverter.cs
- ImportContext.cs
- Buffer.cs
- Model3DGroup.cs
- ExpandCollapseIsCheckedConverter.cs
- SettingsPropertyValueCollection.cs
- Transform3DCollection.cs
- CodeTypeConstructor.cs
- DbParameterHelper.cs
- KnownTypeAttribute.cs
- DataSourceSelectArguments.cs
- DbConnectionPoolGroupProviderInfo.cs
- TextModifier.cs
- XPathBinder.cs
- UpdatePanelTriggerCollection.cs
- Table.cs
- SafeSerializationManager.cs
- PageStatePersister.cs
- DiffuseMaterial.cs
- CodeExporter.cs
- WmfPlaceableFileHeader.cs
- RIPEMD160.cs
- UInt64Converter.cs
- SoapWriter.cs
- DynamicResourceExtension.cs
- Condition.cs