コード例 #1
0
ファイル: Controls.cs プロジェクト: Pzkgw/Camera-Support
        private void ToggleAspectRatio()
        {
            if (_mPlayer != null)
            {
                ViewSettings setari = _info.Cam.Data.ViewSettings;

                bool aspectDefault = _mPlayer.AspectRatio == setari.AspectRatioDefault;

                _mPlayer.AspectRatio = (aspectDefault) ?           // AspectRatio e Default
                                       setari.AspectRatioMode :    // Mode 2
                                       setari.AspectRatioDefault;  // Default

                //  Notificari optionale
                _form.btnRatio.Text = (aspectDefault) ? setari.AspectRatioDefault.ToString() : setari.AspectRatioMode.ToString();

                _lblEventsShowCount = 10;
                _form.lblEvent.Text = @"Event: aspect ratio change from " + ((aspectDefault) ?
                                                                             (VlcUtils.AspectRatioToString(setari.AspectRatioDefault) + " to " +
                                                                              VlcUtils.AspectRatioToString(setari.AspectRatioMode)) :
                                                                             (VlcUtils.AspectRatioToString(setari.AspectRatioMode) + " to " +
                                                                              VlcUtils.AspectRatioToString(setari.AspectRatioDefault)));
            }
            else
            {
                _form.lblEvent.Text = @"No video, cannot change aspect ratio";
            }
        }
コード例 #2
0
        private Texture CreateTexture(Device device /*, Device parentDeviceForDx9ExShared */)
        {
            Texture       retVal = null;
            DoubleTexture t2     = null;

            //return CreateManagedTexture(device, Math.Max( this.doubleBuffer.GetWidth(), 1 ), Math.Max( this.doubleBuffer.GetHeight(), 1 ) );
            if (memoryToTextureRendererBusyMutex.WaitOne())
            {
                //Log( LogType.Debug, "CreateTexture on device " + device.ComPointer.ToInt64() + " ---------------------------------------------------------------- " );
                t2 = CreateDoubleTexture(device /*, parentDeviceForDx9ExShared */);

/*
 *                                      //Log( LogType.Debug, "CreateTexture on device " + device.ComPointer.ToInt64() + "=" + t2.GetDevice().ComPointer.ToInt64() + " ---------------------------------------------------------------- " );
 *                                      foreach (Device d in device2DoubleTexture.Keys) {
 *                                              DoubleTexture t2Temp;
 *                                              if (device2DoubleTexture.TryGetValue(d, out t2Temp)) {
 *                                                      Log( LogType.Debug, "\tDoubleTexture (device " + t2.GetDevice().ComPointer.ToInt64() + "=" + device.ComPointer.ToInt64() + ", " + t2Temp.GetWidth() + "x" + t2Temp.GetHeight() + ")" );
 *                                              }
 *                                      }
 */
                memoryToTextureRendererBusyMutex.ReleaseMutex();

                retVal = t2 != null?t2.GetFrontTexture() : null;
            }
            else
            {
                Log(LogType.Error, "[CreateTexture ERROR] CreateTexture(device " + device.ComPointer.ToInt64() + ") FAILED because mutex not available !!!");
                //This shouldn't happen
                int w = Math.Max(this.doubleBuffer.GetWidth(), 2);
                int h = Math.Max(this.doubleBuffer.GetHeight(), 2);
                return(VlcUtils.CreateManagedTexture(device, w, h));
            }

            if (retVal != null)
            {
                //Log( LogType.Debug, "[CreateTexture] done, trying to update." );
                //if ( ( ! ( device is DeviceEx ) || ( device == t2.GetDevice() /* device == parentDeviceForDx9ExShared */ ) ) ) {
                UpdateTexture_Threaded();
                //}
                //Log( LogType.Debug, "[CreateTexture] update should be ok. " );
            }
            else
            {
                Log(LogType.Error, "CreateTexture(" + device.ComPointer.ToInt64() + " FAILED");
            }

            return(retVal);
//				return CreateManagedTexture(device, Math.Max(this.doubleBuffer.GetWidth(), 1), Math.Max(this.doubleBuffer.GetHeight(), 1));
        }
コード例 #3
0
ファイル: DoubleTexture.cs プロジェクト: vnmone/vvvv-sdk
        private int CreateTexturesIfDeviceSharingOff(int w, int h)
        {
            if (LockBothTextures(tryLockTimeout))
            {
                try {
                    //if ( texture0 != null ) { device = texture0.Device; }

                    Texture newTexture0 = VlcUtils.CreateManagedTexture(device, w, h);
                    Texture newTexture1 = VlcUtils.CreateManagedTexture(device, w, h);

                    Dispose( );

                    texture0 = newTexture0;
                    texture1 = newTexture1;

                    width  = w;
                    height = h;
                    try {
                        DataRectangle r = texture0.LockRectangle(0, LockFlags.Discard);
                        if (r != null)
                        {
                            pitch = r.Pitch;
                        }
                        texture0.UnlockRectangle(0);
                    }
                    catch {
                        pitch = w;
                    }

                    if (device == null)
                    {
                        //Device seems to become null (only when calling SetNewSize only instead of from constructor?),
                        //don't know why. Maybe because we disposed the old textures...
                        device = texture0.Device;
                    }
                }
                finally {
                    UnlockBothTextures( );
                }
            }
            else
            {
                return(-3);
            }
            return(0);
        }
コード例 #4
0
        /*
         * This function should decide whether vvvv has been started with the dx9ex option,
         * and if so only create one (double)texture, with a sharedhandle
         * (instead of a different texture for each device)
         *
         */
        //public Texture CreateOrReturnSharedTexture( Device device /*, Device parentDeviceForDx9ExShared*/ ) {
        //	Texture retVal = null;

        //	retVal = CreateTexture( device );

        //	return retVal;
        //}

        public Texture CreateTexture(Device device /*, Device parentDeviceForDx9ExShared */)
        {
            Texture       retVal = null;
            DoubleTexture t2     = null;

            //return CreateManagedTexture(device, Math.Max( this.doubleBuffer.GetWidth(), 1 ), Math.Max( this.doubleBuffer.GetHeight(), 1 ) );
            if (memoryToTextureRendererBusyMutex.WaitOne( ))
            {
                //Log( LogType.Debug, "CreateTexture on device " + device.ComPointer.ToInt64() + " ---------------------------------------------------------------- " );
                t2 = CreateDoubleTexture(device);

                memoryToTextureRendererBusyMutex.ReleaseMutex( );

                retVal = t2 != null ? t2.FrontTexture : null;
            }
            else
            {
                Log(LogType.Error, "[CreateTexture ERROR] CreateTexture(device " + device.ComPointer.ToInt64( ) + ") FAILED because mutex not available !!!");
                //This shouldn't happen
                int w = Math.Max(this.doubleBuffer.Width, 2);
                int h = Math.Max(this.doubleBuffer.Height, 2);
                return(VlcUtils.CreateManagedTexture(device, w, h));
            }

            if (retVal != null)
            {
                //Log( LogType.Debug, "[CreateTexture] done, trying to update." );
                //if ( ( ! ( device is DeviceEx ) || ( device == t2.Device /* device == parentDeviceForDx9ExShared */ ) ) ) {
                UpdateTexture_Threaded( );

                deviceDataNeedsUpdatingOnEvaluate = true;
                //}
                //Log( LogType.Debug, "[CreateTexture] update should be ok. " );
            }
            else
            {
                Log(LogType.Error, "CreateTexture(" + device.ComPointer.ToInt64( ) + " FAILED");
            }

            return(retVal);
            //				return CreateManagedTexture(device, Math.Max(this.doubleBuffer.GetWidth(), 1), Math.Max(this.doubleBuffer.GetHeight(), 1));
        }