changeset 23028:57f56d8e182e

Add shift_[xy] (vector that is added to the glyph before transformation) to bitmap glyph key. Result of rotation depends on them because of perspective transformation. They are only set when some rotation take place.
author eugeni
date Fri, 20 Apr 2007 23:19:23 +0000
parents b4db05aea29e
children edb61a7aa38a
files libass/ass_cache.h libass/ass_render.c
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_cache.h	Fri Apr 20 23:16:29 2007 +0000
+++ b/libass/ass_cache.h	Fri Apr 20 23:19:23 2007 +0000
@@ -39,6 +39,9 @@
 
 	unsigned scale_x, scale_y; // 16.16
 	int frx, fry, frz; // signed 16.16
+	int shift_x, shift_y; // shift vector that was added to glyph before applying rotation
+	                      // = 0, if frx = fry = frx = 0
+	                      // = (glyph base point) - (rotation origin), otherwise
 	
 	FT_Vector advance; // subpixel shift vector
 } bitmap_hash_key_t;
--- a/libass/ass_render.c	Fri Apr 20 23:16:29 2007 +0000
+++ b/libass/ass_render.c	Fri Apr 20 23:19:23 2007 +0000
@@ -1926,9 +1926,6 @@
 		render_context.clip_y1 = y2scr(render_context.clip_y1);
 	}
 
-	for (i = 0; i < text_info.length; ++i)
-		get_bitmap_glyph(text_info.glyphs + i);
-
 	// rotate glyphs if needed
 	{
 		FT_Vector center;
@@ -1949,6 +1946,15 @@
 			FT_Vector shift;
 			glyph_info_t* info = text_info.glyphs + i;
 
+			if (info->hash_key.frx || info->hash_key.fry || info->hash_key.frz) {
+				info->hash_key.shift_x = info->pos.x + device_x - center.x;
+				info->hash_key.shift_y = - (info->pos.y + device_y - center.y);
+			} else {
+				info->hash_key.shift_x = 0;
+				info->hash_key.shift_y = 0;
+			}
+			get_bitmap_glyph(info);
+
 			if (info->bm == 0) {
 				// calculating shift vector
 				shift.x = int_to_d6(info->pos.x + device_x - center.x);