Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / GlyphCache.cs / 2 / 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
- _RequestCacheProtocol.cs
- PersonalizationProviderHelper.cs
- XmlQuerySequence.cs
- QueryRewriter.cs
- NeutralResourcesLanguageAttribute.cs
- XmlSchemaValidator.cs
- UriTemplate.cs
- DataGridViewImageColumn.cs
- PageParser.cs
- XmlDataSource.cs
- Int64AnimationBase.cs
- Baml2006SchemaContext.cs
- RoutedEvent.cs
- ExtendedProtectionPolicy.cs
- ExternalException.cs
- BrowsableAttribute.cs
- WeakReference.cs
- DynamicRenderer.cs
- EditBehavior.cs
- SetIndexBinder.cs
- SettingsSection.cs
- LinkedList.cs
- MenuAutoFormat.cs
- PropertyManager.cs
- Utils.cs
- SizeChangedEventArgs.cs
- TransformerInfoCollection.cs
- BooleanKeyFrameCollection.cs
- StrokeDescriptor.cs
- WorkflowHostingEndpoint.cs
- BoundingRectTracker.cs
- OracleException.cs
- PropertyDescriptor.cs
- TextDecorationLocationValidation.cs
- ResourceReferenceExpression.cs
- IntSumAggregationOperator.cs
- PersonalizableAttribute.cs
- _CacheStreams.cs
- InProcStateClientManager.cs
- RowTypeElement.cs
- Certificate.cs
- FilteredReadOnlyMetadataCollection.cs
- SimpleLine.cs
- DefaultValidator.cs
- GridViewCancelEditEventArgs.cs
- SimpleTypesSurrogate.cs
- OpacityConverter.cs
- CompilationRelaxations.cs
- PrintPreviewControl.cs
- AlternationConverter.cs
- SoapSchemaMember.cs
- IconEditor.cs
- ScrollPattern.cs
- safemediahandle.cs
- JsonSerializer.cs
- XmlMemberMapping.cs
- FixedSOMPage.cs
- CollectionView.cs
- WindowsListView.cs
- RawStylusSystemGestureInputReport.cs
- CounterSampleCalculator.cs
- DispatcherProcessingDisabled.cs
- LowerCaseStringConverter.cs
- Filter.cs
- BatchServiceHost.cs
- _LocalDataStore.cs
- AlternateViewCollection.cs
- MediaEntryAttribute.cs
- StatusBar.cs
- XmlSerializationGeneratedCode.cs
- ReflectionPermission.cs
- DBSchemaTable.cs
- RenderDataDrawingContext.cs
- BlobPersonalizationState.cs
- FontDialog.cs
- SimpleWebHandlerParser.cs
- DataTableTypeConverter.cs
- VisualBasicImportReference.cs
- TimeoutValidationAttribute.cs
- ComPlusServiceLoader.cs
- AccessText.cs
- DocumentOutline.cs
- AppDomainShutdownMonitor.cs
- XmlCodeExporter.cs
- MarshalByValueComponent.cs
- LinkedDataMemberFieldEditor.cs
- FilePrompt.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- EdmComplexTypeAttribute.cs
- Unit.cs
- DBCommandBuilder.cs
- IPipelineRuntime.cs
- WorkflowServiceAttributesTypeConverter.cs
- TableItemProviderWrapper.cs
- WebBrowserHelper.cs
- SqlDataSourceCommandEventArgs.cs
- ProfileModule.cs
- BStrWrapper.cs
- RC2CryptoServiceProvider.cs
- Timer.cs