//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Obtain handles for animated properties DUCE.ResourceHandle hMatrixAnimations = GetAnimationResourceHandle(MatrixProperty, channel); // Pack & send command packet DUCE.MILCMD_MATRIXTRANSFORM data; unsafe { data.Type = MILCMD.MilCmdMatrixTransform; data.Handle = _duceResource.GetHandle(channel); if (hMatrixAnimations.IsNull) { data.Matrix = CompositionResourceManager.MatrixToMilMatrix3x2D(Matrix); } data.hMatrixAnimations = hMatrixAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_MATRIXTRANSFORM)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Obtain handles for animated properties DUCE.ResourceHandle hQuaternionAnimations = GetAnimationResourceHandle(QuaternionProperty, channel); // Pack & send command packet DUCE.MILCMD_QUATERNIONROTATION3D data; unsafe { data.Type = MILCMD.MilCmdQuaternionRotation3D; data.Handle = _duceResource.GetHandle(channel); if (hQuaternionAnimations.IsNull) { data.quaternion = CompositionResourceManager.QuaternionToMilQuaternionF(Quaternion); } data.hQuaternionAnimations = hQuaternionAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_QUATERNIONROTATION3D)); } } }
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); // Read values of properties into local variables Drawing vDrawing = Drawing; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hDrawing = vDrawing != null ? ((DUCE.IResource)vDrawing).GetHandle(channel) : DUCE.ResourceHandle.Null; // Pack & send command packet DUCE.MILCMD_DRAWINGIMAGE data; unsafe { data.Type = MILCMD.MilCmdDrawingImage; data.Handle = _duceResource.GetHandle(channel); data.hDrawing = hDrawing; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_DRAWINGIMAGE)); } } }
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 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); // Read values of properties into local variables GlyphRun vGlyphRun = GlyphRun; Brush vForegroundBrush = ForegroundBrush; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hGlyphRun = vGlyphRun != null ? ((DUCE.IResource)vGlyphRun).GetHandle(channel) : DUCE.ResourceHandle.Null; DUCE.ResourceHandle hForegroundBrush = vForegroundBrush != null ? ((DUCE.IResource)vForegroundBrush).GetHandle(channel) : DUCE.ResourceHandle.Null; // Pack & send command packet DUCE.MILCMD_GLYPHRUNDRAWING data; unsafe { data.Type = MILCMD.MilCmdGlyphRunDrawing; data.Handle = _duceResource.GetHandle(channel); data.hGlyphRun = hGlyphRun; data.hForegroundBrush = hForegroundBrush; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_GLYPHRUNDRAWING)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Read values of properties into local variables Brush vBrush = Brush; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hBrush = vBrush != null ? ((DUCE.IResource)vBrush).GetHandle(channel) : DUCE.ResourceHandle.Null; // Pack & send command packet DUCE.MILCMD_DIFFUSEMATERIAL data; unsafe { data.Type = MILCMD.MilCmdDiffuseMaterial; data.Handle = _duceResource.GetHandle(channel); data.color = CompositionResourceManager.ColorToMilColorF(Color); data.ambientColor = CompositionResourceManager.ColorToMilColorF(AmbientColor); data.hbrush = hBrush; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_DIFFUSEMATERIAL)); } } }
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)); } }
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); // Obtain handles for animated properties DUCE.ResourceHandle hRadiusAnimations = GetAnimationResourceHandle(RadiusProperty, channel); // Pack & send command packet DUCE.MILCMD_BLUREFFECT data; unsafe { data.Type = MILCMD.MilCmdBlurEffect; data.Handle = _duceResource.GetHandle(channel); if (hRadiusAnimations.IsNull) { data.Radius = Radius; } data.hRadiusAnimations = hRadiusAnimations; data.KernelType = KernelType; data.RenderingBias = RenderingBias; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_BLUREFFECT)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Obtain handles for animated properties DUCE.ResourceHandle hRenderAtScaleAnimations = GetAnimationResourceHandle(RenderAtScaleProperty, channel); // Pack & send command packet DUCE.MILCMD_BITMAPCACHE data; unsafe { data.Type = MILCMD.MilCmdBitmapCache; data.Handle = _duceResource.GetHandle(channel); if (hRenderAtScaleAnimations.IsNull) { data.RenderAtScale = RenderAtScale; } data.hRenderAtScaleAnimations = hRenderAtScaleAnimations; data.SnapsToDevicePixels = CompositionResourceManager.BooleanToUInt32(SnapsToDevicePixels); data.EnableClearType = CompositionResourceManager.BooleanToUInt32(EnableClearType); // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_BITMAPCACHE)); } } }
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); // Read values of properties into local variables Transform vTransform = Transform; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hTransform; if (vTransform == null || Object.ReferenceEquals(vTransform, Transform.Identity) ) { hTransform = DUCE.ResourceHandle.Null; } else { hTransform = ((DUCE.IResource)vTransform).GetHandle(channel); } // Obtain handles for animated properties DUCE.ResourceHandle hRadiusXAnimations = GetAnimationResourceHandle(RadiusXProperty, channel); DUCE.ResourceHandle hRadiusYAnimations = GetAnimationResourceHandle(RadiusYProperty, channel); DUCE.ResourceHandle hCenterAnimations = GetAnimationResourceHandle(CenterProperty, channel); // Pack & send command packet DUCE.MILCMD_ELLIPSEGEOMETRY data; unsafe { data.Type = MILCMD.MilCmdEllipseGeometry; data.Handle = _duceResource.GetHandle(channel); data.hTransform = hTransform; if (hRadiusXAnimations.IsNull) { data.RadiusX = RadiusX; } data.hRadiusXAnimations = hRadiusXAnimations; if (hRadiusYAnimations.IsNull) { data.RadiusY = RadiusY; } data.hRadiusYAnimations = hRadiusYAnimations; if (hCenterAnimations.IsNull) { data.Center = Center; } data.hCenterAnimations = hCenterAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_ELLIPSEGEOMETRY)); } } }
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 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); // Obtain handles for animated properties DUCE.ResourceHandle hShadowDepthAnimations = GetAnimationResourceHandle(ShadowDepthProperty, channel); DUCE.ResourceHandle hColorAnimations = GetAnimationResourceHandle(ColorProperty, channel); DUCE.ResourceHandle hDirectionAnimations = GetAnimationResourceHandle(DirectionProperty, channel); DUCE.ResourceHandle hOpacityAnimations = GetAnimationResourceHandle(OpacityProperty, channel); DUCE.ResourceHandle hBlurRadiusAnimations = GetAnimationResourceHandle(BlurRadiusProperty, channel); // Pack & send command packet DUCE.MILCMD_DROPSHADOWEFFECT data; unsafe { data.Type = MILCMD.MilCmdDropShadowEffect; data.Handle = _duceResource.GetHandle(channel); if (hShadowDepthAnimations.IsNull) { data.ShadowDepth = ShadowDepth; } data.hShadowDepthAnimations = hShadowDepthAnimations; if (hColorAnimations.IsNull) { data.Color = CompositionResourceManager.ColorToMilColorF(Color); } data.hColorAnimations = hColorAnimations; if (hDirectionAnimations.IsNull) { data.Direction = Direction; } data.hDirectionAnimations = hDirectionAnimations; if (hOpacityAnimations.IsNull) { data.Opacity = Opacity; } data.hOpacityAnimations = hOpacityAnimations; if (hBlurRadiusAnimations.IsNull) { data.BlurRadius = BlurRadius; } data.hBlurRadiusAnimations = hBlurRadiusAnimations; data.RenderingBias = RenderingBias; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_DROPSHADOWEFFECT)); } } }
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); // Read values of properties into local variables Transform3D vTransform = Transform; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hTransform; if (vTransform == null || Object.ReferenceEquals(vTransform, Transform3D.Identity) ) { hTransform = DUCE.ResourceHandle.Null; } else { hTransform = ((DUCE.IResource)vTransform).GetHandle(channel); } // Obtain handles for animated properties DUCE.ResourceHandle hColorAnimations = GetAnimationResourceHandle(ColorProperty, channel); DUCE.ResourceHandle hDirectionAnimations = GetAnimationResourceHandle(DirectionProperty, channel); // Pack & send command packet DUCE.MILCMD_DIRECTIONALLIGHT data; unsafe { data.Type = MILCMD.MilCmdDirectionalLight; data.Handle = _duceResource.GetHandle(channel); data.htransform = hTransform; if (hColorAnimations.IsNull) { data.color = CompositionResourceManager.ColorToMilColorF(Color); } data.hColorAnimations = hColorAnimations; if (hDirectionAnimations.IsNull) { data.direction = CompositionResourceManager.Vector3DToMilPoint3F(Direction); } data.hDirectionAnimations = hDirectionAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_DIRECTIONALLIGHT)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Read values of properties into local variables Rotation3D vRotation = Rotation; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hRotation = vRotation != null ? ((DUCE.IResource)vRotation).GetHandle(channel) : DUCE.ResourceHandle.Null; // Obtain handles for animated properties DUCE.ResourceHandle hCenterXAnimations = GetAnimationResourceHandle(CenterXProperty, channel); DUCE.ResourceHandle hCenterYAnimations = GetAnimationResourceHandle(CenterYProperty, channel); DUCE.ResourceHandle hCenterZAnimations = GetAnimationResourceHandle(CenterZProperty, channel); // Pack & send command packet DUCE.MILCMD_ROTATETRANSFORM3D data; unsafe { data.Type = MILCMD.MilCmdRotateTransform3D; data.Handle = _duceResource.GetHandle(channel); if (hCenterXAnimations.IsNull) { data.centerX = CenterX; } data.hCenterXAnimations = hCenterXAnimations; if (hCenterYAnimations.IsNull) { data.centerY = CenterY; } data.hCenterYAnimations = hCenterYAnimations; if (hCenterZAnimations.IsNull) { data.centerZ = CenterZ; } data.hCenterZAnimations = hCenterZAnimations; data.hrotation = hRotation; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_ROTATETRANSFORM3D)); } } }
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); // Obtain handles for animated properties DUCE.ResourceHandle hAngleXAnimations = GetAnimationResourceHandle(AngleXProperty, channel); DUCE.ResourceHandle hAngleYAnimations = GetAnimationResourceHandle(AngleYProperty, channel); DUCE.ResourceHandle hCenterXAnimations = GetAnimationResourceHandle(CenterXProperty, channel); DUCE.ResourceHandle hCenterYAnimations = GetAnimationResourceHandle(CenterYProperty, channel); // Pack & send command packet DUCE.MILCMD_SKEWTRANSFORM data; unsafe { data.Type = MILCMD.MilCmdSkewTransform; data.Handle = _duceResource.GetHandle(channel); if (hAngleXAnimations.IsNull) { data.AngleX = AngleX; } data.hAngleXAnimations = hAngleXAnimations; if (hAngleYAnimations.IsNull) { data.AngleY = AngleY; } data.hAngleYAnimations = hAngleYAnimations; if (hCenterXAnimations.IsNull) { data.CenterX = CenterX; } data.hCenterXAnimations = hCenterXAnimations; if (hCenterYAnimations.IsNull) { data.CenterY = CenterY; } data.hCenterYAnimations = hCenterYAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_SKEWTRANSFORM)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Read values of properties into local variables Transform3D vTransform = Transform; Geometry3D vGeometry = Geometry; Material vMaterial = Material; Material vBackMaterial = BackMaterial; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hTransform; if (vTransform == null || Object.ReferenceEquals(vTransform, Transform3D.Identity) ) { hTransform = DUCE.ResourceHandle.Null; } else { hTransform = ((DUCE.IResource)vTransform).GetHandle(channel); } DUCE.ResourceHandle hGeometry = vGeometry != null ? ((DUCE.IResource)vGeometry).GetHandle(channel) : DUCE.ResourceHandle.Null; DUCE.ResourceHandle hMaterial = vMaterial != null ? ((DUCE.IResource)vMaterial).GetHandle(channel) : DUCE.ResourceHandle.Null; DUCE.ResourceHandle hBackMaterial = vBackMaterial != null ? ((DUCE.IResource)vBackMaterial).GetHandle(channel) : DUCE.ResourceHandle.Null; // Pack & send command packet DUCE.MILCMD_GEOMETRYMODEL3D data; unsafe { data.Type = MILCMD.MilCmdGeometryModel3D; data.Handle = _duceResource.GetHandle(channel); data.htransform = hTransform; data.hgeometry = hGeometry; data.hmaterial = hMaterial; data.hbackMaterial = hBackMaterial; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_GEOMETRYMODEL3D)); } } }
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); // Read values of properties into local variables Transform vTransform = Transform; Geometry vGeometry1 = Geometry1; Geometry vGeometry2 = Geometry2; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hTransform; if (vTransform == null || Object.ReferenceEquals(vTransform, Transform.Identity) ) { hTransform = DUCE.ResourceHandle.Null; } else { hTransform = ((DUCE.IResource)vTransform).GetHandle(channel); } DUCE.ResourceHandle hGeometry1 = vGeometry1 != null ? ((DUCE.IResource)vGeometry1).GetHandle(channel) : DUCE.ResourceHandle.Null; DUCE.ResourceHandle hGeometry2 = vGeometry2 != null ? ((DUCE.IResource)vGeometry2).GetHandle(channel) : DUCE.ResourceHandle.Null; // Pack & send command packet DUCE.MILCMD_COMBINEDGEOMETRY data; unsafe { data.Type = MILCMD.MilCmdCombinedGeometry; data.Handle = _duceResource.GetHandle(channel); data.hTransform = hTransform; data.GeometryCombineMode = GeometryCombineMode; data.hGeometry1 = hGeometry1; data.hGeometry2 = hGeometry2; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_COMBINEDGEOMETRY)); } } }
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); // Read values of properties into local variables Brush vBrush = Brush; DashStyle vDashStyle = DashStyle; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hBrush = vBrush != null ? ((DUCE.IResource)vBrush).GetHandle(channel) : DUCE.ResourceHandle.Null; DUCE.ResourceHandle hDashStyle = vDashStyle != null ? ((DUCE.IResource)vDashStyle).GetHandle(channel) : DUCE.ResourceHandle.Null; // Obtain handles for animated properties DUCE.ResourceHandle hThicknessAnimations = GetAnimationResourceHandle(ThicknessProperty, channel); // Pack & send command packet DUCE.MILCMD_PEN data; unsafe { data.Type = MILCMD.MilCmdPen; data.Handle = _duceResource.GetHandle(channel); data.hBrush = hBrush; if (hThicknessAnimations.IsNull) { data.Thickness = Thickness; } data.hThicknessAnimations = hThicknessAnimations; data.StartLineCap = StartLineCap; data.EndLineCap = EndLineCap; data.DashCap = DashCap; data.LineJoin = LineJoin; data.MiterLimit = MiterLimit; data.hDashStyle = hDashStyle; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_PEN)); } } }
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); // Obtain handles for animated properties DUCE.ResourceHandle hOffsetXAnimations = GetAnimationResourceHandle(OffsetXProperty, channel); DUCE.ResourceHandle hOffsetYAnimations = GetAnimationResourceHandle(OffsetYProperty, channel); DUCE.ResourceHandle hOffsetZAnimations = GetAnimationResourceHandle(OffsetZProperty, channel); // Pack & send command packet DUCE.MILCMD_TRANSLATETRANSFORM3D data; unsafe { data.Type = MILCMD.MilCmdTranslateTransform3D; data.Handle = _duceResource.GetHandle(channel); if (hOffsetXAnimations.IsNull) { data.offsetX = OffsetX; } data.hOffsetXAnimations = hOffsetXAnimations; if (hOffsetYAnimations.IsNull) { data.offsetY = OffsetY; } data.hOffsetYAnimations = hOffsetYAnimations; if (hOffsetZAnimations.IsNull) { data.offsetZ = OffsetZ; } data.hOffsetZAnimations = hOffsetZAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_TRANSLATETRANSFORM3D)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Read values of properties into local variables Transform3D vTransform = Transform; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hTransform; if (vTransform == null || Object.ReferenceEquals(vTransform, Transform3D.Identity) ) { hTransform = DUCE.ResourceHandle.Null; } else { hTransform = ((DUCE.IResource)vTransform).GetHandle(channel); } // Pack & send command packet DUCE.MILCMD_MATRIXCAMERA data; unsafe { data.Type = MILCMD.MilCmdMatrixCamera; data.Handle = _duceResource.GetHandle(channel); data.htransform = hTransform; data.viewMatrix = CompositionResourceManager.Matrix3DToD3DMATRIX(ViewMatrix); data.projectionMatrix = CompositionResourceManager.Matrix3DToD3DMATRIX(ProjectionMatrix); // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_MATRIXCAMERA)); } } }
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.SendCommand((byte *)&cmd, sizeof(DUCE.MILCMD_GLYPHCACHE_SETCALLBACK), false /* sendInSeparateBatch */); }
protected override void UpdateResource( DUCE.ResourceHandle handle, DUCE.Channel channel) { DUCE.MILCMD_SIZERESOURCE cmd = new DUCE.MILCMD_SIZERESOURCE(); cmd.Type = MILCMD.MilCmdSizeResource; cmd.Handle = handle; cmd.Value = CurrentValue; unsafe { channel.SendCommand( (byte *)&cmd, sizeof(DUCE.MILCMD_SIZERESOURCE)); } // Validate this resource IsResourceInvalid = false; }
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); // Read values of properties into local variables ImageSource vImageSource = ImageSource; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hImageSource = vImageSource != null ? ((DUCE.IResource)vImageSource).GetHandle(channel) : DUCE.ResourceHandle.Null; // Obtain handles for animated properties DUCE.ResourceHandle hRectAnimations = GetAnimationResourceHandle(RectProperty, channel); // Pack & send command packet DUCE.MILCMD_IMAGEDRAWING data; unsafe { data.Type = MILCMD.MilCmdImageDrawing; data.Handle = _duceResource.GetHandle(channel); data.hImageSource = hImageSource; if (hRectAnimations.IsNull) { data.Rect = Rect; } data.hRectAnimations = hRectAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_IMAGEDRAWING)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Obtain handles for animated properties DUCE.ResourceHandle hAxisAnimations = GetAnimationResourceHandle(AxisProperty, channel); DUCE.ResourceHandle hAngleAnimations = GetAnimationResourceHandle(AngleProperty, channel); // Pack & send command packet DUCE.MILCMD_AXISANGLEROTATION3D data; unsafe { data.Type = MILCMD.MilCmdAxisAngleRotation3D; data.Handle = _duceResource.GetHandle(channel); if (hAxisAnimations.IsNull) { data.axis = CompositionResourceManager.Vector3DToMilPoint3F(Axis); } data.hAxisAnimations = hAxisAnimations; if (hAngleAnimations.IsNull) { data.angle = Angle; } data.hAngleAnimations = hAngleAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_AXISANGLEROTATION3D)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Pack & send command packet DUCE.MILCMD_MATRIXTRANSFORM3D data; unsafe { data.Type = MILCMD.MilCmdMatrixTransform3D; data.Handle = _duceResource.GetHandle(channel); data.matrix = CompositionResourceManager.Matrix3DToD3DMATRIX(Matrix); // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_MATRIXTRANSFORM3D)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Read values of properties into local variables Brush vBrush = Brush; Pen vPen = Pen; Geometry vGeometry = Geometry; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hBrush = vBrush != null ? ((DUCE.IResource)vBrush).GetHandle(channel) : DUCE.ResourceHandle.Null; DUCE.ResourceHandle hPen = vPen != null ? ((DUCE.IResource)vPen).GetHandle(channel) : DUCE.ResourceHandle.Null; DUCE.ResourceHandle hGeometry = vGeometry != null ? ((DUCE.IResource)vGeometry).GetHandle(channel) : DUCE.ResourceHandle.Null; // Pack & send command packet DUCE.MILCMD_GEOMETRYDRAWING data; unsafe { data.Type = MILCMD.MilCmdGeometryDrawing; data.Handle = _duceResource.GetHandle(channel); data.hBrush = hBrush; data.hPen = hPen; data.hGeometry = hGeometry; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_GEOMETRYDRAWING)); } } }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods 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); // Read values of properties into local variables Transform vTransform = Transform; Transform vRelativeTransform = RelativeTransform; Drawing vDrawing = Drawing; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hTransform; if (vTransform == null || Object.ReferenceEquals(vTransform, Transform.Identity) ) { hTransform = DUCE.ResourceHandle.Null; } else { hTransform = ((DUCE.IResource)vTransform).GetHandle(channel); } DUCE.ResourceHandle hRelativeTransform; if (vRelativeTransform == null || Object.ReferenceEquals(vRelativeTransform, Transform.Identity) ) { hRelativeTransform = DUCE.ResourceHandle.Null; } else { hRelativeTransform = ((DUCE.IResource)vRelativeTransform).GetHandle(channel); } DUCE.ResourceHandle hDrawing = vDrawing != null ? ((DUCE.IResource)vDrawing).GetHandle(channel) : DUCE.ResourceHandle.Null; // Obtain handles for animated properties DUCE.ResourceHandle hOpacityAnimations = GetAnimationResourceHandle(OpacityProperty, channel); DUCE.ResourceHandle hViewportAnimations = GetAnimationResourceHandle(ViewportProperty, channel); DUCE.ResourceHandle hViewboxAnimations = GetAnimationResourceHandle(ViewboxProperty, channel); // Pack & send command packet DUCE.MILCMD_DRAWINGBRUSH data; unsafe { data.Type = MILCMD.MilCmdDrawingBrush; data.Handle = _duceResource.GetHandle(channel); if (hOpacityAnimations.IsNull) { data.Opacity = Opacity; } data.hOpacityAnimations = hOpacityAnimations; data.hTransform = hTransform; data.hRelativeTransform = hRelativeTransform; data.ViewportUnits = ViewportUnits; data.ViewboxUnits = ViewboxUnits; if (hViewportAnimations.IsNull) { data.Viewport = Viewport; } data.hViewportAnimations = hViewportAnimations; if (hViewboxAnimations.IsNull) { data.Viewbox = Viewbox; } data.hViewboxAnimations = hViewboxAnimations; data.Stretch = Stretch; data.TileMode = TileMode; data.AlignmentX = AlignmentX; data.AlignmentY = AlignmentY; data.CachingHint = (CachingHint)GetValue(RenderOptions.CachingHintProperty); data.CacheInvalidationThresholdMinimum = (double)GetValue(RenderOptions.CacheInvalidationThresholdMinimumProperty); data.CacheInvalidationThresholdMaximum = (double)GetValue(RenderOptions.CacheInvalidationThresholdMaximumProperty); data.hDrawing = hDrawing; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_DRAWINGBRUSH)); } } }
/// <summary> /// Invalidates the bitmap source. /// </summary> public void Invalidate(Int32Rect?dirtyRect) { // A null dirty rect indicates the entire bitmap should be // invalidated, while a value indicates that only a dirty rect // should be invalidated. if (dirtyRect.HasValue) { dirtyRect.Value.ValidateForDirtyRect("dirtyRect", _pixelWidth, _pixelHeight); if (!dirtyRect.Value.HasArea) { // Nothing needs done. return; } } WritePreamble(); if (_unmanagedSource != null) { if (UsableWithoutCache) { // For bitmap sources that do not require caching on the // UI thread, we can just add a dirty rect to the // CWICWrapperBitmap. The render thread will respond by // updating the affected realizations by copying from this // bitmap. Since this bitmap is not cached, it will get // the most current bits. unsafe { for (int i = 0, numChannels = _duceResource.GetChannelCount(); i < numChannels; ++i) { DUCE.Channel channel = _duceResource.GetChannel(i); DUCE.MILCMD_BITMAP_INVALIDATE data; data.Type = MILCMD.MilCmdBitmapInvalidate; data.Handle = _duceResource.GetHandle(channel); bool useDirtyRect = dirtyRect.HasValue; if (useDirtyRect) { data.DirtyRect.left = dirtyRect.Value.X; data.DirtyRect.top = dirtyRect.Value.Y; data.DirtyRect.right = dirtyRect.Value.X + dirtyRect.Value.Width; data.DirtyRect.bottom = dirtyRect.Value.Y + dirtyRect.Value.Height; } data.UseDirtyRect = (uint)(useDirtyRect ? 1 : 0); channel.SendCommand((byte *)&data, sizeof(DUCE.MILCMD_BITMAP_INVALIDATE)); } } } else { // For bitmap sources that require caching on the // UI thread, we can't just add a dirty rect to the // CWICWrapperBitmap because it will just read the cached // contents again. We really need a caching bitmap // implementation that understands dirty rects and will // update its cache. Unfortunately, today the caching // bitmap is a standard WIC implementation, and does not // support this functionality. // // For now, we just recreate the caching bitmap. Setting // _needsUpdate to true will cause BitmapSource to throw // away the old DUCECompatiblePtr, and create a new caching // bitmap to send to the render thread. Since the render // thread sees a brand new bitmap, it will copy the bits out. _needsUpdate = true; RegisterForAsyncUpdateResource(); } } WritePostscript(); }
private void SendPresent(object sender, EventArgs args) { Debug.Assert(_isDirty); Debug.Assert(_isWaitingForPresent); Debug.Assert(_lockCount == 0); // // If we were waiting for present when the bitmap changed, SetBackBuffer removed // us from waiting for present. So if this is true then the NEW bitmap has been // dirtied before it has been sent to the render thread. We need to delay the // present until after the update resource because the D3DImage resource is still // referencing the old bitmap. // if (_waitingForUpdateResourceBecauseBitmapChanged) { return; } UnsubscribeFromCommittingBatch(); unsafe { DUCE.MILCMD_D3DIMAGE_PRESENT data; DUCE.Channel channel = sender as DUCE.Channel; Debug.Assert(_duceResource.IsOnChannel(channel)); data.Type = MILCMD.MilCmdD3DImagePresent; data.Handle = _duceResource.GetHandle(channel); // We need to make sure the event stays alive in case we get collected before // the composition thread processes the packet IntPtr hDuplicate; IntPtr hCurrentProc = MS.Win32.UnsafeNativeMethods.GetCurrentProcess(); if (!MS.Win32.UnsafeNativeMethods.DuplicateHandle( hCurrentProc, _canWriteEvent.SafeWaitHandle, hCurrentProc, out hDuplicate, 0, false, MS.Win32.UnsafeNativeMethods.DUPLICATE_SAME_ACCESS )) { throw new Win32Exception(); } data.hEvent = (ulong)hDuplicate.ToPointer(); // Send packed command structure // Note that the command is sent in its own batch (sendInSeparateBatch == true) because this method is called under the // context of the MediaContext.CommitChannel and the command needs to make it into the current set of changes which are // being commited to the compositor. If the command would not be added to a separate batch, it would go into the // "future" batch which would not get submitted this time around. This leads to a dead-lock situation which occurs when // the app calls Lock on the D3DImage because Lock waits on _canWriteEvent which the compositor sets when it sees the // Present command. However, since the compositor does not get the Present command, it will not set the event and the // UI thread will wait forever on the compositor which will hang the application. channel.SendCommand( (byte*)&data, sizeof(DUCE.MILCMD_D3DIMAGE_PRESENT), true /* sendInSeparateBatch */ ); } _isDirty = false; // Block on next Lock _canWriteEvent.Reset(); }
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); // Read values of properties into local variables Transform3D vTransform = Transform; // Obtain handles for properties that implement DUCE.IResource DUCE.ResourceHandle hTransform; if (vTransform == null || Object.ReferenceEquals(vTransform, Transform3D.Identity) ) { hTransform = DUCE.ResourceHandle.Null; } else { hTransform = ((DUCE.IResource)vTransform).GetHandle(channel); } // Obtain handles for animated properties DUCE.ResourceHandle hNearPlaneDistanceAnimations = GetAnimationResourceHandle(NearPlaneDistanceProperty, channel); DUCE.ResourceHandle hFarPlaneDistanceAnimations = GetAnimationResourceHandle(FarPlaneDistanceProperty, channel); DUCE.ResourceHandle hPositionAnimations = GetAnimationResourceHandle(PositionProperty, channel); DUCE.ResourceHandle hLookDirectionAnimations = GetAnimationResourceHandle(LookDirectionProperty, channel); DUCE.ResourceHandle hUpDirectionAnimations = GetAnimationResourceHandle(UpDirectionProperty, channel); DUCE.ResourceHandle hFieldOfViewAnimations = GetAnimationResourceHandle(FieldOfViewProperty, channel); // Pack & send command packet DUCE.MILCMD_PERSPECTIVECAMERA data; unsafe { data.Type = MILCMD.MilCmdPerspectiveCamera; data.Handle = _duceResource.GetHandle(channel); data.htransform = hTransform; if (hNearPlaneDistanceAnimations.IsNull) { data.nearPlaneDistance = NearPlaneDistance; } data.hNearPlaneDistanceAnimations = hNearPlaneDistanceAnimations; if (hFarPlaneDistanceAnimations.IsNull) { data.farPlaneDistance = FarPlaneDistance; } data.hFarPlaneDistanceAnimations = hFarPlaneDistanceAnimations; if (hPositionAnimations.IsNull) { data.position = CompositionResourceManager.Point3DToMilPoint3F(Position); } data.hPositionAnimations = hPositionAnimations; if (hLookDirectionAnimations.IsNull) { data.lookDirection = CompositionResourceManager.Vector3DToMilPoint3F(LookDirection); } data.hLookDirectionAnimations = hLookDirectionAnimations; if (hUpDirectionAnimations.IsNull) { data.upDirection = CompositionResourceManager.Vector3DToMilPoint3F(UpDirection); } data.hUpDirectionAnimations = hUpDirectionAnimations; if (hFieldOfViewAnimations.IsNull) { data.fieldOfView = FieldOfView; } data.hFieldOfViewAnimations = hFieldOfViewAnimations; // Send packed command structure channel.SendCommand( (byte *)&data, sizeof(DUCE.MILCMD_PERSPECTIVECAMERA)); } } }