From b8fc177d9c406ce2fea87d9c66eef0dcb1f2ed68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 3 Jul 2006 19:49:51 +0000 Subject: [PATCH] * default source BRect is now offset to B_ORIGIN because Bitmap bounds lefttop could be something else than (0,0). This caused some bugs in Haiku SoundRecorder app i* thus the NOTE in Painter isn't valid anymore * in Painter::_DrawBimap() moved scale computation after potential changes to BRects * fix typo : right => bottom. This caused a bug in Haiku Mouse preferences app git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18017 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 6 +++--- src/servers/app/drawing/Painter/Painter.cpp | 22 +++++++++------------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 234820ccaa..77d5bed06b 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -2204,7 +2204,7 @@ BView::DrawBitmapAsync(const BBitmap *bitmap, BRect srcRect, BRect dstRect) void BView::DrawBitmapAsync(const BBitmap *bitmap, BRect dstRect) { - DrawBitmapAsync(bitmap, bitmap->Bounds(), dstRect); + DrawBitmapAsync(bitmap, bitmap->Bounds().OffsetToCopy(B_ORIGIN), dstRect); } @@ -2226,7 +2226,7 @@ BView::DrawBitmapAsync(const BBitmap *bitmap, BPoint where) fOwner->fLink->StartMessage(AS_LAYER_DRAW_BITMAP); fOwner->fLink->Attach(bitmap->_ServerToken()); - BRect src = bitmap->Bounds(); + BRect src = bitmap->Bounds().OffsetToCopy(B_ORIGIN); BRect dst = src.OffsetToCopy(where); fOwner->fLink->Attach(dst); fOwner->fLink->Attach(src); @@ -2256,7 +2256,7 @@ BView::DrawBitmap(const BBitmap *bitmap, BPoint where) void BView::DrawBitmap(const BBitmap *bitmap, BRect dstRect) { - DrawBitmap(bitmap, bitmap->Bounds(), dstRect); + DrawBitmap(bitmap, bitmap->Bounds().OffsetToCopy(B_ORIGIN), dstRect); } diff --git a/src/servers/app/drawing/Painter/Painter.cpp b/src/servers/app/drawing/Painter/Painter.cpp index 358abf462c..6bb9b89ec2 100644 --- a/src/servers/app/drawing/Painter/Painter.cpp +++ b/src/servers/app/drawing/Painter/Painter.cpp @@ -1328,19 +1328,9 @@ Painter::_DrawBitmap(agg::rendering_buffer& srcBuffer, color_space format, if (!fSubpixelPrecise) align_rect_to_pixels(&viewRect); - double xScale = (viewRect.Width() + 1) / (bitmapRect.Width() + 1); - double yScale = (viewRect.Height() + 1) / (bitmapRect.Height() + 1); - - if (xScale == 0.0 || yScale == 0.0) - return; - // compensate for the lefttop offset the actualBitmapRect might have -// NOTE: I have no clue why enabling the next call gives a wrong result! -// According to the BeBook, bitmapRect is supposed to be in native -// bitmap space! Disabling this call makes it look like the bitmap bounds are -// assumed to have a left/top coord of 0,0 at all times. This is simply not true. -// bitmapRect.OffsetBy(-actualBitmapRect.left, -actualBitmapRect.top); - // actualBitmapRect has the right size, but put it at B_ORIGIN too + // actualBitmapRect has the right size, but put it at B_ORIGIN + // bitmapRect is already in good coordinates actualBitmapRect.OffsetBy(-actualBitmapRect.left, -actualBitmapRect.top); // constrain rect to passed bitmap bounds @@ -1361,10 +1351,16 @@ Painter::_DrawBitmap(agg::rendering_buffer& srcBuffer, color_space format, bitmapRect.right = actualBitmapRect.right; } if (bitmapRect.bottom > actualBitmapRect.bottom) { - float diff = bitmapRect.right - actualBitmapRect.bottom; + float diff = bitmapRect.bottom - actualBitmapRect.bottom; viewRect.bottom -= diff; bitmapRect.bottom = actualBitmapRect.bottom; } + + double xScale = (viewRect.Width() + 1) / (bitmapRect.Width() + 1); + double yScale = (viewRect.Height() + 1) / (bitmapRect.Height() + 1); + + if (xScale == 0.0 || yScale == 0.0) + return; double xOffset = viewRect.left - bitmapRect.left; double yOffset = viewRect.top - bitmapRect.top;