fixed invalid styleID. possibly fixes disappearing coastlines.

This commit is contained in:
rachytski 2011-03-13 14:56:33 +02:00 committed by Alex Zolotarev
parent d3a4d29409
commit 285f8b79f3
3 changed files with 28 additions and 38 deletions

View file

@ -1,6 +1,7 @@
#include "pen_info.hpp"
#include "../std/algorithm.hpp"
#include "../std/iterator.hpp"
#include "../std/numeric.hpp"
namespace yg
{
@ -72,6 +73,18 @@ namespace yg
return false;
}
m2::PointU const PenInfo::patternSize() const
{
if (m_isSolid)
return m2::PointU(ceil(m_w) + 4,
ceil(m_w) + 4);
else
{
uint32_t len = static_cast<uint32_t>(accumulate(m_pat.begin(), m_pat.end(), 0.0));
return m2::PointU(len + 4, m_w + 4);
}
}
bool operator < (PenInfo const & l, PenInfo const & r)
{
if (l.m_isSolid != r.m_isSolid)

View file

@ -2,6 +2,7 @@
#include "color.hpp"
#include "../geometry/point2d.hpp"
#include "../std/vector.hpp"
#include "../base/buffer_vector.hpp"
@ -30,6 +31,8 @@ namespace yg
double firstDashOffset() const;
bool atDashOffset(double offset) const;
m2::PointU const patternSize() const;
};
bool operator < (PenInfo const & l, PenInfo const & r);

View file

@ -330,52 +330,26 @@ namespace yg
if (foundHandle != m_packer.invalidHandle())
return foundHandle;
if (penInfo.m_isSolid)
{
m2::Packer::handle_t handle = m_packer.pack(
ceil(penInfo.m_w + 4),
ceil(penInfo.m_w + 4));
m2::RectU texRect = m_packer.find(handle).second;
m_penUploadCommands.push_back(PenUploadCmd(penInfo, texRect));
m_penInfoMap[penInfo] = handle;
m2::PointU p = penInfo.patternSize();
m_styles[handle] = boost::shared_ptr<ResourceStyle>(
new LineStyle(false,
texRect,
m_pageID,
penInfo));
}
else
{
uint32_t len = static_cast<uint32_t>(accumulate(penInfo.m_pat.begin(), penInfo.m_pat.end(), 0.0));
m2::Packer::handle_t handle = m_packer.pack(p.x, p.y);
m2::RectU texRect = m_packer.find(handle).second;
m_penUploadCommands.push_back(PenUploadCmd(penInfo, texRect));
m_penInfoMap[penInfo] = handle;
m2::Packer::handle_t handle = m_packer.pack(len + 4, penInfo.m_w + 4);
m2::RectU texRect = m_packer.find(handle).second;
m_penUploadCommands.push_back(PenUploadCmd(penInfo, texRect));
m_penInfoMap[penInfo] = handle;
m_styles[handle] = boost::shared_ptr<ResourceStyle>(
new LineStyle(false,
texRect,
m_pageID,
penInfo));
}
m_styles[handle] = boost::shared_ptr<ResourceStyle>(
new LineStyle(false,
texRect,
m_pageID,
penInfo));
return m_penInfoMap[penInfo];
}
bool SkinPage::hasRoom(const PenInfo &penInfo) const
{
if (penInfo.m_isSolid)
{
return m_packer.hasRoom(penInfo.m_w + 4, penInfo.m_w + 4);
// return hasRoom(penInfo.m_color);
}
else
{
uint32_t len = static_cast<uint32_t>(accumulate(penInfo.m_pat.begin(), penInfo.m_pat.end(), 0.0));
return m_packer.hasRoom(len + 4, penInfo.m_w + 4);
}
m2::PointU p = penInfo.patternSize();
return m_packer.hasRoom(p.x, p.y);
}
bool SkinPage::isDynamic() const