Browse Source

GL!

pull/1977/head
Nikita Tsukanov 7 years ago
parent
commit
abd78e7680
  1. 7
      src/Avalonia.Native.OSX/gl.mm
  2. 2
      src/Avalonia.Native.OSX/window.mm
  3. 1
      src/Avalonia.Native/AvaloniaNativePlatform.cs
  4. 2
      src/Avalonia.Native/WindowImplBase.cs

7
src/Avalonia.Native.OSX/gl.mm

@ -103,6 +103,7 @@ class GlFeature : public virtual ComSingleObject<IAvnGlFeature, &IID_IAvnGlFeatu
{
IAvnGlDisplay* _display;
AvnGlContext *_immediate;
NSOpenGLContext* _shared;
public:
FORWARD_IUNKNOWN()
NSOpenGLPixelFormat* _format;
@ -111,11 +112,13 @@ public:
_display = display;
_immediate = immediate;
_format = format;
_shared = [[NSOpenGLContext alloc] initWithFormat:_format shareContext:_immediate->GlContext];
}
NSOpenGLContext* CreateContext()
{
return [[NSOpenGLContext alloc] initWithFormat:_format shareContext:nil];
return _shared;
//return [[NSOpenGLContext alloc] initWithFormat:_format shareContext:nil];
}
virtual HRESULT ObtainDisplay(IAvnGlDisplay**retOut)
@ -208,6 +211,7 @@ public:
glFlush();
[_context flushBuffer];
[_context setView:nil];
CGLUnlockContext([_context CGLContextObj]);
[_view unlockFocus];
}
};
@ -235,6 +239,7 @@ public:
return E_ABORT;
auto gl = _context;
CGLLockContext([_context CGLContextObj]);
[gl setView: _view];
[gl makeCurrentContext];
auto frame = [_view frame];

2
src/Avalonia.Native.OSX/window.mm

@ -782,7 +782,7 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
}
auto swOp = &_parent->CurrentSwDrawingOperation;
_parent->BaseEvents->Paint();
_parent->BaseEvents->Paint();
if(swOp->Data != NULL)
[self drawFb: &swOp->Desc];

1
src/Avalonia.Native/AvaloniaNativePlatform.cs

@ -76,6 +76,7 @@ namespace Avalonia.Native
.Bind<IRenderLoop>().ToConstant(new RenderLoop())
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
.Bind<ISystemDialogImpl>().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs()))
.Bind<IWindowingPlatformGlFeature>().ToConstant(new GlPlatformFeature(_factory.ObtainGlFeature()))
.Bind<AvaloniaNativeOptions>().ToConstant(opts);
}

2
src/Avalonia.Native/WindowImplBase.cs

@ -188,7 +188,7 @@ namespace Avalonia.Native
void IAvnWindowBaseEvents.RunRenderPriorityJobs()
{
if (_parent._deferredRendering && !_parent._gpu
if (_parent._deferredRendering
&& _parent._lastRenderedLogicalSize != _parent.ClientSize)
// Hack to trigger Paint event on the renderer
_parent.Paint?.Invoke(new Rect());

Loading…
Cancel
Save