From 7a60b790b046af0ae3a2e5e98565699b60073eb2 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 14 Jan 2018 23:53:50 +0100 Subject: [PATCH 1/3] Added failing test for #1341. --- .../Avalonia.RenderTests/Shapes/PathTests.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/Avalonia.RenderTests/Shapes/PathTests.cs b/tests/Avalonia.RenderTests/Shapes/PathTests.cs index 9a580794f8..fab867f428 100644 --- a/tests/Avalonia.RenderTests/Shapes/PathTests.cs +++ b/tests/Avalonia.RenderTests/Shapes/PathTests.cs @@ -362,5 +362,28 @@ namespace Avalonia.Direct2D1.RenderTests.Shapes await RenderToFile(target); CompareImages(); } + + [Fact] + public async Task Path_With_Rotated_Geometry() + { + var target = new Border + { + Width = 200, + Height = 200, + Background = Brushes.White, + Child = new Path + { + Fill = Brushes.Red, + Data = new RectangleGeometry + { + Rect = new Rect(50, 50, 100, 100), + Transform = new RotateTransform(45), + } + } + }; + + await RenderToFile(target); + CompareImages(); + } } } From 438bc89a9066391483c721c9f443c4c2970beca1 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 15 Jan 2018 00:07:24 +0100 Subject: [PATCH 2/3] Preserve defining geometry transform. Previous logic was overwriting `DefiningGeometry`'s transform with the transform calculated by the layout pass. Be sure to apply both transforms to the `RenderedGeometry`. --- src/Avalonia.Controls/Shapes/Shape.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/Shapes/Shape.cs b/src/Avalonia.Controls/Shapes/Shape.cs index 2ea681891d..a1848a95b1 100644 --- a/src/Avalonia.Controls/Shapes/Shape.cs +++ b/src/Avalonia.Controls/Shapes/Shape.cs @@ -61,12 +61,26 @@ namespace Avalonia.Controls.Shapes { get { - if (_renderedGeometry == null) + if (_renderedGeometry == null && DefiningGeometry != null) { - if (DefiningGeometry != null) + if (_transform == Matrix.Identity) + { + _renderedGeometry = DefiningGeometry; + } + else { _renderedGeometry = DefiningGeometry.Clone(); - _renderedGeometry.Transform = new MatrixTransform(_transform); + + if (_renderedGeometry.Transform == null || + _renderedGeometry.Transform.Value == Matrix.Identity) + { + _renderedGeometry.Transform = new MatrixTransform(_transform); + } + else + { + _renderedGeometry.Transform = new MatrixTransform( + _renderedGeometry.Transform.Value * _transform); + } } } @@ -193,6 +207,7 @@ namespace Avalonia.Controls.Shapes return finalSize; } + private Size CalculateShapeSizeAndSetTransform(Size availableSize) { // This should probably use GetRenderBounds(strokeThickness) but then the calculations From 062f67cd189e4a50d470702b0a070aac351caf86 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 15 Jan 2018 00:10:44 +0100 Subject: [PATCH 3/3] Added expected test output. --- .../Path/Path_With_Rotated_Geometry.expected.png | Bin 0 -> 1100 bytes .../Path/Path_With_Rotated_Geometry.expected.png | Bin 0 -> 1149 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/TestFiles/Direct2D1/Shapes/Path/Path_With_Rotated_Geometry.expected.png create mode 100644 tests/TestFiles/Skia/Shapes/Path/Path_With_Rotated_Geometry.expected.png diff --git a/tests/TestFiles/Direct2D1/Shapes/Path/Path_With_Rotated_Geometry.expected.png b/tests/TestFiles/Direct2D1/Shapes/Path/Path_With_Rotated_Geometry.expected.png new file mode 100644 index 0000000000000000000000000000000000000000..767690045966974d1b2f61cc8feb121c93054348 GIT binary patch literal 1100 zcmdVa-A|HX0LI}r#6%D^=d6?&Lsx5SlZwikYe1B+m6>Z(H?xa=q4|KH|T25VH z*7}%H(Q*Te5Up8lW>QAB8EMWW#Kiobh+8dE{HXi+Gdh6x$HRT?87I`Fr=@b)v22Q> zxC*%}1J7>qVy(sd(=5wc5o`w^QHgi=sQ7F)}QAW7h9{DUsoC=GRBkD@EL)oynX-ssL=MG^V^%{ zp1R)`BI`Sk&T69T#jM8a%O5Aiwema8A$%4#%`&zMl+wYF4B6ZKLJq#IamUNoh2D6X zbWISoxwxEvFfq*60dH}6zCqQg(A%NaI z2atSh3847;et=Qt3cy=ifPkRi1cb~G5Z+q^;5E+!IFJ1Wu-@2CenZF@0d_k9TrB}{ z8wuDgBsZj}ya1)03*-jlUUEbDF9Nia1jO|akl8?hMM!RFSNZ^0WKzx=-&1du@{?*V za~Q7@qjDp=8*0bq<xhzbRj}nZ5kmT{aG*Ou@^E>@NC2 zUlG?PFGOgnD`}s&%N94umGN?v4&=>Aj*RD~ElBNTC{n3I-m^!@cqz0OS!u^sP4^%V z*|Alt%t*T(TQ7YTnHIp-Ynn$o0@(5lpOKOPwmefa(iXs0Z>U2mT-fSObI6Y_Y(<7o z;x0*o3tLg+Q)HeCTaihNeB{7Z2TpuX?;N1zl3 K(_|JYUGWb9wxlKi literal 0 HcmV?d00001 diff --git a/tests/TestFiles/Skia/Shapes/Path/Path_With_Rotated_Geometry.expected.png b/tests/TestFiles/Skia/Shapes/Path/Path_With_Rotated_Geometry.expected.png new file mode 100644 index 0000000000000000000000000000000000000000..7f258aa9de35ce524d04e6a97c285fd2ff3ce625 GIT binary patch literal 1149 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yu@pObhHwBu4M$1`kZa=U;uumf z=j~nFAQ?}Q){EQ=kDfd_2n;dij_rzsML7* zUoE>J=bSJ9y?1#$=-vPSs1WC$r*H4?QEL1@=O3SvkVjChh6rcP2h~^=op+DdswpKV z&cEHQDkS#x=h-f$M91fEpNVpITh{O1?GbSz^|_820LH(-|1@U z%q>=nRq@H%y^vQa(do9IsUYX%n{{vcJ!YJ+E8ggGNadTfjJlB8hW9D16AgC!b?@(L zX_Pgd9j?OjYRAK?N{J4~{mR8Tn=SwSVxDL)!R&i;M~mZ@-45<5JPY3P1}iNre!D(F zm{T@e-a|=f*Hw3gPLCHs_Khk^3$1HeCv~)}`yvjKxR?%-aM}-&*tw6{)5R(HFFQ~= z?HGrOAg6DSFi;Vnc^FWU#gz)6qK5{_Y(Qz}9%-ONnRyvd;>Ojp!Jn>F3C{lU%k<}0 z?Vq2Pe)XDh;)nl)^#1;n+w)J(w_h86$mJQQil>~M%b{h@xPS)Fo~1v*MI|TgoP*HB z4V{%hdk%N)${iWdcgvyav*d9tqM>b88mJ5y97ZfkN_8)i98yl7T`?trj%Fam7I6Up$yGiryc^eK0KjAI> z(Bu#&#J-;6$xI8No=%I3=?+I66W=-RKP9`RD0oo1kg6OU;HjICRfT89xd2d2UI2d!Wbyk`46Z{ z_N6wEIkOJLe5DLzuKd<`=YDr{-qydN_wK9P*QuDB`%Y(kpZT3dkexY0xWhu?$VZ@& zjWW_e=9xkulTj8VdgUKT^essAP92cR`35LD;uWQ`H)u!uPF6Uc1+!~Evaw7bmFb9jK|34^DrpUXO@geCx4r>2Vl literal 0 HcmV?d00001