Add gdk_draw_rectangle_alpha_libgtk_only which uses XRenderFillRectangle

2004-07-27  Anders Carlsson  <andersca@gnome.org>

	* demos/gtk-demo/iconview.c: (do_iconview):
	* gdk/gdkdrawable.h:
	* gdk/linux-fb/gdkdrawable-fb2.c:
	(gdk_draw_rectangle_alpha_libgtk_only):
	* gdk/win32/gdkdrawable-win32.c:
	(gdk_draw_rectangle_alpha_libgtk_only):
	* gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
	(get_impl_drawable), (gdk_x11_draw_pixbuf),
	(gdk_draw_rectangle_alpha_libgtk_only):
	Add gdk_draw_rectangle_alpha_libgtk_only which uses
	XRenderFillRectangle on X11. It's stubbed out on the
	Win32 and fb backends.

	* gtk/gtkiconview.c:
	(gtk_icon_view_paint_rubberband):
	Use gdk_draw_rectangle_alpha_libgtk_only here.
This commit is contained in:
Anders Carlsson 2004-07-27 21:58:09 +00:00 committed by Anders Carlsson
parent c5541ca6c8
commit 564ab37a07
10 changed files with 196 additions and 17 deletions

View File

@ -1,3 +1,22 @@
2004-07-27 Anders Carlsson <andersca@gnome.org>
* demos/gtk-demo/iconview.c: (do_iconview):
* gdk/gdkdrawable.h:
* gdk/linux-fb/gdkdrawable-fb2.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/win32/gdkdrawable-win32.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
(get_impl_drawable), (gdk_x11_draw_pixbuf),
(gdk_draw_rectangle_alpha_libgtk_only):
Add gdk_draw_rectangle_alpha_libgtk_only which uses
XRenderFillRectangle on X11. It's stubbed out on the
Win32 and fb backends.
* gtk/gtkiconview.c:
(gtk_icon_view_paint_rubberband):
Use gdk_draw_rectangle_alpha_libgtk_only here.
2004-07-27 Anders Carlsson <andersca@gnome.org>
* gtk/gtkaboutdialog.c: (gtk_about_dialog_init),

View File

@ -1,3 +1,22 @@
2004-07-27 Anders Carlsson <andersca@gnome.org>
* demos/gtk-demo/iconview.c: (do_iconview):
* gdk/gdkdrawable.h:
* gdk/linux-fb/gdkdrawable-fb2.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/win32/gdkdrawable-win32.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
(get_impl_drawable), (gdk_x11_draw_pixbuf),
(gdk_draw_rectangle_alpha_libgtk_only):
Add gdk_draw_rectangle_alpha_libgtk_only which uses
XRenderFillRectangle on X11. It's stubbed out on the
Win32 and fb backends.
* gtk/gtkiconview.c:
(gtk_icon_view_paint_rubberband):
Use gdk_draw_rectangle_alpha_libgtk_only here.
2004-07-27 Anders Carlsson <andersca@gnome.org>
* gtk/gtkaboutdialog.c: (gtk_about_dialog_init),

View File

@ -1,3 +1,22 @@
2004-07-27 Anders Carlsson <andersca@gnome.org>
* demos/gtk-demo/iconview.c: (do_iconview):
* gdk/gdkdrawable.h:
* gdk/linux-fb/gdkdrawable-fb2.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/win32/gdkdrawable-win32.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
(get_impl_drawable), (gdk_x11_draw_pixbuf),
(gdk_draw_rectangle_alpha_libgtk_only):
Add gdk_draw_rectangle_alpha_libgtk_only which uses
XRenderFillRectangle on X11. It's stubbed out on the
Win32 and fb backends.
* gtk/gtkiconview.c:
(gtk_icon_view_paint_rubberband):
Use gdk_draw_rectangle_alpha_libgtk_only here.
2004-07-27 Anders Carlsson <andersca@gnome.org>
* gtk/gtkaboutdialog.c: (gtk_about_dialog_init),

View File

@ -1,3 +1,22 @@
2004-07-27 Anders Carlsson <andersca@gnome.org>
* demos/gtk-demo/iconview.c: (do_iconview):
* gdk/gdkdrawable.h:
* gdk/linux-fb/gdkdrawable-fb2.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/win32/gdkdrawable-win32.c:
(gdk_draw_rectangle_alpha_libgtk_only):
* gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
(get_impl_drawable), (gdk_x11_draw_pixbuf),
(gdk_draw_rectangle_alpha_libgtk_only):
Add gdk_draw_rectangle_alpha_libgtk_only which uses
XRenderFillRectangle on X11. It's stubbed out on the
Win32 and fb backends.
* gtk/gtkiconview.c:
(gtk_icon_view_paint_rubberband):
Use gdk_draw_rectangle_alpha_libgtk_only here.
2004-07-27 Anders Carlsson <andersca@gnome.org>
* gtk/gtkaboutdialog.c: (gtk_about_dialog_init),

View File

@ -320,6 +320,8 @@ do_iconview (GtkWidget *do_widget)
fill_store (store);
icon_view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
GTK_SELECTION_MULTIPLE);
g_object_unref (store);
/* Connect to the "clicked" signal of the "Up" tool button */

View File

@ -360,6 +360,15 @@ GdkImage *gdk_drawable_copy_to_image (GdkDrawable *drawable,
GdkRegion *gdk_drawable_get_clip_region (GdkDrawable *drawable);
GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable);
gboolean gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
gint x,
gint y,
gint width,
gint height,
GdkColor *color,
guint16 alpha);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1643,3 +1643,15 @@ gdk_shadow_fb_draw_lines (GdkDrawable *drawable,
}
#endif
gboolean
gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
gint x,
gint y,
gint width,
gint height,
GdkColor *color,
guint16 alpha)
{
return FALSE;
}

View File

@ -1822,3 +1822,15 @@ gdk_win32_drawable_get_handle (GdkDrawable *drawable)
{
return GDK_DRAWABLE_HANDLE (drawable);
}
gboolean
gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
gint x,
gint y,
gint width,
gint height,
GdkColor *color,
guint16 alpha)
{
return FALSE;
}

View File

@ -817,7 +817,7 @@ gdk_x11_draw_image (GdkDrawable *drawable,
gint height)
{
GdkDrawableImplX11 *impl;
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
#ifdef USE_SHM
@ -846,7 +846,7 @@ static GdkDrawable * get_impl_drawable (GdkDrawable *drawable)
GdkDrawable *impl;
if (GDK_IS_WINDOW (drawable))
impl = ((GdkPixmapObject *)drawable)->impl;
impl = ((GdkWindowObject *)drawable)->impl;
else if (GDK_IS_PIXMAP (drawable))
impl = ((GdkPixmapObject *)drawable)->impl;
else
@ -1456,3 +1456,68 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable,
rowstride,
dest_x, dest_y, width, height);
}
/**
* gdk_draw_rectangle_alpha_libgtk_only:
* @drawable: The #GdkDrawable to draw on
* @x: the x coordinate of the left edge of the rectangle.
* @y: the y coordinate of the top edge of the rectangle.
* @width: the width of the rectangle.
* @height: the height of the rectangle.
* @color: The color
* @alpha: The alpha value.
*
* Tries to draw a filled alpha blended rectangle using the window
* system's native routines. This is not public API and must not be
* used by applications.
*
* Return value: TRUE if the rectangle could be drawn, FALSE
* otherwise.
**/
gboolean
gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
gint x,
gint y,
gint width,
gint height,
GdkColor *color,
guint16 alpha)
{
Display *xdisplay;
XRenderColor render_color;
Picture pict;
int x_offset, y_offset;
GdkDrawable *real_drawable, *impl;
g_return_val_if_fail (color != NULL, FALSE);
if (!GDK_IS_WINDOW (drawable))
return FALSE;
if (!_gdk_x11_have_render (gdk_drawable_get_display (drawable)))
return FALSE;
gdk_window_get_internal_paint_info (GDK_WINDOW (drawable),
&real_drawable,
&x_offset, &y_offset);
impl = ((GdkWindowObject *)real_drawable)->impl;
pict = gdk_x11_drawable_get_picture (impl);
if (pict == None)
return FALSE;
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_drawable_get_display (drawable));
render_color.alpha = alpha;
render_color.red = color->red * render_color.alpha / 0xffff;
render_color.green = color->green * render_color.alpha / 0xffff;
render_color.blue = color->blue * render_color.alpha / 0xffff;
XRenderFillRectangle (xdisplay,
PictOpOver, pict, &render_color,
x - x_offset, y - y_offset,
width, height);
return TRUE;
}

View File

@ -109,7 +109,7 @@ struct _GtkIconViewPrivate
gint press_start_x;
gint press_start_y;
#endif
/* Layout used to draw icon text */
PangoLayout *layout;
@ -173,7 +173,6 @@ static gboolean gtk_icon_view_button_press (GtkWidget *widget,
GdkEventButton *event);
static gboolean gtk_icon_view_button_release (GtkWidget *widget,
GdkEventButton *event);
/* GtkIconView signals */
static void gtk_icon_view_set_adjustments (GtkIconView *icon_view,
GtkAdjustment *hadj,
@ -293,7 +292,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
widget_class->motion_notify_event = gtk_icon_view_motion;
widget_class->button_press_event = gtk_icon_view_button_press;
widget_class->button_release_event = gtk_icon_view_button_release;
klass->set_scroll_adjustments = gtk_icon_view_set_adjustments;
klass->select_all = gtk_icon_view_real_select_all;
klass->unselect_all = gtk_icon_view_real_unselect_all;
@ -736,8 +735,6 @@ gtk_icon_view_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window);
gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
}
static void
@ -1067,7 +1064,6 @@ gtk_icon_view_button_release (GtkWidget *widget,
return TRUE;
}
static void
gtk_icon_view_update_rubberband (gpointer data)
{
@ -1888,16 +1884,23 @@ gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
fill_color = gtk_gdk_color_to_rgb (fill_color_gdk) << 8 | fill_color_alpha;
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, rect.width, rect.height);
gdk_pixbuf_fill (pixbuf, fill_color);
if (!gdk_draw_rectangle_alpha_libgtk_only (icon_view->priv->bin_window,
rect.x, rect.y, rect.width, rect.height,
fill_color_gdk,
fill_color_alpha << 8 | fill_color_alpha))
{
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, rect.width, rect.height);
gdk_pixbuf_fill (pixbuf, fill_color);
gdk_draw_pixbuf (icon_view->priv->bin_window, NULL, pixbuf,
0, 0,
rect.x,rect.y,
rect.width, rect.height,
GDK_RGB_DITHER_NONE,
0, 0);
g_object_unref (pixbuf);
}
gdk_draw_pixbuf (icon_view->priv->bin_window, NULL, pixbuf,
0, 0,
rect.x,rect.y,
rect.width, rect.height,
GDK_RGB_DITHER_NONE,
0, 0);
g_object_unref (pixbuf);
gc = gdk_gc_new (icon_view->priv->bin_window);
gdk_gc_set_rgb_fg_color (gc, fill_color_gdk);
gdk_gc_set_clip_rectangle (gc, &rect);