]> O.S.I.I.S - jp/crow.git/commitdiff
caching enabled
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 1 May 2019 16:15:06 +0000 (18:15 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 1 May 2019 16:15:06 +0000 (18:15 +0200)
Crow/Crow.csproj
Crow/Default.style
Crow/src/BmpPicture.cs
Crow/src/Cairo/DrawingHelpers.cs
Crow/src/GraphicObjects/Widget.cs
Crow/src/Interface.cs
Crow/src/PerformanceMeasure.cs
Crow/src/vkvg/Context.cs
Tests/Interfaces/Divers/perfMeasures.crow

index ac334f25005f79c7287b212e02463cda43931373..2434712c7db6db5680aa8fb7a6e5fbe21c29b394 100644 (file)
@@ -31,7 +31,7 @@
     <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
     <Optimize>false</Optimize>
     <OutputPath>$(SolutionDir)build\Debug</OutputPath>
-    <DefineConstants>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</DefineConstants>
+    <DefineConstants>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</DefineConstants>
     <EnvironmentVariables>
       <EnvironmentVariables>
         <Variable name="MONO_CAIRO_DEBUG_DISPOSE" value="1" />
index da26c243ecfe64c5a7bf8aaf1ecc1d364668eeb5..3f64e873f55f691102f975b1cd3ef4030d7ea716 100644 (file)
@@ -39,6 +39,7 @@ Label {
        Height = "Fit";
        Width = "Fit";
        Margin = "1";
+    CacheEnabled = "false";
 }
 Menu {
        Margin = "1";
index b4080428ee21ead8f53b7bacd41a432e91345abb..349d7d6490b44c225186cb7ea7e62cd22c730ca4 100644 (file)
@@ -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;
                }
        }
 }
index 83bb10ccb4099e887762864a018826171d288d34..55849cdd2458f84b4b751b3a6a88e2faf88e96d0 100644 (file)
@@ -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();
         }
     }
 }
index a5df87911e7cf2e8b4112e224ad48906f5dffe3b..3154faed4b4219545c4e0500141f8c01f875f928 100644 (file)
@@ -490,7 +490,7 @@ namespace Crow
                /// If enabled, resulting bitmap of graphic object is cached
                /// speeding up rendering of complex object. Default is enabled.
                /// </summary>
-               [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;
                        }
index df36403816ab75e0afe5e4bff8c072b2f547d619..1c339b00884d305137236d0d9753cd7282b747fa 100644 (file)
@@ -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*/
index e94692de6b26dd9c444aaf0683cb431a6a0d0947..1e8031815df42b5a4cbb617a9ecd244980409969 100644 (file)
@@ -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;
index 3186444f05ab65da46b69b885a282bdd1ae121c8..0f709c68b90f0b977c50f94fece18c5a73f780d4 100644 (file)
@@ -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);
                }
index ec13cf0e109a3187aa2cf803953c00168dbf7fac..d2d5138f50eb5efdd1cce4a35ba30d2bf741b103 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
 <Window Focusable="true" Caption="Measures" Width="30%" Height="300" MinimumSize="100,100">
        <ListBox Data="{PerfMeasures}"
-               ItemTemplate="#Tests.Interfaces.perfMsr.crow"/>
+               ItemTemplate="#ui.perfMsr.crow"/>
 </Window>