Fix some more off-by-one errors in Haiku image code

* src/haiku_draw_support.cc (BView_DrawBitmapWithEraseOp):
(BView_DrawMask):
(BBitmap_transform_bitmap):
* src/haiku_support.cc (AttachCairoSurface): Adjust calculations
to take account of BRect width and height functions returning
(start - end) instead of the actual width and height of the
rectangle.
This commit is contained in:
Po Lu 2022-01-01 09:56:14 +00:00
parent c6d83707d6
commit ab3c6c799e
2 changed files with 9 additions and 8 deletions

View file

@ -310,9 +310,9 @@ BView_DrawBitmapWithEraseOp (void *view, void *bitmap, int x,
if (bm->ColorSpace () == B_GRAY1)
{
rgb_color low_color = vw->LowColor ();
for (int y = 0; y <= bc.Bounds ().Height (); ++y)
for (int y = 0; y <= bc.Bounds ().Height () + 1; ++y)
{
for (int x = 0; x <= bc.Bounds ().Width (); ++x)
for (int x = 0; x <= bc.Bounds ().Width () + 1; ++x)
{
if (bits[y * (stride / 4) + x] == 0xFF000000)
bits[y * (stride / 4) + x] = RGB_COLOR_UINT32 (low_color);
@ -338,9 +338,9 @@ BView_DrawMask (void *src, void *view,
BBitmap bm (source->Bounds (), B_RGBA32);
if (bm.InitCheck () != B_OK)
return;
for (int y = 0; y <= bm.Bounds ().Height (); ++y)
for (int y = 0; y <= bm.Bounds ().IntegerHeight (); ++y)
{
for (int x = 0; x <= bm.Bounds ().Width (); ++x)
for (int x = 0; x <= bm.Bounds ().IntegerWidth (); ++x)
{
int bit = haiku_get_pixel ((void *) source, x, y);
@ -443,8 +443,8 @@ BBitmap_transform_bitmap (void *bitmap, void *mask, uint32_t m_color,
vw.DrawBitmap (bm, n);
if (mk)
BView_DrawMask ((void *) mk, (void *) &vw,
0, 0, mk->Bounds ().Width (),
mk->Bounds ().Height (),
0, 0, mk->Bounds ().Width () + 1,
mk->Bounds ().Height () + 1,
0, 0, desw, desh, m_color);
vw.Sync ();
vw.RemoveSelf ();

View file

@ -960,8 +960,9 @@ class EmacsView : public BView
gui_abort ("Trying to attach cr surface when one already exists");
cr_surface = cairo_image_surface_create_for_data
((unsigned char *) offscreen_draw_bitmap_1->Bits (),
CAIRO_FORMAT_ARGB32, offscreen_draw_bitmap_1->Bounds ().Width (),
offscreen_draw_bitmap_1->Bounds ().Height (),
CAIRO_FORMAT_ARGB32,
offscreen_draw_bitmap_1->Bounds ().IntegerWidth () + 1,
offscreen_draw_bitmap_1->Bounds ().IntegerHeight () + 1,
offscreen_draw_bitmap_1->BytesPerRow ());
if (!cr_surface)
gui_abort ("Cr surface allocation failed for double-buffered view");