aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-01-01 09:56:14 +0000
committerPo Lu2022-01-01 09:56:14 +0000
commitab3c6c799ea6973ba8496eae3827e8fa2c5caae0 (patch)
tree8bcee27593ea3a16144d0f85a3e26fb51dbc0ad7 /src
parentc6d83707d6c5b9af67f69d34034a60719584b805 (diff)
downloademacs-ab3c6c799ea6973ba8496eae3827e8fa2c5caae0.tar.gz
emacs-ab3c6c799ea6973ba8496eae3827e8fa2c5caae0.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/haiku_draw_support.cc12
-rw-r--r--src/haiku_support.cc5
2 files changed, 9 insertions, 8 deletions
diff --git a/src/haiku_draw_support.cc b/src/haiku_draw_support.cc
index 5b1eccfbe6e..0f0f0a34f1d 100644
--- a/src/haiku_draw_support.cc
+++ b/src/haiku_draw_support.cc
@@ -310,9 +310,9 @@ BView_DrawBitmapWithEraseOp (void *view, void *bitmap, int x,
310 if (bm->ColorSpace () == B_GRAY1) 310 if (bm->ColorSpace () == B_GRAY1)
311 { 311 {
312 rgb_color low_color = vw->LowColor (); 312 rgb_color low_color = vw->LowColor ();
313 for (int y = 0; y <= bc.Bounds ().Height (); ++y) 313 for (int y = 0; y <= bc.Bounds ().Height () + 1; ++y)
314 { 314 {
315 for (int x = 0; x <= bc.Bounds ().Width (); ++x) 315 for (int x = 0; x <= bc.Bounds ().Width () + 1; ++x)
316 { 316 {
317 if (bits[y * (stride / 4) + x] == 0xFF000000) 317 if (bits[y * (stride / 4) + x] == 0xFF000000)
318 bits[y * (stride / 4) + x] = RGB_COLOR_UINT32 (low_color); 318 bits[y * (stride / 4) + x] = RGB_COLOR_UINT32 (low_color);
@@ -338,9 +338,9 @@ BView_DrawMask (void *src, void *view,
338 BBitmap bm (source->Bounds (), B_RGBA32); 338 BBitmap bm (source->Bounds (), B_RGBA32);
339 if (bm.InitCheck () != B_OK) 339 if (bm.InitCheck () != B_OK)
340 return; 340 return;
341 for (int y = 0; y <= bm.Bounds ().Height (); ++y) 341 for (int y = 0; y <= bm.Bounds ().IntegerHeight (); ++y)
342 { 342 {
343 for (int x = 0; x <= bm.Bounds ().Width (); ++x) 343 for (int x = 0; x <= bm.Bounds ().IntegerWidth (); ++x)
344 { 344 {
345 int bit = haiku_get_pixel ((void *) source, x, y); 345 int bit = haiku_get_pixel ((void *) source, x, y);
346 346
@@ -443,8 +443,8 @@ BBitmap_transform_bitmap (void *bitmap, void *mask, uint32_t m_color,
443 vw.DrawBitmap (bm, n); 443 vw.DrawBitmap (bm, n);
444 if (mk) 444 if (mk)
445 BView_DrawMask ((void *) mk, (void *) &vw, 445 BView_DrawMask ((void *) mk, (void *) &vw,
446 0, 0, mk->Bounds ().Width (), 446 0, 0, mk->Bounds ().Width () + 1,
447 mk->Bounds ().Height (), 447 mk->Bounds ().Height () + 1,
448 0, 0, desw, desh, m_color); 448 0, 0, desw, desh, m_color);
449 vw.Sync (); 449 vw.Sync ();
450 vw.RemoveSelf (); 450 vw.RemoveSelf ();
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 6a7a043fe06..6a270d338a2 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -960,8 +960,9 @@ public:
960 gui_abort ("Trying to attach cr surface when one already exists"); 960 gui_abort ("Trying to attach cr surface when one already exists");
961 cr_surface = cairo_image_surface_create_for_data 961 cr_surface = cairo_image_surface_create_for_data
962 ((unsigned char *) offscreen_draw_bitmap_1->Bits (), 962 ((unsigned char *) offscreen_draw_bitmap_1->Bits (),
963 CAIRO_FORMAT_ARGB32, offscreen_draw_bitmap_1->Bounds ().Width (), 963 CAIRO_FORMAT_ARGB32,
964 offscreen_draw_bitmap_1->Bounds ().Height (), 964 offscreen_draw_bitmap_1->Bounds ().IntegerWidth () + 1,
965 offscreen_draw_bitmap_1->Bounds ().IntegerHeight () + 1,
965 offscreen_draw_bitmap_1->BytesPerRow ()); 966 offscreen_draw_bitmap_1->BytesPerRow ());
966 if (!cr_surface) 967 if (!cr_surface)
967 gui_abort ("Cr surface allocation failed for double-buffered view"); 968 gui_abort ("Cr surface allocation failed for double-buffered view");