protected override void UpdateResourceCore(DUCE.Channel channel) { Debug.Assert(_duceResource.IsOnChannel(channel)); DependencyObject dobj = ((DependencyObject) _dependencyObject.Target); // The dependency object was GCed, nothing to do here if (dobj == null) { return; } Quaternion tempValue = (Quaternion)dobj.GetValue(_dependencyProperty); DUCE.MILCMD_QUATERNIONRESOURCE data; data.Type = MILCMD.MilCmdQuaternionResource; data.Handle = _duceResource.GetHandle(channel); data.Value = CompositionResourceManager.QuaternionToMilQuaternionF(tempValue); unsafe { channel.SendCommand( (byte*)&data, sizeof(DUCE.MILCMD_QUATERNIONRESOURCE)); } }
internal override void CreateUCEResources(DUCE.Channel channel, DUCE.Channel outOfBandChannel) { Debug.Assert(channel != null); Debug.Assert(outOfBandChannel != null); _outOfBandChannel = outOfBandChannel; // create visual target resources base.CreateUCEResources(channel, outOfBandChannel); // Update state to propagate flags as necessary StateChangedCallback( new object[] { HostStateFlags.None }); // // Addref content node on the channel. We need extra reference // on that node so that it does not get immediately released // when Dispose is called. Actual release of the node needs // to be synchronized with node disconnect by the host. // bool resourceCreated = _contentRoot.CreateOrAddRefOnChannel(this, outOfBandChannel, s_contentRootType); Debug.Assert(!resourceCreated); _contentRoot.CreateOrAddRefOnChannel(this, channel, s_contentRootType); BeginHosting(); }
protected override void UpdateResourceCore(DUCE.Channel channel) { Debug.Assert(_duceResource.IsOnChannel(channel)); DependencyObject dobj = ((DependencyObject) _dependencyObject.Target); // The dependency object was GCed, nothing to do here if (dobj == null) { return; } Double tempValue = (Double)dobj.GetValue(_dependencyProperty); DUCE.MILCMD_DOUBLERESOURCE data; data.Type = MILCMD.MilCmdDoubleResource; data.Handle = _duceResource.GetHandle(channel); data.Value = tempValue; unsafe { channel.SendCommand( (byte*)&data, sizeof(DUCE.MILCMD_DOUBLERESOURCE)); } }
static public void Render( IntPtr pRenderTarget, DUCE.Channel channel, Visual visual, int width, int height, double dpiX, double dpiY) { Render(pRenderTarget, channel, visual, width, height, dpiX, dpiY, Matrix.Identity, Rect.Empty); }
/// <summary> /// This method is used to create all uce resources either on Startup or session connect /// </summary> internal virtual void CreateUCEResources(DUCE.Channel channel, DUCE.Channel outOfBandChannel) { Debug.Assert(channel != null); Debug.Assert(!_contentRoot.IsOnChannel(channel)); Debug.Assert(outOfBandChannel != null); Debug.Assert(!_contentRoot.IsOnChannel(outOfBandChannel)); // // Create root visual on the current channel and send // this command out of band to ensure that composition node is // created by the time this visual target is available for hosting // and to avoid life-time issues when we are working with this node // from the different channels. // bool resourceCreated = _contentRoot.CreateOrAddRefOnChannel(this, outOfBandChannel, s_contentRootType); Debug.Assert(resourceCreated); _contentRoot.DuplicateHandle(outOfBandChannel, channel); outOfBandChannel.CloseBatch(); outOfBandChannel.Commit(); }
/// <summary> /// AddRefOnChannel /// </summary> DUCE.ResourceHandle DUCE.IResource.AddRefOnChannel(DUCE.Channel channel) { // using (CompositionEngineLock.Acquire()) { #if DEBUG // We assume that a multi-channel resource can only be multi-channel // if it is Frozen and does not have animated properties. In this case we know // the target resource has at least one animated property so we expect that this // independently animated property resource will only be added to the channel // associated with the MediaContext associated with the target object's Dispatcher. DependencyObject d = (DependencyObject)_dependencyObject.Target; // I'm not sure how our target animated DependencyObject would get garbage // collected before we call AddRefOnChannel on one of its animated property // resources, but if it happens it will be a bad thing. Debug.Assert(d != null); // Any animated DependencyObject must be associated with a Dispatcher because the // AnimationClocks doing the animating must be associated with a Dispatcher. Debug.Assert(d.Dispatcher != null); // Make sure the target belongs to this thread Debug.Assert(d.CheckAccess()); #endif if (_duceResource.CreateOrAddRefOnChannel(this, channel, ResourceType)) { _updateResourceHandler = new MediaContext.ResourcesUpdatedHandler(UpdateResource); UpdateResourceCore(channel); } return _duceResource.GetHandle(channel); } }
internal virtual void AddRefOnChannelAnimations(DUCE.Channel channel) { if (IAnimatable_HasAnimatedProperties) { FrugalMap animatedPropertiesMap = AnimationStorage.GetAnimatedPropertiesMap(this); Debug.Assert(animatedPropertiesMap.Count > 0); for (int i = 0; i < animatedPropertiesMap.Count; i++) { Int32 dpGlobalIndex; Object storageObject; animatedPropertiesMap.GetKeyValuePair(i, out dpGlobalIndex, out storageObject); DUCE.IResource storage = storageObject as DUCE.IResource; if (storage != null) { storage.AddRefOnChannel(channel); } } } }
internal override DUCE.ResourceHandle AddRefOnChannelCore(DUCE.Channel channel) { if (_duceResource.CreateOrAddRefOnChannel(this, channel, DUCE.ResourceType.TYPE_BITMAPSOURCE)) { UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ ); } return _duceResource.GetHandle(channel); }
DUCE.ResourceHandle DUCE.IResource.AddRefOnChannel(DUCE.Channel channel) { // Reconsider the need for this lock when removing the MultiChannelResource. using (CompositionEngineLock.Acquire()) { return AddRefOnChannelCore(channel); } }
internal override void ReleaseOnChannelCore(DUCE.Channel channel) { Debug.Assert(_duceResource.IsOnChannel(channel)); if (_duceResource.ReleaseOnChannel(channel)) { ReleaseOnChannelAnimations(channel); // If we are being pulled off the asynchronous compositor channel // while we still have a handler hooked to the commit batch event, // remove the handler to avoid situations where would leak the D3DImage if (!channel.IsSynchronous) { UnsubscribeFromCommittingBatch(); } } }
internal override void ReleaseOnChannelCore(DUCE.Channel channel) { Debug.Assert(_duceResource.IsOnChannel(channel)); if (_duceResource.ReleaseOnChannel(channel)) { MaterialCollection vChildren = Children; if (vChildren != null) { int count = vChildren.Count; for (int i = 0; i < count; i++) { ((DUCE.IResource) vChildren.Internal_GetItem(i)).ReleaseOnChannel(channel); } } ReleaseOnChannelAnimations(channel); } }
DUCE.ResourceHandle DUCE.IResource.GetHandle(DUCE.Channel channel) { using (CompositionEngineLock.Acquire()) { return GetHandleCore(channel); } }
protected override void UpdateResource( DUCE.ResourceHandle handle, DUCE.Channel channel) { DUCE.MILCMD_RECTRESOURCE cmd = new DUCE.MILCMD_RECTRESOURCE(); cmd.Type = MILCMD.MilCmdRectResource; cmd.Handle = handle; cmd.Value = CurrentValue; unsafe { channel.SendCommand( (byte*)&cmd, sizeof(DUCE.MILCMD_RECTRESOURCE)); } // Validate this resource IsResourceInvalid = false; }
//------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods #endregion ProtectedMethods //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods internal abstract DUCE.ResourceHandle AddRefOnChannelCore(DUCE.Channel channel);
void DUCE.IResource.ReleaseOnChannel(DUCE.Channel channel) { // using (CompositionEngineLock.Acquire()) { ReleaseOnChannelCore(channel); } }
void DUCE.IResource.ReleaseOnChannel(DUCE.Channel channel) { using (CompositionEngineLock.Acquire()) { Debug.Assert(_duceResource.IsOnChannel(channel)); if (_duceResource.ReleaseOnChannel(channel)) { ReleaseOnChannelAnimations(channel); } } }
DUCE.ResourceHandle DUCE.IResource.GetHandle(DUCE.Channel channel) { DUCE.ResourceHandle h; // Reconsider the need for this lock when removing the MultiChannelResource. using (CompositionEngineLock.Acquire()) { h = _duceResource.GetHandle(channel); } return h; }
DUCE.ResourceHandle DUCE.IResource.AddRefOnChannel(DUCE.Channel channel) { using (CompositionEngineLock.Acquire()) { if (_duceResource.CreateOrAddRefOnChannel(this, channel, System.Windows.Media.Composition.DUCE.ResourceType.TYPE_PIXELSHADER)) { AddRefOnChannelAnimations(channel); UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ ); } return _duceResource.GetHandle(channel); } }
internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck) { ManualUpdateResource(channel, skipOnChannelCheck); base.UpdateResource(channel, skipOnChannelCheck); }
internal override DUCE.ResourceHandle GetHandleCore(DUCE.Channel channel) { // Note that we are in a lock here already. return _duceResource.GetHandle(channel); }
internal virtual void UpdateBitmapSourceResource(DUCE.Channel channel, bool skipOnChannelCheck) { if (_needsUpdate) { _convertedDUCEPtr = null; _needsUpdate = false; } // If we're told we can skip the channel check, then we must be on channel Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel)); if (skipOnChannelCheck || _duceResource.IsOnChannel(channel)) { // We may end up loading in the bitmap bits so it's necessary to take the [....] lock here. lock (_syncObject) { channel.SendCommandBitmapSource( _duceResource.GetHandle(channel), DUCECompatiblePtr ); } } }
internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck) { // If we're told we can skip the channel check, then we must be on channel Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel)); if (skipOnChannelCheck || _duceResource.IsOnChannel(channel)) { base.UpdateResource(channel, skipOnChannelCheck); bool isSynchronous = channel.IsSynchronous; DUCE.MILCMD_D3DIMAGE data; unsafe { data.Type = MILCMD.MilCmdD3DImage; data.Handle = _duceResource.GetHandle(channel); if (_pInteropDeviceBitmap != null) { UnsafeNativeMethods.MILUnknown.AddRef(_pInteropDeviceBitmap); data.pInteropDeviceBitmap = (ulong)_pInteropDeviceBitmap.DangerousGetHandle().ToPointer(); } else { data.pInteropDeviceBitmap = 0; } data.pSoftwareBitmap = 0; if (isSynchronous) { _softwareCopy = CopyBackBuffer(); if (_softwareCopy != null) { UnsafeNativeMethods.MILUnknown.AddRef(_softwareCopy.WicSourceHandle); data.pSoftwareBitmap = (ulong)_softwareCopy.WicSourceHandle.DangerousGetHandle().ToPointer(); } } // Send packed command structure channel.SendCommand( (byte*)&data, sizeof(DUCE.MILCMD_D3DIMAGE), false /* sendInSeparateBatch */ ); } // Presents only happen on the async channel so don't let RTB flip this bit if (!isSynchronous) { _waitingForUpdateResourceBecauseBitmapChanged = false; } } }
internal override void ReleaseOnChannelCore(DUCE.Channel channel) { Debug.Assert(_duceResource.IsOnChannel(channel)); _duceResource.ReleaseOnChannel(channel); }
/// <summary> /// ReleaseOnChannel /// </summary> void DUCE.IResource.ReleaseOnChannel(DUCE.Channel channel) { // Reconsider the need for this lock when removing the MultiChannelResource. using (CompositionEngineLock.Acquire()) { ReleaseOnChannelCore(channel); } }
internal override DUCE.ResourceHandle GetHandleCore(DUCE.Channel channel) { return _duceResource.GetHandle(channel); }
internal abstract DUCE.ResourceHandle GetHandleCore(DUCE.Channel channel);
internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck) { base.UpdateResource(channel, skipOnChannelCheck); UpdateBitmapSourceResource(channel, skipOnChannelCheck); }
/// <summary> /// GetHandle /// </summary> DUCE.ResourceHandle DUCE.IResource.GetHandle(DUCE.Channel channel) { DUCE.ResourceHandle handle; using (CompositionEngineLock.Acquire()) { handle = GetHandleCore(channel); } return handle; }
internal abstract void ReleaseOnChannelCore(DUCE.Channel channel);
internal override DUCE.ResourceHandle AddRefOnChannelCore(DUCE.Channel channel) { if (_duceResource.CreateOrAddRefOnChannel(this, channel, System.Windows.Media.Composition.DUCE.ResourceType.TYPE_D3DIMAGE)) { AddRefOnChannelAnimations(channel); UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ ); // If we are being put onto the asynchronous compositor channel in // a dirty state, we need to subscribe to the commit batch event. if (!channel.IsSynchronous && _isDirty) { SubscribeToCommittingBatch(); } } return _duceResource.GetHandle(channel); }