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();
                }
            }
        }
Exemplo n.º 2
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
                MaterialCollection vChildren = Children;

                // Store the count of this resource's contained collections in local variables.
                int ChildrenCount = (vChildren == null) ? 0 : vChildren.Count;

                // Pack & send command packet
                DUCE.MILCMD_MATERIALGROUP data;
                unsafe
                {
                    data.Type = MILCMD.MilCmdMaterialGroup;
                    data.Handle = _duceResource.GetHandle(channel);
                    data.ChildrenSize = (uint)(sizeof(DUCE.ResourceHandle) * ChildrenCount);

                    channel.BeginCommand(
                        (byte*)&data,
                        sizeof(DUCE.MILCMD_MATERIALGROUP),
                        (int)(data.ChildrenSize)
                        );


                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < ChildrenCount; i++)
                    {
                        DUCE.ResourceHandle resource = ((DUCE.IResource)vChildren.Internal_GetItem(i)).GetHandle(channel);;
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(DUCE.ResourceHandle)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }
        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))
            {
                checked
                {
                    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);
                    }

                    DUCE.MILCMD_PATHGEOMETRY data;
                    data.Type = MILCMD.MilCmdPathGeometry;
                    data.Handle = _duceResource.GetHandle(channel);
                    data.hTransform = hTransform;
                    data.FillRule = FillRule;

                    byte[] pathDataToMarshal = _data == null ?
                        Geometry.GetEmptyPathGeometryData().SerializedData :
                        _data;

                    unsafe
                    {
                        fixed (byte* pbPathData = pathDataToMarshal)
                        {
                            data.FiguresSize = (uint)GetFigureSize(pbPathData);

                            channel.BeginCommand(
                                (byte*)&data,
                                sizeof(DUCE.MILCMD_PATHGEOMETRY),
                                (int)data.FiguresSize
                                );

                            channel.AppendCommandData(pbPathData, (int)data.FiguresSize);
                        }

                        channel.EndCommand();
                    }
                }
            }

            base.UpdateResource(channel, skipOnChannelCheck);
        }
Exemplo n.º 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 
                Transform vTransform = Transform; 
                GeometryCollection vChildren = Children;
 
                // 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);
                }
 
                // Store the count of this resource's contained collections in local variables.
                int ChildrenCount = (vChildren == null) ? 0 : vChildren.Count; 
 
                // Pack & send command packet
                DUCE.MILCMD_GEOMETRYGROUP data; 
                unsafe
                {
                    data.Type = MILCMD.MilCmdGeometryGroup;
                    data.Handle = _duceResource.GetHandle(channel); 
                    data.hTransform = hTransform;
                    data.FillRule = FillRule; 
                    data.ChildrenSize = (uint)(sizeof(DUCE.ResourceHandle) * ChildrenCount); 

                    channel.BeginCommand( 
                        (byte*)&data,
                        sizeof(DUCE.MILCMD_GEOMETRYGROUP),
                        (int)(data.ChildrenSize)
                        ); 

 
                    // Copy this collection's elements (or their handles) to reserved data 
                    for(int i = 0; i < ChildrenCount; i++)
                    { 
                        DUCE.ResourceHandle resource = ((DUCE.IResource)vChildren.Internal_GetItem(i)).GetHandle(channel);;
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(DUCE.ResourceHandle) 
                            );
                    } 
 
                    channel.EndCommand();
                } 
            }
        }
Exemplo n.º 5
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
                DoubleCollection vGuidelinesX = GuidelinesX;
                DoubleCollection vGuidelinesY = GuidelinesY;

                // Store the count of this resource's contained collections in local variables.
                int GuidelinesXCount = (vGuidelinesX == null) ? 0 : vGuidelinesX.Count;
                int GuidelinesYCount = (vGuidelinesY == null) ? 0 : vGuidelinesY.Count;

                // Pack & send command packet
                DUCE.MILCMD_GUIDELINESET data;
                unsafe
                {
                    data.Type = MILCMD.MilCmdGuidelineSet;
                    data.Handle = _duceResource.GetHandle(channel);
                    data.GuidelinesXSize = (uint)(sizeof(Double) * GuidelinesXCount);
                    data.GuidelinesYSize = (uint)(sizeof(Double) * GuidelinesYCount);
                    data.IsDynamic = CompositionResourceManager.BooleanToUInt32(IsDynamic);

                    channel.BeginCommand(
                        (byte*)&data,
                        sizeof(DUCE.MILCMD_GUIDELINESET),
                        (int)(data.GuidelinesXSize + 
                              data.GuidelinesYSize)
                        );


                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < GuidelinesXCount; i++)
                    {
                        Double resource = vGuidelinesX.Internal_GetItem(i);
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(Double)
                            );
                    }

                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < GuidelinesYCount; i++)
                    {
                        Double resource = vGuidelinesY.Internal_GetItem(i);
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(Double)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }
Exemplo n.º 6
0
        private void MarshalToDUCE(DUCE.Channel channel) 
        {
            Debug.Assert(_duceResource.IsOnChannel(channel));

            DUCE.MILCMD_RENDERDATA renderdataCmd; 
            renderdataCmd.Type = MILCMD.MilCmdRenderData;
            renderdataCmd.Handle = _duceResource.GetHandle(channel); 
            renderdataCmd.cbData = (uint)DataSize; 

            // This is the total extra size required 
            uint cbExtraData = renderdataCmd.cbData;

            // This cast is to ensure that cbExtraData can be cast to an int without
            // wrapping over, since in managed code indices are int, not uint. 
            Debug.Assert(cbExtraData <= (uint)Int32.MaxValue);
 
            unsafe 
            {
                channel.BeginCommand( 
                    (byte*)&renderdataCmd,
                    sizeof(DUCE.MILCMD_RENDERDATA),
                    (int)cbExtraData
                    ); 

                // We shouldn't have any dependent resources if _curOffset is 0 
                // (_curOffset == 0) -> (renderData._dependentResources.Count == 0) 
                Debug.Assert((_curOffset > 0) || (_dependentResources.Count == 0));
 
                // The buffer being null implies that _curOffset must be 0.
                // (_buffer == null) -> (_curOffset == 0)
                Debug.Assert((_buffer != null) || (_curOffset == 0));
 
                // The _curOffset must be less than the length, if there is a buffer.
                Debug.Assert((_buffer == null) || (_curOffset <= _buffer.Length)); 
 
                Stack<PushType> pushStack = new Stack<PushType>();
                int pushedEffects = 0; 

                if (_curOffset > 0)
                {
                    fixed (byte* pByte = this._buffer) 
                    {
                        // This pointer points to the current read point in the 
                        // instruction stream. 
                        byte* pCur = pByte;
 
                        // This points to the first byte past the end of the
                        // instruction stream (i.e. when to stop)
                        byte* pEndOfInstructions = pByte + _curOffset;
 
                        while (pCur < pEndOfInstructions)
                        { 
                            RecordHeader *pCurRecord = (RecordHeader*)pCur; 

                            channel.AppendCommandData( 
                            (byte*)pCurRecord,
                                sizeof(RecordHeader)
                                );
 
                             switch (pCurRecord->Id)
                             { 
                                case MILCMD.MilDrawLine: 
                                {
                                    MILCMD_DRAW_LINE data = *(MILCMD_DRAW_LINE*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents

                                    if ( data.hPen != 0 ) 
                                    {
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel)); 
                                    } 

                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        40 /* codegen'ed size of this instruction struct */
                                        );
                                } 
                                break;
                                case MILCMD.MilDrawLineAnimate: 
                                { 
                                    MILCMD_DRAW_LINE_ANIMATE data = *(MILCMD_DRAW_LINE_ANIMATE*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents

                                    if ( data.hPen != 0)
                                    { 
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel));
                                    } 
 
                                    if ( data.hPoint0Animations != 0)
                                    { 
                                        data.hPoint0Animations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPoint0Animations - 1)]).GetHandle(channel));
                                    }

                                    if ( data.hPoint1Animations != 0) 
                                    {
                                        data.hPoint1Animations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPoint1Animations - 1)]).GetHandle(channel)); 
                                    } 

                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        48 /* codegen'ed size of this instruction struct */
                                        );
                                } 
                                break;
                                case MILCMD.MilDrawRectangle: 
                                { 
                                    MILCMD_DRAW_RECTANGLE data = *(MILCMD_DRAW_RECTANGLE*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents

                                    if ( data.hBrush != 0 )
                                    { 
                                        data.hBrush = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hBrush - 1)]).GetHandle(channel));
                                    } 
 
                                    if ( data.hPen != 0 )
                                    { 
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel));
                                    }

                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        40 /* codegen'ed size of this instruction struct */ 
                                        ); 
                                }
                                break; 
                                case MILCMD.MilDrawRectangleAnimate:
                                {
                                    MILCMD_DRAW_RECTANGLE_ANIMATE data = *(MILCMD_DRAW_RECTANGLE_ANIMATE*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents
 
                                    if ( data.hBrush != 0) 
                                    {
                                        data.hBrush = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hBrush - 1)]).GetHandle(channel)); 
                                    }

                                    if ( data.hPen != 0)
                                    { 
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel));
                                    } 
 
                                    if ( data.hRectangleAnimations != 0)
                                    { 
                                        data.hRectangleAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hRectangleAnimations - 1)]).GetHandle(channel));
                                    }

                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        48 /* codegen'ed size of this instruction struct */ 
                                        ); 
                                }
                                break; 
                                case MILCMD.MilDrawRoundedRectangle:
                                {
                                    MILCMD_DRAW_ROUNDED_RECTANGLE data = *(MILCMD_DRAW_ROUNDED_RECTANGLE*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents
 
                                    if ( data.hBrush != 0 ) 
                                    {
                                        data.hBrush = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hBrush - 1)]).GetHandle(channel)); 
                                    }

                                    if ( data.hPen != 0 )
                                    { 
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel));
                                    } 
 
                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        56 /* codegen'ed size of this instruction struct */
                                        );
                                }
                                break; 
                                case MILCMD.MilDrawRoundedRectangleAnimate:
                                { 
                                    MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE data = *(MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents 

                                    if ( data.hBrush != 0)
                                    {
                                        data.hBrush = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hBrush - 1)]).GetHandle(channel)); 
                                    }
 
                                    if ( data.hPen != 0) 
                                    {
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel)); 
                                    }

                                    if ( data.hRectangleAnimations != 0)
                                    { 
                                        data.hRectangleAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hRectangleAnimations - 1)]).GetHandle(channel));
                                    } 
 
                                    if ( data.hRadiusXAnimations != 0)
                                    { 
                                        data.hRadiusXAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hRadiusXAnimations - 1)]).GetHandle(channel));
                                    }

                                    if ( data.hRadiusYAnimations != 0) 
                                    {
                                        data.hRadiusYAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hRadiusYAnimations - 1)]).GetHandle(channel)); 
                                    } 

                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        72 /* codegen'ed size of this instruction struct */
                                        );
                                } 
                                break;
                                case MILCMD.MilDrawEllipse: 
                                { 
                                    MILCMD_DRAW_ELLIPSE data = *(MILCMD_DRAW_ELLIPSE*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents

                                    if ( data.hBrush != 0 )
                                    { 
                                        data.hBrush = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hBrush - 1)]).GetHandle(channel));
                                    } 
 
                                    if ( data.hPen != 0 )
                                    { 
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel));
                                    }

                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        40 /* codegen'ed size of this instruction struct */ 
                                        ); 
                                }
                                break; 
                                case MILCMD.MilDrawEllipseAnimate:
                                {
                                    MILCMD_DRAW_ELLIPSE_ANIMATE data = *(MILCMD_DRAW_ELLIPSE_ANIMATE*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents
 
                                    if ( data.hBrush != 0) 
                                    {
                                        data.hBrush = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hBrush - 1)]).GetHandle(channel)); 
                                    }

                                    if ( data.hPen != 0)
                                    { 
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel));
                                    } 
 
                                    if ( data.hCenterAnimations != 0)
                                    { 
                                        data.hCenterAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hCenterAnimations - 1)]).GetHandle(channel));
                                    }

                                    if ( data.hRadiusXAnimations != 0) 
                                    {
                                        data.hRadiusXAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hRadiusXAnimations - 1)]).GetHandle(channel)); 
                                    } 

                                    if ( data.hRadiusYAnimations != 0) 
                                    {
                                        data.hRadiusYAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hRadiusYAnimations - 1)]).GetHandle(channel));
                                    }
 
                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        56 /* codegen'ed size of this instruction struct */ 
                                        );
                                } 
                                break;
                                case MILCMD.MilDrawGeometry:
                                {
                                    MILCMD_DRAW_GEOMETRY data = *(MILCMD_DRAW_GEOMETRY*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents 
 
                                    if ( data.hBrush != 0 )
                                    { 
                                        data.hBrush = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hBrush - 1)]).GetHandle(channel));
                                    }

                                    if ( data.hPen != 0 ) 
                                    {
                                        data.hPen = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPen - 1)]).GetHandle(channel)); 
                                    } 

                                    if ( data.hGeometry != 0 ) 
                                    {
                                        data.hGeometry = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hGeometry - 1)]).GetHandle(channel));
                                    }
 
                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        16 /* codegen'ed size of this instruction struct */ 
                                        );
                                } 
                                break;
                                case MILCMD.MilDrawImage:
                                {
                                    MILCMD_DRAW_IMAGE data = *(MILCMD_DRAW_IMAGE*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents 
 
                                    if ( data.hImageSource != 0 )
                                    { 
                                        data.hImageSource = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hImageSource - 1)]).GetHandle(channel));
                                    }

                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        40 /* codegen'ed size of this instruction struct */ 
                                        ); 
                                }
                                break; 
                                case MILCMD.MilDrawImageAnimate:
                                {
                                    MILCMD_DRAW_IMAGE_ANIMATE data = *(MILCMD_DRAW_IMAGE_ANIMATE*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents
 
                                    if ( data.hImageSource != 0) 
                                    {
                                        data.hImageSource = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hImageSource - 1)]).GetHandle(channel)); 
                                    }

                                    if ( data.hRectangleAnimations != 0)
                                    { 
                                        data.hRectangleAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hRectangleAnimations - 1)]).GetHandle(channel));
                                    } 
 
                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        40 /* codegen'ed size of this instruction struct */
                                        );
                                }
                                break; 
                                case MILCMD.MilDrawGlyphRun:
                                { 
                                    MILCMD_DRAW_GLYPH_RUN data = *(MILCMD_DRAW_GLYPH_RUN*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents 

                                    if ( data.hForegroundBrush != 0 )
                                    {
                                        data.hForegroundBrush = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hForegroundBrush - 1)]).GetHandle(channel)); 
                                    }
 
                                    if ( data.hGlyphRun != 0 ) 
                                    {
                                        data.hGlyphRun = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hGlyphRun - 1)]).GetHandle(channel)); 
                                    }

                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        8 /* codegen'ed size of this instruction struct */
                                        ); 
                                } 
                                break;
                                case MILCMD.MilDrawDrawing: 
                                {
                                    MILCMD_DRAW_DRAWING data = *(MILCMD_DRAW_DRAWING*)(pCur + sizeof(RecordHeader));

                                    // Marshal the Handles for the dependents 

                                    if ( data.hDrawing != 0 ) 
                                    { 
                                        data.hDrawing = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hDrawing - 1)]).GetHandle(channel));
                                    } 

                                    channel.AppendCommandData(
                                        (byte*)&data,
                                        8 /* codegen'ed size of this instruction struct */ 
                                        );
                                } 
                                break; 
                                case MILCMD.MilDrawVideo:
                                { 
                                    MILCMD_DRAW_VIDEO data = *(MILCMD_DRAW_VIDEO*)(pCur + sizeof(RecordHeader));

                                    // Marshal the Handles for the dependents
 
                                    if ( data.hPlayer != 0 )
                                    { 
                                        data.hPlayer = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPlayer - 1)]).GetHandle(channel)); 
                                    }
 
                                    channel.AppendCommandData(
                                        (byte*)&data,
                                        40 /* codegen'ed size of this instruction struct */
                                        ); 
                                }
                                break; 
                                case MILCMD.MilDrawVideoAnimate: 
                                {
                                    MILCMD_DRAW_VIDEO_ANIMATE data = *(MILCMD_DRAW_VIDEO_ANIMATE*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents

                                    if ( data.hPlayer != 0) 
                                    {
                                        data.hPlayer = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hPlayer - 1)]).GetHandle(channel)); 
                                    } 

                                    if ( data.hRectangleAnimations != 0) 
                                    {
                                        data.hRectangleAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hRectangleAnimations - 1)]).GetHandle(channel));
                                    }
 
                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        40 /* codegen'ed size of this instruction struct */ 
                                        );
                                } 
                                break;
                                case MILCMD.MilPushClip:
                                {
                                    pushStack.Push(PushType.Other); 
                                    MILCMD_PUSH_CLIP data = *(MILCMD_PUSH_CLIP*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents 

                                    if ( data.hClipGeometry != 0 ) 
                                    {
                                        data.hClipGeometry = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hClipGeometry - 1)]).GetHandle(channel));
                                    }
 
                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        8 /* codegen'ed size of this instruction struct */ 
                                        );
                                } 
                                break;
                                case MILCMD.MilPushOpacityMask:
                                {
                                    pushStack.Push(PushType.Other); 
                                    MILCMD_PUSH_OPACITY_MASK data = *(MILCMD_PUSH_OPACITY_MASK*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents 

                                    if ( data.hOpacityMask != 0 ) 
                                    {
                                        data.hOpacityMask = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hOpacityMask - 1)]).GetHandle(channel));
                                    }
 
                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        24 /* codegen'ed size of this instruction struct */ 
                                        );
                                } 
                                break;
                                case MILCMD.MilPushOpacity:
                                {
                                    pushStack.Push(PushType.Other); 
                                    MILCMD_PUSH_OPACITY data = *(MILCMD_PUSH_OPACITY*)(pCur + sizeof(RecordHeader));
 
                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        8 /* codegen'ed size of this instruction struct */ 
                                        );
                                }
                                break;
                                case MILCMD.MilPushOpacityAnimate: 
                                {
                                    pushStack.Push(PushType.Other); 
                                    MILCMD_PUSH_OPACITY_ANIMATE data = *(MILCMD_PUSH_OPACITY_ANIMATE*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents 

                                    if ( data.hOpacityAnimations != 0)
                                    {
                                        data.hOpacityAnimations = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hOpacityAnimations - 1)]).GetHandle(channel)); 
                                    }
 
                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        16 /* codegen'ed size of this instruction struct */ 
                                        );
                                }
                                break;
                                case MILCMD.MilPushTransform: 
                                {
                                    pushStack.Push(PushType.Other); 
                                    MILCMD_PUSH_TRANSFORM data = *(MILCMD_PUSH_TRANSFORM*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents 

                                    if ( data.hTransform != 0 )
                                    {
                                        data.hTransform = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hTransform - 1)]).GetHandle(channel)); 
                                    }
 
                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        8 /* codegen'ed size of this instruction struct */ 
                                        );
                                }
                                break;
                                case MILCMD.MilPushGuidelineSet: 
                                {
                                    pushStack.Push(PushType.Other); 
                                    MILCMD_PUSH_GUIDELINE_SET data = *(MILCMD_PUSH_GUIDELINE_SET*)(pCur + sizeof(RecordHeader)); 

                                    // Marshal the Handles for the dependents 

                                    if ( data.hGuidelines != 0 )
                                    {
                                        data.hGuidelines = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hGuidelines - 1)]).GetHandle(channel)); 
                                    }
 
                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        8 /* codegen'ed size of this instruction struct */ 
                                        );
                                }
                                break;
                                case MILCMD.MilPushGuidelineY1: 
                                {
                                    pushStack.Push(PushType.Other); 
                                    MILCMD_PUSH_GUIDELINE_Y1 data = *(MILCMD_PUSH_GUIDELINE_Y1*)(pCur + sizeof(RecordHeader)); 

                                    channel.AppendCommandData( 
                                        (byte*)&data,
                                        8 /* codegen'ed size of this instruction struct */
                                        );
                                } 
                                break;
                                case MILCMD.MilPushGuidelineY2: 
                                { 
                                    pushStack.Push(PushType.Other);
                                    MILCMD_PUSH_GUIDELINE_Y2 data = *(MILCMD_PUSH_GUIDELINE_Y2*)(pCur + sizeof(RecordHeader)); 

                                    channel.AppendCommandData(
                                        (byte*)&data,
                                        16 /* codegen'ed size of this instruction struct */ 
                                        );
                                } 
                                break; 
                                case MILCMD.MilPushEffect:
                                { 
                                    pushStack.Push(PushType.BitmapEffect);
                                    pushedEffects++;
                                    MILCMD_PUSH_EFFECT data = *(MILCMD_PUSH_EFFECT*)(pCur + sizeof(RecordHeader));
 
                                    // Marshal the Handles for the dependents
 
                                    if ( data.hEffect != 0 ) 
                                    {
                                        data.hEffect = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hEffect - 1)]).GetHandle(channel)); 
                                    }

                                    if ( data.hEffectInput != 0 )
                                    { 
                                        data.hEffectInput = (uint)(((DUCE.IResource)_dependentResources[ (int)( data.hEffectInput - 1)]).GetHandle(channel));
                                    } 
 
                                    channel.AppendCommandData(
                                        (byte*)&data, 
                                        8 /* codegen'ed size of this instruction struct */
                                        );
                                }
                                break; 
                                case MILCMD.MilPop:
                                { 
                                    if (pushStack.Pop() == PushType.BitmapEffect) 
                                    {
                                        pushedEffects -= 1; 
                                    }
                                    /* instruction size is zero, do nothing */
                                }
                                break; 

                                default: 
                                { 
                                    Debug.Assert(false);
                                } 
                                break;
                             }
                            pCur += pCurRecord->Size;
                        } 
                    }
                } 
                channel.EndCommand(); 
            }
        } 
Exemplo n.º 7
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
                DoubleCollection vDashes = Dashes;

                // Obtain handles for animated properties
                DUCE.ResourceHandle hOffsetAnimations = GetAnimationResourceHandle(OffsetProperty, channel);

                // Store the count of this resource's contained collections in local variables.
                int DashesCount = (vDashes == null) ? 0 : vDashes.Count;

                // Pack & send command packet
                DUCE.MILCMD_DASHSTYLE data;
                unsafe
                {
                    data.Type = MILCMD.MilCmdDashStyle;
                    data.Handle = _duceResource.GetHandle(channel);
                    if (hOffsetAnimations.IsNull)
                    {
                        data.Offset = Offset;
                    }
                    data.hOffsetAnimations = hOffsetAnimations;
                    data.DashesSize = (uint)(sizeof(Double) * DashesCount);

                    channel.BeginCommand(
                        (byte*)&data,
                        sizeof(DUCE.MILCMD_DASHSTYLE),
                        (int)(data.DashesSize)
                        );


                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < DashesCount; i++)
                    {
                        Double resource = vDashes.Internal_GetItem(i);
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(Double)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }
Exemplo n.º 8
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
                DrawingCollection vChildren = Children;
                Geometry vClipGeometry = ClipGeometry;
                Brush vOpacityMask = OpacityMask;
                Transform vTransform = Transform;
                GuidelineSet vGuidelineSet = GuidelineSet;

                // Obtain handles for properties that implement DUCE.IResource
                DUCE.ResourceHandle hClipGeometry = vClipGeometry != null ? ((DUCE.IResource)vClipGeometry).GetHandle(channel) : DUCE.ResourceHandle.Null;
                DUCE.ResourceHandle hOpacityMask = vOpacityMask != null ? ((DUCE.IResource)vOpacityMask).GetHandle(channel) : DUCE.ResourceHandle.Null;
                DUCE.ResourceHandle hTransform;
                if (vTransform == null ||
                    Object.ReferenceEquals(vTransform, Transform.Identity)
                    )
                {
                    hTransform = DUCE.ResourceHandle.Null;
                }
                else
                {
                    hTransform = ((DUCE.IResource)vTransform).GetHandle(channel);
                }
                DUCE.ResourceHandle hGuidelineSet = vGuidelineSet != null ? ((DUCE.IResource)vGuidelineSet).GetHandle(channel) : DUCE.ResourceHandle.Null;

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

                // Store the count of this resource's contained collections in local variables.
                int ChildrenCount = (vChildren == null) ? 0 : vChildren.Count;

                // Pack & send command packet
                DUCE.MILCMD_DRAWINGGROUP data;
                unsafe
                {
                    data.Type = MILCMD.MilCmdDrawingGroup;
                    data.Handle = _duceResource.GetHandle(channel);
                    data.ChildrenSize = (uint)(sizeof(DUCE.ResourceHandle) * ChildrenCount);
                    data.hClipGeometry = hClipGeometry;
                    if (hOpacityAnimations.IsNull)
                    {
                        data.Opacity = Opacity;
                    }
                    data.hOpacityAnimations = hOpacityAnimations;
                    data.hOpacityMask = hOpacityMask;
                    data.hTransform = hTransform;
                    data.hGuidelineSet = hGuidelineSet;
                    data.EdgeMode = (EdgeMode)GetValue(RenderOptions.EdgeModeProperty);
                    data.bitmapScalingMode = (BitmapScalingMode)GetValue(RenderOptions.BitmapScalingModeProperty);
                    data.ClearTypeHint = (ClearTypeHint)GetValue(RenderOptions.ClearTypeHintProperty);

                    channel.BeginCommand(
                        (byte*)&data,
                        sizeof(DUCE.MILCMD_DRAWINGGROUP),
                        (int)(data.ChildrenSize)
                        );


                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < ChildrenCount; i++)
                    {
                        DUCE.ResourceHandle resource = ((DUCE.IResource)vChildren.Internal_GetItem(i)).GetHandle(channel);;
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(DUCE.ResourceHandle)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }
Exemplo n.º 9
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))
            {
                checked
                {
                    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);
                    }

                    DUCE.MILCMD_PATHGEOMETRY data;
                    data.Type = MILCMD.MilCmdPathGeometry;
                    data.Handle = _duceResource.GetHandle(channel);
                    data.hTransform = hTransform;
                    data.FillRule = FillRule;

                    PathGeometryData pathData = GetPathGeometryData();

                    data.FiguresSize = pathData.Size;

                    unsafe
                    {
                        channel.BeginCommand(
                            (byte*)&data,
                            sizeof(DUCE.MILCMD_PATHGEOMETRY),
                            (int)data.FiguresSize
                            ); 

                        fixed (byte *pPathData = pathData.SerializedData)
                        {
                            channel.AppendCommandData(pPathData, (int)data.FiguresSize);
                        }
                    }

                    channel.EndCommand();
                }
            }
        }
Exemplo n.º 10
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
                Point3DCollection vPositions = Positions;
                Vector3DCollection vNormals = Normals;
                PointCollection vTextureCoordinates = TextureCoordinates;
                Int32Collection vTriangleIndices = TriangleIndices;

                // Store the count of this resource's contained collections in local variables.
                int PositionsCount = (vPositions == null) ? 0 : vPositions.Count;
                int NormalsCount = (vNormals == null) ? 0 : vNormals.Count;
                int TextureCoordinatesCount = (vTextureCoordinates == null) ? 0 : vTextureCoordinates.Count;
                int TriangleIndicesCount = (vTriangleIndices == null) ? 0 : vTriangleIndices.Count;

                // Pack & send command packet
                DUCE.MILCMD_MESHGEOMETRY3D data;
                unsafe
                {
                    data.Type = MILCMD.MilCmdMeshGeometry3D;
                    data.Handle = _duceResource.GetHandle(channel);
                    data.PositionsSize = (uint)(sizeof(MilPoint3F) * PositionsCount);
                    data.NormalsSize = (uint)(sizeof(MilPoint3F) * NormalsCount);
                    data.TextureCoordinatesSize = (uint)(sizeof(Point) * TextureCoordinatesCount);
                    data.TriangleIndicesSize = (uint)(sizeof(Int32) * TriangleIndicesCount);

                    channel.BeginCommand(
                        (byte*)&data,
                        sizeof(DUCE.MILCMD_MESHGEOMETRY3D),
                        (int)(data.PositionsSize + 
                              data.NormalsSize + 
                              data.TextureCoordinatesSize + 
                              data.TriangleIndicesSize)
                        );


                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < PositionsCount; i++)
                    {
                        MilPoint3F resource = CompositionResourceManager.Point3DToMilPoint3F(vPositions.Internal_GetItem(i));
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(MilPoint3F)
                            );
                    }

                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < NormalsCount; i++)
                    {
                        MilPoint3F resource = CompositionResourceManager.Vector3DToMilPoint3F(vNormals.Internal_GetItem(i));
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(MilPoint3F)
                            );
                    }

                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < TextureCoordinatesCount; i++)
                    {
                        Point resource = vTextureCoordinates.Internal_GetItem(i);
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(Point)
                            );
                    }

                    // Copy this collection's elements (or their handles) to reserved data
                    for(int i = 0; i < TriangleIndicesCount; i++)
                    {
                        Int32 resource = vTriangleIndices.Internal_GetItem(i);
                        channel.AppendCommandData(
                            (byte*)&resource,
                            sizeof(Int32)
                            );
                    }

                    channel.EndCommand();
                }
            }
        }
Exemplo n.º 11
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))
            {
                checked
                {
                    DUCE.MILCMD_PIXELSHADER data;
                    data.Type = MILCMD.MilCmdPixelShader;
                    data.Handle = _duceResource.GetHandle(channel);
                    data.PixelShaderBytecodeSize = (_shaderBytecode.Value == null) ? 0 : (uint)(_shaderBytecode.Value).Length;
                    data.ShaderRenderMode = ShaderRenderMode;
                    data.CompileSoftwareShader = CompositionResourceManager.BooleanToUInt32(!(ShaderMajorVersion == 3 && ShaderMinorVersion == 0));

                    unsafe
                    {
                        channel.BeginCommand(
                            (byte*)&data,                      
                            sizeof(DUCE.MILCMD_PIXELSHADER),
                            (int)data.PixelShaderBytecodeSize);   // extra data

                            if (data.PixelShaderBytecodeSize > 0)
                            {
                                fixed (byte *pPixelShaderBytecode = _shaderBytecode.Value)
                                {
                                    channel.AppendCommandData(pPixelShaderBytecode, (int)data.PixelShaderBytecodeSize);
                                }
                            }
                    }
                }

                channel.EndCommand();
            }
        }