Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/image.c
| Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | static void image_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag) | ||||
| LISTBASE_FOREACH (RenderSlot *, slot, &image_dst->renderslots) { | LISTBASE_FOREACH (RenderSlot *, slot, &image_dst->renderslots) { | ||||
| slot->render = NULL; | slot->render = NULL; | ||||
| } | } | ||||
| BLI_listbase_clear(&image_dst->anims); | BLI_listbase_clear(&image_dst->anims); | ||||
| BLI_duplicatelist(&image_dst->tiles, &image_src->tiles); | BLI_duplicatelist(&image_dst->tiles, &image_src->tiles); | ||||
| for (int eye = 0; eye < 2; eye++) { | |||||
| for (int i = 0; i < TEXTARGET_COUNT; i++) { | for (int i = 0; i < TEXTARGET_COUNT; i++) { | ||||
| image_dst->gputexture[i] = NULL; | image_dst->gputexture[i][eye] = NULL; | ||||
| } | |||||
| } | } | ||||
| if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { | if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { | ||||
| BKE_previewimg_id_copy(&image_dst->id, &image_src->id); | BKE_previewimg_id_copy(&image_dst->id, &image_src->id); | ||||
| } | } | ||||
| else { | else { | ||||
| image_dst->preview = NULL; | image_dst->preview = NULL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 366 Lines • ▼ Show 20 Lines | bool BKE_image_scale(Image *image, int width, int height) | ||||
| BKE_image_release_ibuf(image, ibuf, lock); | BKE_image_release_ibuf(image, ibuf, lock); | ||||
| return (ibuf != NULL); | return (ibuf != NULL); | ||||
| } | } | ||||
| bool BKE_image_has_opengl_texture(Image *ima) | bool BKE_image_has_opengl_texture(Image *ima) | ||||
| { | { | ||||
| for (int eye = 0; eye < 2; eye++) { | |||||
| for (int i = 0; i < TEXTARGET_COUNT; i++) { | for (int i = 0; i < TEXTARGET_COUNT; i++) { | ||||
| if (ima->gputexture[i] != NULL) { | if (ima->gputexture[i][eye] != NULL) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| return false; | return false; | ||||
| } | } | ||||
| ImageTile *BKE_image_get_tile(Image *ima, int tile_number) | ImageTile *BKE_image_get_tile(Image *ima, int tile_number) | ||||
| { | { | ||||
| if (ima == NULL) { | if (ima == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,768 Lines • ▼ Show 20 Lines | static void image_free_tile(Image *ima, ImageTile *tile) | ||||
| for (int i = 0; i < TEXTARGET_COUNT; i++) { | for (int i = 0; i < TEXTARGET_COUNT; i++) { | ||||
| /* Only two textures depends on all tiles, so if this is a secondary tile we can keep the other | /* Only two textures depends on all tiles, so if this is a secondary tile we can keep the other | ||||
| * two. */ | * two. */ | ||||
| if (tile != ima->tiles.first && | if (tile != ima->tiles.first && | ||||
| !(ELEM(i, TEXTARGET_TEXTURE_2D_ARRAY, TEXTARGET_TEXTURE_TILE_MAPPING))) { | !(ELEM(i, TEXTARGET_TEXTURE_2D_ARRAY, TEXTARGET_TEXTURE_TILE_MAPPING))) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (ima->gputexture[i] != NULL) { | for (int eye = 0; eye < 2; eye++) { | ||||
| GPU_texture_free(ima->gputexture[i]); | if (ima->gputexture[i][eye] != NULL) { | ||||
| ima->gputexture[i] = NULL; | GPU_texture_free(ima->gputexture[i][eye]); | ||||
| ima->gputexture[i][eye] = NULL; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| if (BKE_image_is_multiview(ima)) { | if (BKE_image_is_multiview(ima)) { | ||||
| const int totviews = BLI_listbase_count(&ima->views); | const int totviews = BLI_listbase_count(&ima->views); | ||||
| for (int i = 0; i < totviews; i++) { | for (int i = 0; i < totviews; i++) { | ||||
| image_remove_ibuf(ima, i, tile->tile_number); | image_remove_ibuf(ima, i, tile->tile_number); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *label) | ||||
| else { | else { | ||||
| BLI_addtail(&ima->tiles, tile); | BLI_addtail(&ima->tiles, tile); | ||||
| } | } | ||||
| if (label) { | if (label) { | ||||
| BLI_strncpy(tile->label, label, sizeof(tile->label)); | BLI_strncpy(tile->label, label, sizeof(tile->label)); | ||||
| } | } | ||||
| for (int eye = 0; eye < 2; eye++) { | |||||
| /* Reallocate GPU tile array. */ | /* Reallocate GPU tile array. */ | ||||
| if (ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY] != NULL) { | if (ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye] != NULL) { | ||||
| GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY]); | GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye]); | ||||
| ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY] = NULL; | ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye] = NULL; | ||||
| } | } | ||||
| if (ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING] != NULL) { | if (ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye] != NULL) { | ||||
| GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING]); | GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye]); | ||||
| ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING] = NULL; | ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye] = NULL; | ||||
| } | |||||
| } | } | ||||
| return tile; | return tile; | ||||
| } | } | ||||
| bool BKE_image_remove_tile(struct Image *ima, ImageTile *tile) | bool BKE_image_remove_tile(struct Image *ima, ImageTile *tile) | ||||
| { | { | ||||
| if (ima == NULL || tile == NULL || ima->source != IMA_SRC_TILED) { | if (ima == NULL || tile == NULL || ima->source != IMA_SRC_TILED) { | ||||
| ▲ Show 20 Lines • Show All 2,204 Lines • Show Last 20 Lines | |||||