forked from organicmaps/organicmaps
removed RectInfo::m_drawScale
This commit is contained in:
parent
d580053405
commit
0fe9a88194
4 changed files with 20 additions and 54 deletions
|
@ -6,6 +6,8 @@
|
|||
#include "../std/set.hpp"
|
||||
#include "../std/algorithm.hpp"
|
||||
|
||||
#include "../indexer/scales.hpp"
|
||||
|
||||
#include "../yg/screen.hpp"
|
||||
#include "../yg/base_texture.hpp"
|
||||
|
||||
|
@ -242,7 +244,7 @@ void ScreenCoverage::SetScreen(ScreenBase const & screen)
|
|||
for (TileSet::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it)
|
||||
{
|
||||
Tiler::RectInfo ri = (*it)->m_rectInfo;
|
||||
drawnTiles.insert(Tiler::RectInfo(0, ri.m_tileScale, ri.m_x, ri.m_y));
|
||||
drawnTiles.insert(Tiler::RectInfo(ri.m_tileScale, ri.m_x, ri.m_y));
|
||||
}
|
||||
|
||||
vector<Tiler::RectInfo> firstClassTiles;
|
||||
|
@ -254,10 +256,10 @@ void ScreenCoverage::SetScreen(ScreenBase const & screen)
|
|||
|
||||
Tiler::RectInfo cr[4] =
|
||||
{
|
||||
Tiler::RectInfo(0, nr.m_tileScale + 1, nr.m_x * 2, nr.m_y * 2),
|
||||
Tiler::RectInfo(0, nr.m_tileScale + 1, nr.m_x * 2 + 1, nr.m_y * 2),
|
||||
Tiler::RectInfo(0, nr.m_tileScale + 1, nr.m_x * 2 + 1, nr.m_y * 2 + 1),
|
||||
Tiler::RectInfo(0, nr.m_tileScale + 1, nr.m_x * 2, nr.m_y * 2 + 1)
|
||||
Tiler::RectInfo(nr.m_tileScale + 1, nr.m_x * 2, nr.m_y * 2),
|
||||
Tiler::RectInfo(nr.m_tileScale + 1, nr.m_x * 2 + 1, nr.m_y * 2),
|
||||
Tiler::RectInfo(nr.m_tileScale + 1, nr.m_x * 2 + 1, nr.m_y * 2 + 1),
|
||||
Tiler::RectInfo(nr.m_tileScale + 1, nr.m_x * 2, nr.m_y * 2 + 1)
|
||||
};
|
||||
|
||||
int childTilesToDraw = 4;
|
||||
|
@ -366,7 +368,7 @@ void ScreenCoverage::EndFrame(yg::gl::Screen *s)
|
|||
|
||||
int ScreenCoverage::GetDrawScale() const
|
||||
{
|
||||
return m_tiler.drawScale();
|
||||
return min(m_tiler.tileScale(), scales::GetUpperScale());
|
||||
}
|
||||
|
||||
bool ScreenCoverage::IsEmptyDrawingCoverage() const
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "../std/bind.hpp"
|
||||
|
||||
#include "../indexer/scales.hpp"
|
||||
|
||||
#include "../base/logging.hpp"
|
||||
#include "../base/condition.hpp"
|
||||
#include "../base/shared_buffer_manager.hpp"
|
||||
|
@ -196,7 +198,7 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
|
|||
/* drawer->clear(yg::Color(rand() % 32 + 128, rand() % 64 + 128, rand() % 32 + 128, 255));
|
||||
|
||||
std::stringstream out;
|
||||
out << rectInfo.m_y << ", " << rectInfo.m_x << ", " << rectInfo.m_tileScale << ", " << rectInfo.m_drawScale;
|
||||
out << rectInfo.m_y << ", " << rectInfo.m_x << ", " << rectInfo.m_tileScale;
|
||||
|
||||
drawer->screen()->drawText(yg::FontDesc(12, yg::Color(0, 0, 0, 255), true),
|
||||
renderRect.Center(),
|
||||
|
@ -218,8 +220,8 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env,
|
|||
frameScreen,
|
||||
selectRect,
|
||||
clipRect,
|
||||
rectInfo.m_drawScale,
|
||||
rectInfo.m_tileScale <= 17
|
||||
min(scales::GetUpperScale(), rectInfo.m_tileScale),
|
||||
rectInfo.m_tileScale <= scales::GetUpperScale()
|
||||
);
|
||||
|
||||
drawer->endFrame();
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include "../platform/platform.hpp"
|
||||
|
||||
Tiler::RectInfo::RectInfo()
|
||||
: m_drawScale(0), m_tileScale(0), m_x(0), m_y(0)
|
||||
: m_tileScale(0), m_x(0), m_y(0)
|
||||
{}
|
||||
|
||||
Tiler::RectInfo::RectInfo(int drawScale, int tileScale, int x, int y)
|
||||
: m_drawScale(drawScale), m_tileScale(tileScale), m_x(x), m_y(y)
|
||||
Tiler::RectInfo::RectInfo(int tileScale, int x, int y)
|
||||
: m_tileScale(tileScale), m_x(x), m_y(y)
|
||||
{
|
||||
initRect();
|
||||
}
|
||||
|
@ -35,8 +35,6 @@ LessByScaleAndDistance::LessByScaleAndDistance(m2::PointD const & pt)
|
|||
|
||||
bool LessByScaleAndDistance::operator()(Tiler::RectInfo const & l, Tiler::RectInfo const & r)
|
||||
{
|
||||
if (l.m_drawScale != r.m_drawScale)
|
||||
return l.m_drawScale < r.m_drawScale;
|
||||
if (l.m_tileScale != r.m_tileScale)
|
||||
return l.m_tileScale < r.m_tileScale;
|
||||
|
||||
|
@ -45,8 +43,6 @@ bool LessByScaleAndDistance::operator()(Tiler::RectInfo const & l, Tiler::RectIn
|
|||
|
||||
bool operator<(Tiler::RectInfo const & l, Tiler::RectInfo const & r)
|
||||
{
|
||||
if (l.m_drawScale != r.m_drawScale)
|
||||
return l.m_drawScale < r.m_drawScale;
|
||||
if (l.m_tileScale != r.m_tileScale)
|
||||
return l.m_tileScale < r.m_tileScale;
|
||||
if (l.m_y != r.m_y)
|
||||
|
@ -60,30 +56,9 @@ bool operator==(Tiler::RectInfo const & l, Tiler::RectInfo const & r)
|
|||
{
|
||||
return (l.m_y == r.m_y)
|
||||
&& (l.m_x == r.m_x)
|
||||
&& (l.m_drawScale == r.m_drawScale)
|
||||
&& (l.m_tileScale == r.m_tileScale);
|
||||
}
|
||||
|
||||
int Tiler::getDrawScale(ScreenBase const & s, int ts, double k) const
|
||||
{
|
||||
ScreenBase tmpS = s;
|
||||
tmpS.Rotate(-tmpS.GetAngle());
|
||||
|
||||
size_t tileSize = min(static_cast<size_t>(ts / 1.05), (size_t)(512 * k));
|
||||
|
||||
m2::RectD glbRect;
|
||||
m2::PointD pxCenter = tmpS.PixelRect().Center();
|
||||
tmpS.PtoG(m2::RectD(pxCenter - m2::PointD(tileSize / 2, tileSize / 2),
|
||||
pxCenter + m2::PointD(tileSize / 2, tileSize / 2)),
|
||||
glbRect);
|
||||
|
||||
double glbRectSize = min(glbRect.SizeX(), glbRect.SizeY());
|
||||
|
||||
int res = static_cast<int>(ceil(log((MercatorBounds::maxX - MercatorBounds::minX) / glbRectSize) / log(2.0)));
|
||||
|
||||
return res > scales::GetUpperScale() ? scales::GetUpperScale() : res;
|
||||
}
|
||||
|
||||
int Tiler::getTileScale(ScreenBase const & s, int ts) const
|
||||
{
|
||||
ScreenBase tmpS = s;
|
||||
|
@ -112,7 +87,6 @@ void Tiler::seed(ScreenBase const & screen, m2::PointD const & centerPt)
|
|||
|
||||
int tileSize = GetPlatform().TileSize();
|
||||
|
||||
m_drawScale = getDrawScale(screen, tileSize, 1);
|
||||
m_tileScale = getTileScale(screen, tileSize);
|
||||
}
|
||||
|
||||
|
@ -136,7 +110,6 @@ void Tiler::tiles(vector<RectInfo> & tiles, int depth)
|
|||
int tileSize = GetPlatform().TileSize() * scale;
|
||||
|
||||
int tileScale = getTileScale(m_screen, tileSize);
|
||||
int drawScale = getDrawScale(m_screen, tileSize, scale);
|
||||
|
||||
double rectSizeX = (MercatorBounds::maxX - MercatorBounds::minX) / (1 << tileScale);
|
||||
double rectSizeY = (MercatorBounds::maxY - MercatorBounds::minY) / (1 << tileScale);
|
||||
|
@ -163,7 +136,7 @@ void Tiler::tiles(vector<RectInfo> & tiles, int depth)
|
|||
(tileY + 1) * rectSizeY);
|
||||
|
||||
if (globalRect.IsIntersect(m2::AnyRectD(tileRect)))
|
||||
tiles.push_back(RectInfo(drawScale, tileScale, tileX, tileY));
|
||||
tiles.push_back(RectInfo(tileScale, tileX, tileY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,16 +144,9 @@ void Tiler::tiles(vector<RectInfo> & tiles, int depth)
|
|||
sort(tiles.begin(), tiles.end(), LessByScaleAndDistance(m_centerPt));
|
||||
}
|
||||
|
||||
Tiler::Tiler()
|
||||
: m_drawScale(0),
|
||||
m_tileScale(0)
|
||||
Tiler::Tiler() : m_tileScale(0)
|
||||
{}
|
||||
|
||||
int Tiler::drawScale() const
|
||||
{
|
||||
return m_drawScale;
|
||||
}
|
||||
|
||||
int Tiler::tileScale() const
|
||||
{
|
||||
return m_tileScale;
|
||||
|
@ -188,5 +154,5 @@ int Tiler::tileScale() const
|
|||
|
||||
bool Tiler::isLeaf(RectInfo const & ri) const
|
||||
{
|
||||
return (ri.m_drawScale == m_drawScale) && (ri.m_tileScale == m_tileScale);
|
||||
return (ri.m_tileScale == m_tileScale);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ public:
|
|||
|
||||
struct RectInfo
|
||||
{
|
||||
int m_drawScale; //< used to select data from model (0, 17)
|
||||
int m_tileScale; //< bounds / (2 ^ m_tileScale) is a size of the grid for a tile,
|
||||
//< could be larger than maximum model scale
|
||||
int m_x;
|
||||
|
@ -20,7 +19,7 @@ public:
|
|||
m2::RectD m_rect;
|
||||
|
||||
RectInfo();
|
||||
RectInfo(int drawScale, int tileScale, int x, int y);
|
||||
RectInfo(int tileScale, int x, int y);
|
||||
|
||||
void initRect();
|
||||
};
|
||||
|
@ -29,10 +28,8 @@ private:
|
|||
|
||||
ScreenBase m_screen;
|
||||
m2::PointD m_centerPt;
|
||||
int m_drawScale;
|
||||
int m_tileScale;
|
||||
|
||||
int getDrawScale(ScreenBase const & s, int ts, double k) const;
|
||||
int getTileScale(ScreenBase const & s, int ts) const;
|
||||
|
||||
public:
|
||||
|
@ -45,7 +42,6 @@ public:
|
|||
void tiles(vector<RectInfo> & tiles, int depth);
|
||||
bool isLeaf(RectInfo const & ri) const;
|
||||
|
||||
int drawScale() const;
|
||||
int tileScale() const;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue