/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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.
 */

#ifndef __PIXEL_CACHE_H__
#define __PIXEL_CACHE_H__

#include "base/tile-manager.h"
#include "base/tile.h"

/* PixelCache is a way to speed up read-only individual pixel access
 * when acceses are assumed to fall on the same tile on repeated
 * access
 */

typedef struct _PixelCache{
    TileManager *tm;
    Tile *tile;              /* currently cached tile */
    gint width,height;       /* lever right corner of data in tile manager */
    gint num;                /* tilenum of currently cached tile */
    gint bpp;                /* bpp */
    guchar bg[MAX_CHANNELS]; /* pixel data used for out accesses outside ares */
} PixelCache;
    
/* Initialize a PixelCache struct, supplying a background color to use
   when accesses are made outside the drawable
*/
void    
pixel_cache_init         (PixelCache  *pc,
                          TileManager *tm,
                          guchar       bg[MAX_CHANNELS]);

/* Free any locked tile(s)
*/
void    
pixel_cache_clear            (PixelCache *pc);

/* Store the pixel at x,y in the user submitted buffer
*/
void    
pixel_cache_get        (PixelCache *pc,
                        gint        x,
                        gint        y,
                        guchar      color[MAX_CHANNELS]);

#endif /* __PIXEL_SURROUND_H__ */
