void ICyclicBrush.RenderForCyclicBrush(DUCE.Channel channel, bool skipChannelCheck)
        {
            Visual vVisual = Visual;

            // The Visual may have been registered for an asynchronous render, but may have been
            // disconnected from the VisualBrush since then.  If so, don't bother to render here, if
            // the Visual is visible it will be rendered elsewhere.
            if (vVisual != null && vVisual.CheckFlagsAnd(VisualFlags.NodeIsCyclicBrushRoot))
            {
                // ------------------------------------------------------------------------------------
                // 1) Prepare the visual for rendering.
                //
                // Updates bounding boxes.
                //

                vVisual.Precompute();


                // ------------------------------------------------------------------------------------
                // 2) Prepare the render context.
                //

                RenderContext rc = new RenderContext();

                rc.Initialize(channel, DUCE.ResourceHandle.Null);


                // ------------------------------------------------------------------------------------
                // 3) Compile the scene.

                if (channel.IsConnected)
                {
                    vVisual.Render(rc, 0);
                }
                else
                {
                    // We can issue the release here instead of putting it in queue
                    // since we are already in Render walk.
                    ((DUCE.IResource)vVisual).ReleaseOnChannel(channel);
                }
            }

            _isAsyncRenderRegistered = false;
        }
Exemplo n.º 2
0
        static internal void Render(
            IntPtr pRenderTarget,
            DUCE.Channel channel,
            Visual visual,
            int width,
            int height,
            double dpiX,
            double dpiY,
            Matrix worldTransform,
            Rect windowClip
            )
        {
            DUCE.Resource target =
                new DUCE.Resource();
            DUCE.Resource root =
                new DUCE.Resource();

            DUCE.ResourceHandle targetHandle = DUCE.ResourceHandle.Null;
            DUCE.ResourceHandle rootHandle = DUCE.ResourceHandle.Null;

            Matrix deviceTransform = new Matrix(
                dpiX * (1.0 / 96.0),    0,
                0,                      dpiY * (1.0 / 96.0),
                0,                      0);

            deviceTransform = worldTransform * deviceTransform;
            MatrixTransform mtDeviceTransform = new MatrixTransform(deviceTransform);

            DUCE.ResourceHandle deviceTransformHandle =
                ((DUCE.IResource)mtDeviceTransform).AddRefOnChannel(channel);


            try
            {
                // ------------------------------------------------------------
                //   Create the composition target and root visual resources.

                target.CreateOrAddRefOnChannel(target, channel, DUCE.ResourceType.TYPE_GENERICRENDERTARGET);
                targetHandle = target.Handle;

                DUCE.CompositionTarget.PrintInitialize(
                    targetHandle,
                    pRenderTarget,
                    width,
                    height,
                    channel);

                root.CreateOrAddRefOnChannel(root, channel, DUCE.ResourceType.TYPE_VISUAL);
                rootHandle = root.Handle;

                DUCE.CompositionNode.SetTransform(
                    rootHandle,
                    deviceTransformHandle,
                    channel);

                DUCE.CompositionTarget.SetRoot(
                    targetHandle,
                    rootHandle,
                    channel);

                channel.CloseBatch();
                channel.Commit();


                // ------------------------------------------------------------
                //   Render the freshly created target.

                RenderContext renderContext = new RenderContext();

                renderContext.Initialize(channel, rootHandle);

                visual.Precompute();

                visual.Render(renderContext, 0);

                // ------------------------------------------------------------
                //   Flush the channel and present the composition target.

                channel.CloseBatch();
                channel.Commit();
                channel.Present();

                MediaContext mediaContext = MediaContext.CurrentMediaContext;
                mediaContext.NotifySyncChannelMessage(channel);

            }
            finally
            {
                // ------------------------------------------------------------
                //   Clean up and release the root visual.

                if (!rootHandle.IsNull)
                {
                    DUCE.CompositionNode.RemoveAllChildren(
                        rootHandle,
                        channel);

                    ((DUCE.IResource)visual).ReleaseOnChannel(channel);

                    root.ReleaseOnChannel(channel);
                }


                // ------------------------------------------------------------
                //   Release the world transform.

                if (!deviceTransformHandle.IsNull)
                {
                    ((DUCE.IResource)mtDeviceTransform).ReleaseOnChannel(channel);
                }


                // ------------------------------------------------------------
                //   Clean up and release the composition target.

                if (!targetHandle.IsNull)
                {
                    DUCE.CompositionTarget.SetRoot(
                        targetHandle,
                        DUCE.ResourceHandle.Null,
                        channel);

                    target.ReleaseOnChannel(channel);
                }

                // ------------------------------------------------------------
                //   Flush the channel and present the composition target.

                channel.CloseBatch();
                channel.Commit();
                channel.Present();

                MediaContext mediaContext = MediaContext.CurrentMediaContext;
                mediaContext.NotifySyncChannelMessage(channel);
            }
        }
Exemplo n.º 3
0
       void ICyclicBrush.RenderForCyclicBrush(DUCE.Channel channel, bool skipChannelCheck)
       {

            Visual vVisual = Visual;

            // The Visual may have been registered for an asynchronous render, but may have been
            // disconnected from the VisualBrush since then.  If so, don't bother to render here, if
            // the Visual is visible it will be rendered elsewhere.
            if (vVisual != null && vVisual.CheckFlagsAnd(VisualFlags.NodeIsCyclicBrushRoot))
            {
                // ------------------------------------------------------------------------------------
                // 1) Prepare the visual for rendering.
                //
                // Updates bounding boxes.
                //

                vVisual.Precompute();


                // ------------------------------------------------------------------------------------
                // 2) Prepare the render context.
                //

                RenderContext rc = new RenderContext();

                rc.Initialize(channel, DUCE.ResourceHandle.Null);


                // ------------------------------------------------------------------------------------
                // 3) Compile the scene.

                if (channel.IsConnected)
                {
                    vVisual.Render(rc, 0);
                }
                else
                {
                    // We can issue the release here instead of putting it in queue
                    // since we are already in Render walk.
                    ((DUCE.IResource)vVisual).ReleaseOnChannel(channel);
                }
            }

            _isAsyncRenderRegistered = false;
        }
        static internal void Render(
            IntPtr pRenderTarget,
            DUCE.Channel channel,
            Visual visual,
            int width,
            int height,
            double dpiX,
            double dpiY,
            Matrix worldTransform,
            Rect windowClip
            )
        {
            DUCE.Resource target =
                new DUCE.Resource();
            DUCE.Resource root =
                new DUCE.Resource();

            DUCE.ResourceHandle targetHandle = DUCE.ResourceHandle.Null;
            DUCE.ResourceHandle rootHandle   = DUCE.ResourceHandle.Null;

            Matrix deviceTransform = new Matrix(
                dpiX * (1.0 / 96.0), 0,
                0, dpiY * (1.0 / 96.0),
                0, 0);

            deviceTransform = worldTransform * deviceTransform;
            MatrixTransform mtDeviceTransform = new MatrixTransform(deviceTransform);

            DUCE.ResourceHandle deviceTransformHandle =
                ((DUCE.IResource)mtDeviceTransform).AddRefOnChannel(channel);


            try
            {
                // ------------------------------------------------------------
                //   Create the composition target and root visual resources.

                target.CreateOrAddRefOnChannel(target, channel, DUCE.ResourceType.TYPE_GENERICRENDERTARGET);
                targetHandle = target.Handle;

                DUCE.CompositionTarget.PrintInitialize(
                    targetHandle,
                    pRenderTarget,
                    width,
                    height,
                    channel);

                root.CreateOrAddRefOnChannel(root, channel, DUCE.ResourceType.TYPE_VISUAL);
                rootHandle = root.Handle;

                DUCE.CompositionNode.SetTransform(
                    rootHandle,
                    deviceTransformHandle,
                    channel);

                DUCE.CompositionTarget.SetRoot(
                    targetHandle,
                    rootHandle,
                    channel);

                channel.CloseBatch();
                channel.Commit();


                // ------------------------------------------------------------
                //   Render the freshly created target.

                RenderContext renderContext = new RenderContext();

                renderContext.Initialize(channel, rootHandle);

                visual.Precompute();

                visual.Render(renderContext, 0);

                // ------------------------------------------------------------
                //   Flush the channel and present the composition target.

                channel.CloseBatch();
                channel.Commit();
                channel.Present();

                MediaContext mediaContext = MediaContext.CurrentMediaContext;
                mediaContext.NotifySyncChannelMessage(channel);
            }
            finally
            {
                // ------------------------------------------------------------
                //   Clean up and release the root visual.

                if (!rootHandle.IsNull)
                {
                    DUCE.CompositionNode.RemoveAllChildren(
                        rootHandle,
                        channel);

                    ((DUCE.IResource)visual).ReleaseOnChannel(channel);

                    root.ReleaseOnChannel(channel);
                }


                // ------------------------------------------------------------
                //   Release the world transform.

                if (!deviceTransformHandle.IsNull)
                {
                    ((DUCE.IResource)mtDeviceTransform).ReleaseOnChannel(channel);
                }


                // ------------------------------------------------------------
                //   Clean up and release the composition target.

                if (!targetHandle.IsNull)
                {
                    DUCE.CompositionTarget.SetRoot(
                        targetHandle,
                        DUCE.ResourceHandle.Null,
                        channel);

                    target.ReleaseOnChannel(channel);
                }

                // ------------------------------------------------------------
                //   Flush the channel and present the composition target.

                channel.CloseBatch();
                channel.Commit();
                channel.Present();

                MediaContext mediaContext = MediaContext.CurrentMediaContext;
                mediaContext.NotifySyncChannelMessage(channel);
            }
        }