private int RenderLayers(GUILayers layers, Int16 width, Int16 height, Int16 arWidth, Int16 arHeight) { UiVisible = false; //lock (GUIGraphicsContext.RenderMadVrLock) { try { if (_reEntrant) { return -1; } if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.LOST) { //Log.Error("1"); return -1; } if (_stopPainting) { //Log.Error("2"); return -1; } if (GUIGraphicsContext.IsSwitchingToNewSkin) { //Log.Error("3"); return -1; } if (GUIWindowManager.IsSwitchingToNewWindow && !_vmr9Util.InMenu) { //Log.Error("4"); return -1; // (0) -> S_OK, (1) -> S_FALSE; //dont present video during window transitions } if (VMR9Util.g_vmr9 != null) { VMR9Util.g_vmr9.StartMadVrPaused(); } _reEntrant = true; GUIGraphicsContext.InVmr9Render = true; if (VMR9Util.g_vmr9 != null) VMR9Util.g_vmr9.PlaneSceneMadvrTimer = DateTime.Now; if (width > 0 && height > 0) { _vmr9Util.VideoWidth = width; _vmr9Util.VideoHeight = height; _vmr9Util.VideoAspectRatioX = arWidth; _vmr9Util.VideoAspectRatioY = arHeight; _arVideoWidth = arWidth; _arVideoHeight = arHeight; //Log.Debug("PlaneScene width {0}, height {1}", width, height); Size nativeSize = new Size(width, height); _shouldRenderTexture = SetVideoWindow(nativeSize); } Device device = GUIGraphicsContext.DX9Device; device.Clear(ClearFlags.Target, Color.FromArgb(0, 0, 0, 0), 1.0f, 0); device.BeginScene(); if (layers == GUILayers.over) { SubtitleRenderer.GetInstance().Render(); BDOSDRenderer.GetInstance().Render(); } GUIGraphicsContext.RenderGUI.RenderFrame(GUIGraphicsContext.TimePassed, layers, ref _visible); GUIFontManager.Present(); device.EndScene(); // Present() call is done on C++ side so we are able to use DirectX 9 Ex device // which allows us to skip the v-sync wait. We don't want to wait with madVR // is it only increases the UI rendering time. //return visible ? 0 : 1; // S_OK, S_FALSE } catch (Exception) { } finally { if (_visible) { UiVisible = true; } if (_disableLowLatencyMode) { _visible = false; } _reEntrant = false; if (VMR9Util.g_vmr9 != null) { VMR9Util.g_vmr9.ProcessMadVrOsd(); } } return _visible ? 0 : 1; // S_OK, S_FALSE } }
public static bool Render(float timePassed, GUILayers layers) { bool uiVisible = false; if (GUIGraphicsContext.BlankScreen) { return(false); } int videoLayer = (int)LayerType.Video; if (GUIGraphicsContext.ShowBackground == false) { if (_layers[videoLayer] != null) { if (_layers[videoLayer].ShouldRenderLayer()) { _layers[videoLayer].RenderLayer(timePassed); GUIFontManager.Present(); } } } List <int> layerCount = new List <int>(); int startLayer = 0; int endLayer = MAX_LAYERS; if (layers == GUILayers.under) { endLayer = videoLayer - 1; } else if (layers == GUILayers.over) { startLayer = videoLayer + 1; } for (int i = startLayer; i < endLayer; ++i) { if (_layers[i] != null) { if (_layers[i].ShouldRenderLayer()) { if (GUIGraphicsContext.ShowBackground == false && i == videoLayer) { continue; } _layers[i].RenderLayer(timePassed); GUIFontManager.Present(); if (videoLayer != i) { uiVisible = true; } if (!layerCount.Contains(i)) { layerCount.Add(i); } } } } // For madVR, first check along all layers to inform that UI is displaying // Check for madVR when GUI/OSD/Dialog is displayed, we should go to latency mode if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR && GUIGraphicsContext.InVmr9Render) { for (var i = 0; i < MAX_LAYERS; ++i) { if (_layers[i] == null) { continue; } GetValue(layerCount, i); } foreach (var layer in from layer in layerCount where _layers[layer] != null where _layers[layer].ShouldRenderLayer() where videoLayer != layer select layer) { uiVisible = true; } } return(uiVisible); }
public void RenderFrame(float timePassed, GUILayers layers, ref bool uiVisible) { if (!_suspended && AppActive) { try { CreateStateBlock(); uiVisible = GUILayerManager.Render(timePassed, layers); RenderStats(); } catch (Exception ex) { Log.Error(ex); Log.Error("RenderFrame exception {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace); } } }
public void RenderFrame(float timePassed, GUILayers layers) { bool uiVisible = false; RenderFrame(timePassed, layers, ref uiVisible); }
public static bool Render(float timePassed, GUILayers layers) { bool uiVisible = false; if (GUIGraphicsContext.BlankScreen) { return false; } int videoLayer = (int) LayerType.Video; if (GUIGraphicsContext.ShowBackground == false) { if (_layers[videoLayer] != null) { if (_layers[videoLayer].ShouldRenderLayer()) { _layers[videoLayer].RenderLayer(timePassed); GUIFontManager.Present(); } } } List<int> layerCount = new List<int>(); int startLayer = 0; int endLayer = MAX_LAYERS; if (layers == GUILayers.under) endLayer = videoLayer - 1; else if (layers == GUILayers.over) { _layers[(int) LayerType.VideoOverlay]?.ShouldRenderLayer(); startLayer = videoLayer + 1; } for (int i = startLayer; i < endLayer; ++i) { if (_layers[i] != null) { if (_layers[i].ShouldRenderLayer()) { if (GUIGraphicsContext.ShowBackground == false && i == videoLayer) { continue; } _layers[i].RenderLayer(timePassed); GUIFontManager.Present(); if (videoLayer != i) { uiVisible = true; } if (!layerCount.Contains(i)) layerCount.Add(i); } } } // For madVR, first check along all layers to inform that UI is displaying // Check for madVR when GUI/OSD/Dialog is displayed, we should go to latency mode if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR && GUIGraphicsContext.InVmr9Render) { for (var i = 0; i < MAX_LAYERS; ++i) { if (_layers[i] == null) continue; GetValue(layerCount, i); } foreach (var layer in from layer in layerCount where _layers[layer] != null where _layers[layer].ShouldRenderLayer() where videoLayer != layer select layer) { uiVisible = true; } } return uiVisible; }