diff options
author | wm4 <wm4@nowhere> | 2015-03-18 12:33:14 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-18 13:15:20 +0100 |
commit | 51befc9debef818cbf071aebf8861457ac095f8d (patch) | |
tree | 140152a3b5db9655c5b869d83a7d0c6212c91a6a /video/out/vo_sdl.c | |
parent | 15478ca31c48d46b576264299803ab43fdeb1d04 (diff) | |
download | mpv-51befc9debef818cbf071aebf8861457ac095f8d.tar.bz2 mpv-51befc9debef818cbf071aebf8861457ac095f8d.tar.xz |
osd: simplify an aspect of change detection handling
There was a somewhat obscure optimization in the OSD and subtitle
rendering path: if only the position of the sub-images changed, and not
the actual image data, uploading of the image data could be skipped. In
theory, this could speed up things like scrolling subtitles.
But it turns out that even in the rare cases subtitles have such scrolls
or axis-aligned movement, modern libass rarely signals this kind of
change. Possibly this is because of sub-pixel handling and such, which
break this.
As such, it's a worthless optimization and just introduces additional
complexity and subtle bugs (especially in cases libass does the
opposite: incorrectly signaling a position change only, which happened
before). Remove this optimization, and rename bitmap_pos_id to
change_id.
Diffstat (limited to 'video/out/vo_sdl.c')
-rw-r--r-- | video/out/vo_sdl.c | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 8bde820b38..c2cc711d2f 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -177,8 +177,7 @@ struct priv { struct mp_osd_res osd_res; struct formatmap_entry osd_format; struct osd_bitmap_surface { - int bitmap_id; - int bitmap_pos_id; + int change_id; struct osd_target { SDL_Rect source; SDL_Rect dest; @@ -702,7 +701,7 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs) if (imgs->format == SUBBITMAP_EMPTY || imgs->num_parts == 0) return; - if (imgs->bitmap_pos_id == sfc->bitmap_pos_id) + if (imgs->change_id == sfc->change_id) return; if (imgs->num_parts > sfc->targets_size) { @@ -725,49 +724,46 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs) bmp->x, bmp->y, bmp->dw, bmp->dh }; - if (imgs->bitmap_id != sfc->bitmap_id || !target->tex) { - // tex: alpha blended texture - if (target->tex) { - SDL_DestroyTexture(target->tex); - target->tex = NULL; - } - if (!target->tex) - target->tex = SDL_CreateTexture(vc->renderer, - vc->osd_format.sdl, SDL_TEXTUREACCESS_STREAMING, - bmp->w, bmp->h); - if (!target->tex) { - MP_ERR(vo, "Could not create texture\n"); - } - if (target->tex) { - SDL_SetTextureBlendMode(target->tex, - SDL_BLENDMODE_BLEND); - SDL_SetTextureColorMod(target->tex, 0, 0, 0); - subbitmap_to_texture(vo, target->tex, bmp, 0); // RGBA -> 000A - } + // tex: alpha blended texture + if (target->tex) { + SDL_DestroyTexture(target->tex); + target->tex = NULL; + } + if (!target->tex) + target->tex = SDL_CreateTexture(vc->renderer, + vc->osd_format.sdl, SDL_TEXTUREACCESS_STREAMING, + bmp->w, bmp->h); + if (!target->tex) { + MP_ERR(vo, "Could not create texture\n"); + } + if (target->tex) { + SDL_SetTextureBlendMode(target->tex, + SDL_BLENDMODE_BLEND); + SDL_SetTextureColorMod(target->tex, 0, 0, 0); + subbitmap_to_texture(vo, target->tex, bmp, 0); // RGBA -> 000A + } - // tex2: added texture - if (target->tex2) { - SDL_DestroyTexture(target->tex2); - target->tex2 = NULL; - } - if (!target->tex2) - target->tex2 = SDL_CreateTexture(vc->renderer, - vc->osd_format.sdl, SDL_TEXTUREACCESS_STREAMING, - bmp->w, bmp->h); - if (!target->tex2) { - MP_ERR(vo, "Could not create texture\n"); - } - if (target->tex2) { - SDL_SetTextureBlendMode(target->tex2, - SDL_BLENDMODE_ADD); - subbitmap_to_texture(vo, target->tex2, bmp, - 0xFF000000); // RGBA -> RGB1 - } + // tex2: added texture + if (target->tex2) { + SDL_DestroyTexture(target->tex2); + target->tex2 = NULL; + } + if (!target->tex2) + target->tex2 = SDL_CreateTexture(vc->renderer, + vc->osd_format.sdl, SDL_TEXTUREACCESS_STREAMING, + bmp->w, bmp->h); + if (!target->tex2) { + MP_ERR(vo, "Could not create texture\n"); + } + if (target->tex2) { + SDL_SetTextureBlendMode(target->tex2, + SDL_BLENDMODE_ADD); + subbitmap_to_texture(vo, target->tex2, bmp, + 0xFF000000); // RGBA -> RGB1 } } - sfc->bitmap_id = imgs->bitmap_id; - sfc->bitmap_pos_id = imgs->bitmap_pos_id; + sfc->change_id = imgs->change_id; } static void draw_osd_part(struct vo *vo, int index) |