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.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <Picture.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
@@ -74,7 +75,7 @@ class AlphaGradientTest : public Test {
|
|||||||
public:
|
public:
|
||||||
AlphaGradientTest()
|
AlphaGradientTest()
|
||||||
:
|
:
|
||||||
Test("Alpha gradient")
|
Test("Alpha gradients")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +93,7 @@ public:
|
|||||||
g.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0);
|
g.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0);
|
||||||
view->FillEllipse(center, radius, radius, g);
|
view->FillEllipse(center, radius, radius, g);
|
||||||
|
|
||||||
// Linear gradient
|
// Linear gradient - Horizontal
|
||||||
BPoint from(100, 0);
|
BPoint from(100, 0);
|
||||||
BPoint to(200, 0);
|
BPoint to(200, 0);
|
||||||
BGradientLinear l(from, to);
|
BGradientLinear l(from, to);
|
||||||
@@ -100,6 +101,15 @@ public:
|
|||||||
l.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0);
|
l.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0);
|
||||||
view->FillRect(BRect(100, 0, 200, 100), l);
|
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
|
// These draw as opaque or almost opaque
|
||||||
|
|
||||||
view->SetOrigin(BPoint(0, 100));
|
view->SetOrigin(BPoint(0, 100));
|
||||||
@@ -110,11 +120,39 @@ public:
|
|||||||
go.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0);
|
go.AddColor((rgb_color){ 0, 255, 0, 255 }, 255.0);
|
||||||
view->FillEllipse(center, radius, radius, go);
|
view->FillEllipse(center, radius, radius, go);
|
||||||
|
|
||||||
// Linear gradient
|
// Linear gradient - Horizontal
|
||||||
BGradientLinear lo(from, to);
|
BGradientLinear lo(from, to);
|
||||||
lo.AddColor((rgb_color){ 255, 0, 0, 255 }, 0.0);
|
lo.AddColor((rgb_color){ 255, 0, 0, 255 }, 0.0);
|
||||||
lo.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0);
|
lo.AddColor((rgb_color){ 0, 255, 0, 0 }, 255.0);
|
||||||
view->FillRect(BRect(100, 0, 200, 100), lo);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user