📄 xp_pw.c
字号:
if (Xp_xv_rop_internal(display, d, gc, x, y, width, height, (Xv_opaque) pr, xr, yr, info) == XV_ERROR) { xv_error(XV_NULL, ERROR_STRING, "xv_rop: xv_rop_internal failed", 0); } } XpFreeGC(display, gc);}#include <pixrect/memvar.h>#include <xview_private/cms_impl.h>#include <xview_private/svrim_impl.h>int GC_CHAIN_KEY;#include <xview/xv_xrect.h>#define INVALID_XID 0extern Screen_visual *screen_add_visual();extern Xv_xrectlist *screen_get_clip_rects();Xv_private voidXp_xv_set_gc_op(display, info, gc, op, fg_mode, fg_bg) Display *display; Xv_Drawable_info *info; GC gc; int op; short fg_mode; int fg_bg;{ unsigned long value_mask; XGCValues val; Cms_info *cms = CMS_PRIVATE(xv_cms(info)); val.function = XV_TO_XOP(op); value_mask = GCForeground | GCBackground | GCFunction | GCPlaneMask; val.plane_mask = xv_plane_mask(info); if (info->is_bitmap) { /* restrict bitmap colors to 1 and 0 */ val.foreground = (fg_bg == XV_DEFAULT_FG_BG) ? 1 : 0; val.background = (fg_bg == XV_DEFAULT_FG_BG) ? 0 : 1; } else if (fg_mode == XV_USE_OP_FG) { if (fg_bg == XV_DEFAULT_FG_BG) { val.foreground = XV_TO_X_PIXEL(PIX_OPCOLOR(op), cms); val.background = xv_bg(info); } else { val.background = XV_TO_X_PIXEL(PIX_OPCOLOR(op), cms); val.foreground = xv_bg(info); } } else { if (fg_bg == XV_DEFAULT_FG_BG) { val.foreground = xv_fg(info); val.background = xv_bg(info); } else { val.background = xv_fg(info); val.foreground = xv_bg(info); } } switch (val.function) { case GXclear: val.foreground = val.background; val.function = GXcopy; break; case GXset: val.foreground = xv_fg(info); val.function = GXcopy; break; case GXxor: val.foreground = val.foreground ^ val.background; val.background = 0; break; case GXinvert: if (val.foreground == val.background) { val.foreground = xv_fg(info); val.background = xv_bg(info); } val.plane_mask = val.foreground ^ val.background; break; } XChangeGC(display, gc, value_mask, &val);}Xv_private intXp_xv_rop_internal(display, d, gc, x, y, width, height, src, xr, yr, dest_info) Display *display; Drawable d; GC gc; int x, y, width, height; Xv_opaque src; int xr, yr; Xv_Drawable_info *dest_info;{ Xv_Drawable_info *src_info; Drawable src_d; XGCValues changes; if (width == 0 || height == 0 || !src) { return (XV_ERROR); } /* * If src is not a client pixrect, it can either be a window or a * server_image. */ if (PR_NOT_MPR(((Pixrect *) src))) { DRAWABLE_INFO_MACRO((Xv_opaque)src, src_info); src_d = (Drawable) xv_xid(src_info); if (PR_IS_SERVER_IMAGE((Pixrect *) src)) { /* * Since src is a server image, avoid the overhead of NoExpose * events by doing stippling/tiling. */ changes.ts_x_origin = x; changes.ts_y_origin = y; /* clip to source dimensions */ width = (width > ((Pixrect *) src)->pr_size.x) ? ((Pixrect *) src)->pr_size.x : width; height = (height > ((Pixrect *) src)->pr_size.y) ? ((Pixrect *) src)->pr_size.y : height; switch (xv_depth_relation(xv_depth(dest_info), xv_depth(src_info))) { case DEST1SRC1: /* * reset foreground/background since fg/bg on color need not * be 1 or 0. */ changes.foreground = 1; changes.background = 0; changes.stipple = xv_xid(src_info); changes.fill_style = FillOpaqueStippled; XChangeGC(display, gc, GCForeground | GCBackground | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin | GCStipple, &changes); XFillRectangle(display, d, gc, x, y, width, height); break;#ifndef SVR4 case DEST8SRC1:#else SVR4 case DESTNSRC1:#endif SVR4 changes.stipple = xv_xid(src_info); changes.fill_style = FillOpaqueStippled; XChangeGC(display, gc, GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin | GCStipple, &changes); XFillRectangle(display, d, gc, x, y, width, height); break;#ifndef SVR4 case DEST8SRC8:#endif SVR4 case DESTEQUALSRC: changes.tile = xv_xid(src_info); changes.fill_style = FillTiled; XChangeGC(display, gc, GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin | GCTile, &changes); XFillRectangle(display, d, gc, x, y, width, height); break; default: xv_error(XV_NULL, ERROR_STRING, "xv_rop: can't handle drawables of different depth", 0); return (XV_ERROR); } } else { /* src is a window */ switch (xv_depth_relation(xv_depth(dest_info), xv_depth(src_info))) { case DEST1SRC1: case DEST8SRC8: case DESTEQUALSRC: XCopyArea(display, src_d, d, gc, xr, yr, width, height, x, y); break; default: xv_error(XV_NULL, ERROR_STRING, "xv_rop: Windows of different depth, can't rop", 0); return (XV_ERROR); } } } else { if (Xp_xv_rop_mpr_internal(display, d, gc, x, y, width, height, src, xr, yr, dest_info, TRUE) == XV_ERROR) return(XV_ERROR); } return(XV_OK);} Xv_private intXp_xv_rop_mpr_internal(display, d, gc, x, y, width, height, src, xr, yr, dest_info, mpr_bits) Display *display; Drawable d; GC gc; int x, y, width, height; Xv_opaque src; int xr, yr; Xv_Drawable_info *dest_info; short mpr_bits;{ int src_depth; XImage *ximage; Cms_info *cms = CMS_PRIVATE(xv_cms(dest_info)); static char *inverse_table = (char *)NULL; src_depth = ((Pixrect *) src)->pr_depth; /* * In Sunview, this case is handled by setting all non-zero color values * to 1's. This is currently a NO-OP in XView. This case must be * handled by creating a separate array of data bits of setting non-zero * pixel values to 1's. */ if ((xv_depth(dest_info) == 1) && (src_depth > 1)) { return(XV_ERROR); } if (src_depth == 1) { if (!(ximage = xv_image_1(dest_info))) { Xv_opaque visual; visual = xv_get(xv_screen(dest_info), SCREEN_STATIC_VISUAL); xv_image_1(dest_info) = ximage = (XImage *) XCreateImage(display, visual, 1, XYBitmap, 0, (char *) mpr_d(((Pixrect *) src))->md_image, 0, 0, MPR_LINEBITPAD, mpr_d(((Pixrect *) src))->md_linebytes); if (!ximage) { return (XV_ERROR); } } } else if ((src_depth == 8) && (xv_depth(dest_info) == 8)) { if (!(ximage = xv_image_8(dest_info))) { Xv_opaque visual; visual = xv_get(xv_screen(dest_info), SCREEN_STATIC_VISUAL); xv_image_8(dest_info) = ximage = (XImage *) XCreateImage(display, visual, 8, ZPixmap, 0, (char *) mpr_d(((Pixrect *) src))->md_image, 0, 0, MPR_LINEBITPAD, mpr_d(((Pixrect *) src))->md_linebytes); if (!ximage) { return (XV_ERROR); } } } else { return (XV_ERROR); } ximage->bitmap_unit = MPR_LINEBITPAD; ximage->bitmap_pad = MPR_LINEBITPAD; ximage->height = ((Pixrect *) src)->pr_height; ximage->width = ((Pixrect *) src)->pr_width; ximage->bytes_per_line = mpr_d(((Pixrect *) src))->md_linebytes; ximage->data = (char *) mpr_d(((Pixrect *) src))->md_image; /* * The bitmap data being passed in might be in either of 2 formats: * 1. memory pixrect format. * 2. Xlib bitmap format. */ if (mpr_bits == TRUE) { /* bitmap data is in memory pixrect format */#ifdef i386 ximage->byte_order = LSBFirst; /* * Check to see if the pixrect data was set by mpr_static(), or by * actually creating the pixrect with mem_create() and drawing into * it. */ if (mpr_d((Pixrect *) src)->md_flags & MP_I386) ximage->bitmap_bit_order = LSBFirst; else ximage->bitmap_bit_order = MSBFirst;#else#ifdef ultrix ximage->byte_order = LSBFirst; ximage->bitmap_bit_order = MSBFirst;#else ximage->byte_order = MSBFirst; ximage->bitmap_bit_order = MSBFirst;#endif /* ~VAX */#endif /* ~i386 */ } else { /* bitmap data is in Xlib bitmap format */ ximage->byte_order = LSBFirst; ximage->bitmap_bit_order = LSBFirst; } if (src_depth == 1) { XPutImage(display, d, gc, ximage, xr, yr, x, y, MIN(width, ximage->width), MIN(height, ximage->height)); } else { register int i, j; unsigned long index; /* * build inverse pixel-to-cms_index table */ if (inverse_table == (char *)NULL) /* malloc only on the first call to this function */ inverse_table = (char *)malloc(256 * sizeof(char)); for (i = 0; i < cms->size; i++) inverse_table[cms->index_table[i]] = i; /* * convert image from cms indices to X pixel values. */ for (i = 0; i < ximage->height; i++) { for (j = 0; j < ximage->bytes_per_line; j++) { index = j + i * ximage->bytes_per_line; ximage->data[index] = cms->index_table[ximage->data[index]]; } } XPutImage(display, d, gc, ximage, xr, yr, x, y, MIN(width, ximage->width), MIN(height, ximage->height)); /* * convert it back to cms indices */ for (i = 0; i < ximage->height; i++) { for (j = 0; j < ximage->bytes_per_line; j++) { index = j + i * ximage->bytes_per_line; ximage->data[index] = inverse_table[ximage->data[index]]; } } } return (XV_OK);}#ifdef NEEDTHISPkg_privatexv_depth_relation(d_depth, s_depth) int d_depth, s_depth;{#ifndef SVR4 if (d_depth == s_depth) { if (d_depth == 1) { return DEST1SRC1; } else if (d_depth == 8) { return DEST8SRC8; } else { return DESTEQUALSRC; } } else if (d_depth == 8 && s_depth == 1) { return DEST8SRC1;#else SVR4 if (d_depth == s_depth) { if (d_depth == 1) { return DEST1SRC1; } else { return DESTEQUALSRC; } } else if (d_depth != 1 && s_depth == 1) { return DESTNSRC1;#endif SVR4 } else { return OTHER_DEPTHS; }}#endif#endif /* xview 2 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -