]> O.S.I.I.S - jp/crow.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 24 Nov 2021 04:00:15 +0000 (05:00 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 24 Nov 2021 04:00:15 +0000 (05:00 +0100)
Backends/CairoBackend/src/Context.cs
Backends/CairoBackend/src/Device.cs
Backends/CairoBackend/src/EGLDevice.cs
Backends/CairoBackend/src/GLSurface.cs
Backends/CairoBackend/src/Surface.cs

index a28c7b0c65072c9273e95c339d7db6f02e78573c..a4eac7a25bfca0f92308db09c838330f883844cf 100644 (file)
@@ -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;
 
index 4cbb180f472ae0adc6819452cf0bd4adc0a663d6..c87b494ba34421268bd425c6b637bae57290d792 100644 (file)
@@ -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 ();
index 5305298b5ddb3515f38ab362f6a222608de4ff36..83629374f90ea0a058d634166a9b26aa2be20ad0 100644 (file)
 // 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);
+               }
+
        }
 }
 
index ddbf0a4fdc34269fae2928e3e46057e4d35fcda7..c7959dc3f2dd76777d0d5126fabca67774ffc1a2 100644 (file)
@@ -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);
index 2d6fac10332f435003ef868556874dc324a40d23..8e7976585b6103d191f3ae5d26e4690046c76f10 100644 (file)
@@ -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();
-               }
        }
 }