forked from amkovkov/GranuSightSoftware2
fix: typos
TOO many typos
This commit is contained in:
@@ -187,7 +187,7 @@
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Изображениямя -->
|
||||
<!-- Изображения -->
|
||||
<Grid ColumnSpacing="5" RowSpacing="5">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
@@ -435,7 +435,7 @@
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Command="{Binding CencelImageCapturingCommand}"
|
||||
Command="{Binding CancelImageCapturingCommand}"
|
||||
Content="Отменить съёмку"
|
||||
IsVisible="{Binding CaptureImagesTask, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
|
||||
@@ -443,7 +443,7 @@
|
||||
|
||||
</core:SectionPanel>
|
||||
|
||||
<!-- Общие конпки гланой панели -->
|
||||
<!-- Общие кнопки главной панели -->
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
|
||||
@@ -14,7 +14,7 @@ using Avalonia.Input;
|
||||
|
||||
using GSS2.UI.Core.ViewModels;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using GSS2.Core.Extentions;
|
||||
using GSS2.Core.UI.Extensions;
|
||||
|
||||
namespace GSS2.UI.Core.Views;
|
||||
|
||||
@@ -40,9 +40,9 @@ public partial class CameraView : OpenGlControlBase
|
||||
public const int EGL_DMA_BUF_PLANE0_OFFSET_EXT = 0x3273;
|
||||
public const int EGL_DMA_BUF_PLANE0_PITCH_EXT = 0x3274;
|
||||
|
||||
public delegate IntPtr GlEGLImageTargetTexture2DOESDeligate(int target, IntPtr image);
|
||||
public delegate IntPtr EglCreateImageKHRDeligate(IntPtr dpy, IntPtr ctx, int target, IntPtr buffer, int[] attribs);
|
||||
public delegate bool EglDestroyImageKHRDeligate(IntPtr dpy, IntPtr image);
|
||||
public delegate IntPtr GlEGLImageTargetTexture2DOESDelegate(int target, IntPtr image);
|
||||
public delegate IntPtr EglCreateImageKHRDelegate(IntPtr dpy, IntPtr ctx, int target, IntPtr buffer, int[] attribs);
|
||||
public delegate bool EglDestroyImageKHRDelegate(IntPtr dpy, IntPtr image);
|
||||
|
||||
private const string VERTEX_SHADER = @"
|
||||
#version 300 es
|
||||
@@ -91,19 +91,19 @@ public partial class CameraView : OpenGlControlBase
|
||||
public int UUvLocation { get; }
|
||||
public int VAO { get; }
|
||||
public int VBO { get; }
|
||||
public EglCreateImageKHRDeligate EglCreateImageKHR { get; }
|
||||
public EglDestroyImageKHRDeligate EglDestroyImageKHR { get; }
|
||||
public GlEGLImageTargetTexture2DOESDeligate GlEGLImageTargetTexture2DOES { get; }
|
||||
public EglCreateImageKHRDelegate EglCreateImageKHR { get; }
|
||||
public EglDestroyImageKHRDelegate EglDestroyImageKHR { get; }
|
||||
public GlEGLImageTargetTexture2DOESDelegate GlEGLImageTargetTexture2DOES { get; }
|
||||
|
||||
public OpenGLContext(GlInterface gl)
|
||||
{
|
||||
var glExtensions = gl.GetString(GlConsts.GL_EXTENSIONS);
|
||||
if (glExtensions is null)
|
||||
throw new Exception("GL extentions query returned null string");
|
||||
throw new Exception("GL extensions query returned null string");
|
||||
|
||||
if (!glExtensions.Contains("GL_OES_EGL_image") &&
|
||||
!glExtensions.Contains("GL_OES_EGL_image_external"))
|
||||
throw new Exception("Required GL extentions \"GL_OES_EGL_image_external\" or \"GL_OES_EGL_image\" not found");
|
||||
throw new Exception("Required GL extensions \"GL_OES_EGL_image_external\" or \"GL_OES_EGL_image\" not found");
|
||||
|
||||
EglDisplay = eglGetCurrentDisplay();
|
||||
if (EglDisplay == IntPtr.Zero)
|
||||
@@ -111,25 +111,25 @@ public partial class CameraView : OpenGlControlBase
|
||||
|
||||
var eglExtensions = Marshal.PtrToStringAnsi(eglQueryString(EglDisplay, EglConsts.EGL_EXTENSIONS));
|
||||
if (eglExtensions is null)
|
||||
throw new Exception("EGL extentions query returned null");
|
||||
throw new Exception("EGL extensions query returned null");
|
||||
|
||||
if (!eglExtensions.Contains("EGL_EXT_image_dma_buf_import"))
|
||||
throw new Exception("Required EGL extention \"EGL_EXT_image_dma_buf_import\" not found");
|
||||
throw new Exception("Required EGL extension \"EGL_EXT_image_dma_buf_import\" not found");
|
||||
|
||||
var pEglCreateImageKHR = eglGetProcAddress("eglCreateImageKHR");
|
||||
if (pEglCreateImageKHR == IntPtr.Zero)
|
||||
throw new Exception("Required EGL method \"eglCreateImageKHR\" not found");
|
||||
EglCreateImageKHR = Marshal.GetDelegateForFunctionPointer<EglCreateImageKHRDeligate>(pEglCreateImageKHR);
|
||||
EglCreateImageKHR = Marshal.GetDelegateForFunctionPointer<EglCreateImageKHRDelegate>(pEglCreateImageKHR);
|
||||
|
||||
var pEglDestroyImageKHR = eglGetProcAddress("eglDestroyImageKHR");
|
||||
if (pEglDestroyImageKHR == IntPtr.Zero)
|
||||
throw new Exception("Required EGL method \"eglDestroyImageKHR\" not found");
|
||||
EglDestroyImageKHR = Marshal.GetDelegateForFunctionPointer<EglDestroyImageKHRDeligate>(pEglDestroyImageKHR);
|
||||
EglDestroyImageKHR = Marshal.GetDelegateForFunctionPointer<EglDestroyImageKHRDelegate>(pEglDestroyImageKHR);
|
||||
|
||||
var pGlEGLImageTargetTexture2DOES = eglGetProcAddress("glEGLImageTargetTexture2DOES");
|
||||
if (pGlEGLImageTargetTexture2DOES == IntPtr.Zero)
|
||||
throw new Exception("Required EGL method \"glEGLImageTargetTexture2DOES\" not found");
|
||||
GlEGLImageTargetTexture2DOES = Marshal.GetDelegateForFunctionPointer<GlEGLImageTargetTexture2DOESDeligate>(pGlEGLImageTargetTexture2DOES);
|
||||
GlEGLImageTargetTexture2DOES = Marshal.GetDelegateForFunctionPointer<GlEGLImageTargetTexture2DOESDelegate>(pGlEGLImageTargetTexture2DOES);
|
||||
|
||||
Texture = gl.GenTexture(); ThrowIfOpenGLError(gl);
|
||||
gl.BindTexture(GlConsts.GL_TEXTURE_2D, Texture); ThrowIfOpenGLError(gl);
|
||||
@@ -189,7 +189,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
}
|
||||
|
||||
private readonly ILogger<CameraView> _logger;
|
||||
private readonly Dictionary<int, IntPtr> _importedDmaBufers = new Dictionary<int, nint>();
|
||||
private readonly Dictionary<int, IntPtr> _importedDmaBuffers = new Dictionary<int, nint>();
|
||||
private bool _isViewFinderStarted = false;
|
||||
private OpenGLContext? _openGLContext = null;
|
||||
private Point? _lastMousePosition = null;
|
||||
@@ -238,7 +238,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
try
|
||||
{
|
||||
viewModel.StartViewFinder();
|
||||
viewModel.RenderReqested += RenderReqested;
|
||||
viewModel.RenderRequested += RenderRequested;
|
||||
_isViewFinderStarted = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -257,7 +257,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
try
|
||||
{
|
||||
viewModel.StopViewFinder();
|
||||
foreach (var (fd, image) in _importedDmaBufers)
|
||||
foreach (var (fd, image) in _importedDmaBuffers)
|
||||
_openGLContext?.EglDestroyImageKHR!(_openGLContext.EglDisplay, image);
|
||||
_isViewFinderStarted = false;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
{
|
||||
_logger.LogCritical(ex, "Exception while view finder stop");
|
||||
}
|
||||
viewModel.RenderReqested -= RenderReqested;
|
||||
viewModel.RenderRequested -= RenderRequested;
|
||||
}
|
||||
else if (_isViewFinderStarted)
|
||||
_logger.LogCritical("Cannot stop view finder, data context is null or not camera view model");
|
||||
@@ -282,7 +282,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
|
||||
// Рассчитываем позицию в координатах изображения (до масштабирования)
|
||||
var imageX = (position.X - Bounds.Width / 2 - _panX) / _zoom;
|
||||
var imageY = (-position.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертированна
|
||||
var imageY = (-position.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертирована
|
||||
|
||||
// Применяем масштаб
|
||||
float zoomFactor = ea.Delta.Y > 0 ? 1.1f : 1 / 1.1f;
|
||||
@@ -294,7 +294,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
{
|
||||
// Пересчитываем смещение так, чтобы указатель остался на месте
|
||||
_panX = (float)(position.X - Bounds.Width / 2 - imageX * _zoom);
|
||||
_panY = (float)(-position.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертированна
|
||||
_panY = (float)(-position.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертирована
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -358,7 +358,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
}
|
||||
var position = ea.GetPosition(this);
|
||||
_panX -= (float)(_lastMousePosition.Value.X - position.X);
|
||||
_panY += (float)(_lastMousePosition.Value.Y - position.Y); // Ось Y инвертированна
|
||||
_panY += (float)(_lastMousePosition.Value.Y - position.Y); // Ось Y инвертирована
|
||||
_lastMousePosition = position;
|
||||
}
|
||||
else if (ea.Pointer.Type == PointerType.Touch)
|
||||
@@ -376,11 +376,11 @@ public partial class CameraView : OpenGlControlBase
|
||||
return;
|
||||
}
|
||||
|
||||
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то токлько перемещение
|
||||
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то только перемещение
|
||||
{
|
||||
var position = ea.GetPosition(this);
|
||||
_panX -= (float)(_lastTouchPositions[ea.Pointer.Id].X - position.X);
|
||||
_panY += (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертированна
|
||||
_panY += (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертирована
|
||||
_lastTouchPositions[ea.Pointer.Id] = position;
|
||||
}
|
||||
else if (_lastTouchPositions.Count() == 2) // Если два прикосновения, то перемещение с приближением
|
||||
@@ -402,14 +402,14 @@ public partial class CameraView : OpenGlControlBase
|
||||
newZoom = (float)Math.Clamp(newZoom, 1f, 10f);
|
||||
|
||||
var imageX = (newCenter.X - Bounds.Width / 2 - _panX) / _zoom;
|
||||
var imageY = (-newCenter.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертированна
|
||||
var imageY = (-newCenter.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертирована
|
||||
|
||||
_zoom = newZoom;
|
||||
|
||||
if (_zoom > 1f)
|
||||
{
|
||||
_panX = (float)(newCenter.X - Bounds.Width / 2 - imageX * _zoom);
|
||||
_panY = (float)(-newCenter.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертированна
|
||||
_panY = (float)(-newCenter.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертирована
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -427,7 +427,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
context.FillRectangle(new SolidColorBrush(Background), new Rect(0, 0, Bounds.Width, Bounds.Height));
|
||||
base.Render(context);
|
||||
}
|
||||
private void RenderReqested(object? sender, EventArgs ea) => Dispatcher.UIThread.Invoke(() => RequestNextFrameRendering());
|
||||
private void RenderRequested(object? sender, EventArgs ea) => Dispatcher.UIThread.Invoke(() => RequestNextFrameRendering());
|
||||
|
||||
protected override void OnOpenGlInit(GlInterface gl)
|
||||
{
|
||||
@@ -463,36 +463,36 @@ public partial class CameraView : OpenGlControlBase
|
||||
return;
|
||||
var (frameBuffer, streamConfiguration) = frame.Value;
|
||||
|
||||
// 0. Проверяем что полученый фрейм ожидаемый праильный формат
|
||||
// 0. Проверяем что полученный фрейм ожидаемый правильный формат
|
||||
var width = streamConfiguration.Size.Width;
|
||||
if (width <= 0)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected frame width >= 0, got {}", streamConfiguration.Size.Width);
|
||||
_logger.LogError("Cannot render frame, stream configuration validation error, expected frame width >= 0, got {}", streamConfiguration.Size.Width);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
var height = streamConfiguration.Size.Height;
|
||||
if (height <= 0)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected frame height >= 0, got {}", streamConfiguration.Size.Height);
|
||||
_logger.LogError("Cannot render frame, stream configuration validation error, expected frame height >= 0, got {}", streamConfiguration.Size.Height);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
if (streamConfiguration.PixelFormat.Fourcc != OpenGLContext.DRM_FORMAT_BGRX8888)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected forcc: 0x{:X}, got 0x{:X}", OpenGLContext.DRM_FORMAT_BGRX8888, streamConfiguration.PixelFormat.Fourcc);
|
||||
_logger.LogError("Cannot render frame, stream configuration validation error, expected fourcc: 0x{:X}, got 0x{:X}", OpenGLContext.DRM_FORMAT_BGRX8888, streamConfiguration.PixelFormat.Fourcc);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
if (streamConfiguration.PixelFormat.Modifier != 0)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected DRM modifier: 0x{:X}, got 0x{:X}", 0, streamConfiguration.PixelFormat.Modifier);
|
||||
_logger.LogError("Cannot render frame, stream configuration validation error, expected DRM modifier: 0x{:X}, got 0x{:X}", 0, streamConfiguration.PixelFormat.Modifier);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
if (frameBuffer.Planes.Count() != 1)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, planes vaildation error, expected planes count: 0, got {}", frameBuffer.Planes.Count());
|
||||
_logger.LogError("Cannot render frame, planes validation error, expected planes count: 0, got {}", frameBuffer.Planes.Count());
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
var fd = plane.Fd.Get();
|
||||
if (fd <= 0)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, FD vaildation error, FD >= 0, got 0x{:X}", fd);
|
||||
_logger.LogError("Cannot render frame, FD validation error, FD >= 0, got 0x{:X}", fd);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
@@ -521,10 +521,10 @@ public partial class CameraView : OpenGlControlBase
|
||||
|
||||
// 2. Создаём EGL изображение из dma-buf
|
||||
IntPtr image;
|
||||
if (_importedDmaBufers.ContainsKey(fd))
|
||||
if (_importedDmaBuffers.ContainsKey(fd))
|
||||
{
|
||||
// 2.1. Если EGL изображение для fd уже создано, то берём его из словаря
|
||||
image = _importedDmaBufers[fd];
|
||||
image = _importedDmaBuffers[fd];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -540,7 +540,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
EglConsts.EGL_NONE
|
||||
};
|
||||
image = _openGLContext.EglCreateImageKHR.Invoke(_openGLContext.EglDisplay, IntPtr.Zero, OpenGLContext.EGL_LINUX_DMA_BUF_EXT, IntPtr.Zero, attribs);
|
||||
_importedDmaBufers.Add(fd, image);
|
||||
_importedDmaBuffers.Add(fd, image);
|
||||
}
|
||||
|
||||
// 3. Биндим текстуры текстуры
|
||||
@@ -550,7 +550,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
// 4. Привязываем EGL изображение к текстуре
|
||||
_openGLContext.GlEGLImageTargetTexture2DOES!(GlConsts.GL_TEXTURE_2D, image);
|
||||
|
||||
// 5. Вычисляем матрицы транформаций
|
||||
// 5. Вычисляем матрицы трансформаций
|
||||
var mvp = ComputeMvp(stretchMode, width, height);
|
||||
var zoom = Matrix4x4.CreateScale(_zoom, _zoom, 1f);
|
||||
var translate = Matrix4x4.CreateTranslation((float)(_panX / Bounds.Width * 2), (float)(_panY / Bounds.Height * 2), 0);
|
||||
@@ -597,7 +597,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Exception whiel OpenGL render");
|
||||
_logger.LogError(ex, "Exception while OpenGL render");
|
||||
}
|
||||
}
|
||||
private Matrix4x4 ComputeMvp(Stretch stretch, float imageWidth, float imageHeight)
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
Orientation="Horizontal"
|
||||
Spacing="20">
|
||||
|
||||
<Slider Classes="horizontal" Value="{Binding WhiteIntencity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding Uv365Intencity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding Uv254Intencity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding WhiteIntensity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding Uv365Intensity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding Uv254Intensity}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
@@ -71,9 +71,9 @@
|
||||
Orientation="Vertical"
|
||||
Spacing="20">
|
||||
|
||||
<Slider Classes="vertical" Value="{Binding WhiteIntencity}" />
|
||||
<Slider Classes="vertical" Value="{Binding Uv365Intencity}" />
|
||||
<Slider Classes="vertical" Value="{Binding Uv254Intencity}" />
|
||||
<Slider Classes="vertical" Value="{Binding WhiteIntensity}" />
|
||||
<Slider Classes="vertical" Value="{Binding Uv365Intensity}" />
|
||||
<Slider Classes="vertical" Value="{Binding Uv254Intensity}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user