Files
test/source
Richard Antalik 2f10db2377 VSE: Draw more correct text boundbox
Text strip along with other effect strips draws into buffer, which is
defined by common render size. However this makes selection, snapping
and other features not work correctly from user perspective.

There are 2 ways to remedy this:
 - Draw text into buffer which size is defined by text boundbox
 - Just draw the correct size boundbox and make UI use it correctly

This PR implements second option, as there are multiple difficulties
asociated with first option. Main problem is, that one would need to
calculate boundboxes for all individual text effects(blur, shadow, ...),
but many of these effects need to know the size of buffer we are trying
to calculate.

Big question here was: What the boundox should look like?
For selection it is best, if it encapsulates the text itself along with its
effects like shadow, blur or box. However for snapping and pivot range
it seems, that encapsulating only the text without any effects applied is
the best solution. This was discussed with UI module and we agreed,
that encapsulating only the text would provide better usability.

The implementation:
Most of the features are on "preview side", where all dimensions are
related to scene render size. Temporary `TextVarsRuntime` is created to
calculate apparent text strip image size. This allows boundbox of
correct size to be drawn.

However to draw boundbox and do transformations correctly, it is
necessary to remap origin point to the subset of image defined by the
boundbox. Since recalculated origin is relative, this function is used
for image transformation during rendering as well.

Main drawback of this method is, that boundbox and origin point
calculation may be needed from multiple places, and `TextVarsRuntime`
may be recalculated about 10x on redraw. `text_effect_calc_runtime`
function can be executed from ~5us for single character to 0.5ms with
512 characters with default font(not sure if that matters).

Drawing origin only during transformation would help with general UI
responsiveness. During playback, these overlays are not drawn, so
there should be no change in performance.

Pull Request: https://projects.blender.org/blender/blender/pulls/140420
2025-06-20 20:06:11 +02:00
..