Fix T85895: Viewing value passes in Image Editor displays the value as alpha

There was a similar report prior to the introduction of the Image
Engine, see T74586.
This was fixed by rB6a5bd812b569 at that time, but got lost in the
refactor it seems.

Above commit introduced the `ED_space_image_get_display_channel_mask`
function that will determine
the valid bitflags for the display channel of a given ImBuf.

But since the refactor, this is not called anymore (`draw_image_main` is
not called anymore)
Now it seems we can safely reuse that said function
`ED_space_image_get_display_channel_mask` also for the Image Engine.

Maniphest Tasks: T85895

Differential Revision: https://developer.blender.org/D10510
This commit is contained in:
2021-02-23 11:43:06 +01:00
parent 64c35769f9
commit b123aadeee

View File

@@ -113,7 +113,8 @@ static void space_image_gpu_texture_get(Image *image,
BKE_image_multiview_index(image, &sima->iuser);
if (ibuf) {
if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) {
const int sima_flag = sima->flag & ED_space_image_get_display_channel_mask(ibuf);
if (sima_flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) {
if (ibuf->zbuf) {
BLI_assert(!"Integer based depth buffers not supported");
}
@@ -204,30 +205,31 @@ static void image_cache_image(IMAGE_Data *vedata, Image *image, ImageUser *iuser
int draw_flags = 0;
if (space_type == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
const int sima_flag = sima->flag & ED_space_image_get_display_channel_mask(ibuf);
const bool do_repeat = (!is_tiled_texture) && ((sima->flag & SI_DRAW_TILE) != 0);
SET_FLAG_FROM_TEST(draw_flags, do_repeat, IMAGE_DRAW_FLAG_DO_REPEAT);
SET_FLAG_FROM_TEST(draw_flags, is_tiled_texture, IMAGE_DRAW_FLAG_USE_WORLD_POS);
if ((sima->flag & SI_USE_ALPHA) != 0) {
if ((sima_flag & SI_USE_ALPHA) != 0) {
/* Show RGBA */
draw_flags |= IMAGE_DRAW_FLAG_SHOW_ALPHA | IMAGE_DRAW_FLAG_APPLY_ALPHA;
}
else if ((sima->flag & SI_SHOW_ALPHA) != 0) {
else if ((sima_flag & SI_SHOW_ALPHA) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_SHUFFLING;
copy_v4_fl4(shuffle, 0.0f, 0.0f, 0.0f, 1.0f);
}
else if ((sima->flag & SI_SHOW_ZBUF) != 0) {
else if ((sima_flag & SI_SHOW_ZBUF) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_DEPTH | IMAGE_DRAW_FLAG_SHUFFLING;
copy_v4_fl4(shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
}
else if ((sima->flag & SI_SHOW_R) != 0) {
else if ((sima_flag & SI_SHOW_R) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
copy_v4_fl4(shuffle, 1.0f, 0.0f, 0.0f, 0.0f);
}
else if ((sima->flag & SI_SHOW_G) != 0) {
else if ((sima_flag & SI_SHOW_G) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
copy_v4_fl4(shuffle, 0.0f, 1.0f, 0.0f, 0.0f);
}
else if ((sima->flag & SI_SHOW_B) != 0) {
else if ((sima_flag & SI_SHOW_B) != 0) {
draw_flags |= IMAGE_DRAW_FLAG_APPLY_ALPHA | IMAGE_DRAW_FLAG_SHUFFLING;
copy_v4_fl4(shuffle, 0.0f, 0.0f, 1.0f, 0.0f);
}