Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2020-01-29 22:25:35 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-01-29 22:29:20 +0300
commit3984586292855bb6710facf5845b44f5d11dcc6f (patch)
treec649e5d521ad4f9012276fcf0175f4e75db22bb7 /source/blender/gpu
parent35c6d68d35699fe088537074ebaa5034c8e6321e (diff)
parente4faed120d9c294ea5d6061b3213ed4f6784db52 (diff)
Merge branch 'blender-v2.82-release'
Merge conflict in source/blender/gpu/GPU_texture.h
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_texture.h7
-rw-r--r--source/blender/gpu/intern/gpu_draw.c28
2 files changed, 25 insertions, 10 deletions
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 19c7386ad6d..bb6af227369 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -36,6 +36,7 @@ struct ImageUser;
struct MovieClip;
struct MovieClipUser;
struct PreviewImage;
+struct ImBuf;
struct GPUFrameBuffer;
typedef struct GPUTexture GPUTexture;
@@ -187,7 +188,11 @@ GPUTexture *GPU_texture_create_from_vertbuf(struct GPUVertBuf *vert);
GPUTexture *GPU_texture_create_buffer(eGPUTextureFormat data_type, const uint buffer);
GPUTexture *GPU_texture_from_bindcode(int textarget, int bindcode);
-GPUTexture *GPU_texture_from_blender(struct Image *ima, struct ImageUser *iuser, int textarget);
+GPUTexture *GPU_texture_from_blender(struct Image *ima,
+ struct ImageUser *iuser,
+ struct ImBuf *ibuf,
+ int textarget);
+GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap);
/* movie clip drawing */
GPUTexture *GPU_texture_from_movieclip(struct MovieClip *clip,
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index d2008680098..cfeb7f6bedb 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -851,7 +851,11 @@ static void gpu_texture_update_from_ibuf(
GPU_texture_unbind(tex);
}
-GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget)
+/* Get the GPUTexture for a given `Image`.
+ *
+ * `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) {
return NULL;
@@ -882,27 +886,33 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget
}
/* check if we have a valid image buffer */
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
- if (ibuf == NULL) {
- *tex = GPU_texture_from_bindcode(textarget, bindcode);
- return *tex;
+ ImBuf *ibuf_intern = ibuf;
+ if (ibuf_intern == NULL) {
+ ibuf_intern = BKE_image_acquire_ibuf(ima, iuser, NULL);
+ if (ibuf_intern == NULL) {
+ *tex = GPU_texture_from_bindcode(textarget, bindcode);
+ return *tex;
+ }
}
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) {
bindcode = gpu_texture_create_tile_mapping(ima);
}
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);
- GPU_texture_orig_size_set(*tex, ibuf->x, ibuf->y);
+ GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
return *tex;
}