diff options
author | Paul Golter <paulgolter> | 2021-12-01 16:58:16 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-12-01 16:58:49 +0300 |
commit | fd8418385c2e3b0cc9ff8a254c3f3e408d0565f9 (patch) | |
tree | 5317424ec59a470ebba0a2a99a2209fe6d4ee31a /source/blender/makesrna/intern/rna_image_api.c | |
parent | 1ef8ef4941dd84c8968109b5c858ed8d082d9187 (diff) |
Add layer and pass index parameters to rna_Image_gl_load
This patch adds a layer_idx and pass_idx parameter to the rna_Image_gl_load function. It exposes both to the Python API as optional parameters.
This allows python scripters to specifiy which layer and pass they want to load in to an OpenGL texture. Right now image.gl_load() always takes the first layer and first pass.
This is limiting when working with multilayer openEXRs.
With this patch scripters can do something like this:
```
pass_idx = area.spaces.active.image_user.multilayer_pass
layer_idx = area.spaces.active.image_user.multilayer_layer
image.gl_load(frame=0, layer_idx=layer_idx, pass_idx=pass_idx)
```
As the parameters are optional and default to 0, it should not break existing code.
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D13435
Diffstat (limited to 'source/blender/makesrna/intern/rna_image_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_image_api.c | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 4b52ceb6241..7d2697c8770 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -213,11 +213,17 @@ 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) +static int rna_Image_gl_load( + Image *image, ReportList *reports, int frame, int layer_index, int pass_index) { ImageUser iuser; BKE_imageuser_default(&iuser); iuser.framenr = frame; + iuser.layer = layer_index; + iuser.pass = pass_index; + if (image->rr != NULL) { + BKE_image_multilayer_index(image->rr, &iuser); + } GPUTexture *tex = BKE_image_get_gpu_texture(image, &iuser, NULL); @@ -230,14 +236,15 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame) return 0; /* GL_NO_ERROR */ } -static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame) +static int rna_Image_gl_touch( + Image *image, ReportList *reports, int frame, int layer_index, int pass_index) { int error = 0; /* GL_NO_ERROR */ BKE_image_tag_time(image); if (image->gputexture[TEXTARGET_2D][0] == NULL) { - error = rna_Image_gl_load(image, reports, frame); + error = rna_Image_gl_load(image, reports, frame, layer_index, pass_index); } return error; @@ -332,6 +339,24 @@ void RNA_api_image(StructRNA *srna) 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, + "layer_index", + 0, + 0, + INT_MAX, + "Layer", + "Index of layer that should be loaded", + 0, + INT_MAX); + RNA_def_int(func, + "pass_index", + 0, + 0, + INT_MAX, + "Pass", + "Index of pass that should be loaded", + 0, + INT_MAX); /* return value */ parm = RNA_def_int( func, "error", 0, -INT_MAX, INT_MAX, "Error", "OpenGL error value", -INT_MAX, INT_MAX); @@ -346,6 +371,24 @@ void RNA_api_image(StructRNA *srna) 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, + "layer_index", + 0, + 0, + INT_MAX, + "Layer", + "Index of layer that should be loaded", + 0, + INT_MAX); + RNA_def_int(func, + "pass_index", + 0, + 0, + INT_MAX, + "Pass", + "Index of pass that should be loaded", + 0, + INT_MAX); /* return value */ parm = RNA_def_int( func, "error", 0, -INT_MAX, INT_MAX, "Error", "OpenGL error value", -INT_MAX, INT_MAX); |