lyx_mirror/src/mathed/MathSupport.h
Guillaume Munch b2b8733096 Remove a conversion to_utf8() inside FontSetChanger
This requires to change many docstrings into std::strings. The logic behind that
is that they represent a fixed set of math fonts, and therefore “string” means
here “poor man's enum” rather than text (this is consistent with MetricsBase).

Profiling of scrolling inside a document over macro-instensive areas:

Before the patch:
  44,1% BufferView::updateMetrics()
   -> 34,8% InsetMathHull::metrics()
     -> 9,8% FontSetChanger::FontSetChanger()
  28,4% BufferView::draw()

After the patch:
  35,3% BufferView::updateMetrics()
   -> 27,2% InsetMathHull::metrics
     -> 0,4% FontSetChanger::FontSetChanger()
  47,5% BufferView::draw()

FontSetChanger::FontSetChanger() is made 41x less expensive (with reference
BV::draw()) just by removing this conversion. The remaining 0,4% could be
squished by replacing the strings with a proper enum, but this is premature. Of
course, this only treats the symptoms: there is no good reason that this
function is called 45500 times over the time of 40 repaints.
2016-06-13 08:46:15 +01:00

79 lines
1.9 KiB
C++

// -*- C++ -*-
/**
* \file MathSupport.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Alejandro Aguilar Sierra
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef MATH_SUPPORT_H
#define MATH_SUPPORT_H
#include "MathParser_flags.h"
#include "support/strfwd.h"
namespace lyx {
class MetricsInfo;
class PainterInfo;
class FontInfo;
class Dimension;
class MathData;
class MathAtom;
class InsetMath;
int mathed_font_em(FontInfo const &);
int mathed_thinmuskip(FontInfo font);
int mathed_medmuskip(FontInfo font);
int mathed_thickmuskip(FontInfo font);
int mathed_char_width(FontInfo const &, char_type c);
int mathed_char_kerning(FontInfo const &, char_type c);
void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
docstring const & name);
void mathed_string_dim(FontInfo const & font,
docstring const & s,
Dimension & dim);
int mathed_string_width(FontInfo const &, docstring const & s);
void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const & s);
void drawStrRed(PainterInfo & pi, int x, int y, docstring const & s);
void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & s);
void math_font_max_dim(FontInfo const &, int & asc, int & desc);
void augmentFont(FontInfo & f, std::string const & cmd);
bool isFontName(std::string const & name);
bool isMathFont(std::string const & name);
bool isTextFont(std::string const & name);
bool isAlphaSymbol(MathAtom const & at);
// converts single cell to string
docstring asString(MathData const & ar);
// converts single inset to string
docstring asString(InsetMath const &);
docstring asString(MathAtom const &);
// converts string to single cell
void asArray(docstring const &, MathData &, Parse::flags f = Parse::NORMAL);
} // namespace lyx
#endif