[Bf-blender-cvs] [2984d39] asset-experiments: Fix and use block caching from UI draw code.
Bastien Montagne
noreply at git.blender.org
Mon Mar 30 12:31:32 CEST 2015
Commit: 2984d39a46d028fda386b2ed247f0f4c366fde2f
Author: Bastien Montagne
Date: Mon Mar 30 12:24:00 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rB2984d39a46d028fda386b2ed247f0f4c366fde2f
Fix and use block caching from UI draw code.
Seems to work nice now.
===================================================================
M source/blender/editors/space_file/file_draw.c
M source/blender/editors/space_file/filelist.c
===================================================================
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 995250d..020497a 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -484,6 +484,12 @@ void file_draw_list(const bContext *C, ARegion *ar)
align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT;
+ {
+ const bool success = filelist_file_cache_block(files, offset + (numfiles_layout / 2));
+ BLI_assert(success);
+ UNUSED_VARS_NDEBUG(success);
+ }
+
for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) {
char path[FILE_MAX_LIBEXTRA];
ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 64f166d..b94aecc 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -210,7 +210,7 @@ typedef struct FileListIntern {
#define FILELIST_ENTRYCACHESIZE 1024 /* Keep it a power of two! */
typedef struct FileListEntryCache {
/* Block cache: all entries between start and end index. used for part of the list on diplay. */
- FileDirEntry (*block_entries)[FILELIST_ENTRYCACHESIZE];
+ FileDirEntry *block_entries[FILELIST_ENTRYCACHESIZE];
int block_start_index, block_end_index, block_cursor;
/* Misc cache: random indices, FIFO behavior.
@@ -1321,7 +1321,9 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index)
BLI_assert((end_index - start_index) <= FILELIST_ENTRYCACHESIZE) ;
- if ((start_index == cache->block_end_index) && (end_index == cache->block_start_index)) {
+// printf("Caching block [%d:%d] (current cache: [%d:%d])\n", start_index, end_index, cache->block_start_index, cache->block_end_index);
+
+ if ((start_index == cache->block_start_index) && (end_index == cache->block_end_index)) {
/* Nothing to do! */
return true;
}
@@ -1329,7 +1331,7 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index)
if ((start_index >= cache->block_end_index) || (end_index <= cache->block_start_index)) {
/* New cached block does not overlap existing one, simple. */
memcpy(cache->block_entries, &filelist->filelist_intern.filtered[start_index],
- sizeof(*cache->block_entries) * (end_index - start_index));
+ sizeof(cache->block_entries[0]) * (end_index - start_index));
cache->block_start_index = start_index;
cache->block_end_index = end_index;
cache->block_cursor = 0;
@@ -1353,10 +1355,10 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index)
if (size2) {
memcpy(&cache->block_entries[idx2], &filelist->filelist_intern.filtered[end_index - size2],
- sizeof(*cache->block_entries) * size2);
+ sizeof(cache->block_entries[0]) * size2);
}
memcpy(&cache->block_entries[idx1], &filelist->filelist_intern.filtered[end_index - size1 - size2],
- sizeof(*cache->block_entries) * size1);
+ sizeof(cache->block_entries[0]) * size1);
}
cache->block_end_index = end_index;
@@ -1381,10 +1383,10 @@ bool filelist_file_cache_block(struct FileList *filelist, const int index)
if (size2) {
memcpy(&cache->block_entries[idx2], &filelist->filelist_intern.filtered[start_index + size1],
- sizeof(*cache->block_entries) * size2);
+ sizeof(cache->block_entries[0]) * size2);
}
memcpy(&cache->block_entries[idx1], &filelist->filelist_intern.filtered[start_index],
- sizeof(*cache->block_entries) * size1);
+ sizeof(cache->block_entries[0]) * size1);
cache->block_cursor = idx1;
}
More information about the Bf-blender-cvs
mailing list