00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef _WIN32
00027 #include "win32/config.h"
00028 #else
00029 #include "config.h"
00030 #endif
00031
00032
00033
00034
00035 #ifdef DO_CLOCKING
00036 #if TIME_WITH_SYS_TIME
00037 # include <sys/time.h>
00038 # include <time.h>
00039 #else
00040 # if HAVE_SYS_TIME_H
00041 # include <sys/time.h>
00042 # else
00043 # include <time.h>
00044 # endif
00045 #endif
00046 #endif
00047 #ifdef HAVE_UNISTD_H
00048 #include <unistd.h>
00049 #endif
00050 #ifdef HAVE_STDLIB_H
00051 #include <stdlib.h>
00052 #endif
00053 #ifdef HAVE_STDARG_H
00054 #include <stdarg.h>
00055 #endif
00056
00057
00058 #ifdef _WIN32
00059 # include "win32/afterbase.h"
00060 #else
00061 # include "afterbase.h"
00062 #endif
00063 #include "asvisual.h"
00064 #include "blender.h"
00065 #include "asimage.h"
00066 #include "imencdec.h"
00067 #include "ximage.h"
00068 #include "transform.h"
00069 #include "pixmap.h"
00070
00071
00072
00073 #define CREATE_TRG_PIXMAP(asv,w,h) create_visual_pixmap(asv,RootWindow(asv->dpy,DefaultScreen(asv->dpy)),(w),(h),0)
00074
00075
00076
00077
00078
00079
00080
00081
00082 int
00083 FillPixmapWithTile (Pixmap pixmap, Pixmap tile, int x, int y, int width, int height, int tile_x, int tile_y)
00084 {
00085 #ifndef X_DISPLAY_MISSING
00086 Display *dpy = get_default_asvisual()->dpy;
00087 if (tile != None && pixmap != None)
00088 {
00089 GC gc;
00090 XGCValues gcv;
00091
00092 gcv.tile = tile;
00093 gcv.fill_style = FillTiled;
00094 gcv.ts_x_origin = -tile_x;
00095 gcv.ts_y_origin = -tile_y;
00096 gc = XCreateGC (dpy, tile, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
00097 XFillRectangle (dpy, pixmap, gc, x, y, width, height);
00098 XFreeGC (dpy, gc);
00099 return 1;
00100 }
00101 #endif
00102 return 0;
00103 }
00104
00105 Pixmap
00106 GetRootPixmap (Atom id)
00107 {
00108 Pixmap currentRootPixmap = None;
00109 #ifndef X_DISPLAY_MISSING
00110 static Atom root_pmap_atom = None ;
00111 Display *dpy = get_default_asvisual()->dpy;
00112 if (id == None)
00113 {
00114 if( root_pmap_atom == None )
00115 root_pmap_atom = XInternAtom (dpy, "_XROOTPMAP_ID", True);
00116 id = root_pmap_atom ;
00117 }
00118
00119 if (id != None)
00120 {
00121 Atom act_type;
00122 int act_format;
00123 unsigned long nitems, bytes_after;
00124 unsigned char *prop = NULL;
00125
00126
00127 if (XGetWindowProperty ( dpy, RootWindow(dpy,DefaultScreen(dpy)), id, 0, 1, False, XA_PIXMAP,
00128 &act_type, &act_format, &nitems, &bytes_after,
00129 &prop) == Success)
00130 {
00131 if (prop)
00132 {
00133 currentRootPixmap = *((Pixmap *) prop);
00134 XFree (prop);
00135
00136 }
00137 }
00138 }
00139 #endif
00140 return currentRootPixmap;
00141 }
00142
00143 #ifndef X_DISPLAY_MISSING
00144 static int
00145 pixmap_error_handler (Display * dpy, XErrorEvent * error)
00146 {
00147 #ifdef DEBUG_IMAGING
00148 show_error ("XError # %u, in resource %lu, Request: %d.%d",
00149 error->error_code, error->resourceid, error->request_code, error->minor_code);
00150 #endif
00151 return 0;
00152 }
00153 #endif
00154
00155 Pixmap
00156 ValidatePixmap (Pixmap p, int bSetHandler, int bTransparent, unsigned int *pWidth, unsigned int *pHeight)
00157 {
00158 #ifndef X_DISPLAY_MISSING
00159 Display *dpy = get_default_asvisual()->dpy;
00160 int (*oldXErrorHandler) (Display *, XErrorEvent *) = NULL;
00161
00162 Window root;
00163 int junk;
00164 unsigned int ujunk ;
00165 if (bSetHandler)
00166 oldXErrorHandler = XSetErrorHandler (pixmap_error_handler);
00167
00168 if (bTransparent)
00169 p = GetRootPixmap (None);
00170 if (!pWidth)
00171 pWidth = &ujunk;
00172 if (!pHeight)
00173 pHeight = &ujunk;
00174
00175 if (p != None)
00176 {
00177 if (!XGetGeometry (dpy, p, &root, &junk, &junk, pWidth, pHeight, &ujunk, &ujunk))
00178 p = None;
00179 }
00180 if(bSetHandler)
00181 XSetErrorHandler (oldXErrorHandler);
00182
00183 return p;
00184 #else
00185 return None ;
00186 #endif
00187 }
00188
00189 int
00190 GetRootDimensions (int *width, int *height)
00191 {
00192 #ifndef X_DISPLAY_MISSING
00193 Display *dpy = get_default_asvisual()->dpy;
00194 if( dpy )
00195 {
00196 *height = XDisplayHeight(dpy, DefaultScreen(dpy) );
00197 *width = XDisplayWidth(dpy, DefaultScreen(dpy) );
00198 }
00199 return 1 ;
00200 #else
00201 return 0;
00202 #endif
00203 }
00204
00205 int
00206 GetWinPosition (Window w, int *x, int *y)
00207 {
00208 return get_dpy_window_position( get_default_asvisual()->dpy, None, w, NULL, NULL, x, y );
00209 }
00210
00211 ARGB32
00212 shading2tint32(ShadingInfo * shading)
00213 {
00214 if( shading && !NO_NEED_TO_SHADE(*shading))
00215 {
00216 CARD16 r16 = ((shading->tintColor.red*shading->shading / 100)>>9)&0x00FF ;
00217 CARD16 g16 = ((shading->tintColor.green*shading->shading / 100)>>9)&0x00FF ;
00218 CARD16 b16 = ((shading->tintColor.blue*shading->shading / 100)>>9)&0x00FF ;
00219 CARD16 a16 = ((0x0000007F*shading->shading / 100))&0x00FF ;
00220 return MAKE_ARGB32(a16,r16,g16,b16);
00221 }
00222 return TINT_LEAVE_SAME ;
00223 }
00224
00225 Pixmap
00226 scale_pixmap (ASVisual *asv, Pixmap src, int src_w, int src_h, int width, int height, GC gc, ARGB32 tint)
00227 {
00228 Pixmap trg = None;
00229 #ifndef X_DISPLAY_MISSING
00230
00231 if (src != None)
00232 {
00233 ASImage *src_im ;
00234 src_im = pixmap2ximage(asv, src, 0, 0, src_w, src_h, AllPlanes, 0 );
00235 if( src_im )
00236 {
00237 if( src_w != width || src_h != height )
00238 {
00239 ASImage *tmp = scale_asimage( asv, src_im, width, height,
00240 (tint != TINT_LEAVE_SAME)?ASA_ASImage:ASA_XImage,
00241 0, ASIMAGE_QUALITY_DEFAULT );
00242 destroy_asimage( &src_im );
00243 src_im = tmp;
00244 }
00245 if( src_im && tint != TINT_LEAVE_SAME )
00246 {
00247 ASImage *tinted = tile_asimage ( asv, src_im, 0, 0,
00248 width, height, tint,
00249 ASA_XImage,
00250 0, ASIMAGE_QUALITY_DEFAULT );
00251 destroy_asimage( &src_im );
00252 src_im = tinted ;
00253 }
00254 if( src_im )
00255 {
00256 trg = asimage2pixmap(asv, None, src_im, gc, True);
00257 destroy_asimage( &src_im );
00258 }
00259 }
00260 }
00261 #endif
00262 return trg;
00263 }
00264
00265 Pixmap
00266 ScalePixmap (Pixmap src, int src_w, int src_h, int width, int height, GC gc, ShadingInfo * shading)
00267 {
00268 Pixmap p = None ;
00269 #ifndef X_DISPLAY_MISSING
00270 p = scale_pixmap( get_default_asvisual(), src, src_w, src_h, width, height, gc, shading2tint32(shading) );
00271 #endif
00272 return p;
00273 }
00274
00275
00276 void
00277 copyshade_drawable_area( ASVisual *asv, Drawable src, Pixmap trg,
00278 int x, int y, int w, int h,
00279 int trg_x, int trg_y,
00280 GC gc, ARGB32 tint)
00281 {
00282 #ifndef X_DISPLAY_MISSING
00283 Display *dpy = get_default_asvisual()->dpy;
00284 if( tint == TINT_LEAVE_SAME || asv == NULL )
00285 {
00286 XCopyArea (dpy, src, trg, gc, x, y, w, h, trg_x, trg_y);
00287 }else
00288 {
00289 ASImage *src_im = pixmap2ximage( asv, src, x, y, w, h, AllPlanes, 0 );
00290 if( src_im )
00291 {
00292 ASImage *tinted = tile_asimage ( asv, src_im, 0, 0,
00293 w, h, tint,
00294 ASA_XImage,
00295 0, ASIMAGE_QUALITY_DEFAULT );
00296 destroy_asimage( &src_im );
00297 if( tinted )
00298 {
00299 asimage2drawable( asv, trg, tinted, gc,
00300 0, 0, trg_x, trg_y,
00301 w, h, True );
00302 destroy_asimage( &tinted );
00303 }
00304 }
00305 }
00306 #endif
00307 }
00308
00309 void
00310 CopyAndShadeArea ( Drawable src, Pixmap trg,
00311 int x, int y, int w, int h,
00312 int trg_x, int trg_y,
00313 GC gc, ShadingInfo * shading)
00314 {
00315 #ifndef X_DISPLAY_MISSING
00316 Display *dpy = get_default_asvisual()->dpy;
00317 ARGB32 tint = shading2tint32( shading );
00318
00319 if (x < 0 || y < 0)
00320 return;
00321
00322 if( tint == TINT_LEAVE_SAME )
00323 {
00324 XCopyArea (dpy, src, trg, gc, x, y, w, h, trg_x, trg_y);
00325 }else
00326 {
00327 copyshade_drawable_area( get_default_asvisual(), src, trg, x, y, w, h, trg_x, trg_y, gc, tint );
00328 }
00329 #endif
00330 }
00331
00332 void
00333 tile_pixmap (ASVisual *asv, Pixmap src, Pixmap trg, int src_w, int src_h, int x, int y, int w, int h, GC gc, ARGB32 tint)
00334 {
00335 #ifndef X_DISPLAY_MISSING
00336 int tile_x, tile_y, left_w, bott_h;
00337
00338 tile_x = x % src_w;
00339 tile_y = y % src_h;
00340 left_w = MIN (src_w - tile_x, w);
00341 bott_h = MIN (src_h - tile_y, h);
00342
00343
00344
00345
00346
00347
00348 copyshade_drawable_area( asv, src, trg, tile_x, tile_y, left_w, bott_h, 0, 0, gc, tint);
00349 if (bott_h < h)
00350 {
00351 copyshade_drawable_area( asv, src, trg, tile_x, 0, left_w, h - bott_h, 0, bott_h, gc, tint);
00352 }
00353 if (left_w < w)
00354 {
00355 copyshade_drawable_area( asv, src, trg, 0, tile_y, w - left_w, bott_h, left_w, 0, gc, tint);
00356 if (bott_h < h)
00357 copyshade_drawable_area( asv, src, trg, 0, 0, w - left_w, h - bott_h, left_w, bott_h, gc, tint);
00358 }
00359 #endif
00360 }
00361
00362 void
00363 ShadeTiledPixmap (Pixmap src, Pixmap trg, int src_w, int src_h, int x, int y, int w, int h, GC gc, ShadingInfo * shading)
00364 {
00365 #ifndef X_DISPLAY_MISSING
00366 ARGB32 tint = shading2tint32( shading );
00367 tile_pixmap (get_default_asvisual(), src, trg, src_w, src_h, x, y, w, h, gc, tint);
00368 #endif
00369 }
00370
00371 Pixmap
00372 shade_pixmap (ASVisual *asv, Pixmap src, int x, int y, int width, int height, GC gc, ARGB32 tint)
00373 {
00374 #ifndef X_DISPLAY_MISSING
00375
00376 Pixmap trg = CREATE_TRG_PIXMAP (asv, width, height);
00377
00378 if (trg != None)
00379 copyshade_drawable_area (asv, src, trg, x, y, width, height, 0, 0, gc, tint);
00380 return trg;
00381 #else
00382 return None ;
00383 #endif
00384 }
00385
00386 Pixmap
00387 ShadePixmap (Pixmap src, int x, int y, int width, int height, GC gc, ShadingInfo * shading)
00388 {
00389 Pixmap trg = None;
00390 #ifndef X_DISPLAY_MISSING
00391 ARGB32 tint = shading2tint32( shading );
00392
00393 trg = CREATE_TRG_PIXMAP (get_default_asvisual(), width, height);
00394 if (trg != None)
00395 {
00396 copyshade_drawable_area (get_default_asvisual(), src, trg, x, y, width, height, 0, 0, gc, tint);
00397 }
00398 #endif
00399 return trg;
00400 }
00401
00402 Pixmap
00403 center_pixmap (ASVisual *asv, Pixmap src, int src_w, int src_h, int width, int height, GC gc, ARGB32 tint)
00404 {
00405 Pixmap trg = None;
00406 #ifndef X_DISPLAY_MISSING
00407 Display *dpy = get_default_asvisual()->dpy;
00408
00409 int x, y, w, h, src_x = 0, src_y = 0;
00410
00411 trg = CREATE_TRG_PIXMAP (asv,width, height);
00412 if (trg != None)
00413 {
00414
00415 XFillRectangle (dpy, trg, gc, 0, 0, width, height);
00416
00417 x = (width - src_w) >> 1;
00418 y = (height - src_h) >> 1;
00419 if (x < 0)
00420 {
00421 src_x -= x;
00422 w = MIN (width, src_w + x);
00423 x = 0;
00424 }else
00425 w = MIN (width, src_w);
00426 if (y < 0)
00427 {
00428 src_y -= y;
00429 h = MIN (height, src_h + y);
00430 y = 0;
00431 }else
00432 h = MIN (height, src_h);
00433
00434 copyshade_drawable_area ( asv, src, trg, src_x, src_y, w, h, x, y, gc, tint);
00435 }
00436 #endif
00437 return trg;
00438 }
00439
00440 Pixmap
00441 CenterPixmap (Pixmap src, int src_w, int src_h, int width, int height, GC gc, ShadingInfo * shading)
00442 {
00443 Pixmap trg = None;
00444 #ifndef X_DISPLAY_MISSING
00445 ARGB32 tint = shading2tint32( shading );
00446
00447 trg = center_pixmap( get_default_asvisual(), src, src_w, src_h, width, height, gc, tint );
00448 #endif
00449 return trg ;
00450 }
00451
00452 Pixmap
00453 grow_pixmap (ASVisual *asv, Pixmap src, int src_w, int src_h, int width, int height, GC gc, ARGB32 tint )
00454 {
00455 Pixmap trg = None;
00456 #ifndef X_DISPLAY_MISSING
00457 Display *dpy = get_default_asvisual()->dpy;
00458
00459 int w, h;
00460
00461 trg = CREATE_TRG_PIXMAP (asv,width, height);
00462 if (trg != None)
00463 {
00464
00465 XFillRectangle (dpy, trg, gc, 0, 0, width, height);
00466
00467 w = MIN (width, src_w);
00468 h = MIN (height, src_h);
00469
00470 copyshade_drawable_area(asv, src, trg, 0, 0, w, h, 0, 0, gc, tint);
00471 }
00472 #endif
00473 return trg;
00474 }
00475
00476 Pixmap
00477 GrowPixmap (Pixmap src, int src_w, int src_h, int width, int height, GC gc, ShadingInfo * shading)
00478 {
00479 Pixmap trg = None;
00480 #ifndef X_DISPLAY_MISSING
00481 ARGB32 tint = shading2tint32( shading );
00482
00483 trg = grow_pixmap( get_default_asvisual(), src, src_w, src_h, width, height, gc, tint );
00484 #endif
00485 return trg ;
00486 }
00487
00488
00489
00490
00491 static Pixmap
00492 cut_pixmap ( ASVisual *asv, Pixmap src, Pixmap trg,
00493 int x, int y,
00494 unsigned int src_w, unsigned int src_h,
00495 unsigned int width, unsigned int height,
00496 GC gc, ARGB32 tint )
00497 {
00498 #ifndef X_DISPLAY_MISSING
00499 Display *dpy = get_default_asvisual()->dpy;
00500
00501 Bool my_pixmap = (trg == None )?True:False ;
00502 int screen_w, screen_h ;
00503 int w = width, h = height;
00504 int offset_x = 0, offset_y = 0;
00505 int screen = DefaultScreen(dpy);
00506
00507 if (width < 2 || height < 2 )
00508 return trg;
00509
00510 screen_w = DisplayWidth( dpy, screen );
00511 screen_h = DisplayHeight( dpy, screen );
00512
00513 while( x+(int)width < 0 ) x+= screen_w ;
00514 while( x >= screen_w ) x-= screen_w ;
00515 while( y+(int)height < 0 ) y+= screen_h ;
00516 while( y >= screen_h ) y-= screen_h ;
00517
00518 if( x < 0 )
00519 {
00520 offset_x = (-x);
00521 w -= offset_x ;
00522 x = 0 ;
00523 }
00524 if( y < 0 )
00525 {
00526 offset_y = (-y) ;
00527 h -= offset_y;
00528 y = 0 ;
00529 }
00530 if( x+w >= screen_w )
00531 w = screen_w - x ;
00532
00533 if( y+height >= screen_h )
00534 h = screen_h - y ;
00535 if( (src_w == 0 || src_h == 0) && src != None )
00536 {
00537 Window root;
00538 unsigned int dum;
00539 int dummy;
00540 if (!XGetGeometry (dpy, src, &root, &dummy, &dummy, &src_w, &src_h, &dum, &dum))
00541 src = None ;
00542 }
00543
00544 if (src == None)
00545 {
00546
00547 XSetWindowAttributes attr ;
00548 XEvent event ;
00549 int tick_count = 0 ;
00550 Bool grabbed = False ;
00551
00552 attr.background_pixmap = ParentRelative ;
00553 attr.backing_store = Always ;
00554 attr.event_mask = ExposureMask ;
00555 attr.override_redirect = True ;
00556 src = create_visual_window(asv, RootWindow(dpy,screen), x, y, w, h,
00557 0, CopyFromParent,
00558 CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask,
00559 &attr);
00560
00561 if( src == None ) return trg ;
00562 XGrabServer( dpy );
00563 grabbed = True ;
00564 XMapRaised( dpy, src );
00565 XSync(dpy, False );
00566 start_ticker(1);
00567
00568 for( tick_count = 0 ; !XCheckWindowEvent( dpy, src, ExposureMask, &event ) && tick_count < 100 ; tick_count++)
00569 wait_tick();
00570 if( tick_count < 100 )
00571 {
00572 if( trg == None ) trg = CREATE_TRG_PIXMAP (asv,width, height);
00573 if (trg != None)
00574 {
00575 if (tint != TINT_LEAVE_SAME)
00576 {
00577 ASImage *src_im = pixmap2ximage( asv, src, 0, 0, w, h, AllPlanes, 0 );
00578 XDestroyWindow( dpy, src );
00579 src = None ;
00580 XUngrabServer( dpy );
00581 grabbed = False ;
00582 if (src_im != NULL)
00583 {
00584 ASImage *tinted = tile_asimage ( asv, src_im, 0, 0,
00585 w, h, tint,
00586 ASA_XImage,
00587 0, ASIMAGE_QUALITY_DEFAULT );
00588 destroy_asimage( &src_im );
00589 asimage2drawable( asv, trg, tinted, gc,
00590 0, 0, offset_x, offset_y,
00591 w, h, True );
00592 destroy_asimage( &tinted );
00593 }else if( my_pixmap )
00594 {
00595 XFreePixmap( dpy, trg );
00596 trg = None ;
00597 }
00598 }else
00599 XCopyArea (dpy, src, trg, gc, 0, 0, w, h, offset_x, offset_y);
00600 }
00601 }
00602 if( src )
00603 XDestroyWindow( dpy, src );
00604 if( grabbed )
00605 XUngrabServer( dpy );
00606 return trg ;
00607 }
00608
00609
00610 if (x + w > src_w || y + h > src_h)
00611 {
00612 Pixmap tmp ;
00613 w = MIN (w, (int)src_w);
00614 h = MIN (h, (int)src_h);
00615
00616 tmp = CREATE_TRG_PIXMAP (asv, w, h);
00617 if (tmp != None)
00618 {
00619 tile_pixmap (asv, src, tmp, src_w, src_h, x, y, w, h, gc, tint);
00620 if( trg == None )
00621 {
00622 if( (trg = CREATE_TRG_PIXMAP (asv, w+offset_x, h+offset_y)) != None )
00623 XCopyArea (dpy, tmp, trg, gc, 0, 0, w, h, offset_x, offset_y);
00624 }else
00625 FillPixmapWithTile( trg, tmp, offset_x, offset_y, width, height, 0, 0 );
00626
00627 XFreePixmap( dpy, tmp );
00628 return trg;
00629 }
00630 }
00631
00632
00633 if( trg == None )
00634 trg = CREATE_TRG_PIXMAP (asv, width, height);
00635 if (trg != None)
00636 {
00637 copyshade_drawable_area( asv, src, trg, x, y, w, h, offset_x, offset_y, gc, tint);
00638 }
00639 return trg;
00640 #else
00641 return None ;
00642 #endif
00643 }
00644
00645 static Pixmap
00646 CutPixmap ( Pixmap src, Pixmap trg,
00647 int x, int y,
00648 unsigned int src_w, unsigned int src_h,
00649 unsigned int width, unsigned int height,
00650 GC gc, ShadingInfo * shading)
00651 {
00652 Pixmap res = None;
00653 #ifndef X_DISPLAY_MISSING
00654 ARGB32 tint = shading2tint32( shading );
00655 res = cut_pixmap( get_default_asvisual(), src, trg, x, y, src_w, src_h, width, height, gc, tint );
00656 #endif
00657 return res ;
00658 }
00659
00660 Pixmap
00661 cut_win_pixmap (ASVisual *asv, Window win, Drawable src, int src_w, int src_h, int width,
00662 int height, GC gc, ARGB32 tint)
00663 {
00664 int x = 0, y = 0;
00665
00666 if (!get_dpy_window_position( asv->dpy, None, win, NULL, NULL, &x, &y))
00667 return None;
00668
00669 return cut_pixmap( asv, src, None, x, y, src_w, src_h, width, height, gc, tint );
00670 }
00671
00672 Pixmap
00673 CutWinPixmap (Window win, Drawable src, int src_w, int src_h, int width,
00674 int height, GC gc, ShadingInfo * shading)
00675 {
00676 int x = 0, y = 0;
00677
00678 if (!get_dpy_window_position( get_default_asvisual()->dpy, None, win, NULL, NULL, &x, &y))
00679 return None;
00680
00681 return CutPixmap( src, None, x, y, src_w, src_h, width, height, gc, shading );
00682 }
00683
00684
00685 int
00686 fill_with_darkened_background (ASVisual *asv, Pixmap * pixmap, ARGB32 tint, int x, int y, int width, int height, int root_x, int root_y, int bDiscardOriginal, ASImage *root_im)
00687 {
00688 #ifndef X_DISPLAY_MISSING
00689 unsigned int root_w, root_h;
00690 Pixmap root_pixmap;
00691 Display *dpy = get_default_asvisual()->dpy;
00692 int screen = DefaultScreen(dpy);
00693
00694
00695
00696 root_pixmap = ValidatePixmap (None, 1, 1, &root_w, &root_h);
00697
00698 if (root_pixmap != None)
00699 {
00700 if (*pixmap == None)
00701 {
00702 *pixmap = create_visual_pixmap(asv, RootWindow (dpy, screen), width, height, 0);
00703 bDiscardOriginal = 1;
00704 }
00705
00706 if ( tint != TINT_LEAVE_SAME)
00707 {
00708 ASImage *src_im = (root_im == NULL)?pixmap2ximage( asv, root_pixmap, 0, 0, root_w, root_h, AllPlanes, 0 ):root_im;
00709 if( root_im )
00710 {
00711 ASImage *tinted = tile_asimage ( asv, src_im, -root_x, -root_y,
00712 width, height, tint,
00713 ASA_XImage,
00714 0, ASIMAGE_QUALITY_DEFAULT );
00715 if( root_im != src_im )
00716 destroy_asimage( &src_im );
00717 if( tinted )
00718 {
00719 asimage2drawable( asv, *pixmap, tinted, NULL,
00720 0, 0, x, y,
00721 width, height, True );
00722 destroy_asimage( &tinted );
00723 }
00724 }
00725 }else
00726 FillPixmapWithTile (*pixmap, root_pixmap, x, y, width, height, root_x, root_y);
00727 return 1;
00728 }
00729 #endif
00730 return 0;
00731 }
00732
00733
00734
00735
00736 int
00737 fill_with_pixmapped_background (ASVisual *asv, Pixmap * pixmap, ASImage *image, int x, int y, int width, int height, int root_x, int root_y, int bDiscardOriginal, ASImage *root_im)
00738 {
00739 #ifndef X_DISPLAY_MISSING
00740 unsigned int root_w, root_h;
00741 Pixmap root_pixmap;
00742 int screen = DefaultScreen(asv->dpy);
00743
00744 root_pixmap = ValidatePixmap (None, 1, 1, &root_w, &root_h);
00745 if (root_pixmap != None)
00746 {
00747 ASImageLayer layers[2];
00748 ASImage *merged_im ;
00749
00750 init_image_layers( &layers[0], 2 );
00751 layers[0].merge_scanlines = allanon_scanlines ;
00752 layers[0].im = root_im ?root_im:
00753 pixmap2ximage( asv, root_pixmap, 0, 0, root_w, root_h, AllPlanes, 0 );
00754 layers[0].dst_x = x ;
00755 layers[0].dst_y = y ;
00756 layers[0].clip_x = root_x ;
00757 layers[0].clip_y = root_y ;
00758 layers[0].clip_width = width ;
00759 layers[0].clip_height = height ;
00760
00761 layers[1].im = image ;
00762 layers[1].dst_x = x ;
00763 layers[1].dst_y = y ;
00764 layers[1].clip_x = 0 ;
00765 layers[1].clip_y = 0 ;
00766 layers[1].clip_width = width ;
00767 layers[1].clip_height = height ;
00768
00769 merged_im = merge_layers( asv, &layers[0], 2,
00770 width, height,
00771 ASA_XImage,
00772 0, ASIMAGE_QUALITY_DEFAULT );
00773 if( root_im != layers[0].im )
00774 destroy_asimage( &(layers[0].im) );
00775
00776 if( merged_im )
00777 {
00778 if (*pixmap == None)
00779 *pixmap = create_visual_pixmap (asv, RootWindow (asv->dpy, screen), width, height, 0);
00780
00781 asimage2drawable( asv, *pixmap, merged_im, NULL,
00782 0, 0, x, y,
00783 width, height, True );
00784 destroy_asimage( &merged_im );
00785 }
00786 return 1;
00787 }
00788 #endif
00789 return 0;
00790 }
00791