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
* \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 tx translate to this x coordinate
* \param ty translate to this y coordinate
* \return new rotated drawable
*/
Drawable
draw_rotate(DrawCtx *ctx, int phys_screen, double angle, int tx, int ty)
void
draw_rotate(DrawCtx *ctx, Drawable dest, int dest_w, int dest_h,
double angle, int tx, int ty)
{
cairo_surface_t *surface, *source;
cairo_t *cr;
Drawable newdrawable;
newdrawable = XCreatePixmap(ctx->display,
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);
surface = cairo_xlib_surface_create(ctx->display, dest, ctx->visual, dest_w, dest_h);
source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
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_surface_destroy(source);
cairo_surface_destroy(surface);
return newdrawable;
}
/** 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_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
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 *);
Alignment draw_align_get_from_str(const char *);
Bool draw_color_new(Display *, int, const char *, XColor *);

View File

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

View File

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