diff options
| author | Alan Third | 2021-08-14 16:11:30 +0100 |
|---|---|---|
| committer | Alan Third | 2021-12-22 20:48:19 +0000 |
| commit | 0f427befe82f88237bdccbd528baf76f6d6485b0 (patch) | |
| tree | dffb5221ec905df3e78f147adbd4fced22e77118 /src/image.c | |
| parent | 5b0121b708986c836fa970b800387363806a035a (diff) | |
| download | emacs-0f427befe82f88237bdccbd528baf76f6d6485b0.tar.gz emacs-0f427befe82f88237bdccbd528baf76f6d6485b0.zip | |
Simplify NS color handling
* src/image.c (RGB_TO_ULONG):
(ARGB_TO_ULONG):
(RED_FROM_ULONG):
(RED16_FROM_ULONG):
(GREEN16_FROM_ULONG):
(BLUE16_FROM_ULONG): Define these here for NS too.
* src/nsfns.m (ns_set_foreground_color):
(ns_set_background_color): Use new EmacsColor methods.
* src/nsterm.h (struct ns_color_table): Replace this struct with a
built-in Objective C type.
(RGB_TO_ULONG):
(ARGB_TO_ULONG):
(ALPHA_FROM_ULONG):
(RED_FROM_ULONG):
(GREEN_FROM_ULONG):
(BLUE_FROM_ULONG):
(RED16_FROM_ULONG):
(GREEN16_FROM_ULONG):
(BLUE16_FROM_ULONG): These are no longer needed in the NS specific code.
(struct ns_display_info): Use an NSMutableArray instead of a custom struct.
* src/nsterm.m ([NSColor colorWithUnsignedLong:hasAlpha:]):
([NSColor unsignedLong]): New methods.
(ns_lookup_indexed_color):
(ns_index_color): Use the NSMutableArray lookup table.
(ns_term_init):
(ns_color_index_to_rgba):
(ns_query_color): Use the new EmacsColor methods.
(ns_initialize_display_info):
(ns_delete_display): Initialize and release the NSMutableArray lookup table.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/image.c b/src/image.c index dd5ea19fc15..dc9aae27c92 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -80,14 +80,7 @@ typedef struct x_bitmap_record Bitmap_Record; | |||
| 80 | #endif /* !USE_CAIRO */ | 80 | #endif /* !USE_CAIRO */ |
| 81 | #endif /* HAVE_X_WINDOWS */ | 81 | #endif /* HAVE_X_WINDOWS */ |
| 82 | 82 | ||
| 83 | #ifdef USE_CAIRO | 83 | #if defined(USE_CAIRO) || defined(HAVE_NS) |
| 84 | #define GET_PIXEL image_pix_context_get_pixel | ||
| 85 | #define PUT_PIXEL image_pix_container_put_pixel | ||
| 86 | #define NO_PIXMAP 0 | ||
| 87 | |||
| 88 | #define PIX_MASK_RETAIN 0 | ||
| 89 | #define PIX_MASK_DRAW 255 | ||
| 90 | |||
| 91 | #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b)) | 84 | #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b)) |
| 92 | #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) | 85 | #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) |
| 93 | #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff) | 86 | #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff) |
| @@ -96,6 +89,15 @@ typedef struct x_bitmap_record Bitmap_Record; | |||
| 96 | #define RED16_FROM_ULONG(color) (RED_FROM_ULONG (color) * 0x101) | 89 | #define RED16_FROM_ULONG(color) (RED_FROM_ULONG (color) * 0x101) |
| 97 | #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG (color) * 0x101) | 90 | #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG (color) * 0x101) |
| 98 | #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG (color) * 0x101) | 91 | #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG (color) * 0x101) |
| 92 | #endif | ||
| 93 | |||
| 94 | #ifdef USE_CAIRO | ||
| 95 | #define GET_PIXEL image_pix_context_get_pixel | ||
| 96 | #define PUT_PIXEL image_pix_container_put_pixel | ||
| 97 | #define NO_PIXMAP 0 | ||
| 98 | |||
| 99 | #define PIX_MASK_RETAIN 0 | ||
| 100 | #define PIX_MASK_DRAW 255 | ||
| 99 | 101 | ||
| 100 | static unsigned long image_alloc_image_color (struct frame *, struct image *, | 102 | static unsigned long image_alloc_image_color (struct frame *, struct image *, |
| 101 | Lisp_Object, unsigned long); | 103 | Lisp_Object, unsigned long); |