static GeglTile * gegl_tile_backend_swap_get_tile (GeglTileSource *self, gint x, gint y, gint z) { GeglTileBackend *backend; GeglTileBackendSwap *tile_backend_swap; SwapEntry *entry; GeglTile *tile = NULL; gint tile_size; backend = GEGL_TILE_BACKEND (self); tile_backend_swap = GEGL_TILE_BACKEND_SWAP (backend); entry = gegl_tile_backend_swap_lookup_entry (tile_backend_swap, x, y, z); if (!entry) return NULL; tile_size = gegl_tile_backend_get_tile_size (GEGL_TILE_BACKEND (self)); tile = gegl_tile_new (tile_size); gegl_tile_mark_as_stored (tile); gegl_tile_backend_swap_entry_read (tile_backend_swap, entry, gegl_tile_get_data (tile)); return tile; }
static GeglTile * get_tile (GeglTileSource *gegl_tile_source, gint x, gint y, gint z) { GeglTileSource *source = ((GeglTileHandler *) gegl_tile_source)->source; GeglTileHandlerEmpty *empty = (GeglTileHandlerEmpty *) gegl_tile_source; GeglTile *tile = NULL; if (source) tile = gegl_tile_source_get_tile (source, x, y, z); if (tile) return tile; if (G_UNLIKELY(!empty->tile)) { gint tile_size = gegl_tile_backend_get_tile_size (empty->backend); empty->tile = gegl_tile_new (tile_size); memset (gegl_tile_get_data (empty->tile), 0x00, tile_size); empty->tile->is_zero_tile = 1; } return gegl_tile_handler_dup_tile (GEGL_TILE_HANDLER (empty), empty->tile, x, y, z); }
/* this is the only place that actually should * instantiate tiles, when the cache is large enough * that should make sure we don't hit this function * too often. */ static GeglTile * gegl_tile_backend_file_get_tile (GeglTileSource *self, gint x, gint y, gint z) { GeglTileBackend *backend; GeglTileBackendFile *tile_backend_file; GeglBufferTile *entry; GeglTile *tile = NULL; gint tile_size; backend = GEGL_TILE_BACKEND (self); tile_backend_file = GEGL_TILE_BACKEND_FILE (backend); entry = gegl_tile_backend_file_lookup_entry (tile_backend_file, x, y, z); if (!entry) return NULL; tile_size = gegl_tile_backend_get_tile_size (GEGL_TILE_BACKEND (self)); tile = gegl_tile_new (tile_size); gegl_tile_set_rev (tile, entry->rev); gegl_tile_mark_as_stored (tile); gegl_tile_backend_file_file_entry_read (tile_backend_file, entry, gegl_tile_get_data (tile)); return tile; }
static GeglTile * get_tile (GeglTileSource *gegl_tile_source, gint x, gint y, gint z) { GeglTileSource *source = ((GeglTileHandler*)(gegl_tile_source))->source; GeglTileHandlerZoom *zoom = (GeglTileHandlerZoom*)(gegl_tile_source); GeglTile *tile = NULL; const Babl *format = gegl_tile_backend_get_format (zoom->backend); gint tile_width; gint tile_height; gint tile_size; if (source) { tile = gegl_tile_source_get_tile (source, x, y, z); } if (tile) return tile; if (z == 0)/* at base level with no tile found->send null, and shared empty tile will be used instead */ { return NULL; } if (z>zoom->tile_storage->seen_zoom) zoom->tile_storage->seen_zoom = z; g_assert (zoom->backend); g_object_get (zoom->backend, "tile-width", &tile_width, "tile-height", &tile_height, "tile-size", &tile_size, NULL); { gint i, j; GeglTile *source_tile[2][2] = { { NULL, NULL }, { NULL, NULL } }; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) { /* we get the tile from ourselves, to make successive rescales work * correctly */ source_tile[i][j] = gegl_tile_source_get_tile (gegl_tile_source, x * 2 + i, y * 2 + j, z - 1); } if (source_tile[0][0] == NULL && source_tile[0][1] == NULL && source_tile[1][0] == NULL && source_tile[1][1] == NULL) { return NULL; /* no data from level below, return NULL and let GeglTileHandlerEmpty fill in the shared empty tile */ } g_assert (tile == NULL); if (tile == NULL) { tile = gegl_tile_new (tile_size); tile->x = x; tile->y = y; tile->z = z; tile->tile_storage = zoom->tile_storage; if (zoom->cache) gegl_tile_handler_cache_insert (zoom->cache, tile, x, y, z); } gegl_tile_lock (tile); for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) { if (source_tile[i][j]) { set_half (tile, source_tile[i][j], tile_width, tile_height, format, i, j); gegl_tile_unref (source_tile[i][j]); } else { set_blank (tile, tile_width, tile_height, format, i, j); } } gegl_tile_unlock (tile); } return tile; }