?? gdkgc-x11.c
字號:
if (x11_dst_gc->stipple) g_object_unref (x11_dst_gc->stipple); x11_dst_gc->stipple = x11_src_gc->stipple; if (x11_dst_gc->stipple) g_object_ref (x11_dst_gc->stipple); if (x11_dst_gc->tile) g_object_unref (x11_dst_gc->tile); x11_dst_gc->tile = x11_src_gc->tile; if (x11_dst_gc->tile) g_object_ref (x11_dst_gc->tile); clear_fg_picture (dst_gc);}/** * gdk_gc_get_screen: * @gc: a #GdkGC. * * Gets the #GdkScreen for which @gc was created * * Returns: the #GdkScreen for @gc. * * Since: 2.2 */GdkScreen * gdk_gc_get_screen (GdkGC *gc){ g_return_val_if_fail (GDK_IS_GC_X11 (gc), NULL); return GDK_GC_X11 (gc)->screen;}/** * gdk_x11_gc_get_xdisplay: * @gc: a #GdkGC. * * Returns the display of a #GdkGC. * * Return value: an Xlib <type>Display*</type>. **/Display *gdk_x11_gc_get_xdisplay (GdkGC *gc){ g_return_val_if_fail (GDK_IS_GC_X11 (gc), NULL); return GDK_SCREEN_XDISPLAY (gdk_gc_get_screen (gc));}/** * gdk_x11_gc_get_xgc: * @gc: a #GdkGC. * * Returns the X GC of a #GdkGC. * * Return value: an Xlib <type>GC</type>. **/GCgdk_x11_gc_get_xgc (GdkGC *gc){ GdkGCX11 *gc_x11; g_return_val_if_fail (GDK_IS_GC_X11 (gc), NULL); gc_x11 = GDK_GC_X11 (gc); if (gc_x11->dirty_mask) _gdk_x11_gc_flush (gc); return gc_x11->xgc;}/* Various bits of the below are roughly cribbed from XFree86 * lib/Xft/xftdraw.c, Copyright 2000, Keith Packard */static XRenderPictFormat *foreground_format (GdkGC *gc){ XRenderPictFormat pf; pf.type = PictTypeDirect; pf.depth = 32; pf.direct.redMask = 0xff; pf.direct.greenMask = 0xff; pf.direct.blueMask = 0xff; pf.direct.alphaMask = 0xff; return XRenderFindFormat (GDK_GC_XDISPLAY (gc), (PictFormatType | PictFormatDepth | PictFormatRedMask | PictFormatGreenMask | PictFormatBlueMask | PictFormatAlphaMask), &pf, 0);}static Picturemake_fg_tile_picture (GdkGC *gc){ GdkGCX11 *x11_gc = GDK_GC_X11 (gc); GdkVisual *visual = gdk_drawable_get_visual (x11_gc->tile); XRenderPictFormat *format = NULL; if (visual) { format = XRenderFindVisualFormat (GDK_GC_XDISPLAY (gc), GDK_VISUAL_XVISUAL (visual)); } else if (x11_gc->depth == 1) { format = XRenderFindStandardFormat (GDK_GC_XDISPLAY (gc), PictStandardA1); } if (format) { XRenderPictureAttributes pa; pa.repeat = True; return XRenderCreatePicture (GDK_GC_XDISPLAY (gc), GDK_PIXMAP_XID (x11_gc->tile), format, CPRepeat, &pa); } return None;}static Picturemake_stipple_picture (GdkGC *gc){ GdkGCX11 *x11_gc = GDK_GC_X11 (gc); XRenderPictFormat *format = NULL; XRenderPictureAttributes pa; format = XRenderFindStandardFormat (GDK_GC_XDISPLAY (gc), PictStandardA1); pa.repeat = True; return XRenderCreatePicture (GDK_GC_XDISPLAY (gc), GDK_PIXMAP_XID (x11_gc->stipple), format, CPRepeat, &pa);}static Picturemake_color_picture (GdkGC *gc, XRenderColor *color){ GdkGCX11 *x11_gc = GDK_GC_X11 (gc); XRenderPictureAttributes pa; XRenderPictFormat *pix_format = foreground_format (gc); Pixmap pix; Picture picture; if (!pix_format) return None; pix = XCreatePixmap (GDK_GC_XDISPLAY (gc), GDK_SCREEN_XROOTWIN (x11_gc->screen), 1, 1, pix_format->depth); pa.repeat = True; picture = XRenderCreatePicture (GDK_GC_XDISPLAY (gc), pix, pix_format, CPRepeat, &pa); XFreePixmap (GDK_GC_XDISPLAY (gc), pix); XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, picture, color, 0, 0, 1, 1); return picture;}static voidget_bg_color (GdkGC *gc, XRenderColor *render_color){ GdkGCX11 *x11_gc = GDK_GC_X11 (gc); GdkColormap *cmap; cmap = gdk_gc_get_colormap (gc); if (cmap) { GdkColor color; gdk_colormap_query_color (cmap, x11_gc->bg_pixel, &color); render_color->alpha = 0xffff; render_color->red = color.red; render_color->green = color.green; render_color->blue = color.blue; } else /* Not worth warning, just use black */ { render_color->alpha = 0xffff; render_color->red = 0; render_color->green = 0; render_color->blue = 0; }}/** * _gdk_x11_gc_get_fg_picture: * @gc: a #GdkGC * * Gets a Xrender Picture object suitable for being the source * drawable for drawing with the foreground the graphics context. * * Return value: a Picture, owned by the GC; this cannot be * used over subsequent modification of the GC. **/Picture_gdk_x11_gc_get_fg_picture (GdkGC *gc){ GdkGCX11 *x11_gc; gboolean new = FALSE; XftColor xftcolor; GdkFill fill; int width, height; g_return_val_if_fail (GDK_IS_GC_X11 (gc), None); if (!_gdk_x11_have_render (GDK_GC_DISPLAY (gc))) return None; x11_gc = GDK_GC_X11 (gc); fill = GDK_SOLID; width = 1; height = 1; switch (x11_gc->fill) { case GDK_SOLID: break; case GDK_TILED: if (x11_gc->tile) { if (!x11_gc->fg_picture) x11_gc->fg_picture = make_fg_tile_picture (gc); if (x11_gc->fg_picture != None) return x11_gc->fg_picture; } break; case GDK_STIPPLED: case GDK_OPAQUE_STIPPLED: if (x11_gc->stipple) { gdk_drawable_get_size (x11_gc->stipple, &width, &height); fill = x11_gc->fill; } break; } if (x11_gc->fg_picture == None) { XRenderPictureAttributes pa; XRenderPictFormat *pix_format = foreground_format (gc); Pixmap pix; if (!pix_format) return None; pix = XCreatePixmap (GDK_GC_XDISPLAY (gc), GDK_SCREEN_XROOTWIN (x11_gc->screen), width, height, pix_format->depth); pa.repeat = True; x11_gc->fg_picture = XRenderCreatePicture (GDK_GC_XDISPLAY (gc), pix, pix_format, CPRepeat, &pa); XFreePixmap (GDK_GC_XDISPLAY (gc), pix); new = TRUE; } _gdk_gc_x11_get_fg_xft_color (gc, &xftcolor); if (x11_gc->fg_picture_color.alpha != 0xffff || x11_gc->fg_picture_color.red != xftcolor.color.red || x11_gc->fg_picture_color.green != xftcolor.color.green || x11_gc->fg_picture_color.blue != xftcolor.color.blue) { x11_gc->fg_picture_color.alpha = 0xffff; x11_gc->fg_picture_color.red = xftcolor.color.red; x11_gc->fg_picture_color.green = xftcolor.color.green; x11_gc->fg_picture_color.blue = xftcolor.color.blue; new = TRUE; } switch (fill) { case GDK_SOLID: XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, x11_gc->fg_picture, &x11_gc->fg_picture_color, 0, 0, width, height); break; case GDK_STIPPLED: { Picture stipple_picture = make_stipple_picture (gc); XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, x11_gc->fg_picture, &x11_gc->fg_picture_color, 0, 0, width, height); XRenderComposite (GDK_GC_XDISPLAY (gc), PictOpInReverse, stipple_picture, None, x11_gc->fg_picture, 0, 0, 0, 0, 0, 0, width, height); XRenderFreePicture (GDK_GC_XDISPLAY (x11_gc), stipple_picture); } break; case GDK_OPAQUE_STIPPLED: { XRenderColor bg_color; Picture stipple_picture = make_stipple_picture (gc); Picture fg_picture = make_color_picture (gc, &x11_gc->fg_picture_color); get_bg_color (gc, &bg_color); XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, x11_gc->fg_picture, &bg_color, 0, 0, width, height); XRenderComposite (GDK_GC_XDISPLAY (gc), PictOpOver, fg_picture, stipple_picture, x11_gc->fg_picture, 0, 0, 0, 0, 0, 0, width, height); XRenderFreePicture (GDK_GC_XDISPLAY (x11_gc), stipple_picture); XRenderFreePicture (GDK_GC_XDISPLAY (x11_gc), fg_picture); } break; case GDK_TILED: g_assert_not_reached (); /* handled above */ break; } return x11_gc->fg_picture;}/** * _gdk_gc_x11_get_fg_xft_color: * @gc: a #GdkGC * @xftcolor: location to store the color * * Gets the foreground color of the GC as a XftColor. **/void_gdk_gc_x11_get_fg_xft_color (GdkGC *gc, XftColor *xftcolor){ GdkGCX11 *x11_gc; GdkColormap *cmap; GdkColor color; g_return_if_fail (GDK_IS_GC_X11 (gc)); x11_gc = GDK_GC_X11 (gc); cmap = gdk_gc_get_colormap (gc); xftcolor->pixel = x11_gc->fg_pixel; if (cmap) { gdk_colormap_query_color (cmap, xftcolor->pixel, &color); xftcolor->color.alpha = 0xffff; xftcolor->color.red = color.red; xftcolor->color.green = color.green; xftcolor->color.blue = color.blue; } else if (x11_gc->depth == 1) { /* Drawing with Xft on a bitmap is a bit bizzare; it * takes alpha >= 0x8000 to mean 'set to 1' and * alpha < 0x8000 to mean 'set to 0'. */ if (xftcolor->pixel) { xftcolor->color.red = 0xffff; xftcolor->color.green = 0xffff; xftcolor->color.blue = 0xffff; xftcolor->color.alpha = 0xffff; } else { xftcolor->color.red = 0; xftcolor->color.green = 0; xftcolor->color.blue = 0; xftcolor->color.alpha = 0; } } else { g_warning ("Using Xft rendering requires the GC argument to have a\n" "specified colormap. If the GC was created for a drawable\n" "with a colormap, the colormap will be set on the GC\n" "automatically. Otherwise, a colormap must be set on it with" "gdk_gc_set_colormap"); }}void_gdk_windowing_gc_get_foreground (GdkGC *gc, GdkColor *color){ GdkGCX11 *x11_gc; GdkColormap *cmap; g_return_if_fail (GDK_IS_GC_X11 (gc)); x11_gc = GDK_GC_X11 (gc); color->pixel = x11_gc->fg_pixel; cmap = gdk_gc_get_colormap (gc); if (cmap) gdk_colormap_query_color (cmap, x11_gc->fg_pixel, color); else g_warning ("No colormap in _gdk_windowing_gc_get_foreground");}#define __GDK_GC_X11_C__#include "gdkaliasdef.c"
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -