当前位置: 首页>>代码示例>>C#>>正文


C# DUCE.Commit方法代码示例

本文整理汇总了C#中System.Windows.Media.Composition.DUCE.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# DUCE.Commit方法的具体用法?C# DUCE.Commit怎么用?C# DUCE.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Composition.DUCE的用法示例。


在下文中一共展示了DUCE.Commit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateUCEResources

        /// <summary>
        /// This method is used to create all uce resources either on Startup or session connect
        /// </summary>
        internal virtual void CreateUCEResources(DUCE.Channel channel, DUCE.Channel outOfBandChannel)
        {
            Debug.Assert(channel != null);
            Debug.Assert(!_contentRoot.IsOnChannel(channel));

            Debug.Assert(outOfBandChannel != null);
            Debug.Assert(!_contentRoot.IsOnChannel(outOfBandChannel));

            //
            // Create root visual on the current channel and send
            // this command out of band to ensure that composition node is
            // created by the time this visual target is available for hosting
            // and to avoid life-time issues when we are working with this node
            // from the different channels.
            //

            bool resourceCreated = _contentRoot.CreateOrAddRefOnChannel(this, outOfBandChannel, s_contentRootType);
            Debug.Assert(resourceCreated);
            _contentRoot.DuplicateHandle(outOfBandChannel, channel);
            outOfBandChannel.CloseBatch();
            outOfBandChannel.Commit();

        }
开发者ID:JianwenSun,项目名称:cc,代码行数:26,代码来源:CompositionTarget.cs

示例2: Render

        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);
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:Renderer.cs

示例3: CreateUCEResources

        internal override void CreateUCEResources(DUCE.Channel channel, DUCE.Channel outOfBandChannel)
        {
            // create visual target resources
            // this forces the creation of the media context if we don't already have one.

            base.CreateUCEResources(channel, outOfBandChannel);

            Debug.Assert(!_compositionTarget.IsOnChannel(channel));
            Debug.Assert(!_compositionTarget.IsOnChannel(outOfBandChannel));

            //
            // For each HwndTarget we are building some structures in the UCE.
            // This includes spinning up a UCE render target. We need to commit the
            // batch for those changes right away, since we need to be able to process
            // the invalidate packages that we send down on WM_PAINTs. If we don't commit
            // right away a WM_PAINT can get fired before we get a chance to commit
            // the batch.
            //

            //
            // First we create the composition target, composition context, and the composition root node.
            // Note, that composition target will be created out of band because invalidate
            // command is also sent out of band and that can occur before current channel is committed.
            // We would like to avoid commiting channel here to prevent visual artifacts.
            //

            bool resourceCreated = _compositionTarget.CreateOrAddRefOnChannel(this, outOfBandChannel, DUCE.ResourceType.TYPE_HWNDRENDERTARGET);
            Debug.Assert(resourceCreated);
            _compositionTarget.DuplicateHandle(outOfBandChannel, channel);
            outOfBandChannel.CloseBatch();
            outOfBandChannel.Commit();

            DUCE.CompositionTarget.HwndInitialize(
                _compositionTarget.GetHandle(channel),
                _hWnd,
                _hwndClientRectInScreenCoords.right - _hwndClientRectInScreenCoords.left,
                _hwndClientRectInScreenCoords.bottom - _hwndClientRectInScreenCoords.top,
                MediaSystem.ForceSoftwareRendering,
                channel
                );

            DUCE.ResourceHandle hWorldTransform = ((DUCE.IResource)_worldTransform).AddRefOnChannel(channel);

            DUCE.CompositionNode.SetTransform(
                _contentRoot.GetHandle(channel),
                hWorldTransform,
                channel);

            DUCE.CompositionTarget.SetClearColor(
                _compositionTarget.GetHandle(channel),
                _backgroundColor,
                channel);

            //
            // Set initial state on the visual target.
            //

            Rect clientRect = new Rect(
                0,
                0,
                (float)(Math.Ceiling((double)(_hwndClientRectInScreenCoords.right - _hwndClientRectInScreenCoords.left))),
                (float)(Math.Ceiling((double)(_hwndClientRectInScreenCoords.bottom - _hwndClientRectInScreenCoords.top))));

            StateChangedCallback(
                new object[]
                {
                    HostStateFlags.WorldTransform |
                    HostStateFlags.ClipBounds,
                    _worldTransform.Matrix,
                    clientRect
                });

            DUCE.CompositionTarget.SetRoot(
                _compositionTarget.GetHandle(channel),
                _contentRoot.GetHandle(channel),
                channel);

            // reset the disable cookie when creating the slave resource. This happens when creating the
            // managed resource and on handling a connect.
            _disableCookie = 0;

            //
            // Finally, update window settings to reflect the state of this object.
            // Because CreateUCEResources is called for each channel, only call
            // UpdateWindowSettings on that channel this time.
            //
            DUCE.ChannelSet channelSet;
            channelSet.Channel = channel;
            channelSet.OutOfBandChannel = outOfBandChannel;
            UpdateWindowSettings(_isRenderTargetEnabled, channelSet);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:91,代码来源:HwndTarget.cs


注:本文中的System.Windows.Media.Composition.DUCE.Commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。