From f663a1dc09af4eed4846f861017db59456469ff8 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 14 Feb 2022 09:18:10 +0100 Subject: Image Engine: Remove region_uv_bounds. They have been replaced by clipping_uv_bounds. Using region_uv_bounds could lead to problems when drawing the compositor backdrop. --- .../draw/engines/image/image_drawing_mode.hh | 52 +++++++++------------- .../draw/engines/image/image_texture_info.hh | 2 - 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh b/source/blender/draw/engines/image/image_drawing_mode.hh index b56f3062901..0aaf0ca9f24 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.hh +++ b/source/blender/draw/engines/image/image_drawing_mode.hh @@ -62,20 +62,6 @@ struct OneTextureMethod { } } - void update_region_uv_bounds(const ARegion *region) - { - TextureInfo &info = instance_data->texture_infos[0]; - if (!BLI_rctf_compare(&info.region_uv_bounds, ®ion->v2d.cur, EPSILON_UV_BOUNDS)) { - info.region_uv_bounds = region->v2d.cur; - info.dirty = true; - } - - /* Mark the other textures as invalid. */ - for (int i = 1; i < SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN; i++) { - BLI_rctf_init_minmax(&instance_data->texture_infos[i].clipping_bounds); - } - } - void update_screen_uv_bounds() { for (int i = 0; i < SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN; i++) { @@ -92,7 +78,13 @@ struct OneTextureMethod { float4x4 mat_inv = mat.inverted(); float3 min_uv = mat_inv * float3(0.0f, 0.0f, 0.0f); float3 max_uv = mat_inv * float3(1.0f, 1.0f, 0.0f); - BLI_rctf_init(&info.clipping_uv_bounds, min_uv[0], max_uv[0], min_uv[1], max_uv[1]); + rctf new_clipping_bounds; + BLI_rctf_init(&new_clipping_bounds, min_uv[0], max_uv[0], min_uv[1], max_uv[1]); + + if (!BLI_rctf_compare(&info.clipping_uv_bounds, &new_clipping_bounds, EPSILON_UV_BOUNDS)) { + info.clipping_uv_bounds = new_clipping_bounds; + info.dirty = true; + } } }; @@ -268,7 +260,7 @@ template class ScreenSpaceDrawingMode : public AbstractD static_cast(iterator.tile_data.tile_buffer->y) + tile_offset_y); rctf changed_overlapping_region_in_uv_space; - const bool region_overlap = BLI_rctf_isect(&info.region_uv_bounds, + const bool region_overlap = BLI_rctf_isect(&info.clipping_uv_bounds, &changed_region_in_uv_space, &changed_overlapping_region_in_uv_space); if (!region_overlap) { @@ -280,14 +272,14 @@ template class ScreenSpaceDrawingMode : public AbstractD rcti gpu_texture_region_to_update; BLI_rcti_init( &gpu_texture_region_to_update, - floor((changed_overlapping_region_in_uv_space.xmin - info.region_uv_bounds.xmin) * - texture_width / BLI_rctf_size_x(&info.region_uv_bounds)), - floor((changed_overlapping_region_in_uv_space.xmax - info.region_uv_bounds.xmin) * - texture_width / BLI_rctf_size_x(&info.region_uv_bounds)), - ceil((changed_overlapping_region_in_uv_space.ymin - info.region_uv_bounds.ymin) * - texture_height / BLI_rctf_size_y(&info.region_uv_bounds)), - ceil((changed_overlapping_region_in_uv_space.ymax - info.region_uv_bounds.ymin) * - texture_height / BLI_rctf_size_y(&info.region_uv_bounds))); + floor((changed_overlapping_region_in_uv_space.xmin - info.clipping_uv_bounds.xmin) * + texture_width / BLI_rctf_size_x(&info.clipping_uv_bounds)), + floor((changed_overlapping_region_in_uv_space.xmax - info.clipping_uv_bounds.xmin) * + texture_width / BLI_rctf_size_x(&info.clipping_uv_bounds)), + ceil((changed_overlapping_region_in_uv_space.ymin - info.clipping_uv_bounds.ymin) * + texture_height / BLI_rctf_size_y(&info.clipping_uv_bounds)), + ceil((changed_overlapping_region_in_uv_space.ymax - info.clipping_uv_bounds.ymin) * + texture_height / BLI_rctf_size_y(&info.clipping_uv_bounds))); rcti tile_region_to_extract; BLI_rcti_init( @@ -311,13 +303,13 @@ template class ScreenSpaceDrawingMode : public AbstractD for (int y = gpu_texture_region_to_update.ymin; y < gpu_texture_region_to_update.ymax; y++) { float yf = y / (float)texture_height; - float v = info.region_uv_bounds.ymax * yf + info.region_uv_bounds.ymin * (1.0 - yf) - + float v = info.clipping_uv_bounds.ymax * yf + info.clipping_uv_bounds.ymin * (1.0 - yf) - tile_offset_y; for (int x = gpu_texture_region_to_update.xmin; x < gpu_texture_region_to_update.xmax; x++) { float xf = x / (float)texture_width; - float u = info.region_uv_bounds.xmax * xf + info.region_uv_bounds.xmin * (1.0 - xf) - - tile_offset_x; + float u = info.clipping_uv_bounds.xmax * xf + + info.clipping_uv_bounds.xmin * (1.0 - xf) - tile_offset_x; nearest_interpolation_color(tile_buffer, nullptr, &extracted_buffer.rect_float[offset * 4], @@ -360,7 +352,6 @@ template class ScreenSpaceDrawingMode : public AbstractD IMAGE_InstanceData &instance_data, const ImageUser *image_user) const { - ImBuf texture_buffer; const int texture_width = GPU_texture_width(info.texture); const int texture_height = GPU_texture_height(info.texture); @@ -429,9 +420,9 @@ template class ScreenSpaceDrawingMode : public AbstractD 1.0f}; rescale_m4(uv_to_texel, scale); uv_to_texel[3][0] += image_tile.get_tile_x_offset() / - BLI_rctf_size_x(&texture_info.region_uv_bounds); + BLI_rctf_size_x(&texture_info.clipping_uv_bounds); uv_to_texel[3][1] += image_tile.get_tile_y_offset() / - BLI_rctf_size_y(&texture_info.region_uv_bounds); + BLI_rctf_size_y(&texture_info.clipping_uv_bounds); uv_to_texel[3][0] *= texture_width; uv_to_texel[3][1] *= texture_height; invert_m4(uv_to_texel); @@ -481,7 +472,6 @@ template class ScreenSpaceDrawingMode : public AbstractD // screen space textures that aren't needed. const ARegion *region = draw_ctx->region; method.update_screen_space_bounds(region); - method.update_region_uv_bounds(region); method.update_screen_uv_bounds(); // Step: Update the GPU textures based on the changes in the image. diff --git a/source/blender/draw/engines/image/image_texture_info.hh b/source/blender/draw/engines/image/image_texture_info.hh index 5cf9016a8c8..2caacb6f2f9 100644 --- a/source/blender/draw/engines/image/image_texture_info.hh +++ b/source/blender/draw/engines/image/image_texture_info.hh @@ -44,8 +44,6 @@ struct TextureInfo { /** \brief area of the texture in screen space. */ rctf clipping_bounds; - /** \brief uv area of the texture (copy from ARegion). */ - rctf region_uv_bounds; /** \brief uv area of the texture in screen space. */ rctf clipping_uv_bounds; -- cgit v1.2.3