@@ -669,183 +669,6 @@ TEST_P(AiksTest, DrawLinesRenderCorrectly) {
669669 ASSERT_TRUE (OpenPlaygroundHere (builder.Build ()));
670670}
671671
672- // The goal of this test is to show that scaling the lines doesn't also scale
673- // the antialiasing. The amount of blurring should be the same for both
674- // horizontal lines.
675- TEST_P (AiksTest, ScaleExperimentAntialiasLines) {
676- // Must be called before any methods that use the context to ensure that
677- // this test is run with the antialias flag.
678- if (!EnsureContextSupportsAntialiasLines ()) {
679- GTEST_SKIP () << " This backend doesn't yet support experimental AA lines." ;
680- }
681-
682- Scalar scale = 5.0 ;
683- Scalar line_width = 10 .f ;
684- auto callback = [&]() -> sk_sp<DisplayList> {
685- if (IsPlaygroundEnabled ()) {
686- ImGui::Begin (" Controls" , nullptr , ImGuiWindowFlags_AlwaysAutoResize);
687- ImGui::SliderFloat (" Scale" , &scale, 0.001 , 5 );
688- ImGui::SliderFloat (" Width" , &line_width, 1 , 20 );
689-
690- ImGui::End ();
691- }
692- DisplayListBuilder builder;
693- builder.Scale (GetContentScale ().x , GetContentScale ().y );
694-
695- builder.DrawPaint (DlPaint (DlColor (0xff111111 )));
696-
697- {
698- DlPaint paint;
699- paint.setColor (DlColor::kGreenYellow ());
700- paint.setStrokeWidth (line_width);
701-
702- builder.DrawLine (DlPoint (100 , 100 ), DlPoint (350 , 100 ), paint);
703- builder.DrawLine (DlPoint (100 , 100 ), DlPoint (350 , 150 ), paint);
704-
705- builder.Save ();
706- builder.Translate (100 , 300 );
707- builder.Scale (scale, scale);
708- builder.Translate (-100 , -300 );
709- builder.DrawLine (DlPoint (100 , 300 ), DlPoint (350 , 300 ), paint);
710- builder.DrawLine (DlPoint (100 , 300 ), DlPoint (350 , 450 ), paint);
711- builder.Restore ();
712- }
713-
714- {
715- DlPaint paint;
716- paint.setColor (DlColor::kGreenYellow ());
717- paint.setStrokeWidth (2.0 );
718-
719- builder.Save ();
720- builder.Translate (100 , 500 );
721- builder.Scale (0.2 , 0.2 );
722- builder.Translate (-100 , -500 );
723- builder.DrawLine (DlPoint (100 , 500 ), DlPoint (350 , 500 ), paint);
724- builder.DrawLine (DlPoint (100 , 500 ), DlPoint (350 , 650 ), paint);
725- builder.Restore ();
726- }
727-
728- return builder.Build ();
729- };
730- ASSERT_TRUE (OpenPlaygroundHere (callback));
731- }
732-
733- TEST_P (AiksTest, HexagonExperimentAntialiasLines) {
734- // Must be called before any methods that use the context to ensure that
735- // this test is run with the antialias flag.
736- if (!EnsureContextSupportsAntialiasLines ()) {
737- GTEST_SKIP () << " This backend doesn't yet support experimental AA lines." ;
738- }
739-
740- float scale = 5 .0f ;
741- float line_width = 10 .f ;
742- float rotation = 0 .f ;
743-
744- auto callback = [&]() -> sk_sp<DisplayList> {
745- if (IsPlaygroundEnabled ()) {
746- ImGui::Begin (" Controls" , nullptr , ImGuiWindowFlags_AlwaysAutoResize);
747- // Use ImGui::SliderFloat for consistency
748- ImGui::SliderFloat (" Scale" , &scale, 0 .001f , 5 .0f );
749- ImGui::SliderFloat (" Width" , &line_width, 1 .0f , 20 .0f );
750- ImGui::SliderFloat (" Rotation" , &rotation, 0 .0f , 180 .0f );
751-
752- ImGui::End ();
753- }
754- DisplayListBuilder builder;
755- builder.Scale (static_cast <float >(GetContentScale ().x ),
756- static_cast <float >(GetContentScale ().y ));
757-
758- builder.DrawPaint (DlPaint (DlColor (0xff111111 ))); // Background
759-
760- {
761- DlPaint hex_paint;
762- hex_paint.setColor (
763- DlColor::kGreen ()); // Changed color to Red for visibility
764- hex_paint.setStrokeWidth (line_width); // Use the interactive width
765-
766- float cx = 512 .0f ; // Center X
767- float cy = 384 .0f ; // Center Y
768- float r = 80 .0f ; // Radius (distance from center to vertex)
769-
770- float r_sin60 = r * std::sqrt (3 .0f ) / 2 .0f ;
771- float r_cos60 = r / 2 .0f ;
772-
773- DlPoint v0 = DlPoint (cx + r, cy); // Right vertex
774- DlPoint v1 = DlPoint (cx + r_cos60, cy - r_sin60); // Top-right vertex
775- DlPoint v2 = DlPoint (
776- cx - r_cos60,
777- cy - r_sin60); // Top-left vertex (v1-v2 is top horizontal side)
778- DlPoint v3 = DlPoint (cx - r, cy); // Left vertex
779- DlPoint v4 = DlPoint (cx - r_cos60, cy + r_sin60); // Bottom-left vertex
780- DlPoint v5 =
781- DlPoint (cx + r_cos60, cy + r_sin60); // Bottom-right vertex (v4-v5 is
782- // bottom horizontal side)
783-
784- builder.Translate (cx, cy);
785- builder.Scale (scale, scale);
786- builder.Rotate (rotation);
787- builder.Translate (-cx, -cy);
788-
789- builder.DrawLine (v0, v1, hex_paint);
790- builder.DrawLine (v1, v2, hex_paint); // Top side
791- builder.DrawLine (v2, v3, hex_paint);
792- builder.DrawLine (v3, v4, hex_paint);
793- builder.DrawLine (v4, v5, hex_paint); // Bottom side
794- builder.DrawLine (v5, v0, hex_paint); // Close the hexagon
795- }
796-
797- return builder.Build ();
798- };
799- ASSERT_TRUE (OpenPlaygroundHere (callback));
800- }
801-
802- TEST_P (AiksTest, SimpleExperimentAntialiasLines) {
803- // Must be called before any methods that use the context to ensure that
804- // this test is run with the antialias flag.
805- if (!EnsureContextSupportsAntialiasLines ()) {
806- GTEST_SKIP () << " This backend doesn't yet support experimental AA lines." ;
807- }
808-
809- DisplayListBuilder builder;
810- builder.Scale (GetContentScale ().x , GetContentScale ().y );
811-
812- builder.DrawPaint (DlPaint (DlColor (0xff111111 )));
813-
814- DlPaint paint;
815- paint.setColor (DlColor::kGreenYellow ());
816- paint.setStrokeWidth (10 );
817-
818- auto draw = [&builder](DlPaint& paint) {
819- for (auto cap :
820- {DlStrokeCap::kButt , DlStrokeCap::kSquare , DlStrokeCap::kRound }) {
821- paint.setStrokeCap (cap);
822- DlPoint origin = {100 , 100 };
823- builder.DrawLine (DlPoint (150 , 100 ), DlPoint (250 , 100 ), paint);
824- for (int d = 15 ; d < 90 ; d += 15 ) {
825- Matrix m = Matrix::MakeRotationZ (Degrees (d));
826- Point origin = {100 , 100 };
827- Point p0 = {50 , 0 };
828- Point p1 = {150 , 0 };
829- auto a = origin + m * p0;
830- auto b = origin + m * p1;
831-
832- builder.DrawLine (a, b, paint);
833- }
834- builder.DrawLine (DlPoint (100 , 150 ), DlPoint (100 , 250 ), paint);
835- builder.DrawCircle (origin, 35 , paint);
836-
837- builder.DrawLine (DlPoint (250 , 250 ), DlPoint (250 , 250 ), paint);
838-
839- builder.Translate (250 , 0 );
840- }
841- builder.Translate (-750 , 250 );
842- };
843-
844- draw (paint);
845-
846- ASSERT_TRUE (OpenPlaygroundHere (builder.Build ()));
847- }
848-
849672TEST_P (AiksTest, DrawRectStrokesRenderCorrectly) {
850673 DisplayListBuilder builder;
851674 DlPaint paint;
0 commit comments