[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 230891d9f3: Implement image transform smoothing on Haiku
From: |
Po Lu |
Subject: |
master 230891d9f3: Implement image transform smoothing on Haiku |
Date: |
Sat, 25 Jun 2022 03:37:25 -0400 (EDT) |
branch: master
commit 230891d9f33644146cf1e962824618256374eadc
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
src/dispextern.h | 4 ++++
src/haiku_draw_support.cc | 11 ++++++++---
src/haiku_support.h | 2 +-
src/haikuterm.c | 3 ++-
src/image.c | 7 ++++++-
5 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/dispextern.h b/src/dispextern.h
index 170641f1ba..9dec8b7d12 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 768ffdabf8..e2025ed68d 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 fcdf6bcb15..7585b62a06 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 7c307afa32..f50f6b34bd 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 5e98945df5..fcf5e97b0b 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 230891d9f3: Implement image transform smoothing on Haiku,
Po Lu <=