emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Po Lu
Subject: master ab3c6c799e: Fix some more off-by-one errors in Haiku image code
Date: Sat, 1 Jan 2022 05:01:11 -0500 (EST)

branch: master
commit ab3c6c799ea6973ba8496eae3827e8fa2c5caae0
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 src/haiku_draw_support.cc | 12 ++++++------
 src/haiku_support.cc      |  5 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/haiku_draw_support.cc b/src/haiku_draw_support.cc
index 5b1eccfbe6..0f0f0a34f1 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,
   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 ();
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 6a7a043fe0..6a270d338a 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -960,8 +960,9 @@ public:
       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");



reply via email to

[Prev in Thread] Current Thread [Next in Thread]