diff options
| author | Po Lu | 2022-05-18 12:36:50 +0000 |
|---|---|---|
| committer | Po Lu | 2022-05-18 12:37:54 +0000 |
| commit | d5540d7dbcee2a35dc928670ac210c5ffb909a75 (patch) | |
| tree | 45abcbd2fcb4c2ba71ee25389834e5d29ec869ab | |
| parent | 3faba1dff6fa340033071e92309a1b112d58a7fa (diff) | |
| download | emacs-d5540d7dbcee2a35dc928670ac210c5ffb909a75.tar.gz emacs-d5540d7dbcee2a35dc928670ac210c5ffb909a75.zip | |
Implement gamma-correction on Haiku
* src/dispextern.h: Add `gamma_correct' prototype on Haiku as
well.
* src/haikufns.c (gamma_correct): New function.
* src/haikuterm.c (haiku_defined_color): Gamma-correct colors if
their pixels are being allocated.
| -rw-r--r-- | src/dispextern.h | 3 | ||||
| -rw-r--r-- | src/haikufns.c | 16 | ||||
| -rw-r--r-- | src/haikuterm.c | 9 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index a7f478acdf8..910f630a50c 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -3615,6 +3615,9 @@ void gamma_correct (struct frame *, XColor *); | |||
| 3615 | #ifdef HAVE_NTGUI | 3615 | #ifdef HAVE_NTGUI |
| 3616 | void gamma_correct (struct frame *, COLORREF *); | 3616 | void gamma_correct (struct frame *, COLORREF *); |
| 3617 | #endif | 3617 | #endif |
| 3618 | #ifdef HAVE_HAIKU | ||
| 3619 | void gamma_correct (struct frame *, Emacs_Color *); | ||
| 3620 | #endif | ||
| 3618 | 3621 | ||
| 3619 | #ifdef HAVE_WINDOW_SYSTEM | 3622 | #ifdef HAVE_WINDOW_SYSTEM |
| 3620 | 3623 | ||
diff --git a/src/haikufns.c b/src/haikufns.c index 8b6296e6ae1..76a8569970a 100644 --- a/src/haikufns.c +++ b/src/haikufns.c | |||
| @@ -268,6 +268,22 @@ haiku_set_tab_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) | |||
| 268 | haiku_change_tab_bar_height (f, nlines * FRAME_LINE_HEIGHT (f)); | 268 | haiku_change_tab_bar_height (f, nlines * FRAME_LINE_HEIGHT (f)); |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | void | ||
| 272 | gamma_correct (struct frame *f, Emacs_Color *color) | ||
| 273 | { | ||
| 274 | if (f->gamma) | ||
| 275 | { | ||
| 276 | color->red = (pow (color->red / 65535.0, f->gamma) | ||
| 277 | * 65535.0 + 0.5); | ||
| 278 | color->green = (pow (color->green / 65535.0, f->gamma) | ||
| 279 | * 65535.0 + 0.5); | ||
| 280 | color->blue = (pow (color->blue / 65535.0, f->gamma) | ||
| 281 | * 65535.0 + 0.5); | ||
| 282 | color->pixel = RGB_TO_ULONG (color->red / 256, | ||
| 283 | color->green / 256, | ||
| 284 | color->blue / 256); | ||
| 285 | } | ||
| 286 | } | ||
| 271 | 287 | ||
| 272 | int | 288 | int |
| 273 | haiku_get_color (const char *name, Emacs_Color *color) | 289 | haiku_get_color (const char *name, Emacs_Color *color) |
diff --git a/src/haikuterm.c b/src/haikuterm.c index af20d1c11c8..2db1e352ffb 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c | |||
| @@ -575,7 +575,14 @@ static bool | |||
| 575 | haiku_defined_color (struct frame *f, const char *name, | 575 | haiku_defined_color (struct frame *f, const char *name, |
| 576 | Emacs_Color *color, bool alloc, bool make_index) | 576 | Emacs_Color *color, bool alloc, bool make_index) |
| 577 | { | 577 | { |
| 578 | return !haiku_get_color (name, color); | 578 | int rc; |
| 579 | |||
| 580 | rc = !haiku_get_color (name, color); | ||
| 581 | |||
| 582 | if (rc && f->gamma && alloc) | ||
| 583 | gamma_correct (f, color); | ||
| 584 | |||
| 585 | return rc; | ||
| 579 | } | 586 | } |
| 580 | 587 | ||
| 581 | /* Adapted from xterm `x_draw_box_rect'. */ | 588 | /* Adapted from xterm `x_draw_box_rect'. */ |