Change draw_rotate() proto to directly render on the right Pixmap

This commit is contained in:
Julien Danjou 2008-03-20 09:17:34 +01:00
parent 024ef921c9
commit 4a7e52cc27
4 changed files with 18 additions and 31 deletions

View File

@ -649,24 +649,22 @@ draw_get_image_size(const char *filename)
/** Rotate a drawable /** Rotate a drawable
* \param ctx Draw context to draw to * \param ctx Draw context to draw to
* \param phys_screen physical screen id * \param dest Drawable to draw the result
* \param dest_w Drawable width
* \param dest_h Drawable height
* \param angle angle to rotate * \param angle angle to rotate
* \param tx translate to this x coordinate * \param tx translate to this x coordinate
* \param ty translate to this y coordinate * \param ty translate to this y coordinate
* \return new rotated drawable * \return new rotated drawable
*/ */
Drawable void
draw_rotate(DrawCtx *ctx, int phys_screen, double angle, int tx, int ty) draw_rotate(DrawCtx *ctx, Drawable dest, int dest_w, int dest_h,
double angle, int tx, int ty)
{ {
cairo_surface_t *surface, *source; cairo_surface_t *surface, *source;
cairo_t *cr; cairo_t *cr;
Drawable newdrawable;
newdrawable = XCreatePixmap(ctx->display, surface = cairo_xlib_surface_create(ctx->display, dest, ctx->visual, dest_w, dest_h);
RootWindow(ctx->display, phys_screen),
ctx->height, ctx->width,
ctx->depth);
surface = cairo_xlib_surface_create(ctx->display, newdrawable, ctx->visual, ctx->height, ctx->width);
source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height); source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
cr = cairo_create (surface); cr = cairo_create (surface);
@ -679,8 +677,6 @@ draw_rotate(DrawCtx *ctx, int phys_screen, double angle, int tx, int ty)
cairo_destroy(cr); cairo_destroy(cr);
cairo_surface_destroy(source); cairo_surface_destroy(source);
cairo_surface_destroy(surface); cairo_surface_destroy(surface);
return newdrawable;
} }
/** Return the width of a text in pixel /** Return the width of a text in pixel

View File

@ -133,7 +133,7 @@ void draw_circle(DrawCtx *, int, int, int, Bool, XColor);
void draw_image(DrawCtx *, int, int, int, const char *); void draw_image(DrawCtx *, int, int, int, const char *);
void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *); void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
area_t draw_get_image_size(const char *filename); area_t draw_get_image_size(const char *filename);
Drawable draw_rotate(DrawCtx *, int, double, int, int); void draw_rotate(DrawCtx *, Drawable, int, int, double, int, int);
unsigned short draw_textwidth(Display *, font_t *, char *); unsigned short draw_textwidth(Display *, font_t *, char *);
Alignment draw_align_get_from_str(const char *); Alignment draw_align_get_from_str(const char *);
Bool draw_color_new(Display *, int, const char *, XColor *); Bool draw_color_new(Display *, int, const char *, XColor *);

View File

@ -107,11 +107,9 @@ statusbar_position_update(Statusbar *statusbar)
static void static void
statusbar_draw(Statusbar *statusbar) statusbar_draw(Statusbar *statusbar)
{ {
int phys_screen = get_phys_screen(statusbar->screen);
Widget *widget; Widget *widget;
int left = 0, right = 0; int left = 0, right = 0;
area_t rectangle = { 0, 0, 0, 0, NULL, NULL }; area_t rectangle = { 0, 0, 0, 0, NULL, NULL };
Drawable d;
rectangle.width = statusbar->width; rectangle.width = statusbar->width;
rectangle.height = statusbar->height; rectangle.height = statusbar->height;
@ -145,16 +143,14 @@ statusbar_draw(Statusbar *statusbar)
switch(statusbar->position) switch(statusbar->position)
{ {
case Right: case Right:
d = draw_rotate(statusbar->ctx, phys_screen, M_PI_2, draw_rotate(statusbar->ctx, statusbar->sw->drawable,
statusbar->height, 0); statusbar->ctx->height, statusbar->ctx->width,
XFreePixmap(globalconf.display, statusbar->sw->drawable); M_PI_2, statusbar->height, 0);
statusbar->sw->drawable = d;
break; break;
case Left: case Left:
d = draw_rotate(statusbar->ctx, phys_screen, - M_PI_2, draw_rotate(statusbar->ctx, statusbar->sw->drawable,
0, statusbar->width); statusbar->ctx->height, statusbar->ctx->width,
XFreePixmap(globalconf.display, statusbar->sw->drawable); - M_PI_2, 0, statusbar->width);
statusbar->sw->drawable = d;
break; break;
default: default:
break; break;

View File

@ -83,7 +83,6 @@ titlebar_init(Client *c)
void void
titlebar_update(Client *c) titlebar_update(Client *c)
{ {
Drawable d;
DrawCtx *ctx; DrawCtx *ctx;
style_t style; style_t style;
area_t geometry; area_t geometry;
@ -136,16 +135,12 @@ titlebar_update(Client *c)
switch(c->titlebar.position) switch(c->titlebar.position)
{ {
case Left: case Left:
d = draw_rotate(ctx, c->titlebar.sw->phys_screen, - M_PI_2, draw_rotate(ctx, c->titlebar.sw->drawable, ctx->height, ctx->width,
0, c->titlebar.sw->geometry.height); - M_PI_2, 0, c->titlebar.sw->geometry.height);
XFreePixmap(globalconf.display, c->titlebar.sw->drawable);
c->titlebar.sw->drawable = d;
break; break;
case Right: case Right:
d = draw_rotate(ctx, c->titlebar.sw->phys_screen, M_PI_2, draw_rotate(ctx, c->titlebar.sw->drawable, ctx->height, ctx->width,
c->titlebar.sw->geometry.width, 0); M_PI_2, c->titlebar.sw->geometry.width, 0);
XFreePixmap(globalconf.display, c->titlebar.sw->drawable);
c->titlebar.sw->drawable = d;
default: default:
break; break;
} }