nsresult gfxGdkNativeRenderer::DrawWithXlib(gfxXlibSurface* surface, nsIntPoint offset, nsIntRect* clipRects, PRUint32 numClipRects) { GdkDrawable *drawable = gfxPlatformGtk::GetGdkDrawable(surface); if (!drawable) { gfxIntSize size = surface->GetSize(); int depth = cairo_xlib_surface_get_depth(surface->CairoSurface()); GdkScreen* screen = gdk_colormap_get_screen(mColormap); drawable = gdk_pixmap_foreign_new_for_screen(screen, surface->XDrawable(), size.width, size.height, depth); if (!drawable) return NS_ERROR_FAILURE; gdk_drawable_set_colormap(drawable, mColormap); gfxPlatformGtk::SetGdkDrawable(surface, drawable); g_object_unref(drawable); // The drawable now belongs to |surface|. } GdkRectangle clipRect; if (numClipRects) { NS_ASSERTION(numClipRects == 1, "Too many clip rects"); clipRect.x = clipRects[0].x; clipRect.y = clipRects[0].y; clipRect.width = clipRects[0].width; clipRect.height = clipRects[0].height; } return DrawWithGDK(drawable, offset.x, offset.y, numClipRects ? &clipRect : NULL, numClipRects); }
/** * gdk_pixbuf_render_pixmap_and_mask_for_colormap: * @pixbuf: A pixbuf. * @colormap: A #GdkColormap * @pixmap_return: Location to store a pointer to the created pixmap, * or %NULL if the pixmap is not needed. * @mask_return: Location to store a pointer to the created mask, * or %NULL if the mask is not needed. * @alpha_threshold: Threshold value for opacity values. * * Creates a pixmap and a mask bitmap which are returned in the @pixmap_return * and @mask_return arguments, respectively, and renders a pixbuf and its * corresponding tresholded alpha mask to them. This is merely a convenience * function; applications that need to render pixbufs with dither offsets or to * given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha(). * * The pixmap that is created uses the #GdkColormap specified by @colormap. * This colormap must match the colormap of the window where the pixmap * will eventually be used or an error will result. * * If the pixbuf does not have an alpha channel, then *@mask_return will be set * to %NULL. **/ void gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf, GdkColormap *colormap, GdkPixmap **pixmap_return, GdkBitmap **mask_return, int alpha_threshold) { GdkScreen *screen; g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); g_return_if_fail (GDK_IS_COLORMAP (colormap)); screen = gdk_colormap_get_screen (colormap); if (pixmap_return) { GdkGC *gc; *pixmap_return = gdk_pixmap_new (gdk_screen_get_root_window (screen), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_colormap_get_visual (colormap)->depth); gdk_drawable_set_colormap (GDK_DRAWABLE (*pixmap_return), colormap); gc = _gdk_drawable_get_scratch_gc (*pixmap_return, FALSE); /* If the pixbuf has an alpha channel, using gdk_pixbuf_draw would give * random pixel values in the area that are within the mask, but semi- * transparent. So we treat the pixbuf like a pixbuf without alpha channel; * see bug #487865. */ if (gdk_pixbuf_get_has_alpha (pixbuf)) gdk_draw_rgb_32_image (*pixmap_return, gc, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GDK_RGB_DITHER_NORMAL, gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_rowstride (pixbuf)); else gdk_draw_pixbuf (*pixmap_return, gc, pixbuf, 0, 0, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GDK_RGB_DITHER_NORMAL, 0, 0); } if (mask_return) { if (gdk_pixbuf_get_has_alpha (pixbuf)) { *mask_return = gdk_pixmap_new (gdk_screen_get_root_window (screen), gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), 1); gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return, 0, 0, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), alpha_threshold); } else *mask_return = NULL; } }
void gfxGdkNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, PRUint32 flags, GdkColormap* colormap) { mColormap = colormap; Visual* visual = gdk_x11_visual_get_xvisual(gdk_colormap_get_visual(colormap)); Screen* screen = gdk_x11_screen_get_xscreen(gdk_colormap_get_screen(colormap)); gfxXlibNativeRenderer::Draw(ctx, size, flags, screen, visual, nsnull); }
static VALUE rg_screen(VALUE self) { return GOBJ2RVAL(gdk_colormap_get_screen(_SELF(self))); }
/*# @method get_screen GdkColormap @brief Gets the screen for which this colormap was created. @return the screen for which this colormap was created. */ FALCON_FUNC Colormap::get_screen( VMARG ) { NO_ARGS vm->retval( new Gdk::Screen( vm->findWKI( "GdkScreen" )->asClass(), gdk_colormap_get_screen( GET_COLORMAP( vm->self() ) ) ) ); }
static GdkPixbuf * render_icon (GtkStyle *style, const GtkIconSource *source, GtkTextDirection direction, GtkStateType state, GtkIconSize size, GtkWidget *widget, const gchar *detail) { int width = 1; int height = 1; GdkPixbuf *scaled; GdkPixbuf *stated; GdkPixbuf *base_pixbuf; GdkScreen *screen; GtkSettings *settings; /* Oddly, style can be NULL in this function, because * GtkIconSet can be used without a style and if so * it uses this function. */ base_pixbuf = gtk_icon_source_get_pixbuf (source); g_return_val_if_fail (base_pixbuf != NULL, NULL); if (widget && gtk_widget_has_screen (widget)) { screen = gtk_widget_get_screen (widget); settings = gtk_settings_get_for_screen (screen); } else if (style->colormap) { screen = gdk_colormap_get_screen (style->colormap); settings = gtk_settings_get_for_screen (screen); } else { settings = gtk_settings_get_default (); GTK_NOTE (MULTIHEAD, g_warning ("Using the default screen for gtk_default_render_icon()")); } if (size != (GtkIconSize) -1 && !gtk_icon_size_lookup_for_settings (settings, size, &width, &height)) { g_warning (G_STRLOC ": invalid icon size '%d'", size); return NULL; } /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise, * leave it alone. */ if (size != (GtkIconSize)-1 && gtk_icon_source_get_size_wildcarded (source)) scaled = scale_or_ref (base_pixbuf, width, height); else scaled = g_object_ref (base_pixbuf); /* If the state was wildcarded, then generate a state. */ if (gtk_icon_source_get_state_wildcarded (source)) { if (state == GTK_STATE_INSENSITIVE) { stated = set_transparency (scaled, 0.3); gdk_pixbuf_saturate_and_pixelate (stated, stated, 0.1, FALSE); g_object_unref (scaled); } else if (state == GTK_STATE_PRELIGHT) { stated = gdk_pixbuf_copy (scaled); gdk_pixbuf_saturate_and_pixelate (scaled, stated, 1.2, FALSE); g_object_unref (scaled); } else { stated = scaled; } } else stated = scaled; return stated; }