diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2022-07-17 20:26:28 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2022-07-17 20:26:28 +0200 |
| commit | 9d786ab096ed36ea384e03ee5cea498790e31eec (patch) | |
| tree | adee54b5b90a35238d5794e9ffd3ebcf65798a06 /Backends/CairoBackend/src | |
| parent | 57daad000aa31c7bcfa1f76b90d40da5a21da041 (diff) | |
wip
Diffstat (limited to 'Backends/CairoBackend/src')
| -rw-r--r-- | Backends/CairoBackend/src/Context.cs | 5 | ||||
| -rw-r--r-- | Backends/CairoBackend/src/EglBackend.cs | 21 | ||||
| -rw-r--r-- | Backends/CairoBackend/src/ImageBackend.cs | 9 | ||||
| -rw-r--r-- | Backends/CairoBackend/src/ImageSurface.cs | 4 | ||||
| -rw-r--r-- | Backends/CairoBackend/src/Surface.cs | 2 |
5 files changed, 36 insertions, 5 deletions
diff --git a/Backends/CairoBackend/src/Context.cs b/Backends/CairoBackend/src/Context.cs index c15ecaa3..f9af1bf1 100644 --- a/Backends/CairoBackend/src/Context.cs +++ b/Backends/CairoBackend/src/Context.cs @@ -661,7 +661,8 @@ namespace Crow.CairoBackend public void RestoreTransformations() => NativeMethods.cairo_set_matrix (handle, ref savedMat); public void SetSource(IPattern pat) => NativeMethods.cairo_set_source (handle, (pat as Pattern).handle); - public void SetSource(ISurface surf, double x = 0, double y = 0) - => NativeMethods.cairo_set_source_surface (handle, (surf as Surface).handle, x, y); + public async void SetSource(ISurface surf, double x = 0, double y = 0) { + NativeMethods.cairo_set_source_surface (handle, surf.Handle, x, y); + } } } diff --git a/Backends/CairoBackend/src/EglBackend.cs b/Backends/CairoBackend/src/EglBackend.cs index 909c3cd9..073793e7 100644 --- a/Backends/CairoBackend/src/EglBackend.cs +++ b/Backends/CairoBackend/src/EglBackend.cs @@ -7,11 +7,13 @@ namespace Crow.CairoBackend { public class EglBackend : CairoBackendBase { EGLDevice device; + GLSurface winSurf; /// <summary> /// Create a new generic backend bound to the application surface /// </summary> /// <param name="width">backend surface width</param> /// <param name="height">backend surface height</param> + /// <param name="nativeWindoPointer"></param> public EglBackend (int width, int height, IntPtr nativeWindoPointer) : base (width, height, nativeWindoPointer) { if (nativeWindoPointer == IntPtr.Zero) { @@ -32,7 +34,9 @@ namespace Crow.CairoBackend Glfw3.SwapInterval (0); device = new EGLDevice (Glfw3.GetEGLDisplay (), Glfw3.GetEGLContext (hWin)); - surf = new GLSurface (device, Glfw3.GetEGLSurface (hWin), width, height); + //surf = new GLTextureSurface (device, width, height); + surf = new ImageSurface (Format.ARGB32, width, height); + winSurf = new GLSurface (device, Glfw3.GetEGLSurface (hWin), width, height); } /// <summary> /// Create a new offscreen backend, used in perfTests @@ -61,9 +65,20 @@ namespace Crow.CairoBackend } public override void FlushUIFrame(IContext ctx) { - base.FlushUIFrame (ctx); - (surf as GLSurface).SwapBuffers (); + base.FlushUIFrame (ctx); + surf.Flush(); + using (Context gr = new Context (winSurf)) { + gr.SetSource (surf); + gr.Paint(); + } + winSurf.SwapBuffers (); + } + public override void ResizeMainSurface(int width, int height) + { + base.ResizeMainSurface(width, height); + winSurf?.Dispose(); + winSurf = new GLSurface (device, Glfw3.GetEGLSurface (hWin), width, height); } } } diff --git a/Backends/CairoBackend/src/ImageBackend.cs b/Backends/CairoBackend/src/ImageBackend.cs index 96899dbd..a90d275a 100644 --- a/Backends/CairoBackend/src/ImageBackend.cs +++ b/Backends/CairoBackend/src/ImageBackend.cs @@ -79,6 +79,15 @@ namespace Crow.CairoBackend base.FlushUIFrame (ctx); } + public override void ResizeMainSurface(int width, int height) + { + if (surf is ImageSurface) { + surf?.Dispose(); + surf = new ImageSurface (Format.ARGB32, width, height); + } else { + base.ResizeMainSurface(width, height); + } + } } } diff --git a/Backends/CairoBackend/src/ImageSurface.cs b/Backends/CairoBackend/src/ImageSurface.cs index 2cfec61c..8870366a 100644 --- a/Backends/CairoBackend/src/ImageSurface.cs +++ b/Backends/CairoBackend/src/ImageSurface.cs @@ -96,5 +96,9 @@ namespace Crow.CairoBackend { public int Stride { get { return NativeMethods.cairo_image_surface_get_stride (handle); } } + public override void Resize(int width, int height) + { + + } } } diff --git a/Backends/CairoBackend/src/Surface.cs b/Backends/CairoBackend/src/Surface.cs index 80435b5e..1f44d3ab 100644 --- a/Backends/CairoBackend/src/Surface.cs +++ b/Backends/CairoBackend/src/Surface.cs @@ -41,6 +41,8 @@ namespace Crow.CairoBackend { public class Surface : ISurface { internal IntPtr handle = IntPtr.Zero; + public IntPtr Handle => handle; + protected Surface() { |