diff options
author | Po Lu <luangruo@yahoo.com> | 2022-06-25 07:34:43 +0000 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-06-25 07:35:45 +0000 |
commit | 230891d9f33644146cf1e962824618256374eadc (patch) | |
tree | 6f3ac2d902b90c4147feab1d2b918932a87c31ad /src | |
parent | 1754b0df75701cadb264b2c3ae829893f1a04327 (diff) | |
download | emacs-230891d9f33644146cf1e962824618256374eadc.tar.gz |
Implement image transform smoothing on Haiku
* src/dispextern.h (struct image): New field
`use_bilinear_filtering'.
* src/haiku_draw_support.cc (BView_DrawBitmap): Accept it.
* src/haiku_support.h: Update prototypes.
* src/haikuterm.c (haiku_draw_image_glyph_string):
* src/image.c (image_set_transform): Set it.
Diffstat (limited to 'src')
-rw-r--r-- | src/dispextern.h | 4 | ||||
-rw-r--r-- | src/haiku_draw_support.cc | 11 | ||||
-rw-r--r-- | src/haiku_support.h | 2 | ||||
-rw-r--r-- | src/haikuterm.c | 3 | ||||
-rw-r--r-- | src/image.c | 7 |
5 files changed, 21 insertions, 6 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index 170641f1ba9..9dec8b7d129 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3090,6 +3090,10 @@ struct image /* The original width and height of the image. */ int original_width, original_height; + + /* Whether or not bilinear filtering should be used to "smooth" the + image. */ + bool use_bilinear_filtering; #endif /* Colors allocated for this image, if any. Allocated via xmalloc. */ diff --git a/src/haiku_draw_support.cc b/src/haiku_draw_support.cc index 768ffdabf82..e2025ed68d4 100644 --- a/src/haiku_draw_support.cc +++ b/src/haiku_draw_support.cc @@ -280,14 +280,19 @@ hsl_color_rgb (double h, double s, double l, uint32_t *rgb) void BView_DrawBitmap (void *view, void *bitmap, int x, int y, int width, int height, int vx, int vy, int vwidth, - int vheight) + int vheight, bool use_bilinear_filtering) { BView *vw = get_view (view); BBitmap *bm = (BBitmap *) bitmap; vw->SetDrawingMode (B_OP_OVER); - vw->DrawBitmap (bm, BRect (x, y, x + width - 1, y + height - 1), - BRect (vx, vy, vx + vwidth - 1, vy + vheight - 1)); + if (!use_bilinear_filtering) + vw->DrawBitmap (bm, BRect (x, y, x + width - 1, y + height - 1), + BRect (vx, vy, vx + vwidth - 1, vy + vheight - 1)); + else + vw->DrawBitmap (bm, BRect (x, y, x + width - 1, y + height - 1), + BRect (vx, vy, vx + vwidth - 1, vy + vheight - 1), + B_FILTER_BITMAP_BILINEAR); vw->SetDrawingMode (B_OP_COPY); } diff --git a/src/haiku_support.h b/src/haiku_support.h index fcdf6bcb154..7585b62a064 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -558,7 +558,7 @@ extern void BView_StrokeLine (void *, int, int, int, int); extern void BView_CopyBits (void *, int, int, int, int, int, int, int, int); extern void BView_InvertRect (void *, int, int, int, int); extern void BView_DrawBitmap (void *, void *, int, int, int, int, int, int, - int, int); + int, int, bool); extern void BView_DrawBitmapWithEraseOp (void *, void *, int, int, int, int); extern void BView_DrawBitmapTiled (void *, void *, int, int, int, int, int, int, int, int); diff --git a/src/haikuterm.c b/src/haikuterm.c index 7c307afa32e..f50f6b34bda 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -1738,7 +1738,8 @@ haiku_draw_image_glyph_string (struct glyph_string *s) s->img->original_height, 0, 0, s->img->original_width, - s->img->original_height); + s->img->original_height, + s->img->use_bilinear_filtering); if (mask) be_draw_image_mask (mask, view, 0, 0, diff --git a/src/image.c b/src/image.c index 5e98945df50..fcf5e97b0b1 100644 --- a/src/image.c +++ b/src/image.c @@ -2563,6 +2563,7 @@ image_set_transform (struct frame *f, struct image *img) img->original_width = img->width; img->original_height = img->height; + img->use_bilinear_filtering = false; memcpy (&img->transform, identity, sizeof identity); #endif @@ -2604,7 +2605,7 @@ image_set_transform (struct frame *f, struct image *img) /* Determine flipping. */ flip = !NILP (image_spec_value (img->spec, QCflip, NULL)); -# if defined USE_CAIRO || defined HAVE_XRENDER || defined HAVE_NS +# if defined USE_CAIRO || defined HAVE_XRENDER || defined HAVE_NS || defined HAVE_HAIKU /* We want scale up operations to use a nearest neighbor filter to show real pixels instead of munging them, but scale down operations to use a blended filter, to avoid aliasing and the like. @@ -2618,6 +2619,10 @@ image_set_transform (struct frame *f, struct image *img) smoothing = !NILP (s); # endif +#ifdef HAVE_HAIKU + img->use_bilinear_filtering = smoothing; +#endif + /* Perform scale transformation. */ matrix3x3 matrix |