A test I am currently working on which is supposed to behave a bit like
Firefox. It stores the active clipping region of a view when Draw() is invoked, and uses that for asynchronous drawing. The test already shows a couple of problems. When PushState() / PopState() is used, it is not equivalent to ConstrainClippingRegion(&someRegion) / ConstrainClippingRegion(NULL). Another problem shows when adding delays (currently disabled), there should not be any difference, regardless of how much delay is inserted into the asynchronous drawing. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25150 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b35b070b59
commit
cda5b8808f
17
src/tests/servers/app/async_drawing/Jamfile
Normal file
17
src/tests/servers/app/async_drawing/Jamfile
Normal file
@ -0,0 +1,17 @@
|
||||
SubDir HAIKU_TOP src tests servers app scrollbar ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
AddSubDirSupportedPlatforms libbe_test ;
|
||||
|
||||
UseHeaders [ FDirName os app ] ;
|
||||
UseHeaders [ FDirName os interface ] ;
|
||||
|
||||
SimpleTest AsyncDrawing :
|
||||
main.cpp
|
||||
: be ;
|
||||
|
||||
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : AsyncDrawing
|
||||
: tests!apps ;
|
||||
}
|
||||
|
120
src/tests/servers/app/async_drawing/main.cpp
Normal file
120
src/tests/servers/app/async_drawing/main.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <Region.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
|
||||
enum {
|
||||
MSG_REDRAW = 'shhd'
|
||||
};
|
||||
|
||||
#define TEST_DELAYS 0
|
||||
|
||||
class View : public BView {
|
||||
public:
|
||||
View(BRect frame, uint8 r, uint8 g, uint8 b, uint8 a)
|
||||
: BView(frame, "view", B_FOLLOW_ALL, B_WILL_DRAW)
|
||||
{
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
SetHighColor(r, g, b, a);
|
||||
}
|
||||
|
||||
virtual void Draw(BRect updateRect)
|
||||
{
|
||||
BRegion region;
|
||||
GetClippingRegion(®ion);
|
||||
BMessage message(MSG_REDRAW);
|
||||
int32 count = region.CountRects();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
message.AddRect("rect", region.RectAt(i));
|
||||
be_app->PostMessage(&message);
|
||||
}
|
||||
|
||||
void AsyncRedraw(BRegion& region)
|
||||
{
|
||||
if (!LockLooper())
|
||||
return;
|
||||
|
||||
#if 0
|
||||
ConstrainClippingRegion(®ion);
|
||||
FillRect(Bounds());
|
||||
ConstrainClippingRegion(NULL);
|
||||
#else
|
||||
PushState();
|
||||
ConstrainClippingRegion(®ion);
|
||||
FillRect(Bounds());
|
||||
PopState();
|
||||
#endif
|
||||
|
||||
UnlockLooper();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Application : public BApplication {
|
||||
public:
|
||||
Application()
|
||||
: BApplication("application/x-vnd.stippi-async.drawing")
|
||||
, fDelay(true)
|
||||
{
|
||||
BWindow* window = new BWindow(BRect(50, 50, 350, 250),
|
||||
"Test Window", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_QUIT_ON_WINDOW_CLOSE);
|
||||
fView = new View(window->Bounds(), 255, 80, 155, 128);
|
||||
window->AddChild(fView);
|
||||
window->Show();
|
||||
|
||||
window = new BWindow(BRect(150, 150, 450, 350),
|
||||
"Drag Window", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_QUIT_ON_WINDOW_CLOSE);
|
||||
window->Show();
|
||||
|
||||
SetPulseRate(100000);
|
||||
}
|
||||
|
||||
virtual void Pulse()
|
||||
{
|
||||
fDelay = true;
|
||||
}
|
||||
|
||||
virtual void MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case MSG_REDRAW:
|
||||
{
|
||||
#if TEST_DELAYS
|
||||
if (fDelay) {
|
||||
snooze(200000);
|
||||
fDelay = false;
|
||||
}
|
||||
#endif
|
||||
BRegion region;
|
||||
BRect rect;
|
||||
for (int32 i = 0;
|
||||
message->FindRect("rect", i, &rect) == B_OK; i++)
|
||||
region.Include(rect);
|
||||
fView->AsyncRedraw(region);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private:
|
||||
View* fView;
|
||||
bool fDelay;
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
Application app;
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
18
src/tests/servers/app/async_drawing/run
Normal file
18
src/tests/servers/app/async_drawing/run
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
../../../../../generated/tests/libbe_test/x86/apps/run_haiku_registrar || exit
|
||||
|
||||
if test -f ../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then
|
||||
../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server &
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
fi
|
||||
|
||||
sleep 1s
|
||||
|
||||
if test -f ../../../../../generated/tests/libbe_test/x86/apps/AsyncDrawing; then
|
||||
../../../../../generated/tests/libbe_test/x86/apps/AsyncDrawing
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user