Add test for ClipToPicture
This draws a rect clipped by a text, and a text clipped by a rect. They should look the same, but they don't because of lack of antialiasing support in ClipToPicture.
This commit is contained in:
@@ -202,6 +202,7 @@ SubInclude HAIKU_TOP src tests servers app benchmark ;
|
|||||||
SubInclude HAIKU_TOP src tests servers app bitmap_bounds ;
|
SubInclude HAIKU_TOP src tests servers app bitmap_bounds ;
|
||||||
SubInclude HAIKU_TOP src tests servers app bitmap_drawing ;
|
SubInclude HAIKU_TOP src tests servers app bitmap_drawing ;
|
||||||
SubInclude HAIKU_TOP src tests servers app code_to_name ;
|
SubInclude HAIKU_TOP src tests servers app code_to_name ;
|
||||||
|
SubInclude HAIKU_TOP src tests servers app clip_to_picture ;
|
||||||
SubInclude HAIKU_TOP src tests servers app constrain_clipping_region ;
|
SubInclude HAIKU_TOP src tests servers app constrain_clipping_region ;
|
||||||
SubInclude HAIKU_TOP src tests servers app copy_bits ;
|
SubInclude HAIKU_TOP src tests servers app copy_bits ;
|
||||||
SubInclude HAIKU_TOP src tests servers app cursor_test ;
|
SubInclude HAIKU_TOP src tests servers app cursor_test ;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
SubDir HAIKU_TOP src tests servers app clip_to_picture ;
|
||||||
|
|
||||||
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
AddSubDirSupportedPlatforms libbe_test ;
|
||||||
|
|
||||||
|
UseHeaders [ FDirName os app ] ;
|
||||||
|
UseHeaders [ FDirName os interface ] ;
|
||||||
|
|
||||||
|
SimpleTest ClipToPicture :
|
||||||
|
main.cpp
|
||||||
|
: be $(TARGET_LIBSUPC++)
|
||||||
|
;
|
||||||
|
|
||||||
|
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||||
|
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : ClipToPicture
|
||||||
|
: tests!apps ;
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Picture.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
static const char* kAppSignature = "application/x.vnd-Haiku.ShapeTest";
|
||||||
|
|
||||||
|
|
||||||
|
class TestView : public BView {
|
||||||
|
public:
|
||||||
|
TestView(BRect frame, const char* name,
|
||||||
|
uint32 resizeFlags, uint32 flags);
|
||||||
|
void AttachedToWindow();
|
||||||
|
|
||||||
|
virtual void Draw(BRect updateRect);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
TestView::TestView(BRect frame, const char* name, uint32 resizeFlags,
|
||||||
|
uint32 flags)
|
||||||
|
:
|
||||||
|
BView(frame, name, resizeFlags, flags)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TestView::AttachedToWindow()
|
||||||
|
{
|
||||||
|
BPicture picture;
|
||||||
|
|
||||||
|
BeginPicture(&picture);
|
||||||
|
DrawString("Hello World! - Clipping", BPoint(10, 10));
|
||||||
|
|
||||||
|
FillRect(BRect(0, 20, 400, 40));
|
||||||
|
EndPicture();
|
||||||
|
|
||||||
|
ClipToPicture(&picture);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TestView::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); // opaque black.
|
||||||
|
DrawString("Hello World! - Clipped", BPoint(10, 30));
|
||||||
|
FillRect(BRect(0, 0, 200, 20));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
BApplication app(kAppSignature);
|
||||||
|
|
||||||
|
BWindow* window = new BWindow(BRect(50.0, 50.0, 300.0, 250.0),
|
||||||
|
"ClipToPicture Test", B_TITLED_WINDOW,
|
||||||
|
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
|
||||||
|
|
||||||
|
BView* view = new TestView(window->Bounds(), "test", B_FOLLOW_ALL,
|
||||||
|
B_WILL_DRAW);
|
||||||
|
window->AddChild(view);
|
||||||
|
|
||||||
|
window->Show();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user