aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-03-18 17:20:28 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-03-18 17:20:28 +0100
commit5ea4d03f077f830e6101463e8692856a1f0f9efe (patch)
tree1774ee777c131a5c8af4088efe8c7bfd636d64c1
parent9023932880b5af2575eb54b4379c753152780427 (diff)
drawing optimisation:group double drawing solved, Region.Reset()
-rw-r--r--Crow/src/Mono.Cairo/Region.cs6
-rw-r--r--Crow/src/Widgets/Group.cs19
-rw-r--r--Crow/src/Widgets/PrivateContainer.cs3
-rw-r--r--Crow/src/Widgets/Widget.cs20
4 files changed, 24 insertions, 24 deletions
diff --git a/Crow/src/Mono.Cairo/Region.cs b/Crow/src/Mono.Cairo/Region.cs
index 5e8d8d60..f2c111d7 100644
--- a/Crow/src/Mono.Cairo/Region.cs
+++ b/Crow/src/Mono.Cairo/Region.cs
@@ -192,5 +192,11 @@ namespace Crow.Cairo
{
return NativeMethods.cairo_region_xor_rectangle (Handle, ref rectangle);
}
+ public void Reset () {
+ if (IsEmpty)
+ return;
+ NativeMethods.cairo_region_destroy (Handle);
+ handle = NativeMethods.cairo_region_create ();
+ }
}
}
diff --git a/Crow/src/Widgets/Group.cs b/Crow/src/Widgets/Group.cs
index 69fc614e..5f6a97f8 100644
--- a/Crow/src/Widgets/Group.cs
+++ b/Crow/src/Widgets/Group.cs
@@ -309,12 +309,8 @@ namespace Crow
}
protected override void UpdateCache (Context ctx)
{
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
-
-
- Context gr = new Context (bmp);
-
if (!Clipping.IsEmpty) {
+ Context gr = new Context (bmp);
for (int i = 0; i < Clipping.NumRectangles; i++)
gr.Rectangle(Clipping.GetRectangle(i));
gr.ClipPreserve();
@@ -348,14 +344,11 @@ namespace Crow
gr.Rectangle(Clipping.GetRectangle(i));
gr.Stroke ();*/
#endif
- }
- gr.Dispose ();
-
- ctx.SetSource (bmp, rb.X, rb.Y);
- ctx.Paint ();
-
- Clipping.Dispose();
- Clipping = new Region ();
+ gr.Dispose ();
+ Clipping.Reset ();
+ }/*else
+ Console.WriteLine("GROUP REPAINT WITH EMPTY CLIPPING");*/
+ paintCache (ctx, Slot + Parent.ClientRectangle.Position);
}
#endregion
diff --git a/Crow/src/Widgets/PrivateContainer.cs b/Crow/src/Widgets/PrivateContainer.cs
index bb0bf531..6bdff7da 100644
--- a/Crow/src/Widgets/PrivateContainer.cs
+++ b/Crow/src/Widgets/PrivateContainer.cs
@@ -224,8 +224,7 @@ namespace Crow
ctx.SetSource (bmp, rb.X, rb.Y);
ctx.Paint ();
- Clipping.Dispose();
- Clipping = new Region ();
+ Clipping.Reset ();
}
#endregion
diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs
index 1553dab4..4c35c153 100644
--- a/Crow/src/Widgets/Widget.cs
+++ b/Crow/src/Widgets/Widget.cs
@@ -1810,14 +1810,11 @@ namespace Crow
onDraw (gr);
}
- IsDirty = false;
+ IsDirty = false;
DbgLogger.EndEvent (DbgEvtType.GORecreateCache);
}
- protected virtual void UpdateCache(Context ctx){
- DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
-
- Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ protected void paintCache(Context ctx, Rectangle rb) {
if (clearBackground) {
ctx.Operator = Operator.Clear;
ctx.Rectangle (rb);
@@ -1827,8 +1824,11 @@ namespace Crow
ctx.SetSource (bmp, rb.X, rb.Y);
ctx.Paint ();
- Clipping.Dispose ();
- Clipping = new Region ();
+ }
+ protected virtual void UpdateCache(Context ctx){
+ DbgLogger.StartEvent(DbgEvtType.GOUpdateCache, this);
+ paintCache (ctx, Slot + Parent.ClientRectangle.Position);
+ Clipping.Reset ();
DbgLogger.EndEvent (DbgEvtType.GOUpdateCache);
}
/// <summary> Chained painting routine on the parent context of the actual cached version
@@ -1866,9 +1866,11 @@ namespace Crow
}
if (cacheEnabled) {
- if (IsDirty)
+ if (IsDirty) {
RecreateCache ();
- UpdateCache (ctx);
+ paintCache (ctx, Slot + Parent.ClientRectangle.Position);
+ }else
+ UpdateCache (ctx);
if (!IsEnabled)
paintDisabled (ctx, Slot + Parent.ClientRectangle.Position);
} else {