forked from organicmaps/organicmaps
[drape] resize must get pixel size of surface. Not logic.
This commit is contained in:
parent
b694d70c8a
commit
da25d3faaf
8 changed files with 27 additions and 55 deletions
|
@ -12,10 +12,11 @@ namespace df
|
|||
|
||||
DrapeEngine::DrapeEngine(dp::RefPointer<dp::OGLContextFactory> contextfactory,
|
||||
Viewport const & viewport,
|
||||
MapDataProvider const & model)
|
||||
MapDataProvider const & model,
|
||||
double vs)
|
||||
: m_viewport(viewport)
|
||||
{
|
||||
VisualParams::Init(viewport.GetPixelRatio(), df::CalculateTileSize(m_viewport.GetWidth(), m_viewport.GetHeight()));
|
||||
VisualParams::Init(vs, df::CalculateTileSize(m_viewport.GetWidth(), m_viewport.GetHeight()));
|
||||
|
||||
m_threadCommutator = dp::MasterPointer<ThreadsCommutator>(new ThreadsCommutator());
|
||||
dp::RefPointer<ThreadsCommutator> commutatorRef = m_threadCommutator.GetRefPointer();
|
||||
|
@ -37,7 +38,7 @@ DrapeEngine::~DrapeEngine()
|
|||
|
||||
void DrapeEngine::Resize(int w, int h)
|
||||
{
|
||||
if (m_viewport.GetLogicWidth() == w && m_viewport.GetLogicHeight() == h)
|
||||
if (m_viewport.GetWidth() == w && m_viewport.GetHeight() == h)
|
||||
return;
|
||||
|
||||
m_viewport.SetViewport(0, 0, w, h);
|
||||
|
|
|
@ -23,7 +23,8 @@ class DrapeEngine
|
|||
public:
|
||||
DrapeEngine(dp::RefPointer<dp::OGLContextFactory> oglcontextfactory,
|
||||
Viewport const & viewport,
|
||||
MapDataProvider const & model);
|
||||
MapDataProvider const & model,
|
||||
double vs);
|
||||
~DrapeEngine();
|
||||
|
||||
void Resize(int w, int h);
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
namespace df
|
||||
{
|
||||
|
||||
Viewport::Viewport(float pixelRatio,
|
||||
uint32_t x0, uint32_t y0,
|
||||
Viewport::Viewport(uint32_t x0, uint32_t y0,
|
||||
uint32_t w, uint32_t h)
|
||||
: m_pixelRatio(pixelRatio)
|
||||
, m_zero(x0, y0)
|
||||
: m_zero(x0, y0)
|
||||
, m_size(w, h)
|
||||
{
|
||||
}
|
||||
|
@ -19,49 +17,24 @@ void Viewport::SetViewport(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h)
|
|||
m_size = m2::PointU(w, h);
|
||||
}
|
||||
|
||||
uint32_t Viewport::GetLogicX0() const
|
||||
uint32_t Viewport::GetX0() const
|
||||
{
|
||||
return m_zero.x;
|
||||
}
|
||||
|
||||
uint32_t Viewport::GetLogicY0() const
|
||||
uint32_t Viewport::GetY0() const
|
||||
{
|
||||
return m_zero.y;
|
||||
}
|
||||
|
||||
uint32_t Viewport::GetLogicWidth() const
|
||||
uint32_t Viewport::GetWidth() const
|
||||
{
|
||||
return m_size.x;
|
||||
}
|
||||
|
||||
uint32_t Viewport::GetLogicHeight() const
|
||||
{
|
||||
return m_size.y;
|
||||
}
|
||||
|
||||
uint32_t Viewport::GetX0() const
|
||||
{
|
||||
return GetLogicX0() * m_pixelRatio;
|
||||
}
|
||||
|
||||
uint32_t Viewport::GetY0() const
|
||||
{
|
||||
return GetLogicY0() * m_pixelRatio;
|
||||
}
|
||||
|
||||
uint32_t Viewport::GetWidth() const
|
||||
{
|
||||
return GetLogicWidth() * m_pixelRatio;
|
||||
}
|
||||
|
||||
uint32_t Viewport::GetHeight() const
|
||||
{
|
||||
return GetLogicHeight() * m_pixelRatio;
|
||||
}
|
||||
|
||||
float Viewport::GetPixelRatio() const
|
||||
{
|
||||
return m_pixelRatio;
|
||||
return m_size.y;
|
||||
}
|
||||
|
||||
void Viewport::Apply() const
|
||||
|
|
|
@ -12,29 +12,24 @@ class Viewport
|
|||
{
|
||||
public:
|
||||
// x0, y0, w, h is device-independent pixels
|
||||
Viewport(float pixelRatio,
|
||||
uint32_t x0, uint32_t y0,
|
||||
Viewport(uint32_t x0, uint32_t y0,
|
||||
uint32_t w, uint32_t h);
|
||||
|
||||
///@{ Device-independent pixels
|
||||
///@{ in surface pixels
|
||||
/// on iOS we must mul this on scaleFactor
|
||||
/// on android we get true size from surface
|
||||
void SetViewport(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h);
|
||||
uint32_t GetLogicX0() const;
|
||||
uint32_t GetLogicY0() const;
|
||||
uint32_t GetLogicWidth() const;
|
||||
uint32_t GetLogicHeight() const;
|
||||
///@}
|
||||
|
||||
uint32_t GetX0() const;
|
||||
uint32_t GetY0() const;
|
||||
uint32_t GetWidth() const;
|
||||
uint32_t GetHeight() const;
|
||||
float GetPixelRatio() const;
|
||||
///@}
|
||||
// Apply viewport to graphics pipeline
|
||||
// with convert start poin and size to physical pixels
|
||||
void Apply() const;
|
||||
|
||||
private:
|
||||
float m_pixelRatio;
|
||||
m2::PointU m_zero;
|
||||
m2::PointU m_size;
|
||||
};
|
||||
|
|
|
@ -132,8 +132,8 @@ void DrapeSurface::CreateEngine()
|
|||
m_model.ReadFeatures(fn, ids);
|
||||
};
|
||||
|
||||
m_drapeEngine = TEnginePrt(new df::DrapeEngine(f, df::Viewport(pixelRatio, 0, 0, width(), height()),
|
||||
df::MapDataProvider(idReadFn, featureReadFn)));
|
||||
m_drapeEngine = TEnginePrt(new df::DrapeEngine(f, df::Viewport(0, 0, width(), height()),
|
||||
df::MapDataProvider(idReadFn, featureReadFn), pixelRatio));
|
||||
}
|
||||
|
||||
void DrapeSurface::UpdateCoverage()
|
||||
|
|
|
@ -131,7 +131,7 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale)
|
|||
|
||||
- (void)onSize:(int)width withHeight:(int)height
|
||||
{
|
||||
GetFramework().OnSize(width, height);
|
||||
GetFramework().OnSize(width * self.contentScaleFactor, height * self.contentScaleFactor);
|
||||
}
|
||||
|
||||
- (double)correctContentScale
|
||||
|
|
|
@ -663,8 +663,7 @@ void Framework::OnSize(int w, int h)
|
|||
|
||||
if (!m_drapeEngine.IsNull())
|
||||
{
|
||||
double vs = df::VisualParams::Instance().GetVisualScale();
|
||||
m_navigator.OnSize(0, 0, vs * w, vs * h);
|
||||
m_navigator.OnSize(0, 0, w, h);
|
||||
m_drapeEngine->Resize(w, h);
|
||||
m_drapeEngine->UpdateCoverage(m_navigator.Screen());
|
||||
}
|
||||
|
@ -1012,7 +1011,9 @@ void Framework::Scale(double scale)
|
|||
m2::PointD center = GetPixelCenter();
|
||||
///@TODO UVR
|
||||
//GetLocationState()->CorrectScalePoint(center);
|
||||
m_animController->AddTask(m_navigator.ScaleToPointAnim(center, scale, 0.25));
|
||||
///@TODO UVR
|
||||
//m_animController->AddTask(m_navigator.ScaleToPointAnim(center, scale, 0.25));
|
||||
m_navigator.ScaleToPoint(center, scale, 0.0);
|
||||
|
||||
if (!m_drapeEngine.IsNull())
|
||||
m_drapeEngine->UpdateCoverage(m_navigator.Screen());
|
||||
|
@ -1381,7 +1382,7 @@ void Framework::CreateDrapeEngine(dp::RefPointer<dp::OGLContextFactory> contextF
|
|||
m_model.ReadFeatures(fn, ids);
|
||||
};
|
||||
|
||||
m_drapeEngine.Reset(new df::DrapeEngine(contextFactory, df::Viewport(vs, 0, 0, w, h), df::MapDataProvider(idReadFn, featureReadFn)));
|
||||
m_drapeEngine.Reset(new df::DrapeEngine(contextFactory, df::Viewport(0, 0, w, h), df::MapDataProvider(idReadFn, featureReadFn), vs));
|
||||
OnSize(w, h);
|
||||
}
|
||||
|
||||
|
|
|
@ -419,7 +419,8 @@ namespace qt
|
|||
|
||||
void DrawWidget::sizeChanged(int)
|
||||
{
|
||||
m_framework->OnSize(width(), height());
|
||||
double scaleFactor = static_cast<double>(devicePixelRatio());
|
||||
m_framework->OnSize(scaleFactor * width(), scaleFactor * height());
|
||||
|
||||
UpdateScaleControl();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue