... | ... |
@@ -130,12 +130,16 @@ fprintf(stderr,"bg_get: \"%s\"\n",bgload->path); |
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
int |
133 |
-bg_add(bg_t *bg, char *path) |
|
133 |
+bg_add(bg_t *bg, char *path, int flag_pinned) |
|
134 | 134 |
{ |
135 | 135 |
int i; |
136 | 136 |
bgload_t *bgload; |
137 | 137 |
if(bg==NULL) |
138 | 138 |
return(-1); |
139 |
+ if(path!=NULL && flag_pinned) { |
|
140 |
+ memset(bg->pinnedpath,0,sizeof(bg->pinnedpath)); |
|
141 |
+ strncpy(bg->pinnedpath,path,sizeof(bg->pinnedpath)-1); |
|
142 |
+ } |
|
139 | 143 |
for(i=0,bgload=bg->bgload;i<bg->sizebgload;i++,bgload++) { |
140 | 144 |
if(bgload->lended_to_thread && strcmp(path,bgload->path)==0) { |
141 | 145 |
bgload->is_todo=1; |
... | ... |
@@ -170,7 +174,11 @@ bg_freeunmarked(bg_t *bg) |
170 | 174 |
now=time(NULL); |
171 | 175 |
for(i=0,bgload=bg->bgload;i<bg->sizebgload;i++,bgload++) { |
172 | 176 |
if(bgload->lended_to_thread && bgload->thread_finished && bgload->has_mark==0) { |
173 |
- if(bgload->has_data && (bgload->lastused<(now-UNLOADTIMEOUTSECONDS) || bgload->lastused>(now+UNLOADTIMEOUTSECONDS))) { |
|
177 |
+ if(bgload->has_data |
|
178 |
+ && (bgload->lastused<(now-UNLOADTIMEOUTSECONDS) |
|
179 |
+ || bgload->lastused>(now+UNLOADTIMEOUTSECONDS)) |
|
180 |
+ && strcmp(bgload->path,bg->pinnedpath)!=0 |
|
181 |
+ ) { |
|
174 | 182 |
#if 1 |
175 | 183 |
fprintf(stderr,"bg: Unloading: \"%s\"\n",bgload->path); |
176 | 184 |
#endif |
... | ... |
@@ -39,6 +39,7 @@ typedef struct bg_t { |
39 | 39 |
int sizebgload; |
40 | 40 |
bgload_t *bgload; |
41 | 41 |
pthread_t thread; |
42 |
+ char pinnedpath[1024]; |
|
42 | 43 |
pthread_attr_t tattr; |
43 | 44 |
int flag_threadstarted; |
44 | 45 |
int do_exit; |
... | ... |
@@ -52,7 +53,7 @@ bg_t *bg_init(int sizebgload); |
52 | 53 |
void bg_free(bg_t *bg); |
53 | 54 |
int bg_resetmarks(bg_t *bg); |
54 | 55 |
bgload_t *bg_get(bg_t *bg, char *path); |
55 |
-int bg_add(bg_t *bg, char *path); |
|
56 |
+int bg_add(bg_t *bg, char *path, int flag_pinned); /* only one image is pinned (excluded from unload) */ |
|
56 | 57 |
int bg_freeunmarked(bg_t *bg); |
57 | 58 |
|
58 | 59 |
void *bg_thread(void *); |
... | ... |
@@ -520,8 +520,13 @@ im_body_draw(body_t *body, mousedata_t *mousedata, int windowwidth, int windowhe |
520 | 520 |
IMDEBUG("begin draw"); |
521 | 521 |
maxw=windowwidth; |
522 | 522 |
maxh=windowheight-body->whxy.y; |
523 |
- if(body->bigtexture.has_texture==0 || strcmp(body->bigtexture.currentpath,body->texture.currentpath)!=0) |
|
523 |
+ if(body->bigtexture.has_texture==0 || strcmp(body->bigtexture.currentpath,body->texture.currentpath)!=0) { |
|
524 |
+#if 1 |
|
525 |
+fprintf(stderr,"~~~ TEXTURE_LOAD FOR BIGTEXTURE \"%s\"\n",body->texture.currentpath); |
|
526 |
+#endif |
|
527 |
+ bg_add(body->bg,body->texture.currentpath,1); |
|
524 | 528 |
texture_load(&(body->bigtexture),body->texture.currentpath,maxw,maxh,body->bg); |
529 |
+ } |
|
525 | 530 |
if(body->bigtexture.has_texture && strcmp(body->bigtexture.currentpath,body->texture.currentpath)==0) { |
526 | 531 |
int x0,y0; |
527 | 532 |
x0=0; |
... | ... |
@@ -529,7 +534,10 @@ im_body_draw(body_t *body, mousedata_t *mousedata, int windowwidth, int windowhe |
529 | 534 |
texture_draw(&(body->bigtexture),x0,y0,maxw,maxh); |
530 | 535 |
return(0); /* all done */ |
531 | 536 |
} else { |
537 |
+#if 0 |
|
538 |
+#warning TEMP |
|
532 | 539 |
body->flag_drawbigtexture=0; /* error loading big texture, draw screen normally */ |
540 |
+#endif |
|
533 | 541 |
} |
534 | 542 |
} |
535 | 543 |
/* calculate positions */ |
... | ... |
@@ -716,7 +724,7 @@ fprintf(stderr,"elem:\"%s\" sidelen:%i old:%ix%i new:%ix%i\n",elem->name+1,sidel |
716 | 724 |
thumb->has_failedload=1; |
717 | 725 |
} |
718 | 726 |
} else if(bgload==NULL) { |
719 |
- bg_add(body->bg,fullpath); |
|
727 |
+ bg_add(body->bg,fullpath,0); |
|
720 | 728 |
} |
721 | 729 |
} |
722 | 730 |
if(thumb->has_texture!=0) { |
... | ... |
@@ -784,7 +792,7 @@ fprintf(stderr,"elem:\"%s\" sidelen:%i old:%ix%i new:%ix%i\n",elem->name+1,sidel |
784 | 792 |
} |
785 | 793 |
} |
786 | 794 |
if(imageundermouse[0]!='\0') |
787 |
- bg_add(body->bg,imageundermouse); /* to prioritise loading this image */ |
|
795 |
+ bg_add(body->bg,imageundermouse,0); /* to prioritise loading this image */ |
|
788 | 796 |
for(;k<dirdata->listing.usedelems;k++) { |
789 | 797 |
elem=dirdata->listing.elems+k; |
790 | 798 |
if(elem->name[0]!='f' && elem->name[0]!='l') |
... | ... |
@@ -1124,11 +1132,15 @@ texture_load(texture_t *texture, char *fullpath, int maxw, int maxh, bg_t *bg) |
1124 | 1132 |
texture->has_texture=0; |
1125 | 1133 |
texture->has_failedload=0; |
1126 | 1134 |
} |
1127 |
- texture->currentpath[0]='\0'; |
|
1128 | 1135 |
if(bg!=NULL && (bgload=bg_get(bg,texture->currentpath))!=NULL && bgload->has_data!=0) { |
1129 | 1136 |
im=ImageCopy(bgload->image); |
1130 | 1137 |
} else { |
1138 |
+#if 0 |
|
1139 |
+#warning TEST CODE |
|
1140 |
+ return(-1); /* if not loaded in background, return -1 to indicate "not ready" */ |
|
1141 |
+#else |
|
1131 | 1142 |
im=global_loadimage(fullpath); |
1143 |
+#endif |
|
1132 | 1144 |
} |
1133 | 1145 |
if(IsImageValid(im)) { |
1134 | 1146 |
imutil_aspectmaximize(im.width,im.height,maxw,maxh,&neww,&newh); |