diff options
author | Richard Antalik <richardantalik@gmail.com> | 2019-02-23 17:14:44 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2019-02-23 17:14:44 +0300 |
commit | 6bcdcc96c2548e0ee5e18acc37915aedee6329e0 (patch) | |
tree | 92fb7e5870dd89a9a0db6f5373d7ca2d1d38a185 /source/blender/editors/space_sequencer/sequencer_view.c | |
parent | 6eb59c57782724cdcbc1564356f2c2e2619c01ec (diff) |
Glyph cache is cleared by UI_view2d_zoom_cache_reset, when zooming V2D, but is required to calculate text height in UI_view2d_text_cache_draw
This caused text in strips to "jump around"
There was a comment in UI_view2d_zoom_cache_reset:
While scaling we can accumulate fonts at many sizes (~20 or so).
Not an issue with embedded font, but can use over 500Mb with i18n ones! See [#38244].
Reviewed by: Brecht
Differential revision: https://developer.blender.org/D4389
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_view.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_view.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index d500a9a081d..962b02aaeb2 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -90,7 +90,6 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) ARegion *ar = CTX_wm_region(C); ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, CFRA, 0, NULL); ImageSampleInfo *info = op->customdata; - float fx, fy; if (ibuf == NULL) { IMB_freeImBuf(ibuf); @@ -98,18 +97,33 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) return; } + short scene_scale_size = sseq->render_size ? 100 : scene->r.size; + float rectx = (float) scene->r.xsch * ((float) scene_scale_size / 100.0f); + float recty = (float) scene->r.ysch * ((float) scene_scale_size / 100.0f); + float scale_x = (float) ibuf->x / rectx; + float scale_y = (float) ibuf->y / recty; + float fx, fy; + + /* max coords are +/- (rect* / 2) + */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); - fx += (float) ibuf->x / 2.0f; - fy += (float) ibuf->y / 2.0f; + fx += rectx / 2.0f; + fy += recty / 2.0f; + + /* to get ibuf coords we have to scale by (ibuf->* / rect*) + */ + fx *= scale_x; + fy *= scale_y; if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) { const float *fp; unsigned char *cp; int x = (int) fx, y = (int) fy; - info->x = x; - info->y = y; + /* we will report mouse position on unscaled image */ + info->x = 1 + x / scale_x; + info->y = 1 + y / scale_y; info->draw = 1; info->channels = ibuf->channels; |