graphics.h revision 2e4f8982
1/* $XTermId: graphics.h,v 1.23 2016/05/29 16:11:41 tom Exp $ */ 2 3/* 4 * Copyright 2013-2015,2016 by Ross Combs 5 * Copyright 2013-2015,2016 by Thomas E. Dickey 6 * 7 * All Rights Reserved 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a 10 * copy of this software and associated documentation files (the 11 * "Software"), to deal in the Software without restriction, including 12 * without limitation the rights to use, copy, modify, merge, publish, 13 * distribute, sublicense, and/or sell copies of the Software, and to 14 * permit persons to whom the Software is furnished to do so, subject to 15 * the following conditions: 16 * 17 * The above copyright notice and this permission notice shall be included 18 * in all copies or substantial portions of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 23 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 24 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 * 28 * Except as contained in this notice, the name(s) of the above copyright 29 * holders shall not be used in advertising or otherwise to promote the 30 * sale, use or other dealings in this Software without prior written 31 * authorization. 32 */ 33 34#ifndef included_graphics_h 35#define included_graphics_h 36/* *INDENT-OFF* */ 37 38#include <ptyx.h> 39 40#if OPT_GRAPHICS 41 42#define CHANNEL_MAX 100 43 44typedef struct { 45 short r, g, b; 46} ColorRegister; 47 48typedef unsigned short RegisterNum; 49 50#define MAX_COLOR_REGISTERS 1024U 51#define COLOR_HOLE ((RegisterNum)MAX_COLOR_REGISTERS) 52 53#define MAX_GRAPHICS 16U 54 55typedef struct { 56 RegisterNum *pixels; 57 ColorRegister *private_color_registers; 58 ColorRegister *color_registers; 59 char color_registers_used[MAX_COLOR_REGISTERS]; 60 XtermWidget xw; 61 int max_width; /* largest image which can be stored */ 62 int max_height; /* largest image which can be stored */ 63 unsigned valid_registers; /* for wrap-around behavior */ 64 int actual_width; /* size of image before scaling */ 65 int actual_height; /* size of image before scaling */ 66 int private_colors; /* if not using the shared color registers */ 67 int charrow; /* upper left starting point in characters */ 68 int charcol; /* upper left starting point in characters */ 69 int pixw; /* width of graphic pixels in screen pixels */ 70 int pixh; /* height of graphic pixels in screen pixels */ 71 int bufferid; /* which screen buffer the graphic is associated with */ 72 unsigned type; /* type of graphic 0==sixel, 1...NUM_REGIS_PAGES==ReGIS page */ 73 unsigned id; /* sequential id used for preserving layering */ 74 int valid; /* if the graphic has been initialized */ 75 int dirty; /* if the graphic needs to be redrawn */ 76 int hidden; /* if the graphic should not be displayed */ 77} Graphic; 78 79extern Graphic *get_new_graphic(XtermWidget /* xw */, int /* charrow */, int /* charcol */, unsigned /* type */); 80extern Graphic *get_new_or_matching_graphic(XtermWidget /* xw */, int /* charrow */, int /* charcol */, int /* actual_width */, int /* actual_height */, unsigned /* type */); 81extern RegisterNum read_pixel(Graphic */* graphic */, int /* x */, int /* y */); 82extern void draw_solid_pixel(Graphic */* graphic */, int /* x */, int /* y */, unsigned /* color */); 83extern void draw_solid_rectangle(Graphic */* graphic */, int /* x1 */, int /* y1 */, int /* x2 */, int /* y2 */, unsigned /* color */); 84extern void draw_solid_line(Graphic */* graphic */, int /* x1 */, int /* y1 */, int /* x2 */, int /* y2 */, unsigned /* color */); 85extern void copy_overlapping_area(Graphic */* graphic */, int /* src_x */, int /* src_y */, int /* dst_x */, int /* dst_y */, unsigned /* w */, unsigned /* h */, unsigned /* default_color */); 86extern void hls2rgb(int /* h */, int /* l */, int /* s */, short */* r */, short */* g */, short */* b */); 87extern void dump_graphic(Graphic const */* graphic */); 88extern unsigned get_color_register_count(TScreen const */* screen */); 89extern void update_color_register(Graphic */* graphic */, unsigned /* color */, int /* r */, int /* g */, int /* b */); 90extern RegisterNum find_color_register(ColorRegister const */* color_registers */, int /* r */, int /* g */, int /* b */); 91extern void chararea_clear_displayed_graphics(TScreen const */* screen */, int /* leftcol */, int /* toprow */, int /* ncols */, int /* nrows */); 92extern void pixelarea_clear_displayed_graphics(TScreen const */* screen */, int /* winx */, int /* winy */, int /* w */, int /* h */); 93extern void refresh_displayed_graphics(XtermWidget /* xw */, int /* leftcol */, int /* toprow */, int /* ncols */, int /* nrows */); 94extern void refresh_modified_displayed_graphics(XtermWidget /* xw */); 95extern void reset_displayed_graphics(TScreen const */* screen */); 96extern void scroll_displayed_graphics(XtermWidget /* xw */, int /* rows */); 97 98#ifdef NO_LEAKS 99extern void noleaks_graphics(void); 100#endif 101 102#else 103 104#define get_new_graphic(xw, charrow, charcol, type) /* nothing */ 105#define get_new_or_matching_graphic(xw, charrow, charcol, actual_width, actual_height, type) /* nothing */ 106#define read_pixel(graphic, x, y) /* nothing */ 107#define draw_solid_pixel(graphic, x, y, color) /* nothing */ 108#define draw_solid_rectangle(graphic, x1, y1, x2, y2, color) /* nothing */ 109#define draw_solid_line(graphic, x1, y1, x2, y2, color) /* nothing */ 110#define copy_overlapping_area(graphic, src_x, src_y, dst_x, dst_y, w, h, default_color) /* nothing */ 111#define hls2rgb(h, l, s, r, g, b) /* nothing */ 112#define dump_graphic(graphic) /* nothing */ 113#define get_color_register_count(screen) /* nothing */ 114#define update_color_register(graphic, color, r, g, b) /* nothing */ 115#define find_color_register(color_registers, r, g, b) /* nothing */ 116#define chararea_clear_displayed_graphics(screen, leftcol, toprow, ncols, nrows) /* nothing */ 117#define pixelarea_clear_displayed_graphics(screen, winx, winy, w, h) /* nothing */ 118#define refresh_displayed_graphics(xw, leftcol, toprow, ncols, nrows) /* nothing */ 119#define refresh_modified_displayed_graphics(xw) /* nothing */ 120#define reset_displayed_graphics(screen) /* nothing */ 121#define scroll_displayed_graphics(xw, rows) /* nothing */ 122 123#endif 124 125/* *INDENT-ON* */ 126 127#endif /* included_graphics_h */ 128