diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-23 04:01:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-23 04:22:22 +0300 |
commit | 64b4b719ebd5201d27aa25d7fa2d765eabded9b0 (patch) | |
tree | c6e1147f3b81b90193d3acaa0df3f8c5c93db328 /source/blender/imbuf/intern/cache.c | |
parent | ac53291e1ff79144ca41d63b0787bfe04da21677 (diff) |
Cleanup: style, use braces for imbuf
Diffstat (limited to 'source/blender/imbuf/intern/cache.c')
-rw-r--r-- | source/blender/imbuf/intern/cache.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c index e6244364ba8..01c588daedd 100644 --- a/source/blender/imbuf/intern/cache.c +++ b/source/blender/imbuf/intern/cache.c @@ -155,8 +155,9 @@ void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty) if (gtile) { /* in case another thread is loading this */ - while (gtile->loading) + while (gtile->loading) { ; + } BLI_ghash_remove(GLOBAL_CACHE.tilehash, gtile, NULL, NULL); BLI_remlink(&GLOBAL_CACHE.tiles, gtile); @@ -209,17 +210,21 @@ void imb_tile_cache_exit(void) int a; if (GLOBAL_CACHE.initialized) { - for (gtile = GLOBAL_CACHE.tiles.first; gtile; gtile = gtile->next) + for (gtile = GLOBAL_CACHE.tiles.first; gtile; gtile = gtile->next) { imb_global_cache_tile_unload(gtile); + } - for (a = 0; a < GLOBAL_CACHE.totthread; a++) + for (a = 0; a < GLOBAL_CACHE.totthread; a++) { imb_thread_cache_exit(&GLOBAL_CACHE.thread_cache[a]); + } - if (GLOBAL_CACHE.memarena) + if (GLOBAL_CACHE.memarena) { BLI_memarena_free(GLOBAL_CACHE.memarena); + } - if (GLOBAL_CACHE.tilehash) + if (GLOBAL_CACHE.tilehash) { BLI_ghash_free(GLOBAL_CACHE.tilehash, NULL, NULL); + } BLI_mutex_end(&GLOBAL_CACHE.mutex); @@ -236,8 +241,9 @@ void IMB_tile_cache_params(int totthread, int maxmem) totthread++; /* lazy initialize cache */ - if (GLOBAL_CACHE.totthread == totthread && GLOBAL_CACHE.maxmem == maxmem) + if (GLOBAL_CACHE.totthread == totthread && GLOBAL_CACHE.maxmem == maxmem) { return; + } imb_tile_cache_exit(); @@ -252,8 +258,9 @@ void IMB_tile_cache_params(int totthread, int maxmem) GLOBAL_CACHE.maxmem = maxmem * 1024 * 1024; GLOBAL_CACHE.totthread = totthread; - for (a = 0; a < totthread; a++) + for (a = 0; a < totthread; a++) { imb_thread_cache_init(&GLOBAL_CACHE.thread_cache[a]); + } BLI_mutex_init(&GLOBAL_CACHE.mutex); } @@ -269,8 +276,9 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, BLI_mutex_lock(&GLOBAL_CACHE.mutex); - if (replacetile) + if (replacetile) { replacetile->refcount--; + } /* find tile in global cache */ lookuptile.ibuf = ibuf; @@ -286,8 +294,9 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, BLI_mutex_unlock(&GLOBAL_CACHE.mutex); - while (gtile->loading) + while (gtile->loading) { ; + } } else { /* not found, let's load it from disk */ @@ -295,9 +304,11 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, /* first check if we hit the memory limit */ if (GLOBAL_CACHE.maxmem && GLOBAL_CACHE.totmem > GLOBAL_CACHE.maxmem) { /* find an existing tile to unload */ - for (gtile = GLOBAL_CACHE.tiles.last; gtile; gtile = gtile->prev) - if (gtile->refcount == 0 && gtile->loading == 0) + for (gtile = GLOBAL_CACHE.tiles.last; gtile; gtile = gtile->prev) { + if (gtile->refcount == 0 && gtile->loading == 0) { break; + } + } } if (gtile) { @@ -312,8 +323,9 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, gtile = GLOBAL_CACHE.unused.first; BLI_remlink(&GLOBAL_CACHE.unused, gtile); } - else + else { gtile = BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImGlobalTile)); + } } /* setup new tile */ @@ -355,8 +367,9 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, /* test if it is already in our thread local cache */ if ((ttile = cache->tiles.first)) { /* check last used tile before going to hash */ - if (ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty) + if (ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty) { return ibuf->tiles[toffs]; + } /* find tile in hash */ lookuptile.ibuf = ibuf; @@ -419,8 +432,9 @@ void IMB_tiles_to_rect(ImBuf *ibuf) mipbuf->mall |= IB_rect; mipbuf->flags |= IB_rect; } - else + else { break; + } } for (ty = 0; ty < mipbuf->ytiles; ty++) { |