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
path: root/source
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2022-03-01 11:32:58 +0300
committerJeroen Bakker <jeroen@blender.org>2022-03-01 11:32:58 +0300
commit4a4701b43c53d1a4946e224821ba398548b22043 (patch)
tree5367f45f7f7cf8cfe14a2c00839ba590e960f9f1 /source
parent34f6a9943333f4b6c9727efb5db7bca1ffc7c531 (diff)
Fix painting on none 256 aligned images.
Internally the update tiles are 256x256. Due to some miscalculations tiles were not generated correctly if the dimension of the image wasn't a multifold of 256.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/image_partial_update.cc4
-rw-r--r--source/blender/draw/engines/image/image_drawing_mode.hh16
2 files changed, 17 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/image_partial_update.cc b/source/blender/blenkernel/intern/image_partial_update.cc
index 7e187c2014e..bec3c193af5 100644
--- a/source/blender/blenkernel/intern/image_partial_update.cc
+++ b/source/blender/blenkernel/intern/image_partial_update.cc
@@ -213,8 +213,8 @@ struct TileChangeset {
tile_width = image_buffer->x;
tile_height = image_buffer->y;
- int chunk_x_len = tile_width / CHUNK_SIZE;
- int chunk_y_len = tile_height / CHUNK_SIZE;
+ int chunk_x_len = (tile_width + CHUNK_SIZE - 1) / CHUNK_SIZE;
+ int chunk_y_len = (tile_height + CHUNK_SIZE - 1) / CHUNK_SIZE;
init_chunks(chunk_x_len, chunk_y_len);
return true;
}
diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh b/source/blender/draw/engines/image/image_drawing_mode.hh
index 4564ef87025..267b0477a29 100644
--- a/source/blender/draw/engines/image/image_drawing_mode.hh
+++ b/source/blender/draw/engines/image/image_drawing_mode.hh
@@ -229,7 +229,21 @@ template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractD
BLI_assert(float_buffer->rect == nullptr);
BLI_assert(src->rect_float == nullptr);
BLI_assert(src->rect != nullptr);
- IMB_float_from_rect_ex(float_buffer, src, &iterator.changed_region.region);
+
+ /* Calculate the overlap between the updated region and the buffer size. Partial Update Checker
+ * always returns a tile (256x256). Which could lay partially outside the buffer when using
+ * different resolutions.
+ */
+ rcti buffer_rect;
+ BLI_rcti_init(&buffer_rect, 0, float_buffer->x, 0, float_buffer->y);
+ rcti clipped_update_region;
+ const bool has_overlap = BLI_rcti_isect(
+ &buffer_rect, &iterator.changed_region.region, &clipped_update_region);
+ if (!has_overlap) {
+ return;
+ }
+
+ IMB_float_from_rect_ex(float_buffer, src, &clipped_update_region);
}
void do_partial_update(PartialUpdateChecker<ImageTileData>::CollectResult &iterator,