From a694f30d6c3d2e62beba0fbb94c4262471c87c22 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Thu, 24 Jul 2014 12:01:50 +0200 Subject: [PATCH] Add more alpha gradient test cases * Add a vertical linear gradient. This bypasses AGG and uses a faster code path, which works. * Add gradients drawn in a ClipToPicture() context. This uses an * unpacked scanline rasterizer, which works. This hints to the problem being the use of a packed scanline rasterizer, with agg gradients touching the alpha channel. --- src/tests/servers/app/gradients/main.cpp | 44 ++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/tests/servers/app/gradients/main.cpp b/src/tests/servers/app/gradients/main.cpp index 6e1a132a96..52c684aba3 100644 --- a/src/tests/servers/app/gradients/main.cpp +++ b/src/tests/servers/app/gradients/main.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -74,7 +75,7 @@ class AlphaGradientTest : public Test { public: AlphaGradientTest() : - Test("Alpha gradient") + Test("Alpha gradients") { } @@ -92,7 +93,7 @@ public: g.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0); view->FillEllipse(center, radius, radius, g); - // Linear gradient + // Linear gradient - Horizontal BPoint from(100, 0); BPoint to(200, 0); BGradientLinear l(from, to); @@ -100,6 +101,15 @@ public: l.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0); view->FillRect(BRect(100, 0, 200, 100), l); + // Linear gradient - Vertical + // (this uses a different code path in app_server) + BPoint top(0, 0); + BPoint bot(0, 100); + BGradientLinear v(top, bot); + v.AddColor((rgb_color){ 255, 0, 0, 0 }, 0.0); + v.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0); + view->FillRect(BRect(200, 0, 300, 100), v); + // These draw as opaque or almost opaque view->SetOrigin(BPoint(0, 100)); @@ -110,11 +120,39 @@ public: go.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0); view->FillEllipse(center, radius, radius, go); - // Linear gradient + // Linear gradient - Horizontal BGradientLinear lo(from, to); lo.AddColor((rgb_color){ 255, 0, 0, 255 }, 0.0); lo.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0); view->FillRect(BRect(100, 0, 200, 100), lo); + + // Linear gradient - Vertical + // (this uses a different code path in app_server) + BGradientLinear vo(top, bot); + vo.AddColor((rgb_color){ 255, 0, 0, 255 }, 0.0); + vo.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0); + view->FillRect(BRect(200, 0, 300, 100), vo); + + // Finally, do the same using ClipToPicture. This forces using an + // unpacked scanline rasterizer, and it works. + view->SetOrigin(BPoint(0, 0)); + + view->SetDrawingMode(B_OP_COPY); + + BPicture picture; + view->BeginPicture(&picture); + view->SetHighColor(make_color(0,0,0,255)); + view->FillRect(BRect(0, 200, 300, 300)); + view->EndPicture(); + view->ClipToPicture(&picture); + + view->SetOrigin(BPoint(0, 200)); + + view->SetDrawingMode(B_OP_ALPHA); + + view->FillEllipse(center, radius, radius, g); + view->FillRect(BRect(100, 0, 200, 100), l); + view->FillRect(BRect(200, 0, 300, 100), v); } };