Image API: add frame argument to gl_load(), gl_touch()
patch D103 by Krantz Geoffroy
This commit is contained in:
parent
c2508b6e1b
commit
274b2590fb
|
@ -205,16 +205,20 @@ static void rna_Image_scale(Image *image, ReportList *reports, int width, int he
|
|||
}
|
||||
}
|
||||
|
||||
static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int mag)
|
||||
static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int filter, int mag)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
unsigned int *bind = &image->bindcode;
|
||||
int error = GL_NO_ERROR;
|
||||
ImageUser iuser = {NULL};
|
||||
void *lock;
|
||||
|
||||
if (*bind)
|
||||
return error;
|
||||
iuser.framenr = frame;
|
||||
iuser.ok = true;
|
||||
|
||||
ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
|
||||
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
||||
|
||||
if (ibuf == NULL || ibuf->rect == NULL) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
|
||||
|
@ -252,7 +256,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int
|
|||
return error;
|
||||
}
|
||||
|
||||
static int rna_Image_gl_touch(Image *image, ReportList *reports, int filter, int mag)
|
||||
static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame, int filter, int mag)
|
||||
{
|
||||
unsigned int *bind = &image->bindcode;
|
||||
int error = GL_NO_ERROR;
|
||||
|
@ -260,7 +264,7 @@ static int rna_Image_gl_touch(Image *image, ReportList *reports, int filter, int
|
|||
BKE_image_tag_time(image);
|
||||
|
||||
if (*bind == 0)
|
||||
error = rna_Image_gl_load(image, reports, filter, mag);
|
||||
error = rna_Image_gl_load(image, reports, frame, filter, mag);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -319,6 +323,8 @@ void RNA_api_image(StructRNA *srna)
|
|||
func = RNA_def_function(srna, "gl_touch", "rna_Image_gl_touch");
|
||||
RNA_def_function_ui_description(func, "Delay the image from being cleaned from the cache due inactivity");
|
||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||
RNA_def_int(func, "frame", 0, 0, INT_MAX, "Frame",
|
||||
"Frame of image sequence or movie", 0, INT_MAX);
|
||||
RNA_def_int(func, "filter", GL_LINEAR_MIPMAP_NEAREST, -INT_MAX, INT_MAX, "Filter",
|
||||
"The texture minifying function to use if the image wasn't loaded", -INT_MAX, INT_MAX);
|
||||
RNA_def_int(func, "mag", GL_LINEAR, -INT_MAX, INT_MAX, "Magnification",
|
||||
|
@ -330,10 +336,13 @@ void RNA_api_image(StructRNA *srna)
|
|||
func = RNA_def_function(srna, "gl_load", "rna_Image_gl_load");
|
||||
RNA_def_function_ui_description(func, "Load the image into OpenGL graphics memory");
|
||||
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
||||
RNA_def_int(func, "frame", 0, 0, INT_MAX, "Frame",
|
||||
"Frame of image sequence or movie", 0, INT_MAX);
|
||||
RNA_def_int(func, "filter", GL_LINEAR_MIPMAP_NEAREST, -INT_MAX, INT_MAX, "Filter",
|
||||
"The texture minifying function", -INT_MAX, INT_MAX);
|
||||
RNA_def_int(func, "mag", GL_LINEAR, -INT_MAX, INT_MAX, "Magnification",
|
||||
"The texture magnification function", -INT_MAX, INT_MAX);
|
||||
|
||||
/* return value */
|
||||
parm = RNA_def_int(func, "error", 0, -INT_MAX, INT_MAX, "Error", "OpenGL error value", -INT_MAX, INT_MAX);
|
||||
RNA_def_function_return(func, parm);
|
||||
|
|
Loading…
Reference in New Issue