Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_draw.c
| Show First 20 Lines • Show All 845 Lines • ▼ Show 20 Lines | static void gpu_texture_update_from_ibuf( | ||||
| } | } | ||||
| else { | else { | ||||
| ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE; | ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE; | ||||
| } | } | ||||
| GPU_texture_unbind(tex); | GPU_texture_unbind(tex); | ||||
| } | } | ||||
| GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget) | /* Get the GPUTexture for a given `Image`. | ||||
jbakker: add comment that this function is similar to `GPU_texture_from_blender`. | |||||
| * | |||||
| * `iuser` and `ibuf` are mutual exclusive parameters. The caller can pass the `ibuf` when already | |||||
| * available. It is also required when requesting the GPUTexture for a render result. */ | |||||
| GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf, int textarget) | |||||
| { | { | ||||
| if (ima == NULL) { | if (ima == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* currently, gpu refresh tagging is used by ima sequences */ | /* currently, gpu refresh tagging is used by ima sequences */ | ||||
| if (ima->gpuflag & IMA_GPU_REFRESH) { | if (ima->gpuflag & IMA_GPU_REFRESH) { | ||||
| gpu_free_image_immediate(ima); | gpu_free_image_immediate(ima); | ||||
| Show All 14 Lines | GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf, int textarget) | ||||
| uint bindcode = 0; | uint bindcode = 0; | ||||
| ImageTile *tile = BKE_image_get_tile(ima, 0); | ImageTile *tile = BKE_image_get_tile(ima, 0); | ||||
| if (tile->ok == 0) { | if (tile->ok == 0) { | ||||
| *tex = GPU_texture_from_bindcode(textarget, bindcode); | *tex = GPU_texture_from_bindcode(textarget, bindcode); | ||||
| return *tex; | return *tex; | ||||
| } | } | ||||
| /* check if we have a valid image buffer */ | /* check if we have a valid image buffer */ | ||||
| ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); | ImBuf *ibuf_intern = ibuf; | ||||
| if (ibuf == NULL) { | if (ibuf_intern == NULL) { | ||||
| ibuf_intern = BKE_image_acquire_ibuf(ima, iuser, NULL); | |||||
| if (ibuf_intern == NULL) { | |||||
| *tex = GPU_texture_from_bindcode(textarget, bindcode); | *tex = GPU_texture_from_bindcode(textarget, bindcode); | ||||
| return *tex; | return *tex; | ||||
| } | } | ||||
| } | |||||
| if (textarget == GL_TEXTURE_2D_ARRAY) { | if (textarget == GL_TEXTURE_2D_ARRAY) { | ||||
| bindcode = gpu_texture_create_tile_array(ima, ibuf); | bindcode = gpu_texture_create_tile_array(ima, ibuf_intern); | ||||
| } | } | ||||
| else if (textarget == GL_TEXTURE_1D_ARRAY) { | else if (textarget == GL_TEXTURE_1D_ARRAY) { | ||||
| bindcode = gpu_texture_create_tile_mapping(ima); | bindcode = gpu_texture_create_tile_mapping(ima); | ||||
| } | } | ||||
| else { | else { | ||||
| bindcode = gpu_texture_create_from_ibuf(ima, ibuf, textarget); | bindcode = gpu_texture_create_from_ibuf(ima, ibuf_intern, textarget); | ||||
| } | } | ||||
| BKE_image_release_ibuf(ima, ibuf, NULL); | /* if `ibuf` was given, we don't own the `ibuf_intern` */ | ||||
| if (ibuf == NULL) { | |||||
| BKE_image_release_ibuf(ima, ibuf_intern, NULL); | |||||
| } | |||||
| *tex = GPU_texture_from_bindcode(textarget, bindcode); | *tex = GPU_texture_from_bindcode(textarget, bindcode); | ||||
| GPU_texture_orig_size_set(*tex, ibuf->x, ibuf->y); | GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y); | ||||
| return *tex; | return *tex; | ||||
| } | } | ||||
| GPUTexture *GPU_texture_from_movieclip(MovieClip *clip, MovieClipUser *cuser, int textarget) | GPUTexture *GPU_texture_from_movieclip(MovieClip *clip, MovieClipUser *cuser, int textarget) | ||||
| { | { | ||||
| if (clip == NULL) { | if (clip == NULL) { | ||||
| return NULL; | return NULL; | ||||
| ▲ Show 20 Lines • Show All 769 Lines • Show Last 20 Lines | |||||
add comment that this function is similar to GPU_texture_from_blender.