예제 #1
0
        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;
            }

            Color tempValue = (Color)dobj.GetValue(_dependencyProperty);

            DUCE.MILCMD_COLORRESOURCE data;
            data.Type   = MILCMD.MilCmdColorResource;
            data.Handle = _duceResource.GetHandle(channel);
            data.Value  = CompositionResourceManager.ColorToMilColorF(tempValue);

            unsafe
            {
                channel.SendCommand(
                    (byte *)&data,
                    sizeof(DUCE.MILCMD_COLORRESOURCE));
            }
        }
예제 #2
0
        //------------------------------------------------------
        //
        //  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));
                }
            }
        }
예제 #3
0
        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));
                }
            }
        }
예제 #4
0
        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 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;

                // 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);
                }

                // Obtain handles for animated properties
                DUCE.ResourceHandle hOpacityAnimations = GetAnimationResourceHandle(OpacityProperty, channel);
                DUCE.ResourceHandle hColorAnimations   = GetAnimationResourceHandle(ColorProperty, channel);

                // Pack & send command packet
                DUCE.MILCMD_SOLIDCOLORBRUSH data;
                unsafe
                {
                    data.Type   = MILCMD.MilCmdSolidColorBrush;
                    data.Handle = _duceResource.GetHandle(channel);
                    if (hOpacityAnimations.IsNull)
                    {
                        data.Opacity = Opacity;
                    }
                    data.hOpacityAnimations = hOpacityAnimations;
                    data.hTransform         = hTransform;
                    data.hRelativeTransform = hRelativeTransform;
                    if (hColorAnimations.IsNull)
                    {
                        data.Color = CompositionResourceManager.ColorToMilColorF(Color);
                    }
                    data.hColorAnimations = hColorAnimations;

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_SOLIDCOLORBRUSH));
                }
            }
        }
예제 #6
0
        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 hPositionAnimations             = GetAnimationResourceHandle(PositionProperty, channel);
                DUCE.ResourceHandle hRangeAnimations                = GetAnimationResourceHandle(RangeProperty, channel);
                DUCE.ResourceHandle hConstantAttenuationAnimations  = GetAnimationResourceHandle(ConstantAttenuationProperty, channel);
                DUCE.ResourceHandle hLinearAttenuationAnimations    = GetAnimationResourceHandle(LinearAttenuationProperty, channel);
                DUCE.ResourceHandle hQuadraticAttenuationAnimations = GetAnimationResourceHandle(QuadraticAttenuationProperty, channel);
                DUCE.ResourceHandle hDirectionAnimations            = GetAnimationResourceHandle(DirectionProperty, channel);
                DUCE.ResourceHandle hOuterConeAngleAnimations       = GetAnimationResourceHandle(OuterConeAngleProperty, channel);
                DUCE.ResourceHandle hInnerConeAngleAnimations       = GetAnimationResourceHandle(InnerConeAngleProperty, channel);

                // Pack & send command packet
                DUCE.MILCMD_SPOTLIGHT data;
                unsafe
                {
                    data.Type       = MILCMD.MilCmdSpotLight;
                    data.Handle     = _duceResource.GetHandle(channel);
                    data.htransform = hTransform;
                    if (hColorAnimations.IsNull)
                    {
                        data.color = CompositionResourceManager.ColorToMilColorF(Color);
                    }
                    data.hColorAnimations = hColorAnimations;
                    if (hPositionAnimations.IsNull)
                    {
                        data.position = CompositionResourceManager.Point3DToMilPoint3F(Position);
                    }
                    data.hPositionAnimations = hPositionAnimations;
                    if (hRangeAnimations.IsNull)
                    {
                        data.range = Range;
                    }
                    data.hRangeAnimations = hRangeAnimations;
                    if (hConstantAttenuationAnimations.IsNull)
                    {
                        data.constantAttenuation = ConstantAttenuation;
                    }
                    data.hConstantAttenuationAnimations = hConstantAttenuationAnimations;
                    if (hLinearAttenuationAnimations.IsNull)
                    {
                        data.linearAttenuation = LinearAttenuation;
                    }
                    data.hLinearAttenuationAnimations = hLinearAttenuationAnimations;
                    if (hQuadraticAttenuationAnimations.IsNull)
                    {
                        data.quadraticAttenuation = QuadraticAttenuation;
                    }
                    data.hQuadraticAttenuationAnimations = hQuadraticAttenuationAnimations;
                    if (hDirectionAnimations.IsNull)
                    {
                        data.direction = CompositionResourceManager.Vector3DToMilPoint3F(Direction);
                    }
                    data.hDirectionAnimations = hDirectionAnimations;
                    if (hOuterConeAngleAnimations.IsNull)
                    {
                        data.outerConeAngle = OuterConeAngle;
                    }
                    data.hOuterConeAngleAnimations = hOuterConeAngleAnimations;
                    if (hInnerConeAngleAnimations.IsNull)
                    {
                        data.innerConeAngle = InnerConeAngle;
                    }
                    data.hInnerConeAngleAnimations = hInnerConeAngleAnimations;

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_SPOTLIGHT));
                }
            }
        }
예제 #7
0
        private void ManualUpdateResource(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))
            {
                Transform vTransform                  = Transform;
                Transform vRelativeTransform          = RelativeTransform;
                GradientStopCollection vGradientStops = GradientStops;

                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 hOpacityAnimations        = GetAnimationResourceHandle(OpacityProperty, channel);
                DUCE.ResourceHandle hCenterAnimations         = GetAnimationResourceHandle(CenterProperty, channel);
                DUCE.ResourceHandle hRadiusXAnimations        = GetAnimationResourceHandle(RadiusXProperty, channel);
                DUCE.ResourceHandle hRadiusYAnimations        = GetAnimationResourceHandle(RadiusYProperty, channel);
                DUCE.ResourceHandle hGradientOriginAnimations = GetAnimationResourceHandle(GradientOriginProperty, channel);

                DUCE.MILCMD_RADIALGRADIENTBRUSH data;
                unsafe
                {
                    data.Type   = MILCMD.MilCmdRadialGradientBrush;
                    data.Handle = _duceResource.GetHandle(channel);
                    double tempOpacity = Opacity;
                    DUCE.CopyBytes((byte *)&data.Opacity, (byte *)&tempOpacity, 8);
                    data.hOpacityAnimations     = hOpacityAnimations;
                    data.hTransform             = hTransform;
                    data.hRelativeTransform     = hRelativeTransform;
                    data.ColorInterpolationMode = ColorInterpolationMode;
                    data.MappingMode            = MappingMode;
                    data.SpreadMethod           = SpreadMethod;

                    Point tempCenter = Center;
                    DUCE.CopyBytes((byte *)&data.Center, (byte *)&tempCenter, 16);
                    data.hCenterAnimations = hCenterAnimations;
                    double tempRadiusX = RadiusX;
                    DUCE.CopyBytes((byte *)&data.RadiusX, (byte *)&tempRadiusX, 8);
                    data.hRadiusXAnimations = hRadiusXAnimations;
                    double tempRadiusY = RadiusY;
                    DUCE.CopyBytes((byte *)&data.RadiusY, (byte *)&tempRadiusY, 8);
                    data.hRadiusYAnimations = hRadiusYAnimations;
                    Point tempGradientOrigin = GradientOrigin;
                    DUCE.CopyBytes((byte *)&data.GradientOrigin, (byte *)&tempGradientOrigin, 16);
                    data.hGradientOriginAnimations = hGradientOriginAnimations;

                    // NTRAID#Longhorn-1011154-2004/8/12-asecchia GradientStopCollection:  Need to enforce upper-limit of gradient stop capacity

                    int count = (vGradientStops == null) ? 0 : vGradientStops.Count;
                    data.GradientStopsSize = (UInt32)(sizeof(DUCE.MIL_GRADIENTSTOP) * count);

                    channel.BeginCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_RADIALGRADIENTBRUSH),
                        sizeof(DUCE.MIL_GRADIENTSTOP) * count
                        );

                    for (int i = 0; i < count; i++)
                    {
                        DUCE.MIL_GRADIENTSTOP stopCmd;
                        GradientStop          gradStop = vGradientStops.Internal_GetItem(i);

                        double temp = gradStop.Offset;
                        DUCE.CopyBytes((byte *)&stopCmd.Position, (byte *)&temp, sizeof(double));
                        stopCmd.Color = CompositionResourceManager.ColorToMilColorF(gradStop.Color);

                        channel.AppendCommandData(
                            (byte *)&stopCmd,
                            sizeof(DUCE.MIL_GRADIENTSTOP)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }
예제 #8
0
        private void ManualUpdateResource(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))
            {
                Transform vTransform                  = Transform;
                Transform vRelativeTransform          = RelativeTransform;
                GradientStopCollection vGradientStops = GradientStops;

                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 hOpacityAnimations    = GetAnimationResourceHandle(OpacityProperty, channel);
                DUCE.ResourceHandle hStartPointAnimations = GetAnimationResourceHandle(StartPointProperty, channel);
                DUCE.ResourceHandle hEndPointAnimations   = GetAnimationResourceHandle(EndPointProperty, channel);

                unsafe
                {
                    DUCE.MILCMD_LINEARGRADIENTBRUSH data;
                    data.Type   = MILCMD.MilCmdLinearGradientBrush;
                    data.Handle = _duceResource.GetHandle(channel);
                    double tempOpacity = Opacity;
                    DUCE.CopyBytes((byte *)&data.Opacity, (byte *)&tempOpacity, 8);
                    data.hOpacityAnimations     = hOpacityAnimations;
                    data.hTransform             = hTransform;
                    data.hRelativeTransform     = hRelativeTransform;
                    data.ColorInterpolationMode = ColorInterpolationMode;
                    data.MappingMode            = MappingMode;
                    data.SpreadMethod           = SpreadMethod;

                    Point tempStartPoint = StartPoint;
                    DUCE.CopyBytes((byte *)&data.StartPoint, (byte *)&tempStartPoint, 16);
                    data.hStartPointAnimations = hStartPointAnimations;
                    Point tempEndPoint = EndPoint;
                    DUCE.CopyBytes((byte *)&data.EndPoint, (byte *)&tempEndPoint, 16);
                    data.hEndPointAnimations = hEndPointAnimations;

                    // GradientStopCollection:  Need to enforce upper-limit of gradient stop capacity

                    int count = (vGradientStops == null) ? 0 : vGradientStops.Count;
                    data.GradientStopsSize = (UInt32)(sizeof(DUCE.MIL_GRADIENTSTOP) * count);

                    channel.BeginCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_LINEARGRADIENTBRUSH),
                        sizeof(DUCE.MIL_GRADIENTSTOP) * count
                        );

                    for (int i = 0; i < count; i++)
                    {
                        DUCE.MIL_GRADIENTSTOP stopCmd;
                        GradientStop          gradStop = vGradientStops.Internal_GetItem(i);

                        double temp = gradStop.Offset;
                        DUCE.CopyBytes((byte *)&stopCmd.Position, (byte *)&temp, sizeof(double));
                        stopCmd.Color = CompositionResourceManager.ColorToMilColorF(gradStop.Color);

                        channel.AppendCommandData(
                            (byte *)&stopCmd,
                            sizeof(DUCE.MIL_GRADIENTSTOP)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }