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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_image_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index cb8fa6c6c85..d839995d15e 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -56,9 +56,6 @@
#include "IMB_imbuf.h"
#include "IMB_colormanagement.h"
-#include "GPU_draw.h"
-#include "GPU_debug.h"
-
#include "DNA_image_types.h"
#include "DNA_scene_types.h"
@@ -223,54 +220,58 @@ static void rna_Image_scale(Image *image, ReportList *reports, int width, int he
static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int filter, int mag)
{
- ImBuf *ibuf;
- unsigned int *bind = &image->bindcode[TEXTARGET_TEXTURE_2D];
+ GPUTexture *tex = image->gputexture[TEXTARGET_TEXTURE_2D];
int error = GL_NO_ERROR;
- ImageUser iuser = {NULL};
- void *lock;
- if (*bind)
+ if (tex)
return error;
+
+ ImageUser iuser = {NULL};
iuser.framenr = frame;
iuser.ok = true;
- ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
+ void *lock;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
/* clean glError buffer */
while (glGetError() != GL_NO_ERROR) {}
if (ibuf == NULL || ibuf->rect == NULL) {
BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
- BKE_image_release_ibuf(image, ibuf, NULL);
+ BKE_image_release_ibuf(image, ibuf, lock);
return (int)GL_INVALID_OPERATION;
}
- GPU_create_gl_tex(bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D,
+ unsigned int bindcode = 0;
+ GPU_create_gl_tex(&bindcode, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D,
(filter != GL_NEAREST && filter != GL_LINEAR), false, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)mag);
+ /* TODO(merwin): validate input (dimensions, filter, mag) before calling OpenGL
+ * instead of trusting input & testing for error after */
error = glGetError();
if (error) {
- glDeleteTextures(1, (GLuint *)bind);
- image->bindcode[TEXTARGET_TEXTURE_2D] = 0;
+ glDeleteTextures(1, (GLuint *)&bindcode);
+ }
+ else {
+ image->gputexture[TEXTARGET_TEXTURE_2D] = GPU_texture_from_bindcode(GL_TEXTURE_2D, bindcode);
}
- BKE_image_release_ibuf(image, ibuf, NULL);
+ BKE_image_release_ibuf(image, ibuf, lock);
return error;
}
static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame, int filter, int mag)
{
- unsigned int *bind = &image->bindcode[TEXTARGET_TEXTURE_2D];
int error = GL_NO_ERROR;
BKE_image_tag_time(image);
- if (*bind == 0)
+ if (image->gputexture[TEXTARGET_TEXTURE_2D] == NULL)
error = rna_Image_gl_load(image, reports, frame, filter, mag);
return error;