Browse Source

Merge pull request #42 from ncarrillo/fix-cairo-transform

Fixes clipping/transform issue with cairo
pull/58/head
Steven Kirk 12 years ago
parent
commit
6aa3aea3fa
  1. 10
      Cairo/Perspex.Cairo/Media/DrawingContext.cs

10
Cairo/Perspex.Cairo/Media/DrawingContext.cs

@ -162,11 +162,10 @@ namespace Perspex.Cairo.Media
/// <returns>A disposable used to undo the clip rectangle.</returns> /// <returns>A disposable used to undo the clip rectangle.</returns>
public IDisposable PushClip(Rect clip) public IDisposable PushClip(Rect clip)
{ {
this.context.Save();
this.context.Rectangle(clip.ToCairo()); this.context.Rectangle(clip.ToCairo());
this.context.Clip(); this.context.Clip();
return Disposable.Create(() => this.context.Restore()); return Disposable.Create(() => this.context.ResetClip());
} }
/// <summary> /// <summary>
@ -176,14 +175,11 @@ namespace Perspex.Cairo.Media
/// <returns>A disposable used to undo the transformation.</returns> /// <returns>A disposable used to undo the transformation.</returns>
public IDisposable PushTransform(Matrix matrix) public IDisposable PushTransform(Matrix matrix)
{ {
this.context.Save();
this.context.Transform(matrix.ToCairo()); this.context.Transform(matrix.ToCairo());
this.CurrentTransform *= matrix;
return Disposable.Create(() => return Disposable.Create(() =>
{ {
this.context.Restore(); this.context.Transform(matrix.Invert().ToCairo());
this.CurrentTransform *= matrix.Invert();
}); });
} }

Loading…
Cancel
Save