added libbeadapter.so (used by the storage kit and the haiku regisrar) to the test libs, it just went unnoticed before

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15530 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-12-13 19:08:18 +00:00
parent f104fa77bd
commit 040ce75726
10 changed files with 325 additions and 26 deletions
+3 -2
View File
@@ -131,8 +131,9 @@ Server haiku_app_server :
# install in the test dir
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_LIB_DIR)
: libpng.so libhaikuappserver.so libbe_haiku.so libhwinterface.so
libhwinterfaceimpl.so libfreetype.so libtextencoding.so
: libpng.so libhaikuappserver.so libbe_haiku.so libbeadapter.so
libhwinterface.so libhwinterfaceimpl.so libfreetype.so
libtextencoding.so
: tests!apps ;
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : haiku_app_server
+4
View File
@@ -10,3 +10,7 @@ SimpleTest CopyBits :
main.cpp
: be ;
if ( $(TARGET_PLATFORM) = libbe_test ) {
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : CopyBits
: tests!apps ;
}
Binary file not shown.
+199 -8
View File
@@ -56,7 +56,7 @@ App::ReadyToRun()
Window* win = new Window("clipping");
win->Show();
win->Test();
// win->Test();
}
// constructor
@@ -88,40 +88,231 @@ Window::~Window()
bool
Window::QuitRequested()
{
if (!fQuit) {
/* if (!fQuit) {
fDesktop->PostMessage(MSG_QUIT);
fQuit = true;
return false;
}
}*/
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
// #pragma mark -
void
fill_line_8(uint8* buffer, int32 pixels, uint8 r, uint8 g, uint8 b)
{
for (int32 i = 0; i < pixels; i++) {
*buffer++ = b;
*buffer++ = g;
*buffer++ = r;
*buffer++ = 255;
}
}
void
fill_line_32(uint8* buffer, int32 pixels, uint8 r, uint8 g, uint8 b)
{
uint32 pixel;
uint32* handle = (uint32*)buffer;
for (int32 i = 0; i < pixels; i++) {
pixel = 0xff000000 | (r << 16) | (g << 8) | (b);
*handle++ = pixel;
}
}
void
fill_line_64(uint8* buffer, int32 pixels, uint8 r, uint8 g, uint8 b)
{
uint64 pixel;
uint64* handle = (uint64*)buffer;
pixels /= 2;
for (int32 i = 0; i < pixels; i++) {
pixel = 0xff000000 | (r << 16) | (g << 8) | (b);
pixel = pixel << 32;
pixel |= 0xff000000 | (r << 16) | (g << 8) | (b);
*handle++ = pixel;
}
}
void
test1(uint8* buffer, uint32 bpr)
{
uint8* handle = buffer;
/* bigtime_t start8 = system_time();
for (int32 x = 0; x < 1000; x++) {
handle = buffer;
for (int32 i = 0; i < 64; i++) {
fill_line_8(handle, 512, 255, 0, 255);
handle += bpr;
}
}
bigtime_t start32 = system_time();
for (int32 x = 0; x < 1000; x++) {
handle = buffer;
for (int32 i = 0; i < 64; i++) {
fill_line_32(handle, 512, 255, 0, 255);
handle += bpr;
}
}
bigtime_t start64 = system_time();
for (int32 x = 0; x < 1000; x++) {*/
handle = buffer;
for (int32 i = 0; i < 640; i++) {
fill_line_64(handle, 512, 0, 255, 255);
handle += bpr;
}
/* }
bigtime_t finish = system_time();
printf("8: %lld\n", start32 - start8);
printf("32: %lld\n", start64 - start32);
printf("64: %lld\n", finish - start64);*/
}
// #pragma mark -
void
blend_line_8(uint8* buffer, int32 pixels, uint8 r, uint8 g, uint8 b, uint8 a)
{
for (int32 i = 0; i < pixels; i++) {
buffer[0] = ((b - buffer[0]) * a + (buffer[0] << 8)) >> 8;
buffer[1] = ((g - buffer[1]) * a + (buffer[1] << 8)) >> 8;
buffer[2] = ((r - buffer[2]) * a + (buffer[2] << 8)) >> 8;;
buffer[3] = a;
buffer += 4;
}
}
union pixel {
uint32 data32;
uint8 data8[4];
};
void
blend_line_32(uint8* buffer, int32 pixels, uint8 r, uint8 g, uint8 b, uint8 a)
{
pixel p;
pixels /= 2;
for (int32 i = 0; i < pixels; i++) {
p.data32 = *(uint32*)buffer;
p.data8[0] = ((b - p.data8[0]) * a + (p.data8[0] << 8)) >> 8;
p.data8[1] = ((g - p.data8[1]) * a + (p.data8[1] << 8)) >> 8;
p.data8[2] = ((r - p.data8[2]) * a + (p.data8[2] << 8)) >> 8;
p.data8[3] = 255;
*((uint32*)buffer) = p.data32;
buffer += 4;
p.data32 = *(uint32*)buffer;
p.data8[0] = ((b - p.data8[0]) * a + (p.data8[0] << 8)) >> 8;
p.data8[1] = ((g - p.data8[1]) * a + (p.data8[1] << 8)) >> 8;
p.data8[2] = ((r - p.data8[2]) * a + (p.data8[2] << 8)) >> 8;
p.data8[3] = 255;
*((uint32*)buffer) = p.data32;
buffer += 4;
}
}
union pixel2 {
uint64 data64;
uint8 data8[8];
};
void
blend_line_64(uint8* buffer, int32 pixels, uint8 r, uint8 g, uint8 b, uint8 a)
{
pixel2 p;
pixels /= 2;
for (int32 i = 0; i < pixels; i++) {
p.data64 = *(uint64*)buffer;
p.data8[0] = ((b - p.data8[0]) * a + (p.data8[0] << 8)) >> 8;
p.data8[1] = ((g - p.data8[1]) * a + (p.data8[1] << 8)) >> 8;
p.data8[2] = ((r - p.data8[2]) * a + (p.data8[2] << 8)) >> 8;
p.data8[3] = a;
p.data8[4] = ((b - p.data8[4]) * a + (p.data8[4] << 8)) >> 8;
p.data8[5] = ((g - p.data8[5]) * a + (p.data8[5] << 8)) >> 8;
p.data8[6] = ((r - p.data8[6]) * a + (p.data8[6] << 8)) >> 8;
p.data8[7] = a;
*((uint64*)buffer) = p.data64;
buffer += 8;
}
}
void
test2(uint8* buffer, uint32 bpr)
{
uint8* handle = buffer;
/* bigtime_t start8 = system_time();
// for (int32 x = 0; x < 10; x++) {
handle = buffer;
for (int32 i = 0; i < 64; i++) {
blend_line_8(handle, 512, 255, 0, 0, 20);
handle += bpr;
}
// }
bigtime_t start32 = system_time();
// for (int32 x = 0; x < 10; x++) {
handle = buffer;
for (int32 i = 0; i < 64; i++) {
blend_line_32(handle, 512, 255, 0, 0, 20);
handle += bpr;
}
// }
bigtime_t start64 = system_time();*/
// for (int32 x = 0; x < 10; x++) {
handle = buffer;
for (int32 i = 0; i < 640; i++) {
blend_line_64(handle, 512, 255, 0, 0, 200);
handle += bpr;
}
// }
/* bigtime_t finish = system_time();
printf("8: %lld\n", start32 - start8);
printf("32: %lld\n", start64 - start32);
printf("64: %lld\n", finish - start64);*/
}
// #pragma mark -
// DirectConnected
void
Window::DirectConnected(direct_buffer_info* info)
{
// TODO: for some reason, this deadlocks
// on B_DIRECT_STOP... be aware
fDesktop->LockClipping();
// fDesktop->LockClipping();
fEngine.Lock();
// fEngine.Lock();
switch(info->buffer_state & B_DIRECT_MODE_MASK) {
case B_DIRECT_START:
case B_DIRECT_MODIFY:
fBuffer.SetTo(info);
fDesktop->SetOffset(info->window_bounds.left, info->window_bounds.top);
test1((uint8*)info->bits, info->bytes_per_row);
break;
case B_DIRECT_STOP:
fBuffer.SetTo(NULL);
break;
}
fDesktop->SetMasterClipping(&fBuffer.WindowClipping());
// fDesktop->SetMasterClipping(&fBuffer.WindowClipping());
fEngine.Unlock();
// fEngine.Unlock();
fDesktop->UnlockClipping();
// fDesktop->UnlockClipping();
}
// AddWindow
@@ -2,7 +2,10 @@
#include <stdio.h>
#include <Bitmap.h>
#include <Message.h>
#include <Region.h>
#include <Shape.h>
#include <String.h>
#include <Window.h>
@@ -22,6 +25,7 @@ ObjectView::ObjectView(BRect frame, const char* name,
fFill(false),
fPenSize(10.0),
fScrolling(false),
fInitiatingDrag(false),
fLastMousePos(0.0, 0.0)
{
@@ -73,16 +77,32 @@ ObjectView::Draw(BRect updateRect)
DrawString(message, p);
message = "to draw an object!";
width = StringWidth(message);
message = "to draw an ";
width = StringWidth("to draw an object");
p.x = r.Width() / 2.0 - width / 2.0;
p.y += 25;
DrawString(message, p);
SetDrawingMode(B_OP_ALPHA);
// SetOrigin(BPoint(50.0, 50.0));
// SetScale(0.5);
DrawChar('o');
DrawChar('b');
DrawChar('j');
DrawChar('e');
DrawChar('c');
DrawChar('t');
DrawChar('!');
// SetHighColor(0, 0, 0);
// StrokeLine(BPoint(-50, -50), BPoint(0.0, 0.0));
for (int32 i = 0; State* state = (State*)fStateList.ItemAt(i); i++)
state->Draw(this);
}
// MouseDown
@@ -93,12 +113,13 @@ ObjectView::MouseDown(BPoint where)
int32 clicks;
Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
Window()->CurrentMessage()->FindInt32("clicks", &clicks);
printf("ObjectView::MouseDown() - clicks: %ld\n", clicks);
//printf("ObjectView::MouseDown() - clicks: %ld\n", clicks);
fScrolling = buttons & B_SECONDARY_MOUSE_BUTTON;
fInitiatingDrag = !fScrolling && (buttons & B_TERTIARY_MOUSE_BUTTON);
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
if (fScrolling) {
if (fScrolling || fInitiatingDrag) {
fLastMousePos = where;
} else {
if (!fState)
@@ -131,10 +152,28 @@ void
ObjectView::MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage)
{
if (dragMessage) {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f)) - DRAG MESSAGE\n", where.x, where.y);
//Window()->CurrentMessage()->PrintToStream();
} else {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f))\n", where.x, where.y);
}
if (fScrolling) {
BPoint offset = fLastMousePos - where;
ScrollBy(offset.x, offset.y);
fLastMousePos = where + offset;
} else if (fInitiatingDrag) {
BPoint offset = fLastMousePos - where;
if (sqrtf(offset.x * offset.x + offset.y * offset.y) > 5.0) {
BMessage dragMessage('drag');
BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 20, 20), B_RGBA32);
memset(dragBitmap->Bits(), 128, dragBitmap->BitsLength());
DragMessage(&dragMessage, dragBitmap, B_OP_ALPHA, B_ORIGIN, this);
fInitiatingDrag = false;
}
} else {
if (fState && fState->IsTracking()) {
BRect before = fState->Bounds();
@@ -148,6 +187,20 @@ ObjectView::MouseMoved(BPoint where, uint32 transit,
}
}
// MessageReceived
void
ObjectView::MessageReceived(BMessage* message)
{
switch (message->what) {
case 'drag':
printf("ObjectView::MessageReceived() - received drag message\n");
break;
default:
BView::MessageReceived(message);
break;
}
}
// SetState
void
ObjectView::SetState(State* state)
@@ -27,6 +27,8 @@ class ObjectView : public BView {
virtual void MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage);
virtual void MessageReceived(BMessage* message);
// ObjectView
void SetState(State* state);
@@ -66,6 +68,7 @@ class ObjectView : public BView {
float fPenSize;
bool fScrolling;
bool fInitiatingDrag;
BPoint fLastMousePos;
};
@@ -5,9 +5,12 @@
#include <Application.h>
#include <Alert.h>
#include <Bitmap.h>
#include <Box.h>
#include <Button.h>
#include <CheckBox.h>
#include <ListItem.h>
#include <ListView.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MenuField.h>
@@ -18,6 +21,7 @@
#include <Slider.h>
#include <String.h>
#include <RadioButton.h>
#include <TabView.h>
#include <TextControl.h>
#include <TextView.h>
@@ -43,9 +47,11 @@ enum {
// constructor
ObjectWindow::ObjectWindow(BRect frame, const char* name)
: BWindow(frame, name, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
: BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
// : BWindow(frame, name, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
// B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
// : BWindow(frame, name, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
// B_ASYNCHRONOUS_CONTROLS)
// : BWindow(frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
// B_ASYNCHRONOUS_CONTROLS)
@@ -69,7 +75,7 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
b = Bounds();
b.top = menuBar->Bounds().bottom + 1;
b.right = ceilf((b.left + b.right) / 3.0);
b.right = ceilf((b.left + b.right) / 2.0);
BBox* bg = new BBox(b, "bg box", B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW, B_PLAIN_BORDER);
AddChild(bg);
@@ -89,10 +95,12 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
if (BScrollBar* scrollBar = fObjectView->ScrollBar(B_VERTICAL)) {
scrollBar->SetRange(0.0, fObjectView->Bounds().Height());
scrollBar->SetProportion(0.5);
// scrollBar->SetRange(0.0, 0.0);
}
if (BScrollBar* scrollBar = fObjectView->ScrollBar(B_HORIZONTAL)) {
scrollBar->SetRange(0.0, fObjectView->Bounds().Width());
scrollBar->SetProportion(0.5);
// scrollBar->SetRange(0.0, 0.0);
}
AddChild(scrollView);
@@ -109,10 +117,12 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
b.top += 10.0;
b.bottom = b.top + 25.0;
b.InsetBy(5.0, 5.0);
b.right = b.left + b.Width() / 2.0 - 3.0;
// new button
fNewB = new BButton(b, "new button", "New Object", new BMessage(MSG_NEW_OBJECT));
controlGroup->AddChild(fNewB);
SetDefaultButton(fNewB);
// clear button
b.OffsetBy(0, fNewB->Bounds().Height() + 5.0);
@@ -194,7 +204,9 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
message = new BMessage(MSG_SET_DRAWING_MODE);
message->AddInt32("mode", B_OP_ALPHA);
popupMenu->AddItem(new BMenuItem("Alpha", message));
BMenuItem* item = new BMenuItem("Alpha", message);
item->SetMarked(true);
popupMenu->AddItem(item);
b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode",
@@ -228,9 +240,6 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
new BMessage(MSG_SET_COLOR));
controlGroup->AddChild(fAlphaTC);
// TODO: while this block of code works in the Haiku app_server running under R5,
// it crashes pretty badly under Haiku. I have no idea why this happens, because
// I was doing the same thing before at other places.
// divide text controls the same
float mWidth = fDrawingModeMF->StringWidth(fDrawingModeMF->Label());
float rWidth = fRedTC->StringWidth(fRedTC->Label());
@@ -263,12 +272,28 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
controlGroup->AddChild(fPenSizeS);
// list view with objects
b = controlGroup->Bounds();
b.top += 10.0;
b.InsetBy(9.0, 7.0);
b.left = b.left + b.Width() / 2.0 + 6.0;
b.right = b.right - B_V_SCROLL_BAR_WIDTH;
b.bottom = fDrawingModeMF->Frame().top - 5.0;
fObjectLV = new BListView(b, "object list", B_MULTIPLE_SELECTION_LIST);
// wrap a scroll view around the list view
scrollView = new BScrollView("list scroller", fObjectLV,
B_FOLLOW_NONE, 0, false, true,
B_FANCY_BORDER);
controlGroup->AddChild(scrollView);
// enforce some size limits
float minWidth = controlGroup->Frame().Width() + 30.0;
float minHeight = fPenSizeS->Frame().bottom +
menuBar->Bounds().Height() + 15.0;
float maxWidth = minWidth * 4.0;
float maxHeight = minHeight;
float maxHeight = minHeight + 100;
SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
ResizeTo(max_c(frame.Width(), minWidth), max_c(frame.Height(), minHeight));
@@ -318,9 +343,21 @@ ObjectWindow::MessageReceived(BMessage* message)
fObjectView->SetStateColor(_GetColor());
_UpdateColorControls();
break;
case MSG_OBJECT_COUNT_CHANGED:
fClearB->SetEnabled(fObjectView->CountObjects() > 0);
case MSG_OBJECT_COUNT_CHANGED: {
int32 count = fObjectView->CountObjects();
//printf("MSG_OBJECT_COUNT_CHANGED: %ld\n", count);
fClearB->SetEnabled(count > 0);
int32 listCount = fObjectLV->CountItems();
int32 diff = count - listCount;
if (diff >= 0) {
for (int32 i = 0; i < diff; i++)
fObjectLV->AddItem(new BStringItem("Object"));
} else {
for (int32 i = listCount - 1; i >= count; i--)
delete fObjectLV->RemoveItem(i);
}
break;
}
case MSG_NEW_OBJECT:
fObjectView->SetState(NULL);
break;
@@ -7,6 +7,7 @@
class BButton;
class BCheckBox;
class BListView;
class BMenuField;
class BTextControl;
class BSlider;
@@ -43,6 +44,8 @@ class ObjectWindow : public BWindow {
BCheckBox* fFillCB;
BSlider* fPenSizeS;
BListView* fObjectLV;
};
#endif // OBJECT_WINDOW_H
+1 -1
View File
@@ -10,7 +10,7 @@ main(int argc, char** argv)
{
BApplication* app = new BApplication("application/x.vnd-Haiku.Objects");
BRect frame(50.0, 50.0, 450.0, 400.0);
BRect frame(50.0, 50.0, 600.0, 400.0);
(new ObjectWindow(frame, "Playground"))->Show();
app->Run();
+8 -1
View File
@@ -10,8 +10,15 @@ fi
sleep 1s
#if test -f ../../../../../generated/tests/apps/MiniTerminal; then
# ../../../../../generated/tests/apps/MiniTerminal &
#else
# echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
#fi
if test -f ../../../../../generated/tests/apps/Playground; then
../../../../../generated/tests/apps//Playground
../../../../../generated/tests/apps/Playground
else
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
fi