From af3ac4e80fb51f526be76c69736f92cf044b7180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 19 Mar 2006 22:26:17 +0000 Subject: [PATCH] replaced usage of floor() and ceil() to convert from BRect to clipping_rect with simple C casts. I think this is more adequate, since clipping_rects are used for pixel indices. This change fixes some graphics problems too, it appears that cursor coords are fractional on Haiku, even with a normal mouse. In Playground, this resulted in the hit points being rendered wrongly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16840 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/interface/clipping.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/headers/private/interface/clipping.h b/headers/private/interface/clipping.h index ed7cc2aa8f..cbbeaab024 100644 --- a/headers/private/interface/clipping.h +++ b/headers/private/interface/clipping.h @@ -85,7 +85,8 @@ offset_rect(clipping_rect &rect, int32 x, int32 y) static inline BRect to_BRect(const clipping_rect &rect) { - return BRect((float)rect.left, (float)rect.top, (float)rect.right, (float)rect.bottom); + return BRect((float)rect.left, (float)rect.top, + (float)rect.right, (float)rect.bottom); } @@ -94,11 +95,20 @@ static inline clipping_rect to_clipping_rect(const BRect &rect) { clipping_rect clipRect; - - clipRect.left = (int32)floor(rect.left); - clipRect.top = (int32)floor(rect.top); - clipRect.right = (int32)ceil(rect.right); - clipRect.bottom = (int32)ceil(rect.bottom); + +// NOTE: test fractional coords BRects -> BRegion on R5 +// and compare with this implementation... +// clipRect.left = (int32)floorf(rect.left); +// clipRect.top = (int32)floorf(rect.top); +// clipRect.right = (int32)ceilf(rect.right); +// clipRect.bottom = (int32)ceilf(rect.bottom); + + // NOTE: clipping_rects are used as "pixel indices" + // therefor, it should be ok to convert them like this: + clipRect.left = (int32)rect.left; + clipRect.top = (int32)rect.top; + clipRect.right = (int32)rect.right; + clipRect.bottom = (int32)rect.bottom; return clipRect; }