Example #1
0
        internal override void UpdateBitmapSourceResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            //
            // If we're in BitmapSource mode, then just defer to the BitmapSource 
            // implementation.
            // 
            if (_actLikeSimpleBitmap) 
            {
                base.UpdateBitmapSourceResource(channel, skipOnChannelCheck); 
                return;
            }

            // We override this method because we use a different resource type 
            // than our base class does.  This probably suggests that the base
            // class should not presume the resource type, but it currently 
            // does.  The base class uses TYPE_BITMAPSOURCE resources, and we 
            // use TYPE_DOUBLEBUFFEREDBITMAP resources.
 
            // 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)) 
            {
                DUCE.MILCMD_DOUBLEBUFFEREDBITMAP command; 
                command.Type = MILCMD.MilCmdDoubleBufferedBitmap; 
                command.Handle = _duceResource.GetHandle(channel);
                unsafe 
                {
                    command.SwDoubleBufferedBitmap = (UInt64) _pDoubleBufferedBitmap.DangerousGetHandle().ToPointer();
                }
                command.UseBackBuffer = channel.IsSynchronous ? 1u : 0u; 

                // 
                // We need to ensure that this object stays alive while traveling over the channel 
                // so we'll AddRef it here, and simply take over the reference on the other side.
                // 
                UnsafeNativeMethods.MILUnknown.AddRef(_pDoubleBufferedBitmap);

                unsafe
                { 
                    channel.SendSecurityCriticalCommand(
                        (byte*)&command, 
                        sizeof(DUCE.MILCMD_DOUBLEBUFFEREDBITMAP), 
                        false /* sendInSeparateBatch */
                        ); 
                }
            }
        }
Example #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);

                bool isSynchronous = channel.IsSynchronous; 

                DUCE.MILCMD_D3DIMAGE data; 
                unsafe 
                {
                    data.Type = MILCMD.MilCmdD3DImage; 
                    data.Handle = _duceResource.GetHandle(channel);
                    if (_pInteropDeviceBitmap != null)
                    {
                        UnsafeNativeMethods.MILUnknown.AddRef(_pInteropDeviceBitmap); 

                        data.pInteropDeviceBitmap = (ulong)_pInteropDeviceBitmap.DangerousGetHandle().ToPointer(); 
                    } 
                    else
                    { 
                        data.pInteropDeviceBitmap = 0;
                    }

                    data.pSoftwareBitmap = 0; 

                    if (isSynchronous) 
                    { 
                        _softwareCopy = CopyBackBuffer();
 
                        if (_softwareCopy != null)
                        {
                            UnsafeNativeMethods.MILUnknown.AddRef(_softwareCopy.WicSourceHandle);
 
                            data.pSoftwareBitmap = (ulong)_softwareCopy.WicSourceHandle.DangerousGetHandle().ToPointer();
                        } 
                    } 

                    // Send packed command structure 
                    channel.SendSecurityCriticalCommand(
                        (byte*)&data,
                        sizeof(DUCE.MILCMD_D3DIMAGE),
                        false /* sendInSeparateBatch */ 
                        );
                } 
 
                // Presents only happen on the async channel so don't let RTB flip this bit
                if (!isSynchronous) 
                {
                    _waitingForUpdateResourceBecauseBitmapChanged = false;
                }
            } 
        }