[Pkg-maemo-commits] r93 ./sapwood/debian: * Merge with trunk branch.
Jonny Lamb
jonnylamb at jonnylamb.com
Mon Jul 23 15:23:30 UTC 2007
------------------------------------------------------------
revno: 93
committer: Jonny Lamb <jonnylamb at jonnylamb.com>
branch nick: sapwood
timestamp: Mon 2007-07-23 16:23:30 +0100
message:
* Merge with trunk branch.
modified:
ChangeLog
NEWS
README
configure.in
debian/changelog
demos/images/treeview-active-alone.png
demos/images/treeview-active-left.png
demos/images/treeview-active-middle.png
demos/images/treeview-active-right.png
demos/images/treeview-active.png
demos/images/treeview-passive.png
demos/treeview.gtkrc
src/sapwood-draw.c
src/sapwood-pixmap.c
src/sapwood-pixmap.h
src/sapwood-render.c
------------------------------------------------------------
revno: 90.1.1
merged: vcs-imports at canonical.com-20070608135020-04s2fu0ro3cs1nzs
committer: tko
timestamp: Fri 2007-06-08 13:50:20 +0000
message:
Improve handling cursor separately from selection.
* src/sapwood-draw.c (maybe_check_cursor_position): Remove special
active focus handling, only update 'shadow' for passive focus. Improves
handling cursor separately from selection.
* README
* demos/treeview.gtkrc
* demos/images/treeview-*: Updated
------------------------------------------------------------
revno: 90.1.2
merged: vcs-imports at canonical.com-20070608142107-tf3kjtda0eope23l
committer: tko
timestamp: Fri 2007-06-08 14:21:07 +0000
message:
* === Release 2.91.5 ===
------------------------------------------------------------
revno: 90.1.3
merged: vcs-imports at canonical.com-20070608142303-zdp0tduep0ig0hu2
committer: tko
timestamp: Fri 2007-06-08 14:23:03 +0000
message:
sapwood (2.91.5-1) unstable; urgency=low
* Fix 'position' handling to correctly check widgets visibility (breadcrumb)
* Improve handling cursor separately from selection (treeview)
------------------------------------------------------------
revno: 90.1.4
merged: vcs-imports at canonical.com-20070626113913-nx4tkwhp0tud0yky
committer: tko
timestamp: Tue 2007-06-26 11:39:13 +0000
message:
Remove unused variables.
2007-06-26 Tommi Komulainen <tommi.komulainen at nokia.com>
* src/sapwood-render.c (theme_pixbuf_render): Remove unused variables.
------------------------------------------------------------
revno: 90.1.5
merged: vcs-imports at canonical.com-20070703124552-clihprly2nlp0jpy
committer: tko
timestamp: Tue 2007-07-03 12:45:52 +0000
message:
When clamping the mask to clip mask, do not change the area to paint.
2007-07-03 Tommi Komulainen <tommi.komulainen at nokia.com>
* src/sapwood-render.c (theme_pixbuf_render): When clamping the mask
to clip mask, do not change the area to paint.
------------------------------------------------------------
revno: 90.1.6
merged: vcs-imports at canonical.com-20070703133808-9wwu0fh9sl26l2l5
committer: tko
timestamp: Tue 2007-07-03 13:38:08 +0000
message:
Refactor painting of centered pixmaps using sapwood_pixmap_render_rects()
2007-07-03 Tommi Komulainen <tommi.komulainen at nokia.com>
* src/sapwood-render.c (theme_pixbuf_render): Refactor painting of
centered pixmaps using sapwood_pixmap_render_rects()
* src/sapwood-pixmap.h (sapwood_pixmap_render)
* src/sapwood-pixmap.c (sapwood_pixmap_render, get_scratch_gc): Remove
as obsolete.
------------------------------------------------------------
revno: 90.1.7
merged: vcs-imports at canonical.com-20070703144255-ciiulox9yjl1tzdd
committer: tko
timestamp: Tue 2007-07-03 14:42:55 +0000
message:
Implement downscaling
2007-07-03 Tommi Komulainen <tommi.komulainen at nokia.com>
* src/sapwood-pixmap.c (sapwood_pixmap_render_rects): Rename to
sapwood_pixmap_render_rects_internal.
* src/sapwood-pixmap.h (sapwood_pixmap_render_rects): Add width and
height parameters in order to do downscaling.
* src/sapwood-pixmap.c (sapwood_pixmap_render_rects): When rendering
to a target smaller than the pixmap, paint first at least as big as
the pixmaps and scale down to target size using cairo.
* configure.in: bump gtk+ dependency to 2.8 due to cairo
------------------------------------------------------------
revno: 90.1.8
merged: vcs-imports at canonical.com-20070704075359-mm7qdfo9eqx9y9uf
committer: tko
timestamp: Wed 2007-07-04 07:53:59 +0000
message:
=== Release 2.91.6 ===
------------------------------------------------------------
revno: 90.1.9
merged: vcs-imports at canonical.com-20070704075413-09qjvqk6wkjh2dyu
committer: tko
timestamp: Wed 2007-07-04 07:54:13 +0000
message:
* Implement downscaling - Fixes: NB#62512 sapwood ignores width/height if smaller than the bitmap * debian/control: Build-depend on libgtk2.0-dev 2.8 due to cairo
-------------- next part --------------
=== modified file 'ChangeLog'
--- a/ChangeLog 2007-06-04 08:45:36 +0000
+++ b/ChangeLog 2007-07-04 07:53:59 +0000
@@ -1,3 +1,49 @@
+2007-07-04 Tommi Komulainen <tommi.komulainen at nokia.com>
+
+ * === Release 2.91.6 ===
+
+2007-07-03 Tommi Komulainen <tommi.komulainen at nokia.com>
+
+ * src/sapwood-pixmap.c (sapwood_pixmap_render_rects): Rename to
+ sapwood_pixmap_render_rects_internal.
+ * src/sapwood-pixmap.h (sapwood_pixmap_render_rects): Add width and
+ height parameters in order to do downscaling.
+ * src/sapwood-pixmap.c (sapwood_pixmap_render_rects): When rendering
+ to a target smaller than the pixmap, paint first at least as big as
+ the pixmaps and scale down to target size using cairo.
+ * configure.in: bump gtk+ dependency to 2.8 due to cairo
+
+2007-07-03 Tommi Komulainen <tommi.komulainen at nokia.com>
+
+ * src/sapwood-render.c (theme_pixbuf_render): Refactor painting of
+ centered pixmaps using sapwood_pixmap_render_rects()
+ * src/sapwood-pixmap.h (sapwood_pixmap_render)
+ * src/sapwood-pixmap.c (sapwood_pixmap_render, get_scratch_gc): Remove
+ as obsolete.
+
+2007-07-03 Tommi Komulainen <tommi.komulainen at nokia.com>
+
+ * src/sapwood-render.c (theme_pixbuf_render): When clamping the mask
+ to clip mask, do not change the area to paint.
+
+2007-06-26 Tommi Komulainen <tommi.komulainen at nokia.com>
+
+ * src/sapwood-render.c (theme_pixbuf_render): Remove unused variables.
+
+2007-06-08 Tommi Komulainen <tommi.komulainen at nokia.com>
+
+ * === Release 2.91.5 ===
+
+2007-06-08 Tommi Komulainen <tommi.komulainen at nokia.com>
+
+ * src/sapwood-draw.c (maybe_check_cursor_position): Remove special
+ active focus handling, only update 'shadow' for passive focus. Improves
+ handling cursor separately from selection.
+
+ * README
+ * demos/treeview.gtkrc
+ * demos/images/treeview-*: Updated
+
2007-05-31 Xan Lopez <xan.lopez at nokia.com>
* src/sapwood-draw.c (check_child_position, check_buttonbox_child_position):
=== modified file 'NEWS'
--- a/NEWS 2007-04-19 12:18:09 +0000
+++ b/NEWS 2007-07-04 07:53:59 +0000
@@ -1,3 +1,27 @@
+sapwood 2.91.6 - 2007-07-04
+===========================
+
+Changes
+-------
+When painting to areas smaller than bitmap use downscaling instead of clipping
+or ignoring the target size.
+
+
+Bugs fixed
+----------
+NB#62512 - sapwood ignores width/height if smaller than the bitmap
+
+
+sapwood 2.91.5 - 2007-06-08
+===========================
+
+Changes
+-------
+Fix 'position' handling to correctly check which widgets are visible.
+
+Improve handling cursor separately from selection.
+
+
sapwood 2.91.4 - 2007-04-19
===========================
=== modified file 'README'
--- a/README 2007-04-17 12:28:29 +0000
+++ b/README 2007-06-08 13:50:20 +0000
@@ -449,10 +449,10 @@
GtkTreeView
-----------
-Focus row background:
+Cursor row background, passive focus:
function = FLAT_BOX
- state = ACTIVE
- shadow = NONE for active, OUT for passive focus
+ state = SELECTED / NORMAL
+ shadow = OUT
See demos/treeview.gtkrc
=== modified file 'configure.in'
--- a/configure.in 2007-04-19 12:18:09 +0000
+++ b/configure.in 2007-07-04 07:53:59 +0000
@@ -1,6 +1,6 @@
AC_INIT([src/sapwood-server.c])
AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE(sapwood, 2.91.4)
+AM_INIT_AUTOMAKE(sapwood, 2.91.6)
dnl Initialize maintainer mode
AM_MAINTAINER_MODE
@@ -89,7 +89,7 @@
AM_DISABLE_STATIC
AM_PROG_LIBTOOL
-PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 1.3.12)
+PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.8)
GTK_VERSION=`$PKG_CONFIG --variable=gtk_binary_version gtk+-2.0`
AC_SUBST(GTK_CFLAGS)
=== modified file 'debian/changelog'
--- a/debian/changelog 2007-06-12 18:22:14 +0000
+++ b/debian/changelog 2007-07-23 15:23:30 +0000
@@ -1,3 +1,24 @@
+sapwood (2.91.6-1) unstable; urgency=low
+
+ * Merge with trunk branch.
+
+ -- Jonny Lamb <jonnylamb at jonnylamb.com> Mon, 23 Jul 2007 16:21:29 +0100
+
+sapwood (2.91.6-1) unstable; urgency=low
+
+ * Implement downscaling
+ - Fixes: NB#62512 sapwood ignores width/height if smaller than the bitmap
+ * debian/control: Build-depend on libgtk2.0-dev 2.8 due to cairo
+
+ -- Tommi Komulainen <tommi.komulainen at nokia.com> Wed, 4 Jul 2007 10:47:00 +0300
+
+sapwood (2.91.5-1) unstable; urgency=low
+
+ * Fix 'position' handling to correctly check widgets visibility (breadcrumb)
+ * Improve handling cursor separately from selection (treeview)
+
+ -- Tommi Komulainen <tommi.komulainen at nokia.com> Fri, 8 Jun 2007 17:21:39 +0300
+
sapwood (2.91.4-1ubuntu2) gutsy; urgency=low
* Build-Depends: autoconf, automake1.8, libtool to get things building from
=== modified file 'demos/images/treeview-active-alone.png'
Binary files a/demos/images/treeview-active-alone.png 2007-01-29 12:28:50 +0000 and b/demos/images/treeview-active-alone.png 2007-06-08 13:50:20 +0000 differ
=== modified file 'demos/images/treeview-active-left.png'
Binary files a/demos/images/treeview-active-left.png 2007-01-29 12:28:50 +0000 and b/demos/images/treeview-active-left.png 2007-06-08 13:50:20 +0000 differ
=== modified file 'demos/images/treeview-active-middle.png'
Binary files a/demos/images/treeview-active-middle.png 2007-01-29 12:28:50 +0000 and b/demos/images/treeview-active-middle.png 2007-06-08 13:50:20 +0000 differ
=== modified file 'demos/images/treeview-active-right.png'
Binary files a/demos/images/treeview-active-right.png 2007-01-29 12:28:50 +0000 and b/demos/images/treeview-active-right.png 2007-06-08 13:50:20 +0000 differ
=== modified file 'demos/images/treeview-active.png'
Binary files a/demos/images/treeview-active.png 2007-01-29 12:28:50 +0000 and b/demos/images/treeview-active.png 2007-06-08 13:50:20 +0000 differ
=== modified file 'demos/images/treeview-passive.png'
Binary files a/demos/images/treeview-passive.png 2007-01-29 12:28:50 +0000 and b/demos/images/treeview-passive.png 2007-06-08 13:50:20 +0000 differ
=== modified file 'demos/treeview.gtkrc'
--- a/demos/treeview.gtkrc 2007-01-29 14:31:32 +0000
+++ b/demos/treeview.gtkrc 2007-06-08 13:50:20 +0000
@@ -2,29 +2,40 @@
pixmap_path "images"
style "treeview" {
engine "sapwood" {
+ image { # passive focus for selection
+ function = FLAT_BOX
+ state = SELECTED
+ shadow = OUT
+
+ file = "treeview-selected.png"
+
+ overlay_file = "treeview-passive.png"
+ overlay_border = { 1, 1, 1, 1 }
+ }
image { # selection
function = FLAT_BOX
state = SELECTED
file = "treeview-selected.png"
}
- image { # passive focus
+
+ image { # normal row passive focus
function = FLAT_BOX
- state = ACTIVE
shadow = OUT
- file = "treeview-passive.png"
- }
+
+ file = "treeview-normal.png"
+
+ overlay_file = "treeview-passive.png"
+ overlay_border = { 1, 1, 1, 1 }
+ }
+ image { # normal row background (fallback)
+ function = FLAT_BOX
+ file = "treeview-normal.png"
+ }
+
image { # active focus
- function = FLAT_BOX
- state = ACTIVE
+ function = FOCUS
file = "treeview-active.png"
- }
- image { # normal row background (fallback)
- function = FLAT_BOX
- file = "treeview-normal.png"
- }
-
- image { # disable the default focus rectangle
- function = FOCUS
+ border = { 1, 1, 1, 1 }
}
}
}
@@ -56,7 +67,17 @@
#}
# selection #######################################################
- image {
+ image { # passive focus for selection
+ function = FLAT_BOX
+ state = SELECTED
+ shadow = OUT
+
+ file = "treeview-selected.png"
+
+ overlay_file = "treeview-passive.png"
+ overlay_border = { 1, 1, 1, 1 }
+ }
+ image { # selection
function = FLAT_BOX
state = SELECTED
file = "treeview-selected.png"
@@ -68,47 +89,45 @@
shadow = OUT
file = "treeview-passive.png"
}
+ # normal row background (fallback) ################################
+ image { # normal row passive focus
+ function = FLAT_BOX
+ shadow = OUT
+
+ file = "treeview-normal.png"
+
+ overlay_file = "treeview-passive.png"
+ overlay_border = { 1, 1, 1, 1 }
+ }
+
# active ##########################################################
image {
- function = FLAT_BOX
- state = ACTIVE
+ function = FOCUS
detail = "*_start"
file = "treeview-active-left.png"
border = { 2, 0, 2, 2 }
}
image {
- function = FLAT_BOX
- state = ACTIVE
+ function = FOCUS
detail = "*_middle"
file = "treeview-active-middle.png"
border = { 0, 0, 1, 1 }
}
image {
- function = FLAT_BOX
- state = ACTIVE
+ function = FOCUS
detail = "*_end"
file = "treeview-active-right.png"
border = { 0, 2, 2, 2 }
}
image {
- function = FLAT_BOX
- state = ACTIVE
+ function = FOCUS
file = "treeview-active-alone.png"
border = { 2, 2, 2, 2 }
}
- # normal row background (fallback) ################################
- image {
- function = FLAT_BOX
- file = "treeview-normal.png"
- }
-
- image { # disable the default focus rectangle
- function = FOCUS
- }
}
}
=== modified file 'src/sapwood-draw.c'
--- a/src/sapwood-draw.c 2007-06-04 08:45:36 +0000
+++ b/src/sapwood-draw.c 2007-06-08 13:50:20 +0000
@@ -852,22 +852,22 @@
if (!gdk_rectangle_intersect (&paint_rect, &cursor_rect, &paint_rect))
return;
- /* We're painting the cursor row background, so distinguish between active
- * and passive focus. Knowing that GTK_STATE_ACTIVE and GTK_SHADOW_NONE are
- * never used in treeview, it should be (more or less) safe to (ab)use them
- * for active/passive focus.
- *
- * Active focus:
- * function = FLAT_BOX
- * state = ACTIVE
+ /* We're painting the cursor row background, so distinguish between focused
+ * and non-focused treeview so that we can paint the passive focus ring when
+ * non-focused. (gtk_paint_focus is used to paint the focus ring when focused.)
+ * Knowing that treeview always uses GTK_SHADOW_NONE, it should be (more or
+ * less) safe to (ab)use it for passive focus.
+ *
+ * Passive focus:
+ * function = FLAT_BOX
+ * state = SELECTED / NORMAL
+ * shadow = OUT
+ *
+ * Selection / normal row:
+ * function = FLAT_BOX
+ * state = SELECTED / NORMAL
* shadow = NONE
- *
- * Passive focus:
- * function = FLAT_BOX
- * state = ACTIVE
- * shadow = OUT
*/
- match_data->state = GTK_STATE_ACTIVE;
if (!GTK_WIDGET_HAS_FOCUS (treeview))
match_data->shadow = GTK_SHADOW_OUT;
}
=== modified file 'src/sapwood-pixmap.c'
--- a/src/sapwood-pixmap.c 2007-01-24 15:06:20 +0000
+++ b/src/sapwood-pixmap.c 2007-07-03 14:42:55 +0000
@@ -296,137 +296,6 @@
return TRUE;
}
-static GdkGC *
-get_scratch_gc (GdkDrawable *drawable)
-{
- static GdkGC *gc[32] = { 0, };
- int depth;
-
- depth = gdk_drawable_get_depth (drawable);
- if (!gc[depth])
- {
- GdkGCValues gc_values;
-
- gc_values.fill = GDK_TILED;
- gc[depth] = gdk_gc_new_with_values (drawable, &gc_values, GDK_GC_FILL);
- }
- return gc[depth];
-}
-
-/* Scale the rectangle (src_x, src_y, src_width, src_height)
- * onto the rectangle (dest_x, dest_y, dest_width, dest_height)
- * of the destination, clip by clip_rect and render
- */
-void
-sapwood_pixmap_render (SapwoodPixmap *self,
- GdkWindow *window,
- GdkBitmap *mask,
- GdkRectangle *clip_rect,
- gint src_x,
- gint src_y,
- gint src_width,
- gint src_height,
- gint dest_x,
- gint dest_y,
- gint dest_width,
- gint dest_height)
-{
- GdkPixmap *pixmap;
- GdkBitmap *pixmask;
- int i, j;
- GdkRectangle rect;
- GdkBitmap *tmp_mask;
- int mask_x, mask_y;
- GdkGC *tmp_gc;
-
- if (dest_width <= 0 || dest_height <= 0)
- return;
-
- rect.x = dest_x;
- rect.y = dest_y;
- rect.width = dest_width;
- rect.height = dest_height;
-
- /* FIXME: Because we use the mask to shape windows, we don't use
- * clip_rect to clip what we draw to the mask, only to clip
- * what we actually draw. But this leads to the horrible ineffiency
- * of scale the whole image to get a little bit of it.
- */
- if (!mask && clip_rect)
- {
- if (!gdk_rectangle_intersect (clip_rect, &rect, &rect))
- return;
- }
-
- if (src_y == 0 && src_height == self->height)
- i = 1;
- else if (src_y == self->border_top)
- i = 1;
- else if (src_y == 0)
- i = 0;
- else
- i = 2;
-
- if (src_x == 0 && src_width == self->width)
- j = 1;
- else if (src_x == self->border_left)
- j = 1;
- else if (src_x == 0)
- j = 0;
- else
- j = 2;
-
- pixmap = self->pixmap[i][j];
- pixmask = self->pixmask[i][j];
-
- /* if we don't have the pixmap it's an error in gtkrc and the pixmap server
- * has already complained about it, no need to flood the console
- */
- if (!pixmap)
- return;
-
- if (mask)
- {
- tmp_mask = mask;
- mask_x = dest_x;
- mask_y = dest_y;
- }
- else
- {
- tmp_mask = gdk_pixmap_new (NULL, dest_width, dest_height, 1);
- mask_x = 0;
- mask_y = 0;
- }
-
- /* tile mask */
- tmp_gc = get_scratch_gc (tmp_mask);
- if (pixmask)
- {
- gdk_gc_set_fill (tmp_gc, GDK_TILED);
- gdk_gc_set_ts_origin (tmp_gc, mask_x, mask_y);
- gdk_gc_set_tile (tmp_gc, pixmask);
- gdk_draw_rectangle (tmp_mask, tmp_gc, TRUE, mask_x, mask_y, dest_width, dest_height);
- }
- else
- {
- GdkColor tmp_fg = { 1, 0, 0, 0 };
- gdk_gc_set_fill (tmp_gc, GDK_SOLID);
- gdk_gc_set_foreground (tmp_gc, &tmp_fg);
- gdk_draw_rectangle (tmp_mask, tmp_gc, TRUE, mask_x, mask_y, dest_width, dest_height);
- }
-
- /* tile pixmap, use generated mask */
- tmp_gc = get_scratch_gc (window);
- gdk_gc_set_ts_origin (tmp_gc, dest_x, dest_y);
- gdk_gc_set_tile (tmp_gc, pixmap);
- gdk_gc_set_clip_mask (tmp_gc, tmp_mask);
- gdk_gc_set_clip_origin (tmp_gc, dest_x - mask_x, dest_y - mask_y);
- gdk_draw_rectangle (window, tmp_gc, TRUE, rect.x, rect.y, rect.width, rect.height);
-
- if (tmp_mask != mask)
- g_object_unref (tmp_mask);
-}
-
void
sapwood_pixmap_get_pixmap (SapwoodPixmap *self, gint x, gint y,
GdkPixmap **pixmap, GdkBitmap **pixmask)
@@ -435,18 +304,18 @@
*pixmask = self->pixmask[y][x];
}
-void
-sapwood_pixmap_render_rects (SapwoodPixmap *self,
- GdkDrawable *draw,
- gint draw_x,
- gint draw_y,
- GdkBitmap *mask,
- gint mask_x,
- gint mask_y,
- gboolean mask_required,
- GdkRectangle *clip_rect,
- gint n_rect,
- SapwoodRect *rect)
+static void
+sapwood_pixmap_render_rects_internal (SapwoodPixmap *self,
+ GdkDrawable *draw,
+ gint draw_x,
+ gint draw_y,
+ GdkBitmap *mask,
+ gint mask_x,
+ gint mask_y,
+ gboolean mask_required,
+ GdkRectangle *clip_rect,
+ gint n_rect,
+ SapwoodRect *rect)
{
static GdkGC *mask_gc = NULL;
static GdkGC *draw_gc = NULL;
@@ -527,3 +396,97 @@
}
}
}
+
+void
+sapwood_pixmap_render_rects (SapwoodPixmap *self,
+ GdkDrawable *draw,
+ gint draw_x,
+ gint draw_y,
+ gint width,
+ gint height,
+ GdkBitmap *mask,
+ gint mask_x,
+ gint mask_y,
+ gboolean mask_required,
+ GdkRectangle *clip_rect,
+ gint n_rect,
+ SapwoodRect *rect)
+{
+ gint tmp_width;
+ gint tmp_height;
+ GdkPixmap *tmp;
+ gboolean need_tmp_mask = FALSE;
+ GdkPixmap *tmp_mask = NULL;
+ cairo_t *mask_cr = NULL;
+ cairo_t *tmp_cr;
+ cairo_t *cr;
+ gint n;
+
+ /* Don't even try to scale down shape masks (should never be useful, and
+ * implementing would add some complexity.) Areas larger than the pixmap
+ * can be tiled fine.
+ */
+ if (mask_required || (width >= self->width && height >= self->height))
+ {
+ sapwood_pixmap_render_rects_internal (self, draw, draw_x, draw_y, mask, mask_x, mask_y, mask_required, clip_rect, n_rect, rect);
+ return;
+ }
+
+ /* offset the drawing on temporary pixmap */
+ for (n = 0; n < n_rect; n++)
+ {
+ SapwoodRect *r = &rect[n];
+ r->dest.x -= draw_x;
+ r->dest.y -= draw_y;
+ if (r->pixmap && r->pixmask)
+ need_tmp_mask = TRUE;
+ }
+
+ /* prepare temporary pixmap and mask to draw in full size */
+ tmp_width = MAX(width, self->width);
+ tmp_height = MAX(height, self->height);
+
+ tmp = gdk_pixmap_new (draw, tmp_width, tmp_height, -1);
+
+ if (need_tmp_mask)
+ {
+ tmp_mask = gdk_pixmap_new (draw, tmp_width, tmp_height, 1);
+
+ mask_cr = gdk_cairo_create (tmp_mask);
+ cairo_set_source_rgb (mask_cr, 1., 1., 1.);
+ cairo_paint (mask_cr);
+ }
+
+ sapwood_pixmap_render_rects_internal (self, tmp, 0, 0, tmp_mask, 0, 0, mask_required, NULL, n_rect, rect);
+
+ tmp_cr = gdk_cairo_create (tmp);
+
+ /* finally, render downscaled at draw_x,draw_y */
+ cr = gdk_cairo_create (draw);
+ if (clip_rect)
+ {
+ gdk_cairo_rectangle (cr, clip_rect);
+ cairo_clip (cr);
+ }
+ cairo_rectangle (cr, draw_x, draw_y, width, height);
+ cairo_clip (cr);
+
+ cairo_translate (cr, draw_x, draw_y);
+ cairo_scale (cr, (double)width / (double)tmp_width,
+ (double)height / (double)tmp_height);
+
+ cairo_set_source_surface (cr, cairo_get_target (tmp_cr), 0, 0);
+ if (mask_cr)
+ cairo_mask_surface (cr, cairo_get_target (mask_cr), 0, 0);
+ else
+ cairo_paint (cr);
+
+ /* clean up */
+ cairo_destroy (cr);
+ if (mask_cr)
+ cairo_destroy (mask_cr);
+ if (tmp_mask)
+ g_object_unref (tmp_mask);
+ cairo_destroy (tmp_cr);
+ g_object_unref (tmp);
+}
=== modified file 'src/sapwood-pixmap.h'
--- a/src/sapwood-pixmap.h 2007-01-24 14:00:54 +0000
+++ b/src/sapwood-pixmap.h 2007-07-03 14:42:55 +0000
@@ -60,23 +60,12 @@
GdkPixmap **ret_pixmap,
GdkBitmap **ret_pixmask) G_GNUC_INTERNAL;
-void sapwood_pixmap_render (SapwoodPixmap *self,
- GdkWindow *window,
- GdkBitmap *mask,
- GdkRectangle *clip_rect,
- gint src_x,
- gint src_y,
- gint src_width,
- gint src_height,
- gint dest_x,
- gint dest_y,
- gint dest_width,
- gint dest_height) G_GNUC_INTERNAL;
-
void sapwood_pixmap_render_rects (SapwoodPixmap *self,
GdkDrawable *draw,
gint draw_x,
gint draw_y,
+ gint width,
+ gint height,
GdkBitmap *mask,
gint mask_x,
gint mask_y,
=== modified file 'src/sapwood-render.c'
--- a/src/sapwood-render.c 2007-01-24 14:00:54 +0000
+++ b/src/sapwood-render.c 2007-07-03 14:42:55 +0000
@@ -247,9 +247,12 @@
gint width,
gint height)
{
- gint src_x[4], src_y[4], dest_x[4], dest_y[4];
+ gint dest_x[4], dest_y[4];
+ SapwoodPixmap *pixmap;
gint pixbuf_width;
gint pixbuf_height;
+ gint draw_width;
+ gint draw_height;
SapwoodRect rect[9];
gint n_rect;
gint mask_x;
@@ -262,35 +265,27 @@
if (!theme_pixbuf_get_geometry (theme_pb, &pixbuf_width, &pixbuf_height))
return FALSE;
+ pixmap = theme_pixbuf_get_pixmap (theme_pb);
+
+ /* if we do scaling we want to draw at least the whole pixmap */
+ draw_width = MAX(width, pixbuf_width);
+ draw_height = MAX(height, pixbuf_height);
+
if (theme_pb->stretch)
{
- SapwoodPixmap *pixmap;
-
- src_x[0] = 0;
- src_x[1] = theme_pb->border_left;
- src_x[2] = pixbuf_width - theme_pb->border_right;
- src_x[3] = pixbuf_width;
-
- src_y[0] = 0;
- src_y[1] = theme_pb->border_top;
- src_y[2] = pixbuf_height - theme_pb->border_bottom;
- src_y[3] = pixbuf_height;
-
dest_x[0] = x;
dest_x[1] = x + theme_pb->border_left;
- dest_x[2] = x + width - theme_pb->border_right;
- dest_x[3] = x + width;
+ dest_x[2] = x + draw_width - theme_pb->border_right;
+ dest_x[3] = x + draw_width;
dest_y[0] = y;
dest_y[1] = y + theme_pb->border_top;
- dest_y[2] = y + height - theme_pb->border_bottom;
- dest_y[3] = y + height;
+ dest_y[2] = y + draw_height - theme_pb->border_bottom;
+ dest_y[3] = y + draw_height;
if (component_mask & COMPONENT_ALL)
component_mask = (COMPONENT_ALL - 1) & ~component_mask;
- pixmap = theme_pixbuf_get_pixmap (theme_pb);
-
#define RENDER_COMPONENT(X,Y) do { \
sapwood_pixmap_get_pixmap (pixmap, X, Y, &rect[n_rect].pixmap, \
&rect[n_rect].pixmask); \
@@ -318,8 +313,13 @@
if (!mask)
{
+ gint mask_width;
+ gint mask_height;
+
mask_x = 0;
mask_y = 0;
+ mask_width = width;
+ mask_height = height;
mask_required = FALSE;
if (clip_rect)
@@ -327,32 +327,32 @@
/* limit the mask to clip_rect size to avoid allocating huge
* pixmaps and getting BadAlloc from X
*/
- if (clip_rect->width < width)
+ if (clip_rect->width < mask_width)
{
- LOG("width: %d -> %d", width, clip_rect->width);
- x = clip_rect->x;
- width = clip_rect->width;
+ LOG("width: %d -> %d", mask_width, clip_rect->width);
+ mask_x = clip_rect->x;
+ mask_width = clip_rect->width;
}
if (clip_rect->height < height)
{
- LOG("height: %d -> %d", height, clip_rect->height);
- y = clip_rect->y;
- height = clip_rect->height;
+ LOG("height: %d -> %d", mask_height, clip_rect->height);
+ mask_y = clip_rect->y;
+ mask_height = clip_rect->height;
}
}
gdk_error_trap_push ();
- mask = gdk_pixmap_new (NULL, width, height, 1);
+ mask = gdk_pixmap_new (NULL, mask_width, mask_height, 1);
/* gdk_flush (); */
if (gdk_error_trap_pop ())
{
if (clip_rect)
g_warning ("theme_pixbuf_render(clip_rect={x: %d,y: %d, width: %d, height: %d}: gdk_pixmap_new(width: %d, height: %d) failed",
- clip_rect->x, clip_rect->y, clip_rect->width, clip_rect->height, width, height);
+ clip_rect->x, clip_rect->y, clip_rect->width, clip_rect->height, mask_width, mask_height);
else
- g_warning ("theme_pixbuf_render(clip_rect=(null)}: gdk_pixmap_new(width: %d, height: %d) failed", width, height);
+ g_warning ("theme_pixbuf_render(clip_rect=(null)}: gdk_pixmap_new(width: %d, height: %d) failed", mask_width, mask_height);
/* pretend that we drew things successfully, there should be a
* new paint call coming to allow us to paint the thing properly
@@ -368,22 +368,29 @@
mask_required = TRUE;
}
- sapwood_pixmap_render_rects (theme_pixbuf_get_pixmap (theme_pb),
- window, x, y,
- mask, mask_x, mask_y, mask_required,
- clip_rect, n_rect, rect);
+ sapwood_pixmap_render_rects (pixmap,
+ window, x, y, width, height,
+ mask, mask_x, mask_y, mask_required,
+ clip_rect, n_rect, rect);
g_object_unref (mask);
}
else if (center)
{
- x += (width - pixbuf_width) / 2;
- y += (height - pixbuf_height) / 2;
-
- sapwood_pixmap_render (theme_pixbuf_get_pixmap (theme_pb),
- window, mask, clip_rect,
- 0, 0, pixbuf_width, pixbuf_height,
- x, y, pixbuf_width, pixbuf_height);
+ x += (draw_width - pixbuf_width) / 2;
+ y += (draw_height - pixbuf_height) / 2;
+
+ sapwood_pixmap_get_pixmap (pixmap, 1, 1,
+ &rect[0].pixmap, &rect[0].pixmask);
+ rect[0].dest.x = x;
+ rect[0].dest.y = y;
+ rect[0].dest.width = pixbuf_width;
+ rect[0].dest.height = pixbuf_height;
+
+ sapwood_pixmap_render_rects (pixmap,
+ window, x, y, width, height,
+ mask, x, y, FALSE,
+ clip_rect, 1, rect);
}
else /* tile? */
{
More information about the Pkg-maemo-commits
mailing list