Welcome to mirror list, hosted at ThFree Co, Russian Federation.

text_renderer.cpp « graphics - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c0382111005f04c1d9ba03dc1668323d0d4216d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "text_renderer.hpp"
#include "overlay.hpp"
#include "resource_manager.hpp"
#include "glyph.hpp"

#include "../geometry/angles.hpp"

#include "../std/bind.hpp"

#include "../base/string_utils.hpp"


namespace graphics
{
  //TextRenderer::Params::Params()
  //  : m_drawTexts(true)
  //{}

  TextRenderer::TextRenderer(base_t::Params const & params)
    : base_t(params)//, m_drawTexts(params.m_drawTexts)
  {}

  void TextRenderer::drawStraightGlyph(m2::PointD const & ptPivot,
                                       m2::PointD const & ptOffs,
                                       Glyph const * p,
                                       float depth)
  {
    float x0 = ptOffs.x + (p->m_info.m_metrics.m_xOffset - 1);
    float y1 = ptOffs.y - (p->m_info.m_metrics.m_yOffset - 1);
    float y0 = y1 - (p->m_texRect.SizeY() - 2);
    float x1 = x0 + (p->m_texRect.SizeX() - 2);

    drawStraightTexturedPolygon(
          ptPivot,
          p->m_texRect.minX() + 1,
          p->m_texRect.minY() + 1,
          p->m_texRect.maxX() - 1,
          p->m_texRect.maxY() - 1,
          x0, y0, x1, y1,
          depth,
          p->m_pipelineID
          );
  }

  void TextRenderer::drawGlyph(m2::PointD const & ptOrg,
                               m2::PointD const & ptGlyph,
                               ang::AngleD const & angle,
                               float /*blOffset*/,
                               Glyph const * p,
                               double depth)
  {
    float x0 = ptGlyph.x + (p->m_info.m_metrics.m_xOffset - 1);
    float y1 = ptGlyph.y - (p->m_info.m_metrics.m_yOffset - 1);
    float y0 = y1 - (p->m_texRect.SizeY() - 2);
    float x1 = x0 + (p->m_texRect.SizeX() - 2);

    drawTexturedPolygon(ptOrg, angle,
                        p->m_texRect.minX() + 1,
                        p->m_texRect.minY() + 1,
                        p->m_texRect.maxX() - 1,
                        p->m_texRect.maxY() - 1,
                        x0, y0, x1, y1,
                        depth,
                        p->m_pipelineID);
  }

  GlyphCache * TextRenderer::glyphCache() const
  {
    return resourceManager()->glyphCache(threadSlot());
  }
}