summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarex <marex@beryl-project.org>2007-05-02 18:23:34 +0200
committermarex <marex@beryl-project.org>2007-05-02 18:23:34 +0200
commit0ba470857e60ed75ad4376f6a2039cf676a16c55 (patch)
treedee041d7b3ed2bb1beaa3e2d6c4747daee1cd931
parent0449ef39be7e753ab7068e4d3e4099654ebfca88 (diff)
downloadberyl-premerge-0ba470857e60ed75ad4376f6a2039cf676a16c55.tar.gz
beryl-premerge-0ba470857e60ed75ad4376f6a2039cf676a16c55.tar.bz2
group: Use pixmap instead of raw image buffer
-rw-r--r--src/group/group.h3
-rw-r--r--src/group/paint.c6
-rw-r--r--src/group/tab.c31
3 files changed, 22 insertions, 18 deletions
diff --git a/src/group/group.h b/src/group/group.h
index 37587bd..adaa4c2 100644
--- a/src/group/group.h
+++ b/src/group/group.h
@@ -198,8 +198,7 @@ typedef enum {
typedef struct _GroupCairoLayer {
- unsigned char *texBuf;
- Pixmap pixmap;
+ Pixmap pixmap;
CompTexture texture;
cairo_surface_t *surface;
cairo_t *cairo;
diff --git a/src/group/paint.c b/src/group/paint.c
index 7e79bbf..6ba2490 100644
--- a/src/group/paint.c
+++ b/src/group/paint.c
@@ -154,9 +154,6 @@ void groupRenderTopTabHighlight(GroupSelection *group)
(group->color[2] / 65535.0f),
(group->color[3] / 65535.0f));
cairo_stroke(cr);
-
- imageBufferToTexture(group->screen, &layer->texture,
- (char*) layer->texBuf, layer->texWidth, layer->texHeight);
}
/*
@@ -470,9 +467,6 @@ void groupRenderTabBarBackground(GroupSelection *group)
a = groupGetTabBorderColorAlpha(group->screen) / 65535.0f;
cairo_set_source_rgba(cr, r, g, b, a);
cairo_stroke(cr);
-
- imageBufferToTexture(group->screen, &layer->texture,
- (char*) layer->texBuf, layer->texWidth, layer->texHeight);
}
/*
diff --git a/src/group/tab.c b/src/group/tab.c
index 5d2b11c..a426762 100644
--- a/src/group/tab.c
+++ b/src/group/tab.c
@@ -1766,10 +1766,7 @@ void groupDestroyCairoLayer(CompScreen *s, GroupCairoLayer *layer)
cairo_destroy(layer->cairo);
if (layer->surface)
- cairo_surface_destroy(layer->surface);
-
- if (layer->texBuf)
- free(layer->texBuf);
+ cairo_surface_destroy(layer->surface);;
if (&layer->texture)
finiTexture(s, &layer->texture);
@@ -1787,10 +1784,14 @@ void groupDestroyCairoLayer(CompScreen *s, GroupCairoLayer *layer)
GroupCairoLayer* groupCreateCairoLayer(CompScreen *s, int width, int height)
{
GroupCairoLayer* layer = (GroupCairoLayer*) malloc(sizeof(GroupCairoLayer));
+
+ Screen *screen;
+ Display *display;
+ display = s->display->display;
+ screen = ScreenOfDisplay (display, s->screenNum);
layer->surface = NULL;
layer->cairo = NULL;
- layer->texBuf = NULL;
layer->animationTime = 0;
layer->state = PaintOff;
layer->texWidth = width;
@@ -1798,19 +1799,29 @@ GroupCairoLayer* groupCreateCairoLayer(CompScreen *s, int width, int height)
layer->pixmap = None;
initTexture(s, &layer->texture);
- layer->texBuf = calloc(4 * width * height, sizeof (unsigned char));
- layer->surface = cairo_image_surface_create_for_data(layer->texBuf, CAIRO_FORMAT_ARGB32,
- width, height, 4 * width);
+
+ XRenderPictFormat *format;
+ format = XRenderFindStandardFormat (display, PictStandardARGB32);
+ layer->pixmap = XCreatePixmap (display, s->root, width, height, 32);
+
+ if (!bindPixmapToTexture(s, &layer->texture, layer->pixmap, width, height, 32)) {
+ XFreePixmap(display, layer->pixmap);
+ free(layer);
+ return NULL;
+ }
+
+ layer->surface =
+ cairo_xlib_surface_create_with_xrender_format(display, layer->pixmap, screen, format, width, height);
if (cairo_surface_status(layer->surface) != CAIRO_STATUS_SUCCESS) {
- free(layer->texBuf);
+ XFreePixmap(display, layer->pixmap);
free(layer);
return NULL;
}
layer->cairo = cairo_create(layer->surface);
if (cairo_status(layer->cairo) != CAIRO_STATUS_SUCCESS) {
- free(layer->texBuf);
+ XFreePixmap(display, layer->pixmap);
free(layer);
return NULL;
}