added a test showing the R5 bug that ignores the internal coordinate
system given by BBitmap::Bounds() when drawing bitmaps (Haiku copies this bug) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18022 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -142,13 +142,16 @@ HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : haiku_app_server
|
|||||||
|
|
||||||
} # if $(TARGET_PLATFORM) = libbe_test
|
} # if $(TARGET_PLATFORM) = libbe_test
|
||||||
|
|
||||||
|
SubInclude HAIKU_TOP src tests servers app archived_view ;
|
||||||
SubInclude HAIKU_TOP src tests servers app avoid_focus ;
|
SubInclude HAIKU_TOP src tests servers app avoid_focus ;
|
||||||
|
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 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 ;
|
||||||
SubInclude HAIKU_TOP src tests servers app desktop_window ;
|
SubInclude HAIKU_TOP src tests servers app desktop_window ;
|
||||||
SubInclude HAIKU_TOP src tests servers app event_mask ;
|
SubInclude HAIKU_TOP src tests servers app event_mask ;
|
||||||
|
SubInclude HAIKU_TOP src tests servers app first_show ;
|
||||||
SubInclude HAIKU_TOP src tests servers app following ;
|
SubInclude HAIKU_TOP src tests servers app following ;
|
||||||
SubInclude HAIKU_TOP src tests servers app look_and_feel ;
|
SubInclude HAIKU_TOP src tests servers app look_and_feel ;
|
||||||
SubInclude HAIKU_TOP src tests servers app painter ;
|
SubInclude HAIKU_TOP src tests servers app painter ;
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
SubDir HAIKU_TOP src tests servers app bitmap_bounds ;
|
||||||
|
|
||||||
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
AddSubDirSupportedPlatforms libbe_test ;
|
||||||
|
|
||||||
|
UseHeaders [ FDirName os app ] ;
|
||||||
|
UseHeaders [ FDirName os interface ] ;
|
||||||
|
|
||||||
|
SimpleTest BitmapBounds :
|
||||||
|
main.cpp
|
||||||
|
: be ;
|
||||||
|
|
||||||
|
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||||
|
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : BitmapBounds
|
||||||
|
: tests!apps ;
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
// main.cpp
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
class TestView : public BView {
|
||||||
|
|
||||||
|
public:
|
||||||
|
TestView(BRect frame, const char* name,
|
||||||
|
uint32 resizeFlags, uint32 flags);
|
||||||
|
|
||||||
|
virtual void Draw(BRect updateRect);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BBitmap* fBitmap;
|
||||||
|
};
|
||||||
|
|
||||||
|
//#define LEFT_OFFSET 0
|
||||||
|
//#define TOP_OFFSET 0
|
||||||
|
#define LEFT_OFFSET 30
|
||||||
|
#define TOP_OFFSET 30
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
TestView::TestView(BRect frame, const char* name,
|
||||||
|
uint32 resizeFlags, uint32 flags)
|
||||||
|
: BView(frame, name, resizeFlags, flags),
|
||||||
|
|
||||||
|
fBitmap(new BBitmap(BRect(0 + LEFT_OFFSET,
|
||||||
|
0 + TOP_OFFSET,
|
||||||
|
99 + LEFT_OFFSET,
|
||||||
|
99 + TOP_OFFSET),
|
||||||
|
B_BITMAP_CLEAR_TO_WHITE,
|
||||||
|
B_RGB32))
|
||||||
|
{
|
||||||
|
SetViewColor(216, 216, 216);
|
||||||
|
|
||||||
|
uint8* bits = (uint8*)fBitmap->Bits();
|
||||||
|
uint32 width = fBitmap->Bounds().IntegerWidth() + 1;
|
||||||
|
uint32 height = fBitmap->Bounds().IntegerHeight() + 1;
|
||||||
|
uint32 bpr = fBitmap->BytesPerRow();
|
||||||
|
|
||||||
|
// top row -> red
|
||||||
|
uint8* b = bits;
|
||||||
|
for (uint32 x = 0; x < width; x++) {
|
||||||
|
b[0] = 0;
|
||||||
|
b[1] = 0;
|
||||||
|
b += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// left/right edge pixels -> red
|
||||||
|
b = bits + bpr;
|
||||||
|
for (uint32 y = 1; y < height - 1; y++) {
|
||||||
|
b[0] = 0;
|
||||||
|
b[1] = 0;
|
||||||
|
b[(width - 1) * 4 + 0] = 0;
|
||||||
|
b[(width - 1) * 4 + 1] = 0;
|
||||||
|
b += bpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// bottom row -> red
|
||||||
|
for (uint32 x = 0; x < width; x++) {
|
||||||
|
b[0] = 0;
|
||||||
|
b[1] = 0;
|
||||||
|
b += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
void
|
||||||
|
TestView::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
// DrawBitmap(BBitmap*, BRect source, BRect destination);
|
||||||
|
//
|
||||||
|
// BeBook:
|
||||||
|
// If a source rectangle is given, only that part of the
|
||||||
|
// bitmap image is drawn. Otherwise, the entire bitmap
|
||||||
|
// is placed in the view. The source rectangle is stated
|
||||||
|
// in the internal coordinates of the BBitmap object.
|
||||||
|
|
||||||
|
// Test 1:
|
||||||
|
// if the above was true, then we should see the left
|
||||||
|
// top area of the bitmap...
|
||||||
|
// BRect view(0, 0, 50, 50);
|
||||||
|
// BRect bitmap = view.OffsetByCopy(fBitmap->Bounds().LeftTop());
|
||||||
|
//
|
||||||
|
// DrawBitmap(fBitmap, bitmap, view);
|
||||||
|
|
||||||
|
// Test 2:
|
||||||
|
// if the above was true, we should simply see the entire
|
||||||
|
// bitmap at the left top corner of the view
|
||||||
|
BRect bitmap = fBitmap->Bounds();
|
||||||
|
BRect view = bitmap.OffsetToCopy(B_ORIGIN);
|
||||||
|
|
||||||
|
DrawBitmap(fBitmap, bitmap, view);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// show_window
|
||||||
|
void
|
||||||
|
show_window(BRect frame, const char* name)
|
||||||
|
{
|
||||||
|
BWindow* window = new BWindow(frame, name,
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
// main
|
||||||
|
int
|
||||||
|
main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
BApplication* app = new BApplication(
|
||||||
|
"application/x.vnd-Haiku.BitmapBounds");
|
||||||
|
|
||||||
|
BRect frame(50.0, 50.0, 300.0, 250.0);
|
||||||
|
show_window(frame, "Bitmap-Bounds Test");
|
||||||
|
|
||||||
|
app->Run();
|
||||||
|
|
||||||
|
delete app;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
#!/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=libbe_test jam install-test-apps\" first."
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 1s
|
||||||
|
|
||||||
|
if test -f ../../../../../generated/tests/libbe_test/x86/apps/BitmapBounds; then
|
||||||
|
../../../../../generated/tests/libbe_test/x86/apps/BitmapBounds
|
||||||
|
else
|
||||||
|
echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first."
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user