From f8a63d3a0b80a9f051dff66ce7310c5226fb3dc1 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 9 Sep 2008 13:28:30 +0000 Subject: [PATCH] non 32 bit offscreen bitmaps were never cleared to white, due to the way they currently work: when the offscreen window is created, the current content of the bitmap is copied to the back buffer, and since the clearing came later, it was never copied to it. This fixes the problem with FlattenPictureTest not working correctly for colorspace different than RGB(A)32. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27389 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Bitmap.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/kits/interface/Bitmap.cpp b/src/kits/interface/Bitmap.cpp index a34d776298..227bafb187 100644 --- a/src/kits/interface/Bitmap.cpp +++ b/src/kits/interface/Bitmap.cpp @@ -1055,16 +1055,6 @@ BBitmap::_InitObject(BRect bounds, color_space colorSpace, uint32 flags, fInitError = error; if (fInitError == B_OK) { - if (flags & B_BITMAP_ACCEPTS_VIEWS) { - fWindow = new(std::nothrow) BWindow(Bounds(), fServerToken); - if (fWindow) { - // A BWindow starts life locked and is unlocked - // in Show(), but this window is never shown and - // it's message loop is never started. - fWindow->Unlock(); - } else - fInitError = B_NO_MEMORY; - } // clear to white if the flags say so. if (flags & (B_BITMAP_CLEAR_TO_WHITE | B_BITMAP_ACCEPTS_VIEWS)) { if (fColorSpace == B_CMAP8) { @@ -1076,6 +1066,20 @@ BBitmap::_InitObject(BRect bounds, color_space colorSpace, uint32 flags, memset(fBasePointer, 0xff, fSize); } } + // TODO: Creating an offscreen window with a non32 bit bitmap + // copies the current content of the bitmap to a back buffer. + // So at this point the bitmap has to be already cleared to white. + // Better move the above code to the server so the problem looks more clear. + if (flags & B_BITMAP_ACCEPTS_VIEWS) { + fWindow = new(std::nothrow) BWindow(Bounds(), fServerToken); + if (fWindow) { + // A BWindow starts life locked and is unlocked + // in Show(), but this window is never shown and + // it's message loop is never started. + fWindow->Unlock(); + } else + fInitError = B_NO_MEMORY; + } } }