aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-12 11:52:50 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-12 11:52:50 +0100
commita823099f5db40fb8b2cbe79179185db5266e01e3 (patch)
tree43d01d1725726fd93613ef5bb3dbfa6714ef616b /src
parent83c588a624723742e77db3914259ee37c530bca2 (diff)
separate RecreateCache and UpdateCache
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/GraphicObject.cs2
-rw-r--r--src/GraphicObjects/Group.cs53
-rw-r--r--src/GraphicObjects/PrivateContainer.cs2
-rw-r--r--src/OpenTKGameWindow.cs34
4 files changed, 30 insertions, 61 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 763d1277..87ac0eef 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -793,7 +793,7 @@ namespace Crow
Rectangle rb = Slot + Parent.ClientRectangle.Position;
ctx.Save ();
- Clipping.clearAndClip (ctx);
+ //Clipping.clearAndClip (ctx);
ctx.Translate (rb.X, rb.Y);
onDraw (ctx);
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index 33fe006d..4305a665 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -204,9 +204,6 @@ namespace Crow
break;
}
}
- public override Rectangle ContextCoordinates(Rectangle r){
- return r + ClientRectangle.Position;
- }
protected override void onDraw (Context gr)
{
@@ -216,43 +213,31 @@ namespace Crow
g.Paint (ref gr);
}
}
-
- public override void Paint(ref Context ctx)
+ protected override void UpdateCache (Context ctx)
{
- if ( !Visible )
- return;
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
- if (CacheEnabled) {
- if (bmp == null)
- RecreateCache ();
- }
+ using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
+ Context gr = new Context (cache);
+
+ //Clipping.clearAndClip (gr);
+ base.onDraw (gr);
- if (Clipping.count > 0) {
- using (ImageSurface cache =
- new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, Slot.Width * 4)) {
- Context gr = new Context (cache);
+ foreach (GraphicObject c in children) {
+ if (!c.Visible)
+ continue;
+ c.Paint (ref gr);
+ }
- Clipping.clearAndClip (gr);
- Rectangle rBack = Slot.Size;
- Background.SetAsSource (gr, rBack);
- CairoHelpers.CairoRectangle (gr, rBack, CornerRadius);
- gr.Fill ();
+ #if DEBUG_CLIP_RECTANGLE
+ Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
+ #endif
- foreach (GraphicObject c in children) {
- if (!c.Visible)
- continue;
- Rectangles childClip = Clipping.intersectingRects (ContextCoordinates (c.Slot));
- if (childClip.count > 0)
- c.Paint (ref ctx);
- }
- #if DEBUG_CLIP_RECTANGLE
- Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
- #endif
+ gr.Dispose ();
- gr.Dispose ();
- }
- }
- base.Paint (ref ctx);
+ ctx.SetSourceSurface (cache, rb.X, rb.Y);
+ ctx.Paint ();
+ }
}
#endregion
diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs
index f3a512d0..0a87d03c 100644
--- a/src/GraphicObjects/PrivateContainer.cs
+++ b/src/GraphicObjects/PrivateContainer.cs
@@ -146,7 +146,7 @@ namespace Crow
using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
Context gr = new Context (cache);
- child.Clipping.clearAndClip (gr);
+ //Clipping.clearAndClip (gr);
base.onDraw (gr);
if (Clipping.count > 0) {
diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs
index e6fc9681..007556bc 100644
--- a/src/OpenTKGameWindow.cs
+++ b/src/OpenTKGameWindow.cs
@@ -290,36 +290,20 @@ namespace Crow
updateTime.Stop ();
drawingTime.Start ();
#endif
- Debug.WriteLine (redrawClip.ToString ());
- lock (redrawClip) {
- if (redrawClip.count > 0) {
- #if DEBUG_CLIP_RECTANGLE
- redrawClip.stroke (ctx, new Color(1.0,0,0,0.3));
- #endif
- redrawClip.clearAndClip (ctx);
- //Link.draw (ctx);
- foreach (GraphicObject p in invGOList) {
- if (!p.Visible)
- continue;
-
- ctx.Save ();
- Rectangles clip = redrawClip.intersectingRects (p.Slot);
+ //Link.draw (ctx);
+ foreach (GraphicObject p in invGOList) {
+ if (!p.Visible)
+ continue;
- if (clip.count > 0)
- p.Paint (ref ctx);
-
- ctx.Restore ();
+ ctx.Save ();
- }
- ctx.ResetClip ();
- #if DEBUG_CLIP_RECTANGLE
- redrawClip.stroke (ctx, Color.Red.AdjustAlpha(0.1));
- #endif
- redrawClip.Reset ();
- }
+ p.Paint (ref ctx);
+
+ ctx.Restore ();
}
+
#if MEASURE_TIME
drawingTime.Stop ();
#endif