-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
121 additions
and
70 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
|
||
using Android.OS; | ||
using Android.Views; | ||
|
||
using Avalonia.Rendering; | ||
|
||
using Java.Lang; | ||
|
||
namespace Avalonia.Android | ||
{ | ||
internal sealed class ChoreographerTimer : Java.Lang.Object, IRenderTimer, Choreographer.IFrameCallback | ||
{ | ||
private readonly object _lock = new object(); | ||
|
||
private readonly Thread _thread; | ||
|
||
private Choreographer _choreographer; | ||
private bool _running; | ||
|
||
public ChoreographerTimer() | ||
{ | ||
_thread = new Thread(Loop); | ||
_thread.Start(); | ||
} | ||
|
||
public event Action<TimeSpan> Tick; | ||
|
||
internal void OnResume() | ||
{ | ||
lock (_lock) | ||
{ | ||
_running = true; | ||
_choreographer.PostFrameCallback(this); | ||
} | ||
} | ||
|
||
internal void OnPause() | ||
{ | ||
lock (_lock) | ||
{ | ||
_running = false; | ||
} | ||
} | ||
|
||
private void Loop() | ||
{ | ||
Looper.Prepare(); | ||
_choreographer = Choreographer.Instance; | ||
Looper.Loop(); | ||
} | ||
|
||
public void DoFrame(long frameTimeNanos) | ||
{ | ||
Tick?.Invoke(TimeSpan.FromTicks(frameTimeNanos / 100)); | ||
|
||
lock (_lock) | ||
{ | ||
if (_running) | ||
{ | ||
Choreographer.Instance.PostFrameCallback(this); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
using Avalonia.OpenGL.Egl; | ||
using System; | ||
|
||
using Avalonia.OpenGL.Egl; | ||
using Avalonia.OpenGL.Surfaces; | ||
|
||
namespace Avalonia.Android.OpenGL | ||
{ | ||
internal sealed class GlRenderTarget : EglPlatformSurfaceRenderTargetBase | ||
internal sealed class GlRenderTarget : EglPlatformSurfaceRenderTargetBase, IGlPlatformSurfaceRenderTargetWithCorruptionInfo | ||
{ | ||
private readonly EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo _info; | ||
private readonly EglSurface _surface; | ||
private readonly IntPtr _handle; | ||
|
||
public GlRenderTarget( | ||
EglPlatformOpenGlInterface egl, | ||
EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo info, | ||
EglSurface surface) | ||
EglSurface surface, | ||
IntPtr handle) | ||
: base(egl) | ||
{ | ||
_info = info; | ||
_surface = surface; | ||
_handle = handle; | ||
} | ||
|
||
public bool IsCorrupted => _handle != _info.Handle; | ||
|
||
public override IGlPlatformSurfaceRenderingSession BeginDraw() => BeginDraw(_surface, _info); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters