Mercurial > octave-nkf
comparison src/graphics.cc @ 12777:6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
author | Konstantinos Poulios <logari81@gmail.com> |
---|---|
date | Mon, 27 Jun 2011 19:54:21 +0200 |
parents | 5cbf660e649d |
children | e77284b6dac6 |
comparison
equal
deleted
inserted
replaced
12774:ec6c52496485 | 12777:6c1d0f03c331 |
---|---|
3170 cameraupvector.add_constraint (dim_vector (1, 3)); | 3170 cameraupvector.add_constraint (dim_vector (1, 3)); |
3171 currentpoint.add_constraint (dim_vector (2, 3)); | 3171 currentpoint.add_constraint (dim_vector (2, 3)); |
3172 ticklength.add_constraint (dim_vector (1, 2)); | 3172 ticklength.add_constraint (dim_vector (1, 2)); |
3173 tightinset.add_constraint (dim_vector (1, 4)); | 3173 tightinset.add_constraint (dim_vector (1, 4)); |
3174 looseinset.add_constraint (dim_vector (1, 4)); | 3174 looseinset.add_constraint (dim_vector (1, 4)); |
3175 update_font (); | |
3175 | 3176 |
3176 x_zlim.resize (1, 2); | 3177 x_zlim.resize (1, 2); |
3177 | 3178 |
3178 sx = "linear"; | 3179 sx = "linear"; |
3179 sy = "linear"; | 3180 sy = "linear"; |
4797 plotboxaspectratio.set (pba, false); | 4798 plotboxaspectratio.set (pba, false); |
4798 } | 4799 } |
4799 } | 4800 } |
4800 } | 4801 } |
4801 | 4802 |
4803 void | |
4804 axes::properties::update_font (void) | |
4805 { | |
4806 #ifdef HAVE_FREETYPE | |
4807 #ifdef HAVE_FONTCONFIG | |
4808 text_renderer.set_font (get ("fontname").string_value (), | |
4809 get ("fontweight").string_value (), | |
4810 get ("fontangle").string_value (), | |
4811 get ("fontsize").double_value ()); | |
4812 #endif | |
4813 #endif | |
4814 } | |
4815 | |
4802 // The INTERNAL flag defines whether position or outerposition is used. | 4816 // The INTERNAL flag defines whether position or outerposition is used. |
4803 | 4817 |
4804 Matrix | 4818 Matrix |
4805 axes::properties::get_boundingbox (bool internal) const | 4819 axes::properties::get_boundingbox (bool internal) const |
4806 { | 4820 { |
5300 Matrix | 5314 Matrix |
5301 axes::properties::get_ticklabel_extents (const Matrix& ticks, | 5315 axes::properties::get_ticklabel_extents (const Matrix& ticks, |
5302 const string_vector& ticklabels, | 5316 const string_vector& ticklabels, |
5303 const Matrix& limits) | 5317 const Matrix& limits) |
5304 { | 5318 { |
5305 #ifdef HAVE_FREETYPE | 5319 #ifndef HAVE_FREETYPE |
5306 //FIXME: text_renderer could be cached | |
5307 ft_render text_renderer; | |
5308 text_renderer.set_font (get ("fontname").string_value (), | |
5309 get ("fontweight").string_value (), | |
5310 get ("fontangle").string_value (), | |
5311 get ("fontsize").double_value ()); | |
5312 #else | |
5313 double fontsize = get ("fontsize").double_value (); | 5320 double fontsize = get ("fontsize").double_value (); |
5314 #endif | 5321 #endif |
5315 | 5322 |
5316 Matrix ext (1, 2, 0.0); | 5323 Matrix ext (1, 2, 0.0); |
5317 double wmax = 0., hmax = 0.; | 5324 double wmax = 0., hmax = 0.; |
5960 | 5967 |
5961 return convert_text_position (m, *this, "pixels", get_units ()); | 5968 return convert_text_position (m, *this, "pixels", get_units ()); |
5962 } | 5969 } |
5963 | 5970 |
5964 void | 5971 void |
5965 text::properties::update_text_extent (void) | 5972 text::properties::update_font (void) |
5966 { | 5973 { |
5967 #ifdef HAVE_FREETYPE | 5974 #ifdef HAVE_FREETYPE |
5968 | |
5969 // FIXME: font and color should be set only when modified, for efficiency | |
5970 #ifdef HAVE_FONTCONFIG | 5975 #ifdef HAVE_FONTCONFIG |
5971 renderer.set_font (get ("fontname").string_value (), | 5976 renderer.set_font (get ("fontname").string_value (), |
5972 get ("fontweight").string_value (), | 5977 get ("fontweight").string_value (), |
5973 get ("fontangle").string_value (), | 5978 get ("fontangle").string_value (), |
5974 get ("fontsize").double_value ()); | 5979 get ("fontsize").double_value ()); |
5975 #endif | 5980 #endif |
5976 renderer.set_color (get_color_rgb ()); | 5981 renderer.set_color (get_color_rgb ()); |
5977 | 5982 #endif |
5983 } | |
5984 | |
5985 void | |
5986 text::properties::update_text_extent (void) | |
5987 { | |
5988 #ifdef HAVE_FREETYPE | |
5978 int halign = 0, valign = 0; | 5989 int halign = 0, valign = 0; |
5979 | 5990 |
5980 if (horizontalalignment_is ("center")) | 5991 if (horizontalalignment_is ("center")) |
5981 halign = 1; | 5992 halign = 1; |
5982 else if (horizontalalignment_is ("right")) | 5993 else if (horizontalalignment_is ("right")) |