forked from organicmaps/organicmaps
implemented PathRenderer::drawSymbolPath and added tests for it.
This commit is contained in:
parent
b26e2d91ea
commit
01b44f4c34
2 changed files with 122 additions and 2 deletions
|
@ -99,6 +99,17 @@ namespace
|
|||
m_depthes.push_back(depth);
|
||||
}
|
||||
|
||||
void AddTest(vector<m2::PointD> const & pts,
|
||||
graphics::Pen::Info const & info,
|
||||
double depth,
|
||||
double pathOffset)
|
||||
{
|
||||
m_pathes.push_back(pts);
|
||||
m_pathOffsets.push_back(pathOffset);
|
||||
m_depthes.push_back(depth);
|
||||
m_penInfos.push_back(info);
|
||||
}
|
||||
|
||||
std::vector<m2::PointD> & GetTestPoints(size_t i)
|
||||
{
|
||||
return m_pathes[i];
|
||||
|
@ -587,6 +598,57 @@ namespace
|
|||
}
|
||||
};
|
||||
|
||||
struct TestDrawPathSymbol : TestDrawPathBase
|
||||
{
|
||||
typedef TestDrawPathBase base_t;
|
||||
|
||||
void Init()
|
||||
{
|
||||
base_t::Init();
|
||||
|
||||
m_drawAxis = true;
|
||||
|
||||
vector<m2::PointD> pts;
|
||||
|
||||
graphics::Pen::Info info;
|
||||
graphics::Pen::Info info1;
|
||||
|
||||
info.m_icon.m_name = "theatre";
|
||||
info.m_step = 15;
|
||||
|
||||
pts.clear();
|
||||
pts.push_back(m2::PointD(100, 100));
|
||||
pts.push_back(m2::PointD(200, 100));
|
||||
|
||||
AddTest(pts, info, graphics::maxDepth, 0);
|
||||
|
||||
pts.clear();
|
||||
pts.push_back(m2::PointD(100, 200));
|
||||
pts.push_back(m2::PointD(200, 200));
|
||||
|
||||
AddTest(pts, info, graphics::maxDepth, 30);
|
||||
|
||||
pts.clear();
|
||||
pts.push_back(m2::PointD(100, 300));
|
||||
pts.push_back(m2::PointD(200, 300));
|
||||
|
||||
vector<double> pat;
|
||||
|
||||
pat.push_back(20);
|
||||
pat.push_back(20);
|
||||
|
||||
info1 = graphics::Pen::Info(graphics::Color(0, 0, 0, 255), 20, &pat[0], pat.size());
|
||||
AddTest(pts, info1, graphics::maxDepth, 30);
|
||||
|
||||
pts.clear();
|
||||
pts.push_back(m2::PointD(300, 100));
|
||||
pts.push_back(m2::PointD(400, 160));
|
||||
pts.push_back(m2::PointD(300, 240));
|
||||
|
||||
AddTest(pts, info, graphics::maxDepth, 0);
|
||||
}
|
||||
};
|
||||
|
||||
struct TestDrawPoly
|
||||
{
|
||||
void DoDraw(shared_ptr<graphics::Screen> p)
|
||||
|
@ -1433,7 +1495,8 @@ namespace
|
|||
UNIT_TEST_GL(TestDrawPathJoin);
|
||||
UNIT_TEST_GL(TestDrawPathSolid1PX);
|
||||
UNIT_TEST_GL(TestDrawPathSolid2PX);*/
|
||||
UNIT_TEST_GL(TestDrawPathSolid);
|
||||
// UNIT_TEST_GL(TestDrawPathSolid);
|
||||
UNIT_TEST_GL(TestDrawPathSymbol);
|
||||
/*UNIT_TEST_GL(TestDrawOverlappedSymbolWithText);
|
||||
UNIT_TEST_GL(TestDrawAnyRect);
|
||||
UNIT_TEST_GL(TestDrawSector);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "resource.hpp"
|
||||
#include "pen.hpp"
|
||||
#include "resource_cache.hpp"
|
||||
#include "path_view.hpp"
|
||||
|
||||
#include "opengl/base_texture.hpp"
|
||||
|
||||
|
@ -54,7 +55,63 @@ namespace graphics
|
|||
|
||||
void PathRenderer::drawSymbolPath(m2::PointD const * pts, size_t ptsCount, double offset, Pen const * pen, double depth)
|
||||
{
|
||||
LOG(LINFO, ("drawSymbolPath is unimplemented. symbolName=", pen->m_info.m_symbol));
|
||||
PathView pv(pts, ptsCount);
|
||||
|
||||
PathPoint pt = pv.front();
|
||||
|
||||
pt = pv.offsetPoint(pt, offset);
|
||||
|
||||
m2::RectU texRect = pen->m_texRect;
|
||||
texRect.Inflate(-1, -1);
|
||||
|
||||
double const w = texRect.SizeX();
|
||||
double const h = texRect.SizeY();
|
||||
|
||||
double const hw = w / 2.0;
|
||||
double const hh = h / 2.0;
|
||||
|
||||
shared_ptr<gl::BaseTexture> tex = pipeline(pen->m_pipelineID).texture();
|
||||
|
||||
while (true)
|
||||
{
|
||||
PivotPoint pvPt = pv.findPivotPoint(pt, hw - 1, 0);
|
||||
|
||||
if (pvPt.m_pp.m_i == -1)
|
||||
break;
|
||||
|
||||
ang::AngleD ang = pvPt.m_angle;
|
||||
|
||||
m2::PointD pts[4];
|
||||
|
||||
pts[0] = pvPt.m_pp.m_pt.Move(-hw, ang.sin(), ang.cos());
|
||||
pts[0] = pts[0].Move(hh + 1, -ang.cos(), ang.sin());
|
||||
|
||||
pts[1] = pts[0].Move(w, ang.sin(), ang.cos());
|
||||
pts[2] = pts[0].Move(-h, -ang.cos(), ang.sin());
|
||||
pts[3] = pts[2].Move(w, ang.sin(), ang.cos());
|
||||
|
||||
m2::PointF texPts[4] =
|
||||
{
|
||||
tex->mapPixel(m2::PointF(texRect.minX(), texRect.minY())),
|
||||
tex->mapPixel(m2::PointF(texRect.maxX(), texRect.minY())),
|
||||
tex->mapPixel(m2::PointF(texRect.minX(), texRect.maxY())),
|
||||
tex->mapPixel(m2::PointF(texRect.maxX(), texRect.maxY()))
|
||||
};
|
||||
|
||||
m2::PointF normal(0, 0);
|
||||
|
||||
addTexturedStripStrided(pts, sizeof(m2::PointD),
|
||||
&normal, 0,
|
||||
texPts, sizeof(m2::PointF),
|
||||
4,
|
||||
depth,
|
||||
pen->m_pipelineID);
|
||||
|
||||
pt = pv.offsetPoint(pvPt.m_pp, pen->m_info.m_step);
|
||||
|
||||
if (pt.m_i == -1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PathRenderer::drawStipplePath(m2::PointD const * points, size_t pointsCount, double offset, Pen const * pen, double depth)
|
||||
|
|
Loading…
Add table
Reference in a new issue