Logo Search packages:      
Sourcecode: fbdesk version File versions  Download package

Pixmap FbTk::ImageControl::renderImage ( unsigned int  width,
unsigned int  height,
const FbTk::Texture src_texture 
)

Render to pixmap

Parameters:
width width of pixmap
height height of pixmap
src_texture texture type to render
Returns:
pixmap of the rendered image, on failure None

Definition at line 176 of file ImageControl.cc.

References FbTk::Texture::color(), FbTk::Texture::colorTo(), FbTk::ImageControl::Cache::count, FbTk::ImageControl::Cache::height, FbTk::Color::pixel(), FbTk::ImageControl::Cache::pixel1, FbTk::ImageControl::Cache::pixel2, FbTk::ImageControl::Cache::pixmap, FbTk::TextureRender::render(), searchCache(), FbTk::ImageControl::Cache::texture, timeout(), FbTk::Texture::type(), and FbTk::ImageControl::Cache::width.

                                                              {

    if (texture.type() & FbTk::Texture::PARENTRELATIVE)
        return ParentRelative;

      // search cache first
    Pixmap pixmap = searchCache(width, height, texture.type(),
                                texture.color(), texture.colorTo());
    if (pixmap)
        return pixmap; // return cache item

      // render new image
    TextureRender image(*this, width, height);
    pixmap = image.render(texture);

    if (pixmap) {
        // create new cache item and add it to cache list

        Cache *tmp = new Cache;

        tmp->pixmap = pixmap;
        tmp->width = width;
        tmp->height = height;
        tmp->count = 1;
        tmp->texture = texture.type();
        tmp->pixel1 = texture.color().pixel();

        if (texture.type() & FbTk::Texture::GRADIENT)
            tmp->pixel2 = texture.colorTo().pixel();
        else
            tmp->pixel2 = 0l;

        cache.push_back(tmp); 

        if ((unsigned) cache.size() > cache_max) {
#ifdef DEBUG
            cerr<<"FbTk::ImageControl::renderImage(): cache is large, forcing cleanout"<<endl;
#endif // DEBUG
            timeout();
        }

        return pixmap;
    }

    return None;
}


Generated by  Doxygen 1.6.0   Back to index