aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-12 13:05:32 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-12 13:05:32 +0100
commitf1f143775245695a0aaa8cd2538d3b3382f9ea56 (patch)
tree0f6ef2fef06cc3254dd0c3b32af38fab8a2e0087 /src
parenta823099f5db40fb8b2cbe79179185db5266e01e3 (diff)
testing clipping rect registration, clear and clip, not working
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/GraphicObject.cs16
-rw-r--r--src/GraphicObjects/Group.cs1
-rw-r--r--src/GraphicObjects/IGOLibHost.cs1
-rw-r--r--src/GraphicObjects/PrivateContainer.cs7
-rw-r--r--src/OpenTKGameWindow.cs92
5 files changed, 65 insertions, 52 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 87ac0eef..97e4eccf 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -31,8 +31,8 @@ namespace Crow
internal List<Binding> Bindings = new List<Binding> ();
internal int layoutingTries = 0;
- Rectangles _clipping = new Rectangles();
- public Rectangles Clipping { get { return _clipping; }}
+ Rectangles clipping = new Rectangles();
+ public Rectangles Clipping { get { return clipping; }}
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
@@ -471,11 +471,10 @@ namespace Crow
public virtual bool Contains(GraphicObject goToFind){
return false;
}
- public void RegisterClip(Rectangle clip){
- Rectangle r = Slot + Parent.ClientRectangle;
+ public void RegisterClip(Rectangle clip){
if (CacheEnabled && bmp != null)
- Clipping.AddRectangle (r);
- Parent.RegisterClip (r);
+ Clipping.AddRectangle (clip);
+ Parent.RegisterClip (clip + Slot.Position + Parent.ClientRectangle.Position);
}
// public virtual void registerClipRect(Rectangle clip)
// {
@@ -768,7 +767,9 @@ namespace Crow
// }
ctx.SetSourceSurface (cache, rb.X, rb.Y);
ctx.Paint ();
- }
+ }
+ //Clipping.clearAndClip (ctx);
+ Clipping.Reset();
}
/// <summary> Chained painting routine on the parent context of the actual cached version
/// of the widget </summary>
@@ -793,7 +794,6 @@ namespace Crow
Rectangle rb = Slot + Parent.ClientRectangle.Position;
ctx.Save ();
- //Clipping.clearAndClip (ctx);
ctx.Translate (rb.X, rb.Y);
onDraw (ctx);
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index 4305a665..efc5240b 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -238,6 +238,7 @@ namespace Crow
ctx.SetSourceSurface (cache, rb.X, rb.Y);
ctx.Paint ();
}
+ Clipping.Reset();
}
#endregion
diff --git a/src/GraphicObjects/IGOLibHost.cs b/src/GraphicObjects/IGOLibHost.cs
index 1c50d558..1cf6978c 100644
--- a/src/GraphicObjects/IGOLibHost.cs
+++ b/src/GraphicObjects/IGOLibHost.cs
@@ -5,7 +5,6 @@ namespace Crow
{
public interface IGOLibHost
{
- Rectangles redrawClip { get; set; }
List<GraphicObject> gobjsToRedraw { get; }
GraphicObject activeWidget { get; set; }
GraphicObject hoverWidget { get; set; }
diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs
index 0a87d03c..4012a7af 100644
--- a/src/GraphicObjects/PrivateContainer.cs
+++ b/src/GraphicObjects/PrivateContainer.cs
@@ -146,11 +146,13 @@ namespace Crow
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);
+ //Clipping.clearAndClip (ctx);
if (Clipping.count > 0) {
if (child != null) {
+
+ base.onDraw (gr);
+
child.Paint (ref gr);
}
}
@@ -160,6 +162,7 @@ namespace Crow
ctx.SetSourceSurface (cache, rb.X, rb.Y);
ctx.Paint ();
}
+ Clipping.Reset();
}
// public override Rectangle ContextCoordinates (Rectangle r)
// {
diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs
index 007556bc..5a2dc7fe 100644
--- a/src/OpenTKGameWindow.cs
+++ b/src/OpenTKGameWindow.cs
@@ -54,7 +54,7 @@ namespace Crow
List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();
#region IGOLibHost implementation
- public Rectangles redrawClip {
+ public Rectangles clipping {
get {
return _redrawClip;
}
@@ -181,7 +181,7 @@ namespace Crow
shader.ProjectionMatrix = Matrix4.CreateOrthographicOffCenter
(0, ClientRectangle.Width, ClientRectangle.Height, 0, 0, 1);
- redrawClip.AddRectangle (ClientRectangle);
+ clipping.AddRectangle (ClientRectangle);
}
void createOpenGLSurface()
{
@@ -253,55 +253,65 @@ namespace Crow
updateTime.Restart ();
#endif
- using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) {
- using (ctx = new Context (surf)){
+ GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
+ GraphicObjects.CopyTo (invGOList, 0);
+ invGOList = invGOList.Reverse ().ToArray ();
- GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
- GraphicObjects.CopyTo (invGOList, 0);
- invGOList = invGOList.Reverse ().ToArray ();
+ #if MEASURE_TIME
+ layoutTime.Start ();
+ #endif
+ //Debug.WriteLine ("======= Layouting queue start =======");
- #if MEASURE_TIME
- layoutTime.Start ();
- #endif
- //Debug.WriteLine ("======= Layouting queue start =======");
+ while (Interface.LayoutingQueue.Count > 0) {
+ LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+ lqi.ProcessLayouting ();
+ }
- while (Interface.LayoutingQueue.Count > 0) {
- LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
- lqi.ProcessLayouting ();
- }
+ #if MEASURE_TIME
+ layoutTime.Stop ();
+ #endif
- #if MEASURE_TIME
- layoutTime.Stop ();
- #endif
+ //Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");
+ //final redraw clips should be added only when layout is completed among parents,
+ //that's why it take place in a second pass
+ GraphicObject[] gotr = new GraphicObject[gobjsToRedraw.Count];
+ gobjsToRedraw.CopyTo (gotr);
+ gobjsToRedraw.Clear ();
+ foreach (GraphicObject p in gotr) {
+ p.IsQueuedForRedraw = false;
+ p.RegisterClip (p.LastPaintedSlot);
+ p.RegisterClip (p.getSlot());
+ }
- //Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");
- //final redraw clips should be added only when layout is completed among parents,
- //that's why it take place in a second pass
- GraphicObject[] gotr = new GraphicObject[gobjsToRedraw.Count];
- gobjsToRedraw.CopyTo (gotr);
- gobjsToRedraw.Clear ();
- foreach (GraphicObject p in gotr) {
- p.IsQueuedForRedraw = false;
- p.RegisterClip (p.LastPaintedSlot);
- p.RegisterClip (p.getSlot());
- }
+ #if MEASURE_TIME
+ updateTime.Stop ();
+ drawingTime.Start ();
+ #endif
+
+ using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) {
+ using (ctx = new Context (surf)){
- #if MEASURE_TIME
- updateTime.Stop ();
- drawingTime.Start ();
- #endif
+ if (clipping.count > 0) {
+ //Link.draw (ctx);
+ clipping.clearAndClip(ctx);
- //Link.draw (ctx);
- foreach (GraphicObject p in invGOList) {
- if (!p.Visible)
- continue;
+ foreach (GraphicObject p in invGOList) {
+ if (!p.Visible)
+ continue;
- ctx.Save ();
+ ctx.Save ();
- p.Paint (ref ctx);
+ p.Paint (ref ctx);
- ctx.Restore ();
+ ctx.Restore ();
+ }
+
+ #if DEBUG_CLIP_RECTANGLE
+ clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
+ #endif
+
+ clipping.Reset ();
}
#if MEASURE_TIME
@@ -536,7 +546,7 @@ namespace Crow
#region ILayoutable implementation
public void RegisterClip(Rectangle r){
- redrawClip.AddRectangle (r);
+ clipping.AddRectangle (r);
}
public int LayoutingTries {
get { throw new NotImplementedException (); }