From: Jean-Philippe Bruyère Date: Wed, 1 May 2019 16:15:06 +0000 (+0200) Subject: caching enabled X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=32ec60b8ac07a49c7b56e4c349d37d6542bab908;p=jp%2Fcrow.git caching enabled --- diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index ac334f25..2434712c 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -31,7 +31,7 @@ true false $(SolutionDir)build\Debug - TRACE0;DEBUG;DEBUG_BINDING_FUNC_CALLS0;DEBUG_DRAGNDROP0;DEBUG_LOG0;XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0 + TRACE0;DEBUG;DEBUG_BINDING_FUNC_CALLS0;DEBUG_DRAGNDROP0;DEBUG_LOG0;XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;MEASURE_TIME0;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0 diff --git a/Crow/Default.style b/Crow/Default.style index da26c243..3f64e873 100644 --- a/Crow/Default.style +++ b/Crow/Default.style @@ -39,6 +39,7 @@ Label { Height = "Fit"; Width = "Fit"; Margin = "1"; + CacheEnabled = "false"; } Menu { Margin = "1"; diff --git a/Crow/src/BmpPicture.cs b/Crow/src/BmpPicture.cs index b4080428..349d7d64 100644 --- a/Crow/src/BmpPicture.cs +++ b/Crow/src/BmpPicture.cs @@ -131,14 +131,15 @@ namespace Crow widthRatio = heightRatio; } - gr.Save (); + Matrix savedMat = gr.Matrix; gr.Translate (rect.Left,rect.Top); gr.Scale (widthRatio, heightRatio); gr.Translate ((rect.Width/widthRatio - Dimensions.Width)/2, (rect.Height/heightRatio - Dimensions.Height)/2); gr.SetSourceSurface (imgSurface, 0,0); gr.Paint (); - gr.Restore (); + + gr.Matrix = savedMat; } } } diff --git a/Crow/src/Cairo/DrawingHelpers.cs b/Crow/src/Cairo/DrawingHelpers.cs index 83bb10cc..55849cdd 100644 --- a/Crow/src/Cairo/DrawingHelpers.cs +++ b/Crow/src/Cairo/DrawingHelpers.cs @@ -76,9 +76,7 @@ namespace Crow { DrawRoundedRectangle(gr, r.X, r.Y, r.Width, r.Height, radius); } public static void DrawRoundedRectangle(Context gr, double x, double y, double width, double height, double radius) - { - gr.Save(); - + { if ((radius > height / 2) || (radius > width / 2)) radius = min(height / 2, width / 2); @@ -92,11 +90,9 @@ namespace Crow { gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); gr.ClosePath(); - gr.Restore(); } public static void StrokeRaisedRectangle(Context gr, Rectangle r, double width = 1) - { - gr.Save(); + { r.Inflate((int)-width / 2, (int)-width / 2); gr.LineWidth = width; gr.SetSourceColor(Color.White); @@ -110,12 +106,9 @@ namespace Crow { gr.LineTo(r.BottomRight); gr.LineTo(r.BottomLeft); gr.Stroke(); - - gr.Restore(); } public static void StrokeLoweredRectangle(Context gr, Rectangle r, double width = 1) { - gr.Save(); r.Inflate((int)-width / 2, (int)-width / 2); gr.LineWidth = width; gr.SetSourceColor(Color.DarkGrey); @@ -128,8 +121,6 @@ namespace Crow { gr.LineTo(r.BottomRight); gr.LineTo(r.BottomLeft); gr.Stroke(); - - gr.Restore(); } } } diff --git a/Crow/src/GraphicObjects/Widget.cs b/Crow/src/GraphicObjects/Widget.cs index a5df8791..3154faed 100644 --- a/Crow/src/GraphicObjects/Widget.cs +++ b/Crow/src/GraphicObjects/Widget.cs @@ -490,7 +490,7 @@ namespace Crow /// If enabled, resulting bitmap of graphic object is cached /// speeding up rendering of complex object. Default is enabled. /// - [DesignCategory ("Behavior")][DefaultValue(false)] + [DesignCategory ("Behavior")][DefaultValue(true)] public virtual bool CacheEnabled { get { return cacheEnabled; } set { @@ -1655,9 +1655,11 @@ namespace Crow Rectangle rBack = new Rectangle (Slot.Size); - background.SetAsSource (gr, rBack); - DrawingHelpers.CairoRectangle (gr, rBack, cornerRadius); - gr.Fill (); + //if (background != Color.Transparent) { + background.SetAsSource (gr, rBack); + DrawingHelpers.CairoRectangle (gr, rBack, cornerRadius); + gr.Fill (); + //} #if DEBUG_LOG dbgEvt.end = DebugLog.chrono.ElapsedTicks; @@ -1738,7 +1740,7 @@ namespace Crow paintDisabled (ctx, Slot + Parent.ClientRectangle.Position); } else { Rectangle rb = Slot + Parent.ClientRectangle.Position; - ctx.Save (); + //ctx.Save (); ctx.Translate (rb.X, rb.Y); @@ -1746,7 +1748,8 @@ namespace Crow if (!isEnabled) paintDisabled (ctx, Slot); - ctx.Restore (); + ctx.Translate (-rb.X, -rb.Y); + //ctx.Restore (); } LastPaintedSlot = Slot; } diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index df364038..1c339b00 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -130,7 +130,7 @@ namespace Crow ProcessEvents (); #if MEASURE_TIME - if (frameCount++ < 1000) + if (frameCount++ < 100) continue; for (int i = 0; i < PerfMeasures.Count; i++) { PerfMeasures [i].NotifyChanges (); @@ -747,39 +747,40 @@ namespace Crow if (DragImage != null) clipping.AddRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight)); - using (ctx = new Context (surf)) { - if (!clipping.IsEmpty) { - IsDirty = true; + lock (RenderMutex) { + using (ctx = new Context (surf)) { + if (!clipping.IsEmpty) { + IsDirty = true; - clipping.clearAndClip (ctx); + clipping.clearAndClip (ctx); - for (int i = GraphicTree.Count - 1; i >= 0; i--) { - Widget p = GraphicTree[i]; - if (!p.Visible) - continue; - if (!clipping.intersect (p.Slot)) - continue; + for (int i = GraphicTree.Count - 1; i >= 0; i--) { + Widget p = GraphicTree[i]; + if (!p.Visible) + continue; + if (!clipping.intersect (p.Slot)) + continue; - ctx.Save (); - p.Paint (ref ctx); - ctx.Restore (); - } + //ctx.Save (); + p.Paint (ref ctx); + //ctx.Restore (); + } - //if (DragAndDropOperation != null) { - // if (DragImage != null) { - // DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); - // DragImageX = Mouse.X - DragImageWidth / 2; - // DragImageY = Mouse.Y - DragImageHeight / 2; - // ctx.Save (); - // ctx.ResetClip (); - // ctx.SetSourceSurface (DragImage, DragImageX, DragImageY); - // ctx.PaintWithAlpha (0.8); - // ctx.Restore (); - // DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); - // IsDirty = true; - // //Console.WriteLine ("dragimage drawn: {0},{1}", DragImageX, DragImageY); - // } - //} + //if (DragAndDropOperation != null) { + // if (DragImage != null) { + // DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); + // DragImageX = Mouse.X - DragImageWidth / 2; + // DragImageY = Mouse.Y - DragImageHeight / 2; + // ctx.Save (); + // ctx.ResetClip (); + // ctx.SetSourceSurface (DragImage, DragImageX, DragImageY); + // ctx.PaintWithAlpha (0.8); + // ctx.Restore (); + // DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); + // IsDirty = true; + // //Console.WriteLine ("dragimage drawn: {0},{1}", DragImageX, DragImageY); + // } + //} #if DEBUG_CLIP_RECTANGLE clippingStrokeColor.R += 0.1f; @@ -789,14 +790,14 @@ namespace Crow clipping.stroke (ctx, clippingStrokeColor); ctx.Stroke (); #endif - //clipping.stroke (ctx, new Color (1, 0, 0)); - clipping.Reset (); - //} - //surf.WriteToPng (@"/mnt/data/test.png"); - + //clipping.stroke (ctx, new Color (1, 0, 0)); + clipping.Reset (); + //} + //surf.WriteToPng (@"/mnt/data/test.png"); + + } } } - /*#if DEBUG_LOG DebugLog.AddEvent (DbgEvtType.IFaceEndDrawing); #endif*/ diff --git a/Crow/src/PerformanceMeasure.cs b/Crow/src/PerformanceMeasure.cs index e94692de..1e803181 100644 --- a/Crow/src/PerformanceMeasure.cs +++ b/Crow/src/PerformanceMeasure.cs @@ -71,15 +71,15 @@ namespace Crow } void computeStats(){ - current = timer.ElapsedTicks; + current = timer.ElapsedMilliseconds; if (current < cancelLimit) return; cptMeasures++; - total += timer.ElapsedTicks; - if (timer.ElapsedTicks < minimum) - minimum = timer.ElapsedTicks; - if (timer.ElapsedTicks > maximum) - maximum = timer.ElapsedTicks; + total += timer.ElapsedMilliseconds; + if (timer.ElapsedMilliseconds < minimum) + minimum = timer.ElapsedMilliseconds; + if (timer.ElapsedMilliseconds > maximum) + maximum = timer.ElapsedMilliseconds; } void ResetStats(){ cptMeasures = total = current = maximum = 0; diff --git a/Crow/src/vkvg/Context.cs b/Crow/src/vkvg/Context.cs index 3186444f..0f709c68 100644 --- a/Crow/src/vkvg/Context.cs +++ b/Crow/src/vkvg/Context.cs @@ -80,6 +80,16 @@ namespace vkvg NativeMethods.vkvg_text_extents (handle, TerminateUtf8(s), out extents); return extents; } + public Matrix Matrix { + get { + Matrix m; + NativeMethods.vkvg_get_matrix (handle, out m); + return m; + } + set { + NativeMethods.vkvg_set_matrix (handle, ref value); + } + } public void ShowText (string txt) { NativeMethods.vkvg_show_text (handle, txt); } @@ -98,7 +108,6 @@ namespace vkvg public void Clear () { NativeMethods.vkvg_clear (handle); } - public void Paint () { NativeMethods.vkvg_paint (handle); } diff --git a/Tests/Interfaces/Divers/perfMeasures.crow b/Tests/Interfaces/Divers/perfMeasures.crow index ec13cf0e..d2d5138f 100755 --- a/Tests/Interfaces/Divers/perfMeasures.crow +++ b/Tests/Interfaces/Divers/perfMeasures.crow @@ -1,5 +1,5 @@ + ItemTemplate="#ui.perfMsr.crow"/>