This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/imbuf/IMB_moviecache.h

82 lines
3.5 KiB
C++
Raw Normal View History

/*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2011 Blender Foundation.
* All rights reserved.
*/
#ifndef __IMB_MOVIECACHE_H__
#define __IMB_MOVIECACHE_H__
/** \file
* \ingroup imbuf
*/
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
2012-07-16 23:23:33 +00:00
/* Cache system for movie data - now supports storing ImBufs only
2012-03-09 18:28:30 +00:00
* Supposed to provide unified cache system for movie clips, sequencer and
* other movie-related areas */
struct ImBuf;
struct MovieCache;
typedef void (*MovieCacheGetKeyDataFP)(void *userkey, int *framenr, int *proxy, int *render_flags);
typedef void *(*MovieCacheGetPriorityDataFP)(void *userkey);
typedef int (*MovieCacheGetItemPriorityFP)(void *last_userkey, void *priority_data);
typedef void (*MovieCachePriorityDeleterFP)(void *priority_data);
void IMB_moviecache_init(void);
void IMB_moviecache_destruct(void);
struct MovieCache *IMB_moviecache_create(const char *name,
int keysize,
GHashHashFP hashfp,
GHashCmpFP cmpfp);
void IMB_moviecache_set_getdata_callback(struct MovieCache *cache,
MovieCacheGetKeyDataFP getdatafp);
void IMB_moviecache_set_priority_callback(struct MovieCache *cache,
MovieCacheGetPriorityDataFP getprioritydatafp,
MovieCacheGetItemPriorityFP getitempriorityfp,
MovieCachePriorityDeleterFP prioritydeleterfp);
void IMB_moviecache_put(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf);
2014-02-03 18:55:59 +11:00
bool IMB_moviecache_put_if_possible(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf);
2012-08-23 07:10:48 +00:00
struct ImBuf *IMB_moviecache_get(struct MovieCache *cache, void *userkey);
Add support for tiled images and the UDIM naming scheme This patch contains the work that I did during my week at the Code Quest - adding support for tiled images to Blender. With this patch, images now contain a list of tiles. By default, this just contains one tile, but if the source type is set to Tiled, the user can add additional tiles. When acquiring an ImBuf, the tile to be loaded is specified in the ImageUser. Therefore, code that is not yet aware of tiles will just access the default tile as usual. The filenames of the additional tiles are derived from the original filename according to the UDIM naming scheme - the filename contains an index that is calculated as (1001 + 10*<y coordinate of the tile> + <x coordinate of the tile>), where the x coordinate never goes above 9. Internally, the various tiles are stored in a cache just like sequences. When acquired for the first time, the code will try to load the corresponding file from disk. Alternatively, a new operator can be used to initialize the tile similar to the New Image operator. The following features are supported so far: - Automatic detection and loading of all tiles when opening the first tile (1001) - Saving all tiles - Adding and removing tiles - Filling tiles with generated images - Drawing all tiles in the Image Editor - Viewing a tiled grid even if no image is selected - Rendering tiled images in Eevee - Rendering tiled images in Cycles (in SVM mode) - Automatically skipping loading of unused tiles in Cycles - 2D texture painting (also across tiles) - 3D texture painting (also across tiles, only limitation: individual faces can not cross tile borders) - Assigning custom labels to individual tiles (drawn in the Image Editor instead of the ID) - Different resolutions between tiles There still are some missing features that will be added later (see T72390): - Workbench engine support - Packing/Unpacking support - Baking support - Cycles OSL support - many other Blender features that rely on images Thanks to Brecht for the review and to all who tested the intermediate versions! Differential Revision: https://developer.blender.org/D3509
2019-12-12 16:06:08 +01:00
void IMB_moviecache_remove(struct MovieCache *cache, void *userkey);
2014-02-03 18:55:59 +11:00
bool IMB_moviecache_has_frame(struct MovieCache *cache, void *userkey);
void IMB_moviecache_free(struct MovieCache *cache);
Image cache rewrite to using generic movie cache Summary: Behaves very much the same as cache for Movie Clip datablock: - Image now have `MovieCache *cache` field which replaced legacy `ListBase ibufs`. This allows image datablock to easily keep of image buffers which are owned by itself. This field isn't saved to the file and getting restored on undo steps. However, cache limit is global for movies, sequences and image datablocks now. So overall cached image buffers size will not go above cache limit size in user preferences. - Image buffers which are marked as BITMAPDIRTY will never be freed from the cache. - Added utility function to iterate over image buffers saved in movie cache. - Movie cache cleanup check callback now have ImBuf argument which can be used in a condition of cleanup. - Added some utility functions which replaces legacy ibufs iterations with image cache iteration which happens from inside a lock. - Fixed `image_mem_size()` which was only counting one of the buffers if both float and byte buffer present. Additional notes: - `BKE_image_get_first_ibuf()` is rather stupid, but direct access to ibufs->first was also the same stupid idea. Would consider avoid this function is another project. - There are some places which doesn't look threadsafe, but they already were not so much threadsafe anyway before. So think not a big deal with solving this later. Finally solves infinite memory usage by image sequences! :) Reviewers: brecht, campbellbarton Reviewed By: brecht CC: sebastian_k Differential Revision: http://developer.blender.org/D95
2013-12-13 16:22:08 +06:00
void IMB_moviecache_cleanup(struct MovieCache *cache,
bool(cleanup_check_cb)(struct ImBuf *ibuf,
void *userkey,
void *userdata),
Image cache rewrite to using generic movie cache Summary: Behaves very much the same as cache for Movie Clip datablock: - Image now have `MovieCache *cache` field which replaced legacy `ListBase ibufs`. This allows image datablock to easily keep of image buffers which are owned by itself. This field isn't saved to the file and getting restored on undo steps. However, cache limit is global for movies, sequences and image datablocks now. So overall cached image buffers size will not go above cache limit size in user preferences. - Image buffers which are marked as BITMAPDIRTY will never be freed from the cache. - Added utility function to iterate over image buffers saved in movie cache. - Movie cache cleanup check callback now have ImBuf argument which can be used in a condition of cleanup. - Added some utility functions which replaces legacy ibufs iterations with image cache iteration which happens from inside a lock. - Fixed `image_mem_size()` which was only counting one of the buffers if both float and byte buffer present. Additional notes: - `BKE_image_get_first_ibuf()` is rather stupid, but direct access to ibufs->first was also the same stupid idea. Would consider avoid this function is another project. - There are some places which doesn't look threadsafe, but they already were not so much threadsafe anyway before. So think not a big deal with solving this later. Finally solves infinite memory usage by image sequences! :) Reviewers: brecht, campbellbarton Reviewed By: brecht CC: sebastian_k Differential Revision: http://developer.blender.org/D95
2013-12-13 16:22:08 +06:00
void *userdata);
void IMB_moviecache_get_cache_segments(
struct MovieCache *cache, int proxy, int render_flags, int *totseg_r, int **points_r);
Image cache rewrite to using generic movie cache Summary: Behaves very much the same as cache for Movie Clip datablock: - Image now have `MovieCache *cache` field which replaced legacy `ListBase ibufs`. This allows image datablock to easily keep of image buffers which are owned by itself. This field isn't saved to the file and getting restored on undo steps. However, cache limit is global for movies, sequences and image datablocks now. So overall cached image buffers size will not go above cache limit size in user preferences. - Image buffers which are marked as BITMAPDIRTY will never be freed from the cache. - Added utility function to iterate over image buffers saved in movie cache. - Movie cache cleanup check callback now have ImBuf argument which can be used in a condition of cleanup. - Added some utility functions which replaces legacy ibufs iterations with image cache iteration which happens from inside a lock. - Fixed `image_mem_size()` which was only counting one of the buffers if both float and byte buffer present. Additional notes: - `BKE_image_get_first_ibuf()` is rather stupid, but direct access to ibufs->first was also the same stupid idea. Would consider avoid this function is another project. - There are some places which doesn't look threadsafe, but they already were not so much threadsafe anyway before. So think not a big deal with solving this later. Finally solves infinite memory usage by image sequences! :) Reviewers: brecht, campbellbarton Reviewed By: brecht CC: sebastian_k Differential Revision: http://developer.blender.org/D95
2013-12-13 16:22:08 +06:00
struct MovieCacheIter;
struct MovieCacheIter *IMB_moviecacheIter_new(struct MovieCache *cache);
void IMB_moviecacheIter_free(struct MovieCacheIter *iter);
bool IMB_moviecacheIter_done(struct MovieCacheIter *iter);
void IMB_moviecacheIter_step(struct MovieCacheIter *iter);
struct ImBuf *IMB_moviecacheIter_getImBuf(struct MovieCacheIter *iter);
void *IMB_moviecacheIter_getUserKey(struct MovieCacheIter *iter);
#endif