aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/GraphicObject.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-08-13 16:45:33 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-08-13 16:45:33 +0200
commita068b75def006a4722d8026f05399bc258ab0d3f (patch)
tree791873b24adabc69aa2a8e47647bf41d0a9fea2f /src/GraphicObjects/GraphicObject.cs
parenta6bd762aeb95d0b872ce2a36254133ff9dc5727b (diff)
dont back cache in byte array
Diffstat (limited to 'src/GraphicObjects/GraphicObject.cs')
-rw-r--r--src/GraphicObjects/GraphicObject.cs38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 0db8fb54..284e4877 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -137,7 +137,7 @@ namespace Crow
/// <summary>Prevent requeuing multiple times the same widget</summary>
public bool IsQueueForRedraw = false;
/// <summary>drawing Cache, if null, a redraw is done, cached or not</summary>
- public byte[] bmp;
+ public Surface bmp;
public bool IsDirty = true;
/// <summary>
/// This size is computed on each child' layout changes.
@@ -1116,33 +1116,27 @@ namespace Crow
/// this trigger the effective drawing routine </summary>
protected virtual void RecreateCache ()
{
- int stride = 4 * Slot.Width;
-
- int bmpSize = Math.Abs (stride) * Slot.Height;
- bmp = new byte[bmpSize];
IsDirty = false;
- using (ImageSurface draw =
- new ImageSurface(bmp, Format.Argb32, Slot.Width, Slot.Height, stride)) {
- using (Context gr = new Context (draw)) {
- gr.Antialias = Interface.Antialias;
- onDraw (gr);
- }
- draw.Flush ();
+ if (bmp != null)
+ bmp.Dispose ();
+ bmp = new ImageSurface (Format.Argb32, Slot.Width, Slot.Height);
+ using (Context gr = new Context (bmp)) {
+ gr.Antialias = Interface.Antialias;
+ onDraw (gr);
}
+ bmp.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)) {
- if (clearBackground) {
- ctx.Save ();
- ctx.Operator = Operator.Clear;
- ctx.Rectangle (rb);
- ctx.Fill ();
- ctx.Restore ();
- }
- ctx.SetSourceSurface (cache, rb.X, rb.Y);
- ctx.Paint ();
+ if (clearBackground) {
+ ctx.Save ();
+ ctx.Operator = Operator.Clear;
+ ctx.Rectangle (rb);
+ ctx.Fill ();
+ ctx.Restore ();
}
+ ctx.SetSourceSurface (bmp, rb.X, rb.Y);
+ ctx.Paint ();
//Clipping.clearAndClip (ctx);
Clipping.Reset();
}