aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/GraphicObject.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-12 11:26:52 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-12 11:26:52 +0100
commit83c588a624723742e77db3914259ee37c530bca2 (patch)
treea3a0cf98cfcb4860b430693df01d84fdb4a2bdd3 /src/GraphicObjects/GraphicObject.cs
parent0f813f1c3d1bc3e4deeee089d771eb0443949e3f (diff)
progressing, not using contextCoord anymore
Diffstat (limited to 'src/GraphicObjects/GraphicObject.cs')
-rw-r--r--src/GraphicObjects/GraphicObject.cs64
1 files changed, 37 insertions, 27 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 699d39a9..763d1277 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -144,7 +144,11 @@ namespace Crow
get { return Parent == null ? null : Parent.HostContainer; }
}
public virtual Rectangle ContextCoordinates(Rectangle r){
- return
+ GraphicObject go = Parent as GraphicObject;
+ if (go == null)
+ return r + Parent.ClientRectangle.Position;
+ return go.CacheEnabled ?
+ r + Parent.ClientRectangle.Position :
Parent.ContextCoordinates (r);
}
public virtual Rectangle ScreenCoordinates (Rectangle r){
@@ -731,9 +735,9 @@ namespace Crow
}
/// <summary>
- /// Interfal drawing context creation on a cached surface limited to slot size
+ /// Internal drawing context creation on a cached surface limited to slot size
/// this trigger the effective drawing routine </summary>
- protected virtual void UpdateGraphic ()
+ protected virtual void RecreateCache ()
{
int stride = 4 * Slot.Width;
@@ -749,6 +753,23 @@ namespace Crow
draw.Flush ();
}
}
+ protected virtual void UpdateCache(Context ctx){
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ using (ImageSurface cache = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
+ // //TODO:improve equality test for basic color and Fill
+ // if (this.Background is SolidColor) {
+ // if ((this.Background as SolidColor).Equals (Color.Clear)) {
+ // ctx.Save ();
+ // ctx.Operator = Operator.Clear;
+ // ctx.Rectangle (rb);
+ // ctx.Fill ();
+ // ctx.Restore ();
+ // }
+ // }
+ ctx.SetSourceSurface (cache, rb.X, rb.Y);
+ ctx.Paint ();
+ }
+ }
/// <summary> Chained painting routine on the parent context of the actual cached version
/// of the widget </summary>
public virtual void Paint (ref Context ctx)
@@ -758,8 +779,6 @@ namespace Crow
LastPaintedSlot = Slot;
- Rectangle rb = Parent.ContextCoordinates (Slot);
-
if (cacheEnabled) {
if (Slot.Width > Interface.MaxCacheSize || Slot.Height > Interface.MaxCacheSize)
cacheEnabled = false;
@@ -767,29 +786,20 @@ namespace Crow
if (cacheEnabled) {
if (bmp == null)
- UpdateGraphic ();
- using (ImageSurface source = new ImageSurface (bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
-// //TODO:improve equality test for basic color and Fill
-// if (this.Background is SolidColor) {
-// if ((this.Background as SolidColor).Equals (Color.Clear)) {
-// ctx.Save ();
-// ctx.Operator = Operator.Clear;
-// ctx.Rectangle (rb);
-// ctx.Fill ();
-// ctx.Restore ();
-// }
-// }
- ctx.SetSourceSurface (source, rb.X, rb.Y);
- ctx.Paint ();
- }
- return;
- }
- ctx.Save ();
+ RecreateCache ();
- Clipping.clearAndClip (ctx);
- ctx.Translate (rb.X, rb.Y);
- onDraw (ctx);
- ctx.Restore ();
+ UpdateCache (ctx);
+ } else {
+ Rectangle rb = Slot + Parent.ClientRectangle.Position;
+ ctx.Save ();
+
+ Clipping.clearAndClip (ctx);
+ ctx.Translate (rb.X, rb.Y);
+
+ onDraw (ctx);
+
+ ctx.Restore ();
+ }
}
#endregion