From 2c34b3483bb709bba64de06e3cc6b16b9acb40f9 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Fri, 19 May 2017 22:17:37 +0200 Subject: [PATCH] debug --- testDrm/Main.cs | 125 +++++++++++-- testDrm/src/Application.cs | 27 ++- testDrm/src/Egl/Context.cs | 3 - testDrm/src/Egl/Surface.cs | 25 ++- testDrm/src/Linux/DRI.cs | 247 +++++++++++--------------- testDrm/src/Linux/DRI/Connector.cs | 2 +- testDrm/src/Linux/DRI/Encoder.cs | 2 +- testDrm/src/Linux/GBM/BufferObject.cs | 2 +- testDrm/test.style | 34 ++++ testDrm/testDrm.csproj | 10 +- testDrm/ui/0.crow | 7 +- testDrm/ui/1.crow | 2 + testDrm/ui/2.crow | 34 ++++ testDrm/ui/colorItem.crow | 10 ++ testDrm/ui/menu.crow | 2 +- 15 files changed, 337 insertions(+), 195 deletions(-) create mode 100644 testDrm/test.style create mode 100755 testDrm/ui/1.crow create mode 100755 testDrm/ui/2.crow create mode 100755 testDrm/ui/colorItem.crow diff --git a/testDrm/Main.cs b/testDrm/Main.cs index 73a165b6..528a8e95 100644 --- a/testDrm/Main.cs +++ b/testDrm/Main.cs @@ -30,14 +30,18 @@ using System.Collections.Generic; using Cairo; using Crow.Linux; using Crow; +using System.Reflection; +using System.Linq; namespace testDrm { public class TestApp : Application, IValueChange { + [STAThread] static void Main () { + System.Threading.Thread.CurrentThread.Name = "Main"; try { using (TestApp crowApp = new TestApp ()) { crowApp.Run (); @@ -45,6 +49,7 @@ namespace testDrm } catch (Exception ex) { Console.WriteLine (ex.ToString ()); } + Console.WriteLine ("terminating"); } #region IValueChange implementation @@ -56,38 +61,114 @@ namespace testDrm } #endregion - public bool Running = true; + public TestApp () : base () { } - int frTime = 0; - int frMin = int.MaxValue; - int frMax = 0; + + public int frameTime = 0; + public int frameMin = int.MaxValue; + public int frameMax = 0; + #region Test values for Binding +// public int intValue = 500; +// DirectoryInfo curDir = new DirectoryInfo (System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); +// public FileSystemInfo[] CurDirectory { +// get { return curDir.GetFileSystemInfos (); } +// } +// public int IntValue { +// get { +// return intValue; +// } +// set { +// intValue = value; +// NotifyValueChanged ("IntValue", intValue); +// } +// } +// void onSpinnerValueChange(object sender, ValueChangeEventArgs e){ +// if (e.MemberName != "Value") +// return; +// intValue = Convert.ToInt32(e.NewValue); +// } +// void change_alignment(object sender, EventArgs e){ +// RadioButton rb = sender as RadioButton; +// if (rb == null) +// return; +// NotifyValueChanged ("alignment", Enum.Parse(typeof(Alignment), rb.Caption)); +// } +// public IList List2 = new List(new string[] +// { +// "string1", +// "string2", +// "string3", +// } +// ); +// public IList TestList2 { +// set{ +// List2 = value; +// NotifyValueChanged ("TestList2", testList); +// } +// get { return List2; } +// } + IList testList = Crow.Color.ColorDic; + public IList TestList { + set{ + testList = value; + NotifyValueChanged ("TestList", testList); + } + get { return testList; } + } +// string curSources = ""; +// public string CurSources { +// get { return curSources; } +// set { +// if (value == curSources) +// return; +// curSources = value; +// NotifyValueChanged ("CurSources", curSources); +// } +// } +// bool boolVal = true; +// public bool BoolVal { +// get { return boolVal; } +// set { +// if (boolVal == value) +// return; +// boolVal = value; +// NotifyValueChanged ("BoolVal", boolVal); +// } +// } + + #endregion public override void Run () - { + { Stopwatch frame = new Stopwatch (); - Load ("#testDrm.ui.menu.crow").DataSource = this; - Load ("#testDrm.ui.0.crow").DataSource = this; - Load ("#testDrm.ui.0.crow").DataSource = this; - Load ("#testDrm.ui.0.crow").DataSource = this; - Load ("#testDrm.ui.0.crow").DataSource = this; +// Load ("#testDrm.ui.menu.crow").DataSource = this; +// Load ("#testDrm.ui.0.crow").DataSource = this; +// Load ("#testDrm.ui.0.crow").DataSource = this; +// Load ("#testDrm.ui.0.crow").DataSource = this; + System.Threading.Thread.Sleep (50); + Load ("#testDrm.ui.menu.crow").DataSource = this; + int i = 0; while(Running){ try { frame.Restart(); + i++; + base.Run (); + frame.Stop(); - frTime = (int)frame.ElapsedTicks; - NotifyValueChanged("frameTime", frTime); - if (frTime > frMax){ - frMax = frTime; - NotifyValueChanged("frameMax", frMax); + frameTime = (int)frame.ElapsedTicks; + NotifyValueChanged("frameTime", frameTime); + if (frameTime > frameMax){ + frameMax = frameTime; + NotifyValueChanged("frameMax", frameMax); } - if (frTime < frMin){ - frMin = frTime; - NotifyValueChanged("frameMin", frMin); + if (frameTime < frameMin){ + frameMin = frameTime; + NotifyValueChanged("frameMin", frameMin); } } catch (Exception ex) { @@ -99,6 +180,14 @@ namespace testDrm { Running = false; } + void onLoadClick(object send, Crow.MouseButtonEventArgs e) + { + Console.WriteLine ("********** LOADING ui item ******************"); + GraphicObject go = Load ("#testDrm.ui.2.crow"); + Console.WriteLine ("********** SETTING DATASOURCE ON ITEM ******************"); + go.DataSource = this; + Console.WriteLine ("********** LOADING FINISHED ******************"); + } } } diff --git a/testDrm/src/Application.cs b/testDrm/src/Application.cs index 43330e03..a1fc45f1 100644 --- a/testDrm/src/Application.cs +++ b/testDrm/src/Application.cs @@ -40,7 +40,8 @@ using OpenTK.Platform.Linux; namespace Crow { public class Application : IDisposable - { + { + public bool Running = true; DRI.GPUControler gpu; Cairo.GLSurface cairoSurf; @@ -61,9 +62,8 @@ namespace Crow // Crow.XCursor cursor; int previousVT = -1, appVT = -1; -// - public Application(){ + public Application(){ if (Kernel.signal (Signal.SIGUSR1, switch_request_handle) < 0) throw new Exception ("signal handler registation failed"); if (Kernel.signal (Signal.SIGINT, sigint_handler) < 0) @@ -83,17 +83,17 @@ namespace Crow gpu = new DRI.GPUControler(); cairoSurf = gpu.CairoSurf; - cursor = Crow.XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0]; - CrowInterface = new Interface (); Thread t = new Thread (interfaceThread); + t.Name = "Interface"; t.IsBackground = true; t.Start (); initInput (); CrowInterface.ProcessResize (new Size (gpu.Width, gpu.Height)); + cursor = Crow.XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0]; gpu.updateCursor (cursor); //CrowInterface.MouseCursorChanged += CrowInterface_MouseCursorChanged; } @@ -105,8 +105,8 @@ namespace Crow } } void sigint_handler (Signal s){ - Console.WriteLine ("SIGINT catched"); - //Running = false; + Console.WriteLine ("{0}: SIGINT catched"); + Running = false; } // void CrowInterface_MouseCursorChanged (object sender, MouseCursorChangedEventArgs e) // { @@ -132,7 +132,13 @@ namespace Crow // using (Cairo.Context ctx = new Cairo.Context (cairoSurf)) { // ctx.Rectangle (0, 0, gpu.Width, gpu.Height); -// ctx.SetSourceRGB (0, 0, 0.1); +// ctx.SetSourceRGB (0, 0, 1); +// ctx.Fill (); +// ctx.Rectangle (5, 5, 50, 50); +// ctx.SetSourceRGB (1, 0, 0); +// ctx.Fill (); +// ctx.Rectangle (1550, 850, 50, 50); +// ctx.SetSourceRGB (0, 1, 0); // ctx.Fill (); // } if (Monitor.TryEnter (CrowInterface.RenderMutex)) { @@ -151,7 +157,7 @@ namespace Crow } Monitor.Exit (CrowInterface.RenderMutex); } - +// // if (!update) // return; // update = false; @@ -160,6 +166,8 @@ namespace Crow cairoSurf.SwapBuffers (); gpu.Update (); + //Thread.Sleep (1); + //gpu.MarkFBDirty (); } @@ -212,6 +220,7 @@ namespace Crow void initInput (){ Semaphore ready = new Semaphore(0, 1); input_thread = new Thread (InputThreadLoop); + input_thread.Name = "input_thread"; input_thread.IsBackground = true; input_thread.Start(ready); } diff --git a/testDrm/src/Egl/Context.cs b/testDrm/src/Egl/Context.cs index 122f2e72..b8efecc8 100644 --- a/testDrm/src/Egl/Context.cs +++ b/testDrm/src/Egl/Context.cs @@ -290,9 +290,6 @@ namespace EGL [DllImportAttribute("libEGL.dll", EntryPoint = "eglWaitNative")] [return: MarshalAsAttribute(UnmanagedType.I1)] public static extern bool WaitNative(int engine); - [DllImportAttribute("libEGL.dll", EntryPoint = "eglSwapBuffers")] - [return: MarshalAsAttribute(UnmanagedType.I1)] - public static extern bool SwapBuffers(EGLDisplay dpy, EGLSurface surface); [DllImportAttribute("libEGL.dll", EntryPoint = "eglCopyBuffers")] [return: MarshalAsAttribute(UnmanagedType.I1)] public static extern bool CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); diff --git a/testDrm/src/Egl/Surface.cs b/testDrm/src/Egl/Surface.cs index ccfcaa9c..5a441a56 100644 --- a/testDrm/src/Egl/Surface.cs +++ b/testDrm/src/Egl/Surface.cs @@ -41,23 +41,26 @@ namespace EGL { #region pinvoke [DllImportAttribute("libEGL.dll")] - public static extern EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, IntPtr win, IntPtr attrib_list); + internal static extern EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, IntPtr win, IntPtr attrib_list); [DllImportAttribute("libEGL.dll")] - public static extern EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, int[] attrib_list); + internal static extern EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, int[] attrib_list); [DllImportAttribute("libEGL.dll")] - public static extern EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, int[] attrib_list); + internal static extern EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, int[] attrib_list); [DllImportAttribute("libEGL.dll")][return: MarshalAsAttribute(UnmanagedType.I1)] - public static extern bool eglDestroySurface(EGLDisplay dpy, EGLSurface surface); + internal static extern bool eglDestroySurface(EGLDisplay dpy, EGLSurface surface); [DllImportAttribute("libEGL.dll")][return: MarshalAsAttribute(UnmanagedType.I1)] - public static extern bool eglQuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, out int value); + internal static extern bool eglQuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, out int value); [DllImportAttribute("libEGL.dll")] - public static extern EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, int buftype, EGLClientBuffer buffer, EGLConfig config, int[] attrib_list); + internal static extern EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, int buftype, EGLClientBuffer buffer, EGLConfig config, int[] attrib_list); [DllImportAttribute("libEGL.dll")][return: MarshalAsAttribute(UnmanagedType.I1)] - public static extern bool eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, int attribute, int value); + internal static extern bool eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, int attribute, int value); [DllImportAttribute("libEGL.dll")][return: MarshalAsAttribute(UnmanagedType.I1)] - public static extern bool eglBindTexImage(EGLDisplay dpy, EGLSurface surface, int buffer); + internal static extern bool eglBindTexImage(EGLDisplay dpy, EGLSurface surface, int buffer); [DllImportAttribute("libEGL.dll")][return: MarshalAsAttribute(UnmanagedType.I1)] - public static extern bool eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, int buffer); + internal static extern bool eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, int buffer); + [DllImportAttribute("libEGL.dll")][return: MarshalAsAttribute(UnmanagedType.I1)] + internal static extern bool eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); + #endregion Context ctx; @@ -75,6 +78,10 @@ namespace EGL if (!Context.MakeCurrent(ctx.dpy, handle, handle, ctx.ctx)) throw new NotSupportedException(string.Format("eglMakeCurrent on surface Failed: {0}",Context.GetError())); } + public void SwapBuffers () { + if (!eglSwapBuffers (ctx.dpy, handle)) + throw new NotSupportedException(string.Format("eglSwapBuffers Failed: {0}",Context.GetError())); + } #region IDisposable implementation ~Surface(){ diff --git a/testDrm/src/Linux/DRI.cs b/testDrm/src/Linux/DRI.cs index c1f60a41..b39044f7 100644 --- a/testDrm/src/Linux/DRI.cs +++ b/testDrm/src/Linux/DRI.cs @@ -27,6 +27,7 @@ using System; using System.Runtime.InteropServices; using System.Collections.Generic; using System.Diagnostics; +using System.Threading; namespace Linux.DRI { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -124,7 +125,8 @@ namespace Linux.DRI { Resources resources = null; Connector connector = null; Crtc currentCrtc = null; - ModeInfo currentMode; + ModeInfo currentMode, originalMode; + uint originalFB; public GPUControler(string gpu_path = "/dev/dri/card0"){ fd_gpu = Libc.open(gpu_path, OpenFlags.ReadWrite | OpenFlags.CloseOnExec); @@ -149,6 +151,42 @@ namespace Linux.DRI { public int Width { get { return (int)currentMode.hdisplay; }} public int Height { get { return (int)currentMode.vdisplay; }} + ModeInfo getNewMode(){ + ModeInfo mode = currentCrtc.CurrentMode; + mode.clock = 118250; + mode.hdisplay = 1600; + mode.hsync_start = 1696; + mode.hsync_end = 1856; + mode.htotal = 2112; + mode.vdisplay = 900; + mode.vsync_start = 903; + mode.vsync_end = 908; + mode.vtotal = 934; + mode.flags |= (uint)VideoMode.NHSYNC; + mode.flags |= (uint)VideoMode.PVSYNC; + return mode; + } + unsafe void setNewMode(){ + + //currentCrtc.handle->mode = currentMode; +// ModeInfo* mode = (ModeInfo*)Marshal.AllocHGlobal (sizeof(ModeInfo));// pConnector->modes; +// *mode = currentMode; + + uint fb; + GBM.gbm_bo* bo = GBM.BufferObject.gbm_bo_create (gbmDev.handle, (uint)Width, (uint)Height, GBM.SurfaceFormat.ARGB8888, GBM.SurfaceFlags.Scanout); + int ret = drmModeAddFB (fd_gpu, (uint)Width, (uint)Height, (byte)depth, (byte)bpp, bo->Stride, (uint)bo->Handle32, out fb); + if (ret != 0) + Console.WriteLine ("addFb failed: {0}", ret); + bo->SetUserData ((IntPtr)fb, handleDestroyFB); + + uint connId = connector.Id; + ret = drmModeSetCrtc (fd_gpu, currentCrtc.Id, fb, 0, 0, &connId, 1, ref currentMode); + if (ret != 0) + Console.WriteLine ("set new mode setCrtc failed: {0}", ret); + //GBM.BufferObject.gbm_bo_destroy (bo); + + //Console.WriteLine ("new mode set to {0} x {1}", Width, Height); + } bool defaultConfiguration (){ //select the first connected connector foreach (Connector c in resources.Connectors) { @@ -161,12 +199,17 @@ namespace Linux.DRI { return false; currentCrtc = connector.CurrentEncoder.CurrentCrtc; - currentMode = currentCrtc.CurrentMode; - + originalMode = currentCrtc.CurrentMode; + originalFB = currentCrtc.CurrentFbId; + currentMode = getNewMode(); + + //configure a rendering stack gbmSurf = new GBM.Surface (gbmDev, Width, Height, GBM.SurfaceFlags.Rendering | GBM.SurfaceFlags.Scanout); + //setNewMode (); + eglSurf = new EGL.Surface (eglctx, gbmSurf); eglSurf.MakeCurrent (); @@ -179,7 +222,17 @@ namespace Linux.DRI { if (cairoDev.Acquire () != Cairo.Status.Success) Console.WriteLine ("[Cairo]: Failed to acquire egl device."); - + +// using (Cairo.Context ctx = new Cairo.Context (CairoSurf)) { +// ctx.Rectangle (0, 0, Width, Height); +// ctx.SetSourceRGB (0, 0, 1); +// ctx.Fill (); +// } +// CairoSurf.Flush (); +// CairoSurf.SwapBuffers (); +// Update (); + + //Thread.Sleep (1); return true; } void handleDestroyFB(ref GBM.gbm_bo bo, IntPtr data) @@ -187,10 +240,14 @@ namespace Linux.DRI { int fb = data.ToInt32(); if (fb != 0) { - if (drmModeRmFB (fd_gpu, fb) != 0) - Console.WriteLine ("DestroyFB failed"); - else - Console.WriteLine ("DestroyFB ok fd={0}", fd_gpu); + try { + if (drmModeRmFB (fd_gpu, fb) != 0) + Console.WriteLine ("DestroyFB failed"); + else + Console.WriteLine ("DestroyFB ok fd={0}", fd_gpu); + } catch (Exception ex) { + Console.WriteLine ("DestroyFB error:" + ex.ToString()); + } } } @@ -200,126 +257,38 @@ namespace Linux.DRI { GBM.gbm_bo* bo; uint fb; -// PollFD fds = new PollFD(); -// fds.fd = fd_gpu; -// fds.events = PollFlags.In; -// -// EventContext evctx = new EventContext(); -// evctx.version = EventContext.Version; -// evctx.page_flip_handler = PageFlipPtr; - -// int timeout = -1;//block ? -1 : 0; -// - if (!gbmSurf.HasFreeBuffers) throw new NotSupportedException("[GBM] Out of free buffer"); bo = gbmSurf.Lock (); - //fb = getFbFromBo (bo); - //unsafe { - //Console.WriteLine ("current fb: {0}", currentCrtc.CurrentFbId); - //if (currentCrtc.CurrentFbId == 0) - int ret = drmModeAddFB (fd_gpu, currentMode.hdisplay, currentMode.vdisplay, (byte)depth, (byte)bpp, bo->Stride, (uint)bo->Handle32, out fb); - if (ret != 0) - Console.WriteLine ("addFb failed: {0}", ret); - //else - // fb = currentCrtc.CurrentFbId; - bo->SetUserData ((IntPtr)fb, handleDestroyFB); + int ret = drmModeAddFB (fd_gpu, currentMode.hdisplay, currentMode.vdisplay, (byte)depth, (byte)bpp, bo->Stride, (uint)bo->Handle32, out fb); + if (ret != 0) + Console.WriteLine ("addFb failed: {0}", ret); + bo->SetUserData ((IntPtr)fb, handleDestroyFB); - uint connId = connector.Id; - ret = drmModeSetCrtc (fd_gpu, currentCrtc.Id, fb, 0, 0, &connId, 1, ref currentMode); - if (ret != 0) - Console.WriteLine ("setCrtc failed: {0}", ret); - //} - gbmSurf.Release (bo); + uint connId = connector.Id; + ret = drmModeSetCrtc (fd_gpu, currentCrtc.Id, fb, 0, 0, &connId, 1, ref currentMode); + if (ret != 0) + Console.WriteLine ("setCrtc failed: {0}", ret); - //bo.Dispose (); -// -// SetScanoutRegion (fb); -// drmTimeOut.Restart(); -// -// while (run && drmTimeOut.ElapsedMilliseconds < 10000){ -// BufferObject next_bo; -// bool update = false; -// -// if (updateMousePos) { -// lock (Sync) { -// updateMousePos = false; -// unsafe { -// Drm.MoveCursor (fd_gpu, pEncoder->crtc_id, MouseX-8, MouseY-4); -// } -// } -// } -// -// if (Monitor.TryEnter (CrowInterface.RenderMutex)) { -// if (CrowInterface.IsDirty) { -// CrowInterface.IsDirty = false; -// update = true; -// using (Cairo.Context ctx = new Cairo.Context (cairoSurf)) { -// using (Cairo.Surface d = new Cairo.ImageSurface (CrowInterface.dirtyBmp, Cairo.Format.Argb32, -// width, height, width * 4)) { -// ctx.SetSourceSurface (d, 0, 0); -// ctx.Operator = Cairo.Operator.Source; -// ctx.Paint (); -// } -// } -// } -// Monitor.Exit (CrowInterface.RenderMutex); -// } -// -// if (!update) -// continue; -// update = false; -// -// cairoSurf.Flush (); -// cairoSurf.SwapBuffers (); -// -// if (Gbm.HasFreeBuffers (gbm_surface) == 0) -// throw new Exception ("[GBM]: Out of free buffers."); -// -// next_bo = Gbm.LockFrontBuffer (gbm_surface); -// if (next_bo == BufferObject.Zero) -// throw new Exception ("[GBM]: Failed to lock front buffer."); -// -// fb = getFbFromBo (next_bo); -// -// unsafe{ -// int is_flip_queued = 1; -// -// while (Drm.ModePageFlip (fd_gpu, pEncoder->crtc_id, fb, PageFlipFlags.FlipEvent, ref is_flip_queued) < 0) { -// //Console.WriteLine ("[DRM] Failed to enqueue framebuffer flip."); -// continue; -// } -// -// while (is_flip_queued != 0) -// { -// fds.revents = 0; -// if (Libc.poll (ref fds, 1, timeout) < 0) -// break; -// -// if ((fds.revents & (PollFlags.Hup | PollFlags.Error)) != 0) -// break; -// -// if ((fds.revents & PollFlags.In) != 0) -// Drm.HandleEvent (fd_gpu, ref evctx); -// else -// break; -// Thread.Sleep (1); -// } -// if (is_flip_queued != 0) -// Console.WriteLine ("flip canceled"); -// -// Gbm.ReleaseBuffer (gbm_surface, bo); -// //Drm.ModeRmFB(fd_gpu, fb); -// -// bo = next_bo; -// next_bo = BufferObject.Zero; -// -// } -// } + gbmSurf.Release (bo); + } + [StructLayout(LayoutKind.Sequential)] + struct drmClip { + public ushort x1; + public ushort y1; + public ushort x2; + public ushort y2; + } + unsafe public void MarkFBDirty(){ + IntPtr pClip = Marshal.AllocHGlobal (sizeof(drmClip)); + drmClip dc = new drmClip () { x1 = 0, y1 = 0, x2 = 500, y2 = 500 }; + Marshal.StructureToPtr (dc, pClip,false); + int ret = drmModeDirtyFB (fd_gpu, currentCrtc.CurrentFbId, IntPtr.Zero, 0); + if (ret < 0) + Console.WriteLine ("set FB dirty failed: {0}", ret); } - #region cursor GBM.BufferObject boMouseCursor; @@ -359,28 +328,7 @@ namespace Linux.DRI { drmModeMoveCursor (fd_gpu, currentCrtc.Id, x, y); } #endregion -// void initGbm (){ -// gbm_surface = Gbm.CreateSurface(gbm_device, mode.hdisplay, mode.vdisplay, SurfaceFormat.ARGB8888, SurfaceFlags.Rendering | SurfaceFlags.Scanout); -// if (gbm_surface == IntPtr.Zero) -// throw new NotSupportedException("[GBM] Failed to create GBM surface for rendering"); -// -// unsafe { -// gbm_bo* bo = Gbm.CreateBO (gbm_device, mode.hdisplay, mode.vdisplay, SurfaceFormat.ARGB8888, SurfaceFlags.Scanout); -// if (bo == null) -// Console.WriteLine ("failed to create a BufferObject for screen 0"); -// else { -// uint fb_id = screens [0].BindBuffer (bo); -// // if (paint (bo)) -// // Console.WriteLine ("[DRI] bo paint succeed"); -// // ModeDirtyFB (fd_gpu, fb_id, IntPtr.Zero, 0); -// } -// // //Gbm.DestroyBuffer (bo); -// ModeAddFB (fd_gpu, bo->Width, bo->Height,(byte)depth, (byte)bpp, bo->Stride, bo->Handle32, out fb_id); -// bo->SetUserData ((IntPtr)fb_id, IntPtr.Zero); -// -// int ret = ModeSetCrtc(fd_gpu, crtc_id, fb_id, x, y, &connector_id, 1, ref mode); -// } -// } + // unsafe public drmPlane GetPlane (uint id) { // drmPlane p = new drmPlane(); // drmPlane* pPlane = ModeGetPlane (fd_gpu, id); @@ -418,6 +366,13 @@ namespace Linux.DRI { CairoSurf = null; } + uint connId = connector.Id; + unsafe{ + int ret = drmModeSetCrtc (fd_gpu, currentCrtc.Id, originalFB, 0, 0, &connId, 1, ref originalMode); + if (ret != 0) + Console.WriteLine ("restore Crtc failed: {0}", ret); + } + if (boMouseCursor != null) boMouseCursor.Dispose (); boMouseCursor = null; @@ -452,9 +407,8 @@ namespace Linux.DRI { byte bpp, uint stride, uint bo_handle, out uint buf_id); [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] public static extern int drmModeRmFB(int fd, int bufferId); - [DllImport(lib, EntryPoint = "drmModeDirtyFB", CallingConvention = CallingConvention.Cdecl)] - public static extern int ModeDirtyFB(int fd, uint bufferId, IntPtr clips, uint num_clips); - + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] + public static extern int drmModeDirtyFB(int fd, uint bufferId, IntPtr clips, uint num_clips); [DllImport(lib, EntryPoint = "drmModeGetFB", CallingConvention = CallingConvention.Cdecl)] unsafe internal static extern drmFrameBuffer* ModeGetFB(int fd, uint fb_id); @@ -481,6 +435,9 @@ namespace Linux.DRI { [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] unsafe static extern int drmModeSetCrtc(int fd, uint crtcId, uint bufferId, uint x, uint y, uint* connectors, int count, ref ModeInfo mode); + [DllImport(lib, EntryPoint = "drmModeSetCrtc", CallingConvention = CallingConvention.Cdecl)] + unsafe static extern int ModeSetCrtc(int fd, uint crtcId, uint bufferId, uint x, uint y, uint* connectors, int count, ModeInfo* mode); + [DllImport(lib, CallingConvention = CallingConvention.Cdecl)] internal static extern int drmModeSetCursor2(int fd, uint crtcId, uint bo_handle, uint width, uint height, int hot_x, int hot_y); diff --git a/testDrm/src/Linux/DRI/Connector.cs b/testDrm/src/Linux/DRI/Connector.cs index 97acf4b8..9021cfad 100644 --- a/testDrm/src/Linux/DRI/Connector.cs +++ b/testDrm/src/Linux/DRI/Connector.cs @@ -128,7 +128,7 @@ namespace Linux.DRI #endregion int fd_gpu; - drmConnector* handle; + internal drmConnector* handle; #region ctor public Connector (int _fd_gpu, uint _id) diff --git a/testDrm/src/Linux/DRI/Encoder.cs b/testDrm/src/Linux/DRI/Encoder.cs index a3b3b705..09376501 100644 --- a/testDrm/src/Linux/DRI/Encoder.cs +++ b/testDrm/src/Linux/DRI/Encoder.cs @@ -50,7 +50,7 @@ namespace Linux.DRI #endregion int fd_gpu; - drmEncoder* handle; + internal drmEncoder* handle; #region ctor unsafe internal Encoder (int _fd_gpu, uint _id) diff --git a/testDrm/src/Linux/GBM/BufferObject.cs b/testDrm/src/Linux/GBM/BufferObject.cs index fd6adcb8..7f6012b3 100644 --- a/testDrm/src/Linux/GBM/BufferObject.cs +++ b/testDrm/src/Linux/GBM/BufferObject.cs @@ -55,7 +55,7 @@ namespace Linux.GBM { #region pinvoke [DllImport("gbm", CallingConvention = CallingConvention.Cdecl)] - static extern gbm_bo* gbm_bo_create (IntPtr gbm, uint width, uint height, SurfaceFormat format, SurfaceFlags flags); + internal static extern gbm_bo* gbm_bo_create (IntPtr gbm, uint width, uint height, SurfaceFormat format, SurfaceFlags flags); [DllImport("gbm", CallingConvention = CallingConvention.Cdecl)] internal static extern void gbm_bo_destroy (gbm_bo* bo); [DllImport("gbm", CallingConvention = CallingConvention.Cdecl)] diff --git a/testDrm/test.style b/testDrm/test.style new file mode 100644 index 00000000..fc327ab1 --- /dev/null +++ b/testDrm/test.style @@ -0,0 +1,34 @@ +FpsLabel { + Width = 50%; + Font = droid, 10; + Margin = 0; + TextAlignment = Center; + Background = Onyx; +} +FpsDisp { + Font = droid bold, 10; + Width = 50%; + Margin = 0; + TextAlignment = Center; + Background = Teal; +} +CheckBox2 { + Template= #Tests.Interfaces.CheckBox2.imlt; + Background = Onyx; + Checked={Background=Mantis;Font=droid bold, 10}; + Unchecked = {Background=Onyx;Font=droid,10}; +} +RadioButton2 { + Template=#Tests.Interfaces.CheckBox2.imlt; + Background = Onyx; + Checked = {Background=Mantis;Font=droid bold, 10}; + Unchecked = {Background=Onyx;Font=droid,10}; +} +labPerf { + Font = droid, 8; + Width = 50%; +} +labPerfVal{ + Font = droid, 8; + Width = 50%; +} diff --git a/testDrm/testDrm.csproj b/testDrm/testDrm.csproj index 5517f274..66df986a 100644 --- a/testDrm/testDrm.csproj +++ b/testDrm/testDrm.csproj @@ -27,10 +27,10 @@ DEBUG; prompt 4 - false true $(SolutionDir)build\obj\$(Configuration) - $(SolutionDir)build\$(Configuration) + $(SolutionDir)build\Debug + true full @@ -40,7 +40,7 @@ false true $(SolutionDir)build\obj\$(Configuration) - $(SolutionDir)build\$(Configuration) + $(SolutionDir)build\Release @@ -105,6 +105,10 @@ + + + + diff --git a/testDrm/ui/0.crow b/testDrm/ui/0.crow index 744f3cb4..bcb80e7c 100755 --- a/testDrm/ui/0.crow +++ b/testDrm/ui/0.crow @@ -149,10 +149,9 @@ --> - + + \ No newline at end of file diff --git a/testDrm/ui/1.crow b/testDrm/ui/1.crow new file mode 100755 index 00000000..c6979205 --- /dev/null +++ b/testDrm/ui/1.crow @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/testDrm/ui/2.crow b/testDrm/ui/2.crow new file mode 100755 index 00000000..1843e2dd --- /dev/null +++ b/testDrm/ui/2.crow @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testDrm/ui/colorItem.crow b/testDrm/ui/colorItem.crow new file mode 100755 index 00000000..e3e54827 --- /dev/null +++ b/testDrm/ui/colorItem.crow @@ -0,0 +1,10 @@ + + + + + + + diff --git a/testDrm/ui/menu.crow b/testDrm/ui/menu.crow index 67e5d604..b3863d5d 100755 --- a/testDrm/ui/menu.crow +++ b/testDrm/ui/menu.crow @@ -1,7 +1,7 @@  - + -- 2.47.3