aboutsummaryrefslogtreecommitdiffstats
path: root/src/androidterm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/androidterm.c')
-rw-r--r--src/androidterm.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/src/androidterm.c b/src/androidterm.c
index c920375fdbe..e4f3abdb2d3 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -1964,10 +1964,33 @@ android_parse_color (struct frame *f, const char *color_name,
1964bool 1964bool
1965android_alloc_nearest_color (struct frame *f, Emacs_Color *color) 1965android_alloc_nearest_color (struct frame *f, Emacs_Color *color)
1966{ 1966{
1967 unsigned int ntsc;
1968
1967 gamma_correct (f, color); 1969 gamma_correct (f, color);
1968 color->pixel = RGB_TO_ULONG (color->red / 256, 1970
1969 color->green / 256, 1971 if (FRAME_DISPLAY_INFO (f)->n_planes == 1)
1970 color->blue / 256); 1972 {
1973 /* Black and white. I think this is the luminance formula applied
1974 by the X server on generic monochrome framebuffers. */
1975 color->pixel = ((((30l * color->red
1976 + 59l * color->green
1977 + 11l * color->blue) >> 8)
1978 >= (((1 << 8) -1) * 50))
1979 ? 0xffffff : 0);
1980 }
1981 else if (FRAME_DISPLAY_INFO (f)->n_planes <= 8)
1982 {
1983 /* 256 grays. */
1984 ntsc = min (255, ((color->red * 0.299
1985 + color->green * 0.587
1986 + color->blue * 0.114)
1987 / 256));
1988 color->pixel = RGB_TO_ULONG (ntsc, ntsc, ntsc);
1989 }
1990 else
1991 color->pixel = RGB_TO_ULONG (color->red / 256,
1992 color->green / 256,
1993 color->blue / 256);
1971 1994
1972 return true; 1995 return true;
1973} 1996}
@@ -1980,8 +2003,8 @@ android_query_colors (struct frame *f, Emacs_Color *colors, int ncolors)
1980 for (i = 0; i < ncolors; ++i) 2003 for (i = 0; i < ncolors; ++i)
1981 { 2004 {
1982 colors[i].red = RED_FROM_ULONG (colors[i].pixel) * 257; 2005 colors[i].red = RED_FROM_ULONG (colors[i].pixel) * 257;
1983 colors[i].green = RED_FROM_ULONG (colors[i].pixel) * 257; 2006 colors[i].green = GREEN_FROM_ULONG (colors[i].pixel) * 257;
1984 colors[i].blue = RED_FROM_ULONG (colors[i].pixel) * 257; 2007 colors[i].blue = BLUE_FROM_ULONG (colors[i].pixel) * 257;
1985 } 2008 }
1986} 2009}
1987 2010
@@ -2630,7 +2653,7 @@ android_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2630 clipmask = ANDROID_NONE; 2653 clipmask = ANDROID_NONE;
2631 background = face->background; 2654 background = face->background;
2632 cursor_pixel = f->output_data.android->cursor_pixel; 2655 cursor_pixel = f->output_data.android->cursor_pixel;
2633 depth = FRAME_DISPLAY_INFO (f)->n_planes; 2656 depth = FRAME_DISPLAY_INFO (f)->n_image_planes;
2634 2657
2635 /* Intersect the destination rectangle with that of the row. 2658 /* Intersect the destination rectangle with that of the row.
2636 Setting a clip mask overrides the clip rectangles provided by 2659 Setting a clip mask overrides the clip rectangles provided by
@@ -6504,8 +6527,8 @@ android_term_init (void)
6504 terminal = android_create_terminal (dpyinfo); 6527 terminal = android_create_terminal (dpyinfo);
6505 terminal->kboard = allocate_kboard (Qandroid); 6528 terminal->kboard = allocate_kboard (Qandroid);
6506 terminal->kboard->reference_count++; 6529 terminal->kboard->reference_count++;
6507
6508 dpyinfo->n_planes = 24; 6530 dpyinfo->n_planes = 24;
6531 dpyinfo->n_image_planes = 24;
6509 6532
6510 /* This function should only be called once at startup. */ 6533 /* This function should only be called once at startup. */
6511 eassert (!x_display_list); 6534 eassert (!x_display_list);
@@ -6702,6 +6725,17 @@ Emacs is running on. */);
6702 doc: /* Name of the developer of the running version of Android. */); 6725 doc: /* Name of the developer of the running version of Android. */);
6703 Vandroid_build_manufacturer = Qnil; 6726 Vandroid_build_manufacturer = Qnil;
6704 6727
6728 DEFVAR_INT ("android-display-planes", android_display_planes,
6729 doc: /* Depth and visual class of the display.
6730This variable controls the visual class and depth of the display, which
6731cannot be detected on Android. The default value of 24, and values from
6732there to 8 represent a TrueColor display providing 24 planes, values
6733between 8 and 1 StaticGray displays providing that many planes, and 1 or
6734lower monochrome displays with a single plane. Modifications to this
6735variable must be completed before the window system is initialized, in,
6736for instance, `early-init.el', or they will be of no effect. */);
6737 android_display_planes = 24;
6738
6705 DEFVAR_LISP ("x-ctrl-keysym", Vx_ctrl_keysym, 6739 DEFVAR_LISP ("x-ctrl-keysym", Vx_ctrl_keysym,
6706 doc: /* SKIP: real doc in xterm.c. */); 6740 doc: /* SKIP: real doc in xterm.c. */);
6707 Vx_ctrl_keysym = Qnil; 6741 Vx_ctrl_keysym = Qnil;