forked from organicmaps/organicmaps
review fixes
This commit is contained in:
parent
455ebbbb7d
commit
c7e6aa6df9
10 changed files with 81 additions and 56 deletions
|
@ -2,20 +2,43 @@
|
|||
|
||||
#include "Stubs.hpp"
|
||||
|
||||
#include "../../../base/logging.hpp"
|
||||
#include "../../../platform/platform.hpp"
|
||||
#include "../../../geometry/any_rect2d.hpp"
|
||||
#include "../../../map/events.hpp"
|
||||
#include "../../../map/navigator.hpp"
|
||||
#include "../../../map/yopme_render_policy.hpp"
|
||||
#include "../../../platform/platform.hpp"
|
||||
#include "../../../geometry/any_rect2d.hpp"
|
||||
#include "../../../base/logging.hpp"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
namespace yopme
|
||||
{
|
||||
static EmptyVideoTimer s_timer;
|
||||
Framework::Framework(int width, int height)
|
||||
: m_width(width)
|
||||
, m_height(height)
|
||||
{
|
||||
LOG(LDEBUG, ("Framework Constructor"));
|
||||
// TODO move this in some method like ExternalStorageConnected
|
||||
m_framework.AddLocalMaps();
|
||||
LOG(LDEBUG, ("Local maps addeded"));
|
||||
}
|
||||
|
||||
Framework::~Framework()
|
||||
{
|
||||
m_framework.PrepareToShutdown();
|
||||
}
|
||||
|
||||
void Framework::ShowRect(double lat, double lon, double zoom)
|
||||
{
|
||||
m_framework.ShowRect(lat, lon, zoom);
|
||||
InitRenderPolicy();
|
||||
RenderMap();
|
||||
TeardownRenderPolicy();
|
||||
}
|
||||
|
||||
void Framework::InitRenderPolicy()
|
||||
{
|
||||
m_timer.reset(new EmptyVideoTimer());
|
||||
shared_ptr<RenderContext> primaryRC(new RenderContext());
|
||||
graphics::ResourceManager::Params rmParams;
|
||||
rmParams.m_rtFormat = graphics::Data8Bpp;
|
||||
|
@ -25,49 +48,30 @@ namespace yopme
|
|||
|
||||
RenderPolicy::Params rpParams;
|
||||
|
||||
rpParams.m_videoTimer = m_timer.get();
|
||||
rpParams.m_videoTimer = &s_timer;
|
||||
rpParams.m_useDefaultFB = true;
|
||||
rpParams.m_rmParams = rmParams;
|
||||
rpParams.m_primaryRC = primaryRC;
|
||||
rpParams.m_density = graphics::EDensityXHDPI;
|
||||
rpParams.m_skinName = "basic.skn";
|
||||
rpParams.m_screenWidth = width;
|
||||
rpParams.m_screenHeight = height;
|
||||
rpParams.m_screenWidth = m_width;
|
||||
rpParams.m_screenHeight = m_height;
|
||||
|
||||
try
|
||||
{
|
||||
RenderPolicy * policy = new ::YopmeRP(rpParams);
|
||||
m_framework.SetRenderPolicy(policy);
|
||||
// TODO move this in some method like ExternalStorageConnected
|
||||
m_framework.AddLocalMaps();
|
||||
m_framework.SetRenderPolicy(new ::YopmeRP(rpParams));
|
||||
}
|
||||
catch(RootException & e)
|
||||
{
|
||||
LOG(LERROR, (e.what()));
|
||||
}
|
||||
|
||||
m_framework.OnSize(width, height);
|
||||
m_framework.OnSize(m_width, m_height);
|
||||
}
|
||||
|
||||
Framework::~Framework()
|
||||
void Framework::TeardownRenderPolicy()
|
||||
{
|
||||
m_framework.PrepareToShutdown();
|
||||
}
|
||||
|
||||
void Framework::ConfigureNavigator(double lat, double lon, double zoom)
|
||||
{
|
||||
Navigator & navigator = m_framework.GetNavigator();
|
||||
ScalesProcessor const & scales = navigator.GetScaleProcessor();
|
||||
m2::RectD rect = scales.GetRectForDrawScale(zoom, m2::PointD(lon, lat));
|
||||
|
||||
m2::PointD leftBottom = rect.LeftBottom();
|
||||
m2::PointD rightTop = rect.RightTop();
|
||||
m2::RectD pixelRect = m2::RectD(MercatorBounds::LonToX(leftBottom.x),
|
||||
MercatorBounds::LatToY(leftBottom.y),
|
||||
MercatorBounds::LonToX(rightTop.x),
|
||||
MercatorBounds::LatToY(rightTop.y));
|
||||
|
||||
navigator.SetFromRect(m2::AnyRectD(pixelRect));
|
||||
m_framework.SetRenderPolicy(0);
|
||||
}
|
||||
|
||||
void Framework::RenderMap()
|
||||
|
|
|
@ -13,11 +13,16 @@ namespace yopme
|
|||
Framework(int width, int height);
|
||||
~Framework();
|
||||
|
||||
void ConfigureNavigator(double lat, double lon, double zoom);
|
||||
void ShowRect(double lat, double lon, double zoom);
|
||||
|
||||
private:
|
||||
void InitRenderPolicy();
|
||||
void TeardownRenderPolicy();
|
||||
void RenderMap();
|
||||
|
||||
private:
|
||||
::Framework m_framework;
|
||||
shared_ptr<VideoTimer> m_timer;
|
||||
int m_width;
|
||||
int m_height;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,7 +3,12 @@
|
|||
|
||||
#include "Framework.hpp"
|
||||
#include "../../../base/logging.hpp"
|
||||
#include "../../../std/shared_ptr.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
static shared_ptr<yopme::Framework> s_framework;
|
||||
}
|
||||
|
||||
// @TODO refactor and remove that
|
||||
void InitNVEvent(JavaVM * jvm) {}
|
||||
|
@ -11,12 +16,17 @@ void InitNVEvent(JavaVM * jvm) {}
|
|||
extern "C"
|
||||
{
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_yopme_map_MapRenderer_nativeCreateFramework(JNIEnv * env, jobject obj, int width, int height)
|
||||
{
|
||||
s_framework.reset(new yopme::Framework(width, height));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_yopme_map_MapRenderer_nativeRenderMap(JNIEnv * env, jobject obj, double lat, double lon, double zoom)
|
||||
{
|
||||
yopme::Framework f(360, 640);
|
||||
f.ConfigureNavigator(lat, lon, zoom);
|
||||
f.RenderMap();
|
||||
ASSERT(s_framework != NULL, ());
|
||||
s_framework->ShowRect(lat, lon, zoom);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
|
|
@ -61,10 +61,6 @@ public class BackscreenActivity extends BSActivity
|
|||
protected void onBSCreate()
|
||||
{
|
||||
super.onBSCreate();
|
||||
|
||||
final Resources res = getResources();
|
||||
mMapDataProvider = new MapRenderer((int) res.getDimension(R.dimen.yota_width),
|
||||
(int)res.getDimension(R.dimen.yota_height));
|
||||
|
||||
final String extStoragePath = getDataStoragePath();
|
||||
final String extTmpPath = getTempPath();
|
||||
|
@ -74,6 +70,12 @@ public class BackscreenActivity extends BSActivity
|
|||
new File(extTmpPath).mkdirs();
|
||||
|
||||
nativeInitPlatform(getApkPath(), extStoragePath, extTmpPath, "", true);
|
||||
|
||||
/// !!! Create MapRenderer ONLY AFTER platform init !!!
|
||||
//final Resources res = getResources();
|
||||
//mMapDataProvider = new MapRenderer((int) res.getDimension(R.dimen.yota_width),
|
||||
// (int)res.getDimension(R.dimen.yota_height));
|
||||
mMapDataProvider = MapRenderer.GetRenderer();
|
||||
|
||||
setUpView();
|
||||
}
|
||||
|
@ -233,8 +235,7 @@ public class BackscreenActivity extends BSActivity
|
|||
{
|
||||
if (mLocation == null)
|
||||
return;
|
||||
data = mMapDataProvider.getMyPositionData(mLocation.getLatitude(),
|
||||
mLocation.getLongitude(), mZoomLevel);
|
||||
data = mMapDataProvider.getMyPositionData(mLocation.getLatitude(), mLocation.getLongitude(), mZoomLevel);
|
||||
}
|
||||
else if (mMode == Mode.POI)
|
||||
data = mMapDataProvider.getPOIData(mPoint, mZoomLevel);
|
||||
|
@ -248,8 +249,9 @@ public class BackscreenActivity extends BSActivity
|
|||
|
||||
public static void startInMode(Context context, Mode mode, MWMPoint point)
|
||||
{
|
||||
final Intent i = new Intent(context, BackscreenActivity.class).putExtra(EXTRA_MODE, mode).putExtra(EXTRA_POINT,
|
||||
point);
|
||||
final Intent i = new Intent(context, BackscreenActivity.class)
|
||||
.putExtra(EXTRA_MODE, mode)
|
||||
.putExtra(EXTRA_POINT, point);
|
||||
|
||||
context.startService(i);
|
||||
}
|
||||
|
@ -302,6 +304,6 @@ public class BackscreenActivity extends BSActivity
|
|||
}
|
||||
|
||||
private native void nativeInitPlatform(String apkPath, String storagePath,
|
||||
String tmpPath, String obbGooglePath,
|
||||
boolean isPro);
|
||||
String tmpPath, String obbGooglePath,
|
||||
boolean isPro);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public class MapRenderer implements MapDataProvider
|
|||
{
|
||||
mPixelBuffer = new PixelBuffer(width, height);
|
||||
mPixelBuffer.init();
|
||||
nativeCreateFramework(width, height);
|
||||
}
|
||||
|
||||
public void terminate()
|
||||
|
@ -57,5 +58,6 @@ public class MapRenderer implements MapDataProvider
|
|||
}
|
||||
}
|
||||
|
||||
private native void nativeCreateFramework(int width, int height);
|
||||
private native void nativeRenderMap(double lat, double lon, double zoom);
|
||||
}
|
||||
|
|
|
@ -877,6 +877,14 @@ bool Framework::CheckMinMaxVisibleScale(m2::RectD & rect, int maxScale/* = -1*/)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Framework::ShowRect(double lat, double lon, double zoom)
|
||||
{
|
||||
m2::RectD rect = m_scales.GetRectForDrawScale(zoom,
|
||||
m2::PointD(MercatorBounds::LonToX(lon),
|
||||
MercatorBounds::LatToY(lat)));
|
||||
ShowRectEx(rect);
|
||||
}
|
||||
|
||||
void Framework::ShowRect(m2::RectD const & r)
|
||||
{
|
||||
m2::AnyRectD rect(r);
|
||||
|
|
|
@ -374,6 +374,7 @@ private:
|
|||
void ShowRectFixed(m2::AnyRectD const & rect);
|
||||
|
||||
public:
|
||||
void ShowRect(double lat, double lon, double zoom);
|
||||
/// Set navigator viewport by rect as-is.
|
||||
void ShowRect(m2::RectD const & rect);
|
||||
/// - Use navigator rotate angle.
|
||||
|
|
|
@ -327,11 +327,6 @@ m2::PointD Navigator::ShiftPoint(m2::PointD const & pt) const
|
|||
return pt + m2::PointD(pxRect.minX(), pxRect.minY());
|
||||
}
|
||||
|
||||
ScalesProcessor const & Navigator::GetScaleProcessor() const
|
||||
{
|
||||
return m_scales;
|
||||
}
|
||||
|
||||
void Navigator::StartDrag(m2::PointD const & pt, double /*timeInSec*/)
|
||||
{
|
||||
m_StartPt1 = m_LastPt1 = pt;
|
||||
|
|
|
@ -66,8 +66,6 @@ public:
|
|||
/// so we should take it into an account
|
||||
m2::PointD ShiftPoint(m2::PointD const & pt) const;
|
||||
|
||||
ScalesProcessor const & GetScaleProcessor() const;
|
||||
|
||||
private:
|
||||
ScalesProcessor const & m_scales;
|
||||
|
||||
|
|
|
@ -53,11 +53,11 @@ macx-* {
|
|||
QMAKE_BUNDLE_DATA += OTHER_RES CLASSIFICATOR_RES SKIN_RES FONT_RES MWM_RES
|
||||
}
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
glwidget.cpp
|
||||
SOURCES += main.cpp \
|
||||
mainwindow.cpp \
|
||||
glwidget.cpp \
|
||||
|
||||
HEADERS += mainwindow.hpp \
|
||||
glwidget.hpp
|
||||
glwidget.hpp \
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
|
|
Loading…
Add table
Reference in a new issue