/// <summary> /// Initializes a new <see cref="SwapChainPanelTarget"/> instance /// </summary> /// <param name="panel">The <see cref="SwapChainPanel"/> to render to</param> public SwapChainPanelTarget(SwapChainPanel panel) { this.panel = panel; // Gets the native panel nativePanel = ComObject.As<ISwapChainPanelNative>(panel); // Register event on Window Size Changed // So that resources dependent size can be resized Window.Current.CoreWindow.SizeChanged += CoreWindow_SizeChanged; }
public XamlGameWindow(SwapChainPanel swapChainPanel) { this.swapChainPanel = swapChainPanel; swapChainPanel.SizeChanged += OnSwapChainPanelSizeChanged; swapChainPanel.CompositionScaleChanged += OnSwapChainPanelCompositionScaleChanged; }
protected override void OnApplyTemplate() { // Pass to base first base.OnApplyTemplate(); // Get the swap chain panel swapPanel = GetTemplateChild(SWAP_PANEL_NAME) as SwapChainPanel; // Ensure panel was found if (swapPanel == null) { throw new InvalidOperationException($"A {nameof(SwapChainPanel)} named {SWAP_PANEL_NAME} is required in the control template."); } // Attempt to get the preview element placeholderElement = GetTemplateChild(PLACEHOLDER_ELEMENT_NAME) as UIElement; // Panel found. If not in design mode, load Unity. if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { // Get the bridge bridge = UnityBridge.Instance; // Subscribe to bridge events bridge.RenderingStarted += Bridge_RenderingStarted; // Initialize Unity bridge.Initialize(this, swapPanel); } }
public EGLSurface CreateSurface(SwapChainPanel panel) { if (panel == null) { throw new ArgumentNullException("SwapChainPanel parameter is invalid"); } EGLSurface surface = Egl.EGL_NO_SURFACE; EGLint[] surfaceAttributes = new[] { // EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above). // If you have compilation issues with it then please update your Visual Studio templates. Egl.EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, Egl.EGL_TRUE, Egl.EGL_NONE }; // Create a PropertySet and initialize with the EGLNativeWindowType. PropertySet surfaceCreationProperties = new PropertySet { { Egl.EGLNativeWindowTypeProperty, panel } }; surface = Egl.eglCreateWindowSurface(mEglDisplay, mEglConfig, surfaceCreationProperties, surfaceAttributes); if (surface == Egl.EGL_NO_SURFACE) { throw new Exception("Failed to create EGL surface"); } return(surface); }
/// <summary> /// Constructor. Creates rendering brush; initializes graphics /// </summary> /// <param name="swapChainPanel">SwapChainPanel on which to render captured ink</param> /// <param name="brushType">Type of brush to use</param> /// <param name="thickness">Relative thickness of brush</param> /// <param name="color">Color of ink</param> /// <param name="style">Shape of brush (VectorBrush only)</param> public Renderer(SwapChainPanel swapChainPanel, VectorBrushStyle style, MediaColor color) { StrokeHandler = new VectorStrokeHandler(this, style, color); mSwapChainPanel = swapChainPanel; Graphics.GraphicsReady += OnGraphicsReady; Graphics.Initialize(mSwapChainPanel, false); }
/// <summary> /// Initializes a new <see cref="SwapChainPanelTarget"/> instance /// </summary> /// <param name="panel">The <see cref="SwapChainPanel"/> to render to</param> public SwapChainPanelTarget(SwapChainPanel panel) { this.panel = panel; // Gets the native panel nativePanel = ComObject.As <ISwapChainPanelNative>(panel); panel.SizeChanged += panel_SizeChanged; }
/// <summary> /// Initializes a new <see cref="SwapChainPanelTarget"/> instance /// </summary> /// <param name="panel">The <see cref="SwapChainPanel"/> to render to</param> public SwapChainPanelTarget(SwapChainPanel panel) { this.panel = panel; // Gets the native panel nativePanel = ComObject.As<ISwapChainPanelNative>(panel); panel.SizeChanged += panel_SizeChanged; }
private void OnCompositionScaleChanged(SwapChainPanel sender, object args) { lock (Lock ?? _dummyLock) { _compositionScaleX = CompositionScaleX; _compositionScaleY = CompositionScaleY; _requiresResize = true; } }
/// <summary> /// Initializes this instance. /// </summary> public void Initialize(SwapChainPanel panel) { this.panel = panel; newWidth = width = (int)panel.ActualWidth; newHeight = height = (int)panel.ActualHeight; LoadPipeline(); LoadAssets(); }
private void M_swapChainPanel_CompositionScaleChanged(SwapChainPanel sender, object args) { lock (m_rendererLock) { m_swapChain.WaitForGpu(); m_ctx.ResetViewDependentResources(); m_swapChain.SetCompositionScale(sender.CompositionScaleX, sender.CompositionScaleY); } }
private void panel_CompositionScaleChanged(SwapChainPanel sender, object args) { if (Width != lastWidth || Height != lastHeight) { lastWidth = Width; lastHeight = Height; CreateSizeDependentResources(this); } }
/// <summary> /// Initializes a new instance of the <see cref="SwapChainPanelWrapper"/> class. /// </summary> /// <param name="panel">The panel for which to create the wrapper.</param> public SwapChainPanelWrapper(SwapChainPanel panel) : this() { m_panel = panel; m_panelNative = ComObject.As <DXGI.ISwapChainPanelNative>(m_panel); m_panel.SizeChanged += OnAnyPanel_SizeChanged; m_panel.Loaded += OnAnyPanel_Loaded; m_panel.Unloaded += OnAnyPanel_Unloaded; m_panel.CompositionScaleChanged += OnPanelCompositionScaleChanged; }
public GamePage() { this.InitializeComponent(); // Create the game. var launchArguments = string.Empty; _game = MonoGame.Framework.XamlGame <Game1> .Create(launchArguments, Window.Current.CoreWindow, swapChainPanel); page = swapChainPanel; }
private void CreateSurface(SwapChainPanel panel, int rbWidth, int rbHeight, GlesBackingOption backingOption, GlesMultisampling multisampling, GlesRenderTarget renderTarget) { if (panel == null) { throw new ArgumentNullException(nameof(panel), "SwapChainPanel parameter is invalid"); } if (rbWidth == 0 || rbHeight == 0) { rbWidth = 320; rbHeight = 480; } // Create a temporary surface so that we can make the context current int[] surfaceAttributes = { Egl.EGL_WIDTH, rbWidth, Egl.EGL_HEIGHT, rbHeight, Egl.EGL_FIXED_SIZE_ANGLE, Egl.EGL_TRUE, // Egl.EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as Egl.EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above). // If you have compilation issues with it then please update your Visual Studio templates. Egl.EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, Egl.EGL_TRUE, Egl.EGL_NONE }; eglSurface = Egl.eglCreateWindowSurface(eglDisplay, eglConfig, panel, surfaceAttributes); if (eglSurface == Egl.EGL_NO_SURFACE) { throw new Exception("Failed to create EGL surface"); } // Set up swap behavior. int swapBehavior = backingOption == GlesBackingOption.Retained ? Egl.EGL_BUFFER_PRESERVED : Egl.EGL_BUFFER_DESTROYED; if (Egl.eglSurfaceAttrib(eglDisplay, eglSurface, Egl.EGL_SWAP_BEHAVIOR, swapBehavior) == Egl.EGL_FALSE) { Debug.WriteLine("Unable to set up backbuffer swap behavior, app may experience graphical glitches!"); } if (multisampling == GlesMultisampling.FourTimes) { Gles.glRenderbufferStorageMultisampleANGLE((uint)renderTarget, 4, Gles.GL_BGRA8_EXT, rbWidth, rbHeight); } else { Gles.glRenderbufferStorage((uint)renderTarget, Gles.GL_BGRA8_EXT, rbWidth, rbHeight); } if (CurrentContext == this) { Egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext); } }
/// <summary> /// Initializes a new <see cref="SwapChainPanelTarget"/> instance /// </summary> /// <param name="panel">The <see cref="SwapChainPanel"/> to render to</param> public SwapChainPanelTarget(SwapChainPanel panel) { this.panel = panel; // Gets the native panel nativePanel = ComObject.As <ISwapChainPanelNative>(panel); // Register event on Window Size Changed // So that resources dependent size can be resized Window.Current.CoreWindow.SizeChanged += CoreWindow_SizeChanged; }
public RenderResult(SwapChainPanel swapChainPanel, Size size, long setupTimeMillis, long renderTimeMillis) { #if WINDOWS_UWP SoftwareBitmap = null; #endif Bitmap = null; Buffer = null; SwapChainPanel = swapChainPanel; Size = size; SetupTimeMillis = setupTimeMillis; RenderTimeMillis = renderTimeMillis; }
/// <summary> /// Initializes a new instance of the <see cref="GameContext" /> class. /// </summary> /// <param name="control">The control.</param> /// <param name="requestedWidth">Width of the requested.</param> /// <param name="requestedHeight">Height of the requested.</param> public GameContext(SwapChainPanel control, int requestedWidth = 0, int requestedHeight = 0) { if (control == null) { throw new ArgumentNullException("control"); } Control = control; RequestedWidth = requestedWidth; RequestedHeight = requestedHeight; ContextType = AppContextType.WindowsRuntime; }
public void CS_WP_N_Basic() { ExecuteOnUIThread(async() => { var capture = new MediaCapture(); await capture.InitializeAsync(new MediaCaptureInitializationSettings { StreamingCaptureMode = StreamingCaptureMode.Video }); var graphicsDevice = MediaGraphicsDevice.CreateFromMediaCapture(capture); var previewProps = (VideoEncodingProperties)capture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview); var image = new SurfaceImageSource((int)previewProps.Width, (int)previewProps.Height); var imagePresenter = ImagePresenter.CreateFromSurfaceImageSource( image, graphicsDevice, (int)previewProps.Width, (int)previewProps.Height ); var panel = new SwapChainPanel(); var swapChainPresenter = ImagePresenter.CreateFromSwapChainPanel( panel, graphicsDevice, (int)previewProps.Width, (int)previewProps.Height ); var readerProps = VideoEncodingProperties.CreateUncompressed(MediaEncodingSubtypes.Bgra8, previewProps.Width, previewProps.Height); readerProps.FrameRate.Numerator = previewProps.FrameRate.Numerator; readerProps.FrameRate.Denominator = previewProps.FrameRate.Denominator; var captureReader = await CaptureReader.CreateAsync( capture, new MediaEncodingProfile { Video = readerProps }); using (MediaSample2D sample = (MediaSample2D)await captureReader.GetVideoSampleAsync()) { swapChainPresenter.Present(sample); imagePresenter.Present(sample); var folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("MediaCaptureReaderTests", CreationCollisionOption.OpenIfExists); var file = await folder.CreateFileAsync("CS_WP_N_Basic.jpg", CreationCollisionOption.ReplaceExisting); await sample.SaveToFileAsync(file, ImageCompression.Jpeg); } }); }
/// <summary> /// Attaches the specified associated object. /// </summary> /// <param name="associatedObject">The associated object.</param> public void Attach(DependencyObject associatedObject) { m_associatedObject = associatedObject; m_appliedSample = null; m_subscriptions = SeeingSharpApplication.Current.UIMessenger.SubscribeAll(this); SwapChainPanel renderElement = m_associatedObject as SwapChainPanel; if (renderElement != null) { m_painter.Attach(renderElement); } }
/// <summary> /// Detaches this instance. /// </summary> public void Detach() { SwapChainPanel renderElement = m_associatedObject as SwapChainPanel; if (renderElement != null) { m_painter.Detach(); } m_subscriptions.ForEachInEnumeration( (actSubscription) => actSubscription.Unsubscribe()); m_subscriptions = null; }
public H264FPVView() { _swapChainPannel = new SwapChainPanel { Width = 640, Height = 480, Visibility = Visibility.Collapsed }; Children.Add(_swapChainPannel); StartVideoCommand = new RelayCommand(StartVideo); StopVideoCommand = new RelayCommand(StopVideo); }
private static void SwapChainPanel_CompositionScaleChanged(SwapChainPanel sender, object args) { SwapChainPanel swapChainPanel = sender as SwapChainPanel; if (swapChainPanel == null) { return; } Debug.WriteLine($"{nameof(SwapChainPanelPainter)}.{nameof(SwapChainPanel_CompositionScaleChanged)} swapChainPanel={swapChainPanel}"); render(swapChainPanel); }
public EGLSurface CreateSurface(SwapChainPanel panel, Size?renderSurfaceSize, float?resolutionScale) { if (panel == null) { throw new ArgumentException("SwapChainPanel parameter is invalid"); } if (renderSurfaceSize != null && resolutionScale != null) { throw new ArgumentException("A size and a scale can't both be specified"); } EGLSurface surface = EGL.NO_SURFACE; int[] surfaceAttributes = { // EGL.ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL.ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above). // If you have compilation issues with it then please update your Visual Studio templates. EGL.ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL.TRUE, EGL.NONE }; // Create a PropertySet and initialize with the EGLNativeWindowType. PropertySet surfaceCreationProperties = new PropertySet(); surfaceCreationProperties.Add(ANGLEWindowsStore.EGLNativeWindowTypeProperty, panel); // If a render surface size is specified, add it to the surface creation properties if (renderSurfaceSize != null) { surfaceCreationProperties.Add(ANGLEWindowsStore.EGLRenderSurfaceSizeProperty, PropertyValue.CreateSize((Size)renderSurfaceSize)); } #if TODO // If a resolution scale is specified, add it to the surface creation properties if (resolutionScale != null) { surfaceCreationProperties.Add(ANGLEWindowsStore.EGLRenderResolutionScaleProperty, PropertyValue.CreateSingle(resolutionScale)); } #endif surface = EGL.CreateWindowSurface(mEglDisplay, mEglConfig, surfaceCreationProperties, surfaceAttributes); if (surface == EGL.NO_SURFACE) { throw new ApplicationException("Failed to create EGL surface"); } return(surface); }
public D3DAppSwapChainPanelTarget(SwapChainPanel panel) { this.panel = panel; nativePanel = ToDispose(ComObject.As<SharpDX.DXGI.ISwapChainPanelNative>(panel)); this.panel.CompositionScaleChanged += (sender, args) => { //SizeChanged(); ScaleChanged(); }; this.panel.SizeChanged += (sender, args) => { SizeChanged(); }; }
private void OnCompositionScaleChanged(SwapChainPanel sender, object args) { var info = Windows.Graphics.Display.DisplayInformation.GetForCurrentView(); var dpi = info.LogicalDpi / 96.0f; if (ContentsScale != dpi) { ContentsScale = dpi; RenderTransform = new ScaleTransform { ScaleX = 1 / ContentsScale, ScaleY = 1 / ContentsScale }; } }
public D3DAppSwapChainPanelTarget(SwapChainPanel panel) { this.panel = panel; nativePanel = ToDispose(ComObject.As <SharpDX.DXGI.ISwapChainPanelNative>(panel)); this.panel.CompositionScaleChanged += (sender, args) => { //SizeChanged(); ScaleChanged(); }; this.panel.SizeChanged += (sender, args) => { SizeChanged(); }; }
internal override void Initialize(GameContext windowContext) { if (windowContext != null) { swapChainPanel = windowContext.Control as SwapChainPanel; if (swapChainPanel == null) { throw new NotSupportedException(string.Format("Unsupported window context [{0}]. Only SwapChainPanel", windowContext.Control.GetType().FullName)); } windowHandle = new WindowHandle(AppContextType.WindowsRuntime, swapChainPanel); //clientBounds = new DrawingRectangle(0, 0, (int)swapChainPanel.ActualWidth, (int)swapChainPanel.ActualHeight); swapChainPanel.SizeChanged += swapChainPanel_SizeChanged; swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged; } }
public VideoControl() { _startVideo = new Windows.UI.Xaml.Controls.Button() { Width = 100, Height = 32, Content = "Start", IsEnabled = true }; _startVideo.Click += _startVideo_Click; _stopVideo = new Windows.UI.Xaml.Controls.Button() { Width = 100, Height = 32, Content = "Stop", IsEnabled = false }; _stopVideo.Click += _stopVideo_Click; _cameras = new ComboBox(); _cameras.Width = 200; var sp = new StackPanel() { Orientation = Orientation.Horizontal }; sp.Children.Add(_startVideo); sp.Children.Add(_stopVideo); sp.Children.Add(_cameras); sp.VerticalAlignment = VerticalAlignment.Bottom; sp.HorizontalAlignment = HorizontalAlignment.Left; Children.Add(sp); _captureElement = new CaptureElement(); _captureElement.Width = 640; _captureElement.Height = 480; _captureElement.Visibility = Visibility.Collapsed; Children.Add(_captureElement); _swapChainPannel = new SwapChainPanel(); _swapChainPannel.Width = 640; _swapChainPannel.Height = 480; _swapChainPannel.Visibility = Visibility.Collapsed; Children.Add(_swapChainPannel); }
protected internal override void Initialize(GameContext windowContext) { swapChainPanel = (windowContext as GameContextUWPXaml)?.Control; coreWindow = (windowContext as GameContextUWPCoreWindow)?.Control; if (swapChainPanel != null) { resizeTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(100) }; resizeTimer.Tick += ResizeTimerOnTick; coreWindow = CoreWindow.GetForCurrentThread(); windowHandle = new WindowHandle(AppContextType.UWPXaml, swapChainPanel, IntPtr.Zero); } else if (coreWindow != null) { coreWindow.SizeChanged += ResizeOnWindowChange; windowHandle = new WindowHandle(AppContextType.UWPCoreWindow, coreWindow, IntPtr.Zero); } else { Debug.Assert(swapChainPanel == null && coreWindow == null, "GameContext was neither UWPXaml nor UWPCoreWindow"); } applicationView = ApplicationView.GetForCurrentView(); if (applicationView != null && windowContext.RequestedWidth != 0 && windowContext.RequestedHeight != 0) { applicationView.SetPreferredMinSize(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight)); canResize = applicationView.TryResizeView(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight)); } requiredRatio = windowContext.RequestedWidth / (double)windowContext.RequestedHeight; if (swapChainPanel != null) { swapChainPanel.SizeChanged += swapChainPanel_SizeChanged; swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged; } coreWindow.SizeChanged += CurrentWindowOnSizeChanged; visible = coreWindow.Visible; coreWindow.VisibilityChanged += CurrentWindowOnVisibilityChanged; coreWindow.Activated += CurrentWindowOnActivated; }
private static void SwapChainPanel_Unloaded(object sender, RoutedEventArgs e) { SwapChainPanel swapChainPanel = sender as SwapChainPanel; if (swapChainPanel == null) { return; } Debug.WriteLine($"{nameof(SwapChainPanelPainter)}.{nameof(SwapChainPanel_Unloaded)} swapChainPanel={swapChainPanel}"); swapChainPanel.Loaded -= SwapChainPanel_Loaded; swapChainPanel.Unloaded -= SwapChainPanel_Unloaded; swapChainPanel.SizeChanged -= SwapChainPanel_SizeChanged; swapChainPanel.CompositionScaleChanged -= SwapChainPanel_CompositionScaleChanged; RenderData.Dispose(swapChainPanel); }
/// <summary> /// Binds the object to a SwapChainPanel and initializes Direct3D11 resources. /// </summary> /// <param name="panel">SwapChainPanel control used for drawing.</param> public void BindToControl(SwapChainPanel panel) { this.ThrowIfDisposed(); this.ThrowIfBound(); this.panel = panel; this.nativePanel = ComObject.As<ISwapChainPanelNative>(this.panel); this.UpdateBackBufferSize(); this.CreateDeviceDependentResources(); this.CreateSizeDependentResources(); CompositionTarget.Rendering += CompositionTarget_Rendering; this.panel.SizeChanged += HostControl_SizeChanged; DisplayInformation.GetForCurrentView().DpiChanged += DisplayInformation_DpiChanged; this.IsBound = true; }
public void SetSurface( SwapChainPanel swapChainPanel, int rbWidth, int rbHeight, GlesBackingOption backingOption = GlesBackingOption.Detroyed, GlesMultisampling multisampling = GlesMultisampling.None, GlesRenderTarget renderTarget = GlesRenderTarget.Renderbuffer) { if (eglSurface != Egl.EGL_NO_SURFACE) { DestroySurface(eglSurface); eglSurface = Egl.EGL_NO_SURFACE; } if (swapChainPanel != null) { CreateSurface(swapChainPanel, rbWidth, rbHeight, backingOption, multisampling, renderTarget); } }
internal void Initialize(Control keyboardControl, SwapChainPanel swapPanel) { // Validate if (keyboardControl == null) { throw new ArgumentNullException(nameof(keyboardControl)); } if (swapPanel == null) { throw new ArgumentNullException(nameof(swapPanel)); } // If already initialized, just ignore if (initStarted) { throw new InvalidOperationException("Unity has already been initialized by another control. Be sure to set cache mode to required on the page that uses UnityView."); } initStarted = true; // Get callbacks singleton appCallbacks = AppCallbacks.Instance; // Setup scripting bridge bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(bridge); // Subscribe to events in order to forward appCallbacks.Initialized += AppCallbacks_Initialized; appCallbacks.RenderingStarted += AppCallbacks_RenderingStarted; // Not sure if we should always do this, never do this or make it an option appCallbacks.SetKeyboardTriggerControl(keyboardControl); // Wire up to swap panel appCallbacks.SetSwapChainPanel(swapPanel); // Leaving this for now since it handles visibility, closing etc. // Hoping it doesn't impact rendering by listening to size changed. appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); // Initialize D3D appCallbacks.InitializeD3DXAML(); }
public void CreateSurface(SwapChainPanel panel, Size?renderSurfaceSize, float?resolutionScale) { if (panel == null) { throw new ArgumentNullException("SwapChainPanel parameter is invalid"); } EGLSurface surface = Egl.EGL_NO_SURFACE; int[] surfaceAttributes = new[] { // EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above). // If you have compilation issues with it then please update your Visual Studio templates. Egl.EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, Egl.EGL_TRUE, Egl.EGL_NONE }; // Create a PropertySet and initialize with the EGLNativeWindowType. PropertySet surfaceCreationProperties = new PropertySet(); surfaceCreationProperties.Add(Egl.EGLNativeWindowTypeProperty, panel); // If a render surface size is specified, add it to the surface creation properties if (renderSurfaceSize.HasValue) { PropertySetExtensions.AddSize(surfaceCreationProperties, Egl.EGLRenderSurfaceSizeProperty, renderSurfaceSize.Value); } // If a resolution scale is specified, add it to the surface creation properties if (resolutionScale.HasValue) { PropertySetExtensions.AddSingle(surfaceCreationProperties, Egl.EGLRenderResolutionScaleProperty, resolutionScale.Value); } surface = Egl.eglCreateWindowSurface(eglDisplay, eglConfig, surfaceCreationProperties, surfaceAttributes); if (surface == Egl.EGL_NO_SURFACE) { throw new Exception("Failed to create EGL surface"); } eglSurface = surface; }
private async Task Init(SwapChainPanel swapChainPanel) { LoggingChannel = Logger.AddLoggingChannel(Name); var instance = new Instance(new List <string> { "-I", "dummy", "--no-osd", "--verbose=3", "--no-stats", "--avcodec-fast", "--subsdec-encoding", "", "--aout=winstore", $"--keystore-file={Path.Combine(ApplicationData.Current.LocalFolder.Path, KeyStoreFilename)}" }, swapChainPanel); Instance = instance; instance.setDialogHandlers(OnError, OnShowLoginDialog, OnShowDialog, (dialog, title, text, intermediate, position, cancel) => { }, OnCancelCurrentDialog, (dialog, position, text) => { }); instance.logSet((param0, param1) => { var logLevel = (LogLevel)param0; Debug.WriteLine($"[VLC {logLevel}] {param1}"); LoggingChannel.LogMessage(param1, logLevel.ToLoggingLevel()); }); await UpdateScale(); UpdateDeinterlaceMode(); AudioDeviceId = MediaDevice.GetDefaultAudioRenderId(AudioDeviceRole.Default); MediaDevice.DefaultAudioRenderDeviceChanged += (sender, e) => { if (e.Role == AudioDeviceRole.Default) { AudioDeviceId = e.Id; } }; OnSourceChanged(); }
public void Initialize(CoreWindow coreWindow, UIElement inputElement, TouchQueue touchQueue) { _coreWindow = coreWindow; _windowEvents = new InputEvents(_coreWindow, inputElement, touchQueue); _dinfo = DisplayInformation.GetForCurrentView(); _appView = ApplicationView.GetForCurrentView(); // Set a min size that is reasonable knowing someone might try // to use some old school resolution like 640x480. var minSize = new Windows.Foundation.Size(640 / _dinfo.RawPixelsPerViewPixel, 480 / _dinfo.RawPixelsPerViewPixel); _appView.SetPreferredMinSize(minSize); _orientation = ToOrientation(_dinfo.CurrentOrientation); _dinfo.OrientationChanged += DisplayProperties_OrientationChanged; _swapChainPanel = inputElement as SwapChainPanel; _swapChainPanel.SizeChanged += SwapChain_SizeChanged; _coreWindow.Closed += Window_Closed; _coreWindow.Activated += Window_FocusChanged; _coreWindow.CharacterReceived += Window_CharacterReceived; SetViewBounds(_appView.VisibleBounds.Width, _appView.VisibleBounds.Height); SetCursor(false); }
/// <summary> /// Disposes this object's resources. /// </summary> /// <param name="disposing">true if releasing managed resources.</param> protected override void Dispose(bool disposing) { if (disposing) { Utilities.Dispose(ref this.swapChain); DisplayInformation.GetForCurrentView().DpiChanged -= DisplayInformation_DpiChanged; CompositionTarget.Rendering -= CompositionTarget_Rendering; if (this.nativeBackgroundPanel != null) { Utilities.Dispose(ref this.nativeBackgroundPanel); this.backgroundPanel.SizeChanged -= HostControl_SizeChanged; } if (this.nativePanel != null) { Utilities.Dispose(ref this.nativePanel); this.panel.SizeChanged -= HostControl_SizeChanged; } this.backgroundPanel = null; this.panel = null; } base.Dispose(disposing); }
internal override void Initialize(GameContext windowContext) { if (windowContext != null) { swapChainPanel = windowContext.Control as SwapChainPanel; if (swapChainPanel == null) { throw new NotSupportedException(string.Format("Unsupported window context [{0}]. Only SwapChainPanel", windowContext.Control.GetType().FullName)); } windowHandle = new WindowHandle(AppContextType.WindowsRuntime, swapChainPanel); #if SILICONSTUDIO_PLATFORM_WINDOWS_10 var appView = ApplicationView.GetForCurrentView(); if (appView != null && windowContext.RequestedWidth != 0 && windowContext.RequestedHeight != 0) appView.TryResizeView(new Size(windowContext.RequestedWidth, windowContext.RequestedHeight)); #endif //clientBounds = new DrawingRectangle(0, 0, (int)swapChainPanel.ActualWidth, (int)swapChainPanel.ActualHeight); swapChainPanel.SizeChanged += swapChainPanel_SizeChanged; swapChainPanel.CompositionScaleChanged += swapChainPanel_CompositionScaleChanged; } }
private async void OnTargetSwapChainPanelLoaded(FrameworkElement frameworkElement) { m_targetSwapChainPanel = (SwapChainPanel)frameworkElement; if (m_targetSwapChainPanel.ActualHeight == 0 || m_targetSwapChainPanel.ActualWidth == 0) { m_targetSwapChainPanel.Width = 800; m_targetSwapChainPanel.Height = 800; } m_renderer = new SwapChainPanelRenderer(CurrentSelectedEffect.Effect, m_targetSwapChainPanel); await LoadDefaultImageAsync(); m_targetSwapChainPanel.SizeChanged += async (sender, args) => { if (m_targetSwapChainPanel.ActualHeight > 0 && m_targetSwapChainPanel.ActualWidth > 0) { SourceImageObservedWidth = m_targetSwapChainPanel.ActualWidth; SourceImageObservedHeight = m_targetSwapChainPanel.ActualHeight; await RenderAsync(); } }; }
private void SwapChainPanelCompositionScaleChanged(SwapChainPanel sender, object args) { OnClientSizeChanged(sender, EventArgs.Empty); }
public SwapChainPanelEvents(SwapChainPanel This) : base(This) { this.This = This; }
/// <summary> /// Apply filter to image /// </summary> /// <param name="fileStream"></param> private async Task ApplyEffectAsync(IRandomAccessStream fileStream, IImageProvider provider, SwapChainPanel target) { using (var _renderer = new SwapChainPanelRenderer(provider, target)) { try { // Rewind the stream to start. fileStream.Seek(0); // Set the imageSource on the effect and render. ((IImageConsumer)provider).Source = new RandomAccessStreamImageSource(fileStream); await _renderer.RenderAsync(); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); } } }
private void OnTargetSwapChainPanelLoaded(FrameworkElement frameworkElement) { m_targetSwapChainPanel = (SwapChainPanel)frameworkElement; if (m_targetSwapChainPanel.ActualHeight == 0 || m_targetSwapChainPanel.ActualWidth == 0) { m_targetSwapChainPanel.Width = SourceImageObservedWidth; m_targetSwapChainPanel.Height = SourceImageObservedHeight; } m_targetSwapChainPanel.SizeChanged += async (sender, args) => { if (m_targetSwapChainPanel.ActualHeight > 0 && m_targetSwapChainPanel.ActualWidth > 0) { SourceImageObservedWidth = m_targetSwapChainPanel.ActualWidth; SourceImageObservedHeight = m_targetSwapChainPanel.ActualHeight; if (SelectedEffect != null) { await m_renderer.RenderAsync(SelectedEffect); } } }; }
public GameRenderer(SwapChainPanel panel) : base(panel) { this.FullScreen = true; }