pike.git / lib / modules / Protocols.pmod / X.pmod / XImage.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/X.pmod/XImage.pmod:19:    * You should have received a copy of the GNU General Public License    * along with this program; if not, write to the Free Software    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    */      #pike __REAL_VERSION__      // Image --> X module.   // Needs: Pike 0.6    + //! Handles Image.Image to XImage conversions. + //! + //! The @[XImage] class behaves more or less exactly like an + //! Image.Image, but it keeps itself synchronized with the server if + //! so needed.    - // Base class. - // FIXME: Why not inherit Image.Image directly? - // Guess five times... /Per +    class Image_wrapper -  + //! Wrapper for Image.Image that keeps track of the modifications done.   {    class funcall    {    function f; -  +     mixed `()( mixed ... args )    {    mixed q = f( @args );    if(objectp(q)) set_image( q );    return q;    }       void create(function q) { f = q; }    }   
pike.git/lib/modules/Protocols.pmod/X.pmod/XImage.pmod:85:    redraw(0,0,image->xsize(),image->ysize());    }       mixed `->( string ind )    {    mixed x;    if((x = `[](this,ind)))    return x;    return funcall(image[ind]);    } -  +    }      class XImage -  + //!   {    inherit Image_wrapper;    import Protocols.X;       object /*(Types.Window)*/ window;    object /*(Types.RootWindow)*/ root; // extends window    object /*(Types.Visual)*/ visual;    object /*(Types.Colormap)*/ colormap;    Image.Colortable ccol;    object /*(Types.GC)*/ dgc; -  +  //!    -  +  //!    int best;       int depth, bpp;    function converter;    int linepad, swapbytes;    int rmask, gmask, bmask; -  +  //!       int offset_x, offset_y; -  +  //!       void set_render(string type)    {    if(type == "best") best=1;    }    -  +  //!    Image.Colortable allocate_colortable()    {   // werror("Allocating colortable\n");    array wanted;    if(best)    wanted = image->select_colors( 100 );    else    wanted = image->select_colors( 32 );       if(sizeof(wanted) < 10)
pike.git/lib/modules/Protocols.pmod/X.pmod/XImage.pmod:168:    ct->ordered();   // werror(sprintf("colortable: %O\n", res));    return ct;    }       void clear_caches(int x, int y, int width, int height)    {    // no inteligence yet...    }    +  //!    void redraw(int x, int y, int width, int height)    {    int max_pixels = ((window->display->maxRequestSize - 64)*32) / bpp;    int slice = (max_pixels / width)-1;      // werror(sprintf("XImage->redraw: [%d, %d]+[%d, %d] (%d)\n",   // x, y, width, height, slice));       if(x+width > image->xsize())    width = image->xsize()-x;
pike.git/lib/modules/Protocols.pmod/X.pmod/XImage.pmod:220:    {    if(!ccol) ccol = allocate_colortable();    string data = converter( mimg, bpp, linepad, depth, ccol );    window->PutImage( dgc, bpp, x + offset_x, y + offset_y,    width, slice, data, 2 );    }    y += slice;    }    }    +  //!    void set_window(object w)    {    set_drawable(w);    }    -  +  //!    void set_drawable(object w)    {    window = w;    if(!w->visual)    {    object q = w->parent;    if(q)    do {    if(q->visual)    {
pike.git/lib/modules/Protocols.pmod/X.pmod/XImage.pmod:305:    ccol = 0;    converter = Image.X.encode_truecolor_masks;    break;    case "DirectColor":    error("Cannot handle Direct Color visual yet.");    break;    }    dgc = window->CreateGC();    }    +  //!    void set_offset(int x, int y)    {    offset_x = x;    offset_y = y;    }   }    - // Steels a few callbacks from the window. + // Steals a few callbacks from the window.      class WindowImage -  + //! A version of XImage that redraws itself at need   { -  +     inherit XImage;       void exposed(mixed event)    {   // werror(sprintf("%O\n", event));   #ifdef BUGGY_X    if(!event->count)    {    remove_call_out(redraw);    call_out(redraw,0.1,0,0,image->xsize(),image->ysize());
pike.git/lib/modules/Protocols.pmod/X.pmod/XImage.pmod:341:       void create(object/*(Types.Window)*/ w)    {    set_drawable(w);    w->set_event_callback("Expose", exposed); // internal callback...    w->SelectInput("Exposure");    }   }      class PixmapImage + //! A pixmap (much like XImage, but stored in the server)   {    inherit XImage;    import Protocols.X;       void create(Types.Pixmap p, object|void ct)    {    if(ct) ccol = ct;    set_drawable( p );    }   }    -  + //! Convert an alpha channel to a shaped-window extension mask   object MakeShapeMask(object in, object alpha)   {    object shape = in->CreatePixmap(alpha->xsize(),alpha->ysize(),1);    mapping f;    foreach(in->display->formats, f) if(f->depth == 1) break;    shape->PutImage( shape->CreateGC(), 1, 0, 0, alpha->xsize(), alpha->ysize(),    Image.X.encode_truecolor( alpha->invert(),    1, f->scanLinePad,    !in->display->bitmapBitOrder,    1, 0, 0, 0, 0, 0), 0);
pike.git/lib/modules/Protocols.pmod/X.pmod/XImage.pmod:381:    if(!ocol)    spcm = 0;    object bgpm = in->CreatePixmap(width, height, in->depth);    object pi = PixmapImage( bgpm, spcm );    pi->set_render("best");    pi->set_image( color );    spcm = pi->ccol;    return bgpm;   }    + //! Make the window @[in] display the image, with a mask shaped + //! according to alpha, and optionally with a colored border aound the + //! mask.   void ShapedWindowImage(object in, object color, object|void alpha,    int|void contour)   {    int width = color->xsize();    int height = color->ysize();       object bgpm = in->CreatePixmap(width, height, in->depth);    PixmapImage( bgpm )->set_image( color );    in->ChangeAttributes( (["BackPixmap":bgpm ]) );    if(alpha)