private void ViewModeModelOnPropertyChanged(object sender, PropertyChangedEventArgs args) { switch (args.PropertyName) { case nameof(DisplayModel.ActiveView): var disable = models.GlContext.Enable(); try { currentView.Dispose(); currentView = null; switch (models.Display.ActiveView) { case DisplayModel.ViewMode.Single: currentView = new SingleTextureView(models); break; case DisplayModel.ViewMode.Polar: currentView = new PolarTextureView(models); break; case DisplayModel.ViewMode.CubeMap: currentView = new CubeTextureView(models); break; case DisplayModel.ViewMode.CubeCrossView: currentView = new CubeCrossTextureView(models); break; default: currentView = new EmptyView(); break; } models.GlContext.RedrawFrame(); } catch (Exception e) { App.ShowErrorDialog(models.App.Window, e.Message); } finally { if (disable) { models.GlContext.Disable(); } } break; case nameof(DisplayModel.ActiveLayer): case nameof(DisplayModel.ActiveMipmap): case nameof(DisplayModel.Zoom): case nameof(DisplayModel.Aperture): models.GlContext.RedrawFrame(); break; } }
void updateTexture() { int newLength = colorIndices.Count; if (newLength <= (textureRows << 8)) { // Still writing the same row updateRange(writtenColorsCount, colorIndices.Count); writtenColorsCount = colorIndices.Count; return; } // Filled a row, resize the texture int capacity = textureRows << 8; if (writtenColorsCount != capacity) { updateRange(writtenColorsCount, capacity); writtenColorsCount = capacity; } int newHeight = (newLength >> 8) + 1; ITexture newTexture; using (var dev = context.device) { var desc = textureDesc(newHeight); newTexture = dev.CreateTexture(ref desc, "Palette"); } context.context.copyTexture(newTexture, texture); texture.Dispose(); m_textureView.Dispose(); texture = newTexture; m_textureView = newTexture.GetDefaultView(TextureViewType.ShaderResource); while (newLength >= writtenColorsCount + 0x100) { int lineEnd = writtenColorsCount + 0x100; updateRange(writtenColorsCount, lineEnd); writtenColorsCount = lineEnd; } updateRange(writtenColorsCount, newLength); writtenColorsCount = newLength; foreach (var sub in textureResized) { sub(); } }
public void Dispose() { currentView?.Dispose(); viewData?.Dispose(); }
private void DisplayOnPropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(DisplayModel.ActiveView): try { currentView.Dispose(); currentView = null; switch (models.Display.ActiveView) { case DisplayModel.ViewMode.Single: if (models.Images.ImageType == typeof(Texture3D)) { currentView = new Single3DView(models, viewData); } else { currentView = new SingleTextureView(models, viewData); } break; case DisplayModel.ViewMode.Polar: currentView = new PolarTextureView(models, viewData); break; case DisplayModel.ViewMode.CubeMap: currentView = new CubeTextureView(models, viewData); break; case DisplayModel.ViewMode.CubeCrossView: currentView = new CubeCrossTextureView(models, viewData); break; case DisplayModel.ViewMode.RayCasting: currentView = new RayCastingView(models, viewData); break; case DisplayModel.ViewMode.ShearWarp: currentView = new ShearWarpView(models, viewData); break; default: currentView = new EmptyView(); break; } for (int i = 0; i < models.NumPipelines; ++i) { if (models.Pipelines[i].Image != null) { currentView.UpdateImage(i, models.Pipelines[i].Image); } } } catch (Exception err) { models.Window.ShowErrorDialog(err.Message); currentView = new EmptyView(); } break; } }
public void Dispose() { currentView?.Dispose(); }
private void DisplayOnPropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(DisplayModel.ActiveMipmap): // recompute texel position DispatchRecomputeTexelColor(); break; case nameof(DisplayModel.ExtendedViewData): if (models.Display.ExtendedViewData == null) { return; } models.Display.ExtendedViewData.ForceTexelRecompute += (o, ev) => DispatchRecomputeTexelColor(); break; case nameof(DisplayModel.ActiveView): try { currentView.Dispose(); currentView = null; switch (models.Display.ActiveView) { case DisplayModel.ViewMode.Single: if (models.Images.ImageType == typeof(Texture3D)) { currentView = new Single3DView(models); } else { currentView = new SingleTextureView(models); } break; case DisplayModel.ViewMode.Polar: currentView = new PolarTextureView(models); break; case DisplayModel.ViewMode.CubeMap: currentView = new CubeTextureView(models); break; case DisplayModel.ViewMode.CubeCrossView: currentView = new CubeCrossTextureView(models); break; case DisplayModel.ViewMode.Volume: currentView = new VolumeView(models); break; case DisplayModel.ViewMode.ShearWarp: Debug.Assert(false); //currentView = new ShearWarpView(models); break; default: currentView = new EmptyView(); break; } for (int i = 0; i < models.NumPipelines; ++i) { if (models.Pipelines[i].Image != null) { currentView.UpdateImage(i, models.Pipelines[i].Image); } } } catch (Exception err) { models.Window.ShowErrorDialog(err); currentView = new EmptyView(); } break; } }
public void Dispose() { blenderBinding?.Dispose(); targetView?.Dispose(); texture?.Dispose(); }
public void finalize() { view?.Dispose(); texture?.Dispose(); }