aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-11-24 05:00:15 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-11-24 05:00:15 +0100
commit09026f4328d0e578823062d6506ffdacac457b25 (patch)
tree5ba70e266321a9409d8ac0e6e4971c6e584b8732
parentf005d76468dc4c6a368b6f1f6eca69da25214e80 (diff)
wip
-rw-r--r--Backends/CairoBackend/src/Context.cs5
-rw-r--r--Backends/CairoBackend/src/Device.cs2
-rw-r--r--Backends/CairoBackend/src/EGLDevice.cs10
-rw-r--r--Backends/CairoBackend/src/GLSurface.cs7
-rw-r--r--Backends/CairoBackend/src/Surface.cs18
5 files changed, 27 insertions, 15 deletions
diff --git a/Backends/CairoBackend/src/Context.cs b/Backends/CairoBackend/src/Context.cs
index a28c7b0c..a4eac7a2 100644
--- a/Backends/CairoBackend/src/Context.cs
+++ b/Backends/CairoBackend/src/Context.cs
@@ -138,6 +138,11 @@ namespace Crow.CairoBackend
return NativeMethods.cairo_status (handle);
}
}
+ public string StatusString {
+ get {
+ return System.Runtime.InteropServices.Marshal.PtrToStringAuto(NativeMethods.cairo_status_to_string (Status));
+ }
+ }
public IntPtr Handle => handle;
diff --git a/Backends/CairoBackend/src/Device.cs b/Backends/CairoBackend/src/Device.cs
index 4cbb180f..c87b494b 100644
--- a/Backends/CairoBackend/src/Device.cs
+++ b/Backends/CairoBackend/src/Device.cs
@@ -112,7 +112,7 @@ namespace Crow.CairoBackend
public virtual ISurface CreateSurface(byte[] data, int width, int height)
=> new ImageSurface (data, Format.ARGB32, width, height, 4 * width);
- public ISurface CreateSurface (IntPtr nativeWindoPointer, int width, int height) {
+ public virtual ISurface CreateSurface (IntPtr nativeWindoPointer, int width, int height) {
switch (Environment.OSVersion.Platform) {
case PlatformID.Unix:
IntPtr disp = Glfw3.GetX11Display ();
diff --git a/Backends/CairoBackend/src/EGLDevice.cs b/Backends/CairoBackend/src/EGLDevice.cs
index 5305298b..83629374 100644
--- a/Backends/CairoBackend/src/EGLDevice.cs
+++ b/Backends/CairoBackend/src/EGLDevice.cs
@@ -28,14 +28,22 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
+using Drawing2D;
namespace Crow.CairoBackend
{
public class EGLDevice : GLDevice
{
- public EGLDevice (IntPtr dpy, IntPtr gl_ctx) : base (NativeMethods.cairo_egl_device_create (dpy, gl_ctx), true)
+ public EGLDevice (IntPtr dpy, IntPtr gl_ctx, bool threadAwayre = false) : base (NativeMethods.cairo_egl_device_create (dpy, gl_ctx), true)
{
+ SetThreadAware(threadAwayre);
}
+ public override ISurface CreateSurface(int width, int height)
+ => new ImageSurface (Format.ARGB32, width, height);
+ public override ISurface CreateSurface (IntPtr nativeWindoPointer, int width, int height) {
+ return new GLSurface (this, Glfw.Glfw3.GetEGLSurface (nativeWindoPointer), width, height);
+ }
+
}
}
diff --git a/Backends/CairoBackend/src/GLSurface.cs b/Backends/CairoBackend/src/GLSurface.cs
index ddbf0a4f..c7959dc3 100644
--- a/Backends/CairoBackend/src/GLSurface.cs
+++ b/Backends/CairoBackend/src/GLSurface.cs
@@ -52,6 +52,13 @@ namespace Crow.CairoBackend {
public GLSurface (WGLDevice device, IntPtr hdc, int width, int height)
: base (NativeMethods.cairo_gl_surface_create_for_dc (device.Handle, hdc, width, height), true)
{}
+ public override void Flush ()
+ {
+ base.Flush ();
+ SwapBuffers ();
+ }
+ public override int Width => NativeMethods.cairo_gl_surface_get_width (handle);
+ public override int Height => NativeMethods.cairo_gl_surface_get_height (handle);
public void SwapBuffers(){
NativeMethods.cairo_gl_surface_swapbuffers (this.Handle);
diff --git a/Backends/CairoBackend/src/Surface.cs b/Backends/CairoBackend/src/Surface.cs
index 2d6fac10..8e797658 100644
--- a/Backends/CairoBackend/src/Surface.cs
+++ b/Backends/CairoBackend/src/Surface.cs
@@ -111,12 +111,9 @@ namespace Crow.CairoBackend {
}
- public Surface CreateSimilar (
- Content content, int width, int height)
- {
+ public ISurface CreateSimilar (int width, int height) {
IntPtr p = NativeMethods.cairo_surface_create_similar (
- this.Handle, content, width, height);
-
+ this.Handle, Content.ColorAlpha, width, height);
return Surface.Lookup(p, true);
}
@@ -152,7 +149,7 @@ namespace Crow.CairoBackend {
return Status;
}
- public void Flush ()
+ public virtual void Flush ()
{
NativeMethods.cairo_surface_flush (handle);
}
@@ -166,8 +163,8 @@ namespace Crow.CairoBackend {
{
NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
}
- public virtual int Width => -1;
- public virtual int Height => -1;
+ public virtual int Width => NativeMethods.cairo_image_surface_get_width (handle);
+ public virtual int Height => NativeMethods.cairo_image_surface_get_height (handle);
public IntPtr Handle {
get {
@@ -235,10 +232,5 @@ namespace Crow.CairoBackend {
{
throw new NotImplementedException();
}
-
- public ISurface CreateSimilar(int width, int height)
- {
- throw new NotImplementedException();
- }
}
}