From 644c29d069d2feed9c6f1396963ab7c96654b6de Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 7 Jan 2022 22:05:00 -0500 Subject: [PATCH] Adjust all in-tree applications after BBitmap::ImportBits API changes. Change-Id: If3a06f35c01089cdbb696de479984f2b59fce7a0 --- src/apps/remotedesktop/RemoteView.cpp | 3 +-- src/apps/screenshot/Screenshot.cpp | 12 ++++------ src/apps/screenshot/Utility.cpp | 29 +++++------------------ src/kits/tracker/Bitmaps.cpp | 2 +- src/servers/app/drawing/DrawingEngine.cpp | 2 +- src/servers/registrar/ShutdownProcess.cpp | 2 +- 6 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/apps/remotedesktop/RemoteView.cpp b/src/apps/remotedesktop/RemoteView.cpp index 74e269bc0e..0f1c742bd2 100644 --- a/src/apps/remotedesktop/RemoteView.cpp +++ b/src/apps/remotedesktop/RemoteView.cpp @@ -1293,8 +1293,7 @@ RemoteView::_DrawThread() // TODO: support the drawCursor flag BBitmap bitmap(bounds, B_BITMAP_NO_SERVER_LINK, B_RGB32); bitmap.ImportBits(fOffscreenBitmap, bounds.LeftTop(), - BPoint(0, 0), bounds.IntegerWidth() + 1, - bounds.IntegerHeight() + 1); + BPoint(0, 0), bounds.Size()); reply.Start(RP_READ_BITMAP_RESULT); reply.Add(token); diff --git a/src/apps/screenshot/Screenshot.cpp b/src/apps/screenshot/Screenshot.cpp index d9b4f57ad1..505d5257cc 100644 --- a/src/apps/screenshot/Screenshot.cpp +++ b/src/apps/screenshot/Screenshot.cpp @@ -224,20 +224,16 @@ Screenshot::_New(bigtime_t delay) // Put the mouse area in a bitmap BRect bounds = fUtility->cursorBitmap->Bounds(); - int cursorWidth = bounds.IntegerWidth() + 1; - int cursorHeight = bounds.IntegerHeight() + 1; fUtility->cursorAreaBitmap = new BBitmap(bounds, B_RGBA32); - fUtility->cursorAreaBitmap->ImportBits(fUtility->wholeScreen->Bits(), - fUtility->wholeScreen->BitsLength(), - fUtility->wholeScreen->BytesPerRow(), - fUtility->wholeScreen->ColorSpace(), - fUtility->cursorPosition, BPoint(0, 0), - cursorWidth, cursorHeight); + fUtility->cursorAreaBitmap->ImportBits(fUtility->wholeScreen, + fUtility->cursorPosition, BPoint(0, 0), bounds.Size()); // Fill in the background of the mouse bitmap uint8* bits = (uint8*)fUtility->cursorBitmap->Bits(); uint8* areaBits = (uint8*)fUtility->cursorAreaBitmap->Bits(); + int cursorWidth = bounds.IntegerWidth() + 1; + int cursorHeight = bounds.IntegerHeight() + 1; for (int32 i = 0; i < cursorHeight; i++) { for (int32 j = 0; j < cursorWidth; j++) { uint8 alpha = 255 - bits[3]; diff --git a/src/apps/screenshot/Utility.cpp b/src/apps/screenshot/Utility.cpp index dd7f624127..1c0b3b297c 100644 --- a/src/apps/screenshot/Utility.cpp +++ b/src/apps/screenshot/Utility.cpp @@ -139,28 +139,14 @@ Utility::MakeScreenshot(bool includeMouse, bool activeWindow, if (wholeScreen == NULL) return NULL; - int cursorWidth = 0; - int cursorHeight = 0; - - if (cursorBitmap != NULL) { - BRect bounds = cursorBitmap->Bounds(); - cursorWidth = bounds.IntegerWidth() + 1; - cursorHeight = bounds.IntegerHeight() + 1; - } - if (includeMouse && cursorBitmap != NULL) { // Import the cursor bitmap into wholeScreen - wholeScreen->ImportBits(cursorBitmap->Bits(), - cursorBitmap->BitsLength(), cursorBitmap->BytesPerRow(), - cursorBitmap->ColorSpace(), BPoint(0, 0), cursorPosition, - cursorWidth, cursorHeight); - + wholeScreen->ImportBits(cursorBitmap, + B_ORIGIN, cursorPosition, cursorBitmap->Bounds().Size()); } else if (cursorAreaBitmap != NULL) { // Import the cursor area bitmap into wholeScreen - wholeScreen->ImportBits(cursorAreaBitmap->Bits(), - cursorAreaBitmap->BitsLength(), cursorAreaBitmap->BytesPerRow(), - cursorAreaBitmap->ColorSpace(), BPoint(0, 0), cursorPosition, - cursorWidth, cursorHeight); + wholeScreen->ImportBits(cursorAreaBitmap, + B_ORIGIN, cursorPosition, cursorAreaBitmap->Bounds().Size()); } BBitmap* screenshot = NULL; @@ -175,11 +161,8 @@ Utility::MakeScreenshot(bool includeMouse, bool activeWindow, screenshot = new BBitmap(frame.OffsetToCopy(B_ORIGIN), includeBorder ? B_RGBA32 : B_RGB32, true); - if (screenshot->ImportBits(wholeScreen->Bits(), - wholeScreen->BitsLength(), wholeScreen->BytesPerRow(), - wholeScreen->ColorSpace(), frame.LeftTop(), - BPoint(0, 0), frame.IntegerWidth() + 1, - frame.IntegerHeight() + 1) != B_OK) { + if (screenshot->ImportBits(wholeScreen, frame.LeftTop(), + B_ORIGIN, frame.Size()) != B_OK) { delete screenshot; return NULL; } diff --git a/src/kits/tracker/Bitmaps.cpp b/src/kits/tracker/Bitmaps.cpp index 37b1cde0b9..6912879a4e 100644 --- a/src/kits/tracker/Bitmaps.cpp +++ b/src/kits/tracker/Bitmaps.cpp @@ -192,7 +192,7 @@ BImageResources::GetIconResource(int32 id, icon_size size, float x = roundf((dest->Bounds().Width() - size) / 2); float y = roundf((dest->Bounds().Height() - size) / 2); return dest->ImportBits(data, (int32)length, size, B_CMAP8, - BPoint(0, 0), BPoint(x, y), size, size); + BPoint(0, 0), BPoint(x, y), BSize(size - 1, size - 1)); } diff --git a/src/servers/app/drawing/DrawingEngine.cpp b/src/servers/app/drawing/DrawingEngine.cpp index c6c8deb941..6a1b7401b1 100644 --- a/src/servers/app/drawing/DrawingEngine.cpp +++ b/src/servers/app/drawing/DrawingEngine.cpp @@ -1505,7 +1505,7 @@ DrawingEngine::ReadBitmap(ServerBitmap* bitmap, bool drawCursor, BRect bounds) cursorArea.ImportBits(bitmap->Bits(), bitmap->BitsLength(), bitmap->BytesPerRow(), bitmap->ColorSpace(), cursorPosition, BPoint(0, 0), - cursorWidth, cursorHeight); + cursorArea.Bounds().Size()); uint8* bits = (uint8*)cursorArea.Bits(); uint8* cursorBits = (uint8*)cursor->Bits(); diff --git a/src/servers/registrar/ShutdownProcess.cpp b/src/servers/registrar/ShutdownProcess.cpp index 92cf11c53c..bdce90224c 100644 --- a/src/servers/registrar/ShutdownProcess.cpp +++ b/src/servers/registrar/ShutdownProcess.cpp @@ -734,7 +734,7 @@ private: fCurrentIconBitmap->ImportBits(sourceBitmap, BPoint(0, fCurrentAnimationRow), BPoint(0, fCurrentAnimationRow), - sourceBitmap->Bounds().IntegerWidth(), 1); + BSize(sourceBitmap->Bounds().IntegerWidth() - 1, 0)); fCurrentAnimationRow--;