Browse Source

texture offsets

tmp-winuicomp_with_manual_fbo
Dan Walmsley 6 years ago
parent
commit
bcf502e1ca
  1. 8
      samples/ControlCatalog.NetCore/Properties/launchSettings.json
  2. 8
      src/Avalonia.OpenGL/Angle/AngleEglInterface.cs
  3. 4
      src/Avalonia.OpenGL/Angle/AngleWin32EglDisplay.cs
  4. 4
      src/Avalonia.OpenGL/EglConsts.cs
  5. 2
      src/Windows/Avalonia.Win32/Composition/CompositionHost.cs

8
samples/ControlCatalog.NetCore/Properties/launchSettings.json

@ -0,0 +1,8 @@
{
"profiles": {
"ControlCatalog.NetCore": {
"commandName": "Project",
"nativeDebugging": true
}
}
}

8
src/Avalonia.OpenGL/Angle/AngleEglInterface.cs

@ -7,8 +7,8 @@ namespace Avalonia.OpenGL.Angle
{
public class AngleEglInterface : EglInterface
{
[DllImport("libegl.dll", CharSet = CharSet.Ansi)]
static extern IntPtr eglGetProcAddress(string proc);
[DllImport("libglesv2.dll", CharSet = CharSet.Ansi)]
static extern IntPtr EGL_GetProcAddress(string proc);
public AngleEglInterface() : base(LoadAngle())
{
@ -20,10 +20,10 @@ namespace Avalonia.OpenGL.Angle
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
throw new PlatformNotSupportedException();
{
var disp = eglGetProcAddress("eglGetPlatformDisplayEXT");
var disp = EGL_GetProcAddress("eglGetPlatformDisplayEXT");
if (disp == IntPtr.Zero)
throw new OpenGlException("libegl.dll doesn't have eglGetPlatformDisplayEXT entry point");
return eglGetProcAddress;
return EGL_GetProcAddress;
}
}

4
src/Avalonia.OpenGL/Angle/AngleWin32EglDisplay.cs

@ -78,11 +78,11 @@ namespace Avalonia.OpenGL.Angle
return d3dDeviceHandle;
}
public EglSurface WrapDirect3D11Texture(IntPtr handle)
public EglSurface WrapDirect3D11Texture(IntPtr handle, int offsetX, int offsetY)
{
if (PlatformApi != AngleOptions.PlatformApi.DirectX11)
throw new InvalidOperationException("Current platform API is " + PlatformApi);
return CreatePBufferFromClientBuffer(EGL_D3D_TEXTURE_ANGLE, handle, new[] { EGL_NONE, EGL_NONE });
return CreatePBufferFromClientBuffer(EGL_D3D_TEXTURE_ANGLE, handle, new[] { EGL_TEXTURE_OFFSET_X_ANGLE, offsetX, EGL_TEXTURE_OFFSET_Y_ANGLE, offsetY, EGL_NONE, EGL_NONE });
}
}
}

4
src/Avalonia.OpenGL/EglConsts.cs

@ -205,5 +205,9 @@ namespace Avalonia.OpenGL
public const int EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE = 0x3200;
public const int EGL_D3D_TEXTURE_ANGLE = 0x33A3;
public const int EGL_TEXTURE_OFFSET_X_ANGLE = 0x3490;
public const int EGL_TEXTURE_OFFSET_Y_ANGLE = 0x3491;
}
}

2
src/Windows/Avalonia.Win32/Composition/CompositionHost.cs

@ -94,7 +94,7 @@ namespace Avalonia.Win32
ref iid,
out IntPtr texture, ref offset);
var surface = (_display as AngleWin32EglDisplay).WrapDirect3D11Texture(texture);
var surface = (_display as AngleWin32EglDisplay).WrapDirect3D11Texture(texture, offset.X, offset.Y);
return base.BeginDraw(surface, _info, () => { _surfaceInterop.EndDraw(); Marshal.Release(texture); surface.Dispose(); }, true);
}

Loading…
Cancel
Save