forked from organicmaps/organicmaps
[ANDROID] refactored eclipse project structure.
This commit is contained in:
parent
deed74c062
commit
10fcfc2ccd
29 changed files with 731 additions and 578 deletions
|
@ -11,23 +11,29 @@ LOCAL_CFLAGS := -ffunction-sections -fdata-sections
|
|||
|
||||
|
||||
LOCAL_HEADER_FILES := \
|
||||
jni_helper.h \
|
||||
jni_string.h \
|
||||
logging.h \
|
||||
android_platform.hpp \
|
||||
android_framework.hpp \
|
||||
rendering.h \
|
||||
com/mapswithme/core/jni_helper.hpp \
|
||||
com/mapswithme/core/jni_string.hpp \
|
||||
com/mapswithme/core/logging.hpp \
|
||||
com/mapswithme/core/download_manager.hpp \
|
||||
com/mapswithme/core/render_context.hpp \
|
||||
com/mapswithme/maps/Framework.hpp \
|
||||
com/mapswithme/maps/Platform.hpp \
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
main_native.cpp \
|
||||
jni_helper.cpp \
|
||||
jni_string.cpp \
|
||||
android_platform.cpp \
|
||||
android_framework.cpp \
|
||||
logging.cpp \
|
||||
temp_stubs.cpp \
|
||||
rendering.cpp \
|
||||
|
||||
com/mapswithme/core/concurrent_runner.cpp \
|
||||
com/mapswithme/core/download_manager.cpp \
|
||||
com/mapswithme/core/jni_helper.cpp \
|
||||
com/mapswithme/core/jni_string.cpp \
|
||||
com/mapswithme/core/logging.cpp \
|
||||
com/mapswithme/core/render_context.cpp \
|
||||
com/mapswithme/location/LocationService.cpp \
|
||||
com/mapswithme/maps/DownloadUI.cpp \
|
||||
com/mapswithme/maps/Framework.cpp \
|
||||
com/mapswithme/maps/GesturesProcessor.cpp \
|
||||
com/mapswithme/maps/MainGLView.cpp \
|
||||
com/mapswithme/maps/Platform.cpp \
|
||||
com/mapswithme/maps/MWMActivity.cpp \
|
||||
|
||||
LOCAL_LDLIBS := -llog -lGLESv1_CM \
|
||||
-lwords -lmap -lstorage -lversion -lsearch -lindexer -lyg -lplatform \
|
||||
-lgeometry -lcoding -lbase -lexpat -lfreetype -lfribidi -lzlib -lbzip2 \
|
||||
|
|
|
@ -1,168 +0,0 @@
|
|||
#include "android_framework.hpp"
|
||||
#include "jni_helper.h"
|
||||
#include "rendering.h"
|
||||
|
||||
#include "../../base/logging.hpp"
|
||||
|
||||
#include "../../indexer/drawing_rules.hpp"
|
||||
|
||||
#include "../../map/render_policy_st.hpp"
|
||||
#include "../../map/tiling_render_policy_st.hpp"
|
||||
#include "../../map/framework.hpp"
|
||||
|
||||
#include "../../std/shared_ptr.hpp"
|
||||
#include "../../std/bind.hpp"
|
||||
|
||||
void AndroidFramework::CallRepaint()
|
||||
{
|
||||
// Always get current env pointer, it's different for each thread
|
||||
JNIEnv * env;
|
||||
m_jvm->AttachCurrentThread(&env, NULL);
|
||||
env->CallVoidMethod(m_parentView, jni::GetJavaMethodID(env, m_parentView, "requestRender", "()V"));
|
||||
}
|
||||
|
||||
AndroidFramework::AndroidFramework(JavaVM * jvm)
|
||||
: m_jvm(jvm),
|
||||
m_handle(new WindowHandle()),
|
||||
m_work(m_handle, 0)
|
||||
{
|
||||
m_work.InitStorage(m_storage);
|
||||
// @TODO refactor storage
|
||||
m_storage.ReInitCountries(false);
|
||||
}
|
||||
|
||||
void AndroidFramework::SetParentView(jobject view)
|
||||
{
|
||||
m_parentView = view;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct make_all_invalid
|
||||
{
|
||||
size_t m_threadCount;
|
||||
|
||||
make_all_invalid(size_t threadCount)
|
||||
: m_threadCount(threadCount)
|
||||
{}
|
||||
|
||||
void operator() (int, int, int, drule::BaseRule * p)
|
||||
{
|
||||
for (size_t threadID = 0; threadID < m_threadCount; ++threadID)
|
||||
{
|
||||
p->MakeEmptyID(threadID);
|
||||
p->MakeEmptyID2(threadID);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
void AndroidFramework::InitRenderer()
|
||||
{
|
||||
LOG(LDEBUG, ("AF::InitRenderer 1"));
|
||||
|
||||
drule::rules().ForEachRule(make_all_invalid(GetPlatform().CpuCores() + 1));
|
||||
|
||||
// temporary workaround
|
||||
m_work.SetRenderPolicy(shared_ptr<RenderPolicy>(new RenderPolicyST(m_handle, bind(&Framework<model::FeaturesFetcher>::DrawModel, &m_work, _1, _2, _3, _4, _5, false))));
|
||||
|
||||
// m_view->setRenderContext(shared_ptr<yg::gl::RenderContext>());
|
||||
// m_view->setDrawer(shared_ptr<DrawerYG>());
|
||||
|
||||
shared_ptr<yg::gl::RenderContext> pRC = CreateRenderContext();
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 2"));
|
||||
shared_ptr<yg::ResourceManager> pRM = CreateResourceManager();
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 3"));
|
||||
//m_view->setRenderContext(pRC);
|
||||
m_drawer = CreateDrawer(pRM);
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 4"));
|
||||
m_work.InitializeGL(pRC, pRM);
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 5"));
|
||||
|
||||
m_work.ShowAll();
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 6"));
|
||||
}
|
||||
|
||||
void AndroidFramework::Resize(int w, int h)
|
||||
{
|
||||
m_drawer->onSize(w, h);
|
||||
m_work.OnSize(w, h);
|
||||
}
|
||||
|
||||
void AndroidFramework::DrawFrame()
|
||||
{
|
||||
if (m_work.NeedRedraw())
|
||||
{
|
||||
m_work.SetNeedRedraw(false);
|
||||
|
||||
shared_ptr<PaintEvent> paintEvent(new PaintEvent(m_drawer.get()));
|
||||
|
||||
m_work.BeginPaint(paintEvent);
|
||||
m_work.DoPaint(paintEvent);
|
||||
|
||||
m_work.EndPaint(paintEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidFramework::Move(int mode, double x, double y)
|
||||
{
|
||||
DragEvent e(x, y);
|
||||
switch (mode)
|
||||
{
|
||||
case 0: m_work.StartDrag(e); break;
|
||||
case 1: m_work.DoDrag(e); break;
|
||||
case 2: m_work.StopDrag(e); break;
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidFramework::Zoom(int mode, double x1, double y1, double x2, double y2)
|
||||
{
|
||||
ScaleEvent e(x1, y1, x2, y2);
|
||||
switch (mode)
|
||||
{
|
||||
case 0: m_work.StartScale(e); break;
|
||||
case 1: m_work.DoScale(e); break;
|
||||
case 2: m_work.StopScale(e); break;
|
||||
}
|
||||
}
|
||||
|
||||
void f()
|
||||
{
|
||||
// empty location stub
|
||||
}
|
||||
|
||||
void AndroidFramework::EnableLocation(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
m_work.StartLocationService(bind(&f));
|
||||
else
|
||||
m_work.StopLocationService();
|
||||
}
|
||||
|
||||
void AndroidFramework::UpdateLocation(uint64_t timestamp, double lat, double lon, float accuracy)
|
||||
{
|
||||
location::GpsInfo info;
|
||||
info.m_timestamp = static_cast<double>(timestamp);
|
||||
info.m_latitude = lat;
|
||||
info.m_longitude = lon;
|
||||
info.m_horizontalAccuracy = accuracy;
|
||||
info.m_status = location::EAccurateMode;
|
||||
info.m_altitude = 0;
|
||||
info.m_course = 0;
|
||||
info.m_verticalAccuracy = 0;
|
||||
m_work.OnGpsUpdate(info);
|
||||
}
|
||||
|
||||
void AndroidFramework::UpdateCompass(uint64_t timestamp, double magneticNorth, double trueNorth, float accuracy)
|
||||
{
|
||||
location::CompassInfo info;
|
||||
info.m_timestamp = static_cast<double>(timestamp);
|
||||
info.m_magneticHeading = magneticNorth;
|
||||
info.m_trueHeading = trueNorth;
|
||||
info.m_accuracy = accuracy;
|
||||
m_work.OnCompassUpdate(info);
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../map/framework.hpp"
|
||||
#include "../../map/drawer_yg.hpp"
|
||||
#include "../../map/window_handle.hpp"
|
||||
#include "../../map/feature_vec_model.hpp"
|
||||
|
||||
#include "../../storage/storage.hpp"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
class AndroidFramework
|
||||
{
|
||||
|
||||
private:
|
||||
shared_ptr<DrawerYG> m_drawer;
|
||||
shared_ptr<WindowHandle> m_handle;
|
||||
|
||||
Framework<model::FeaturesFetcher> m_work;
|
||||
storage::Storage m_storage;
|
||||
|
||||
JavaVM * m_jvm;
|
||||
jobject m_parentView;
|
||||
|
||||
void CallRepaint();
|
||||
|
||||
public:
|
||||
AndroidFramework(JavaVM * jvm);
|
||||
|
||||
storage::Storage & Storage() { return m_storage; }
|
||||
|
||||
void SetParentView(jobject view);
|
||||
|
||||
void InitRenderer();
|
||||
|
||||
void Resize(int w, int h);
|
||||
|
||||
void DrawFrame();
|
||||
|
||||
void Move(int mode, double x, double y);
|
||||
void Zoom(int mode, double x1, double y1, double x2, double y2);
|
||||
|
||||
void EnableLocation(bool enable);
|
||||
void UpdateLocation(uint64_t timestamp, double lat, double lon, float accuracy);
|
||||
void UpdateCompass(uint64_t timestamp, double magneticNorth, double trueNorth, float accuracy);
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
#include "android_platform.hpp"
|
||||
#include "jni_string.h"
|
||||
|
||||
#include "../../base/logging.hpp"
|
||||
|
||||
void AndroidPlatform::Initialize(JNIEnv * env, jstring apkPath, jstring storagePath)
|
||||
{
|
||||
m_resourcesDir = jni::ToString(env, apkPath);
|
||||
m_writableDir = jni::ToString(env, storagePath);
|
||||
LOG(LDEBUG, ("Apk path = ", m_resourcesDir));
|
||||
LOG(LDEBUG, ("Writable path = ", m_writableDir));
|
||||
}
|
||||
|
||||
AndroidPlatform & GetAndroidPlatform()
|
||||
{
|
||||
static AndroidPlatform platform;
|
||||
return platform;
|
||||
}
|
||||
|
||||
Platform & GetPlatform()
|
||||
{
|
||||
return GetAndroidPlatform();
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../platform/platform.hpp"
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
class AndroidPlatform : public Platform
|
||||
{
|
||||
public:
|
||||
void Initialize(JNIEnv * env, jstring apkPath, jstring storagePath);
|
||||
};
|
||||
|
||||
AndroidPlatform & GetAndroidPlatform();
|
21
android/jni/com/mapswithme/core/concurrent_runner.cpp
Normal file
21
android/jni/com/mapswithme/core/concurrent_runner.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "../../../../../platform/concurrent_runner.hpp"
|
||||
|
||||
namespace threads
|
||||
{
|
||||
ConcurrentRunner::ConcurrentRunner()
|
||||
{
|
||||
}
|
||||
|
||||
ConcurrentRunner::~ConcurrentRunner()
|
||||
{
|
||||
}
|
||||
|
||||
void ConcurrentRunner::Run(RunnerFuncT const & f) const
|
||||
{
|
||||
}
|
||||
|
||||
void ConcurrentRunner::Join()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
28
android/jni/com/mapswithme/core/download_manager.cpp
Normal file
28
android/jni/com/mapswithme/core/download_manager.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* download_manager.cpp
|
||||
*
|
||||
* Created on: Oct 14, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
#include "download_manager.hpp"
|
||||
|
||||
namespace android
|
||||
{
|
||||
void DownloadManager::HttpRequest(HttpStartParams const & params)
|
||||
{}
|
||||
|
||||
void DownloadManager::CancelDownload(string const & url)
|
||||
{}
|
||||
|
||||
void DownloadManager::CancelAllDownloads()
|
||||
{}
|
||||
|
||||
}
|
||||
|
||||
DownloadManager & GetDownloadManager()
|
||||
{
|
||||
static android::DownloadManager manager;
|
||||
return manager;
|
||||
}
|
||||
|
23
android/jni/com/mapswithme/core/download_manager.hpp
Normal file
23
android/jni/com/mapswithme/core/download_manager.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* download_manager.hpp
|
||||
*
|
||||
* Created on: Oct 14, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../../../platform/download_manager.hpp"
|
||||
|
||||
namespace android
|
||||
{
|
||||
class DownloadManager : public ::DownloadManager
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void HttpRequest(HttpStartParams const & params);
|
||||
virtual void CancelDownload(string const & url);
|
||||
virtual void CancelAllDownloads();
|
||||
};
|
||||
}
|
||||
|
||||
DownloadManager & GetDownloadManager();
|
|
@ -1,6 +1,6 @@
|
|||
#include "jni_helper.h"
|
||||
#include "jni_helper.hpp"
|
||||
|
||||
#include "../../base/assert.hpp"
|
||||
#include "../../../../../base/assert.hpp"
|
||||
|
||||
|
||||
namespace jni {
|
|
@ -1,6 +1,6 @@
|
|||
#include "jni_string.h"
|
||||
#include "jni_string.hpp"
|
||||
|
||||
#include "../../base/string_utils.hpp"
|
||||
#include "../../../../../base/string_utils.hpp"
|
||||
|
||||
|
||||
namespace jni
|
|
@ -3,7 +3,7 @@
|
|||
#include <string.h>
|
||||
#include <jni.h>
|
||||
|
||||
#include "../../std/string.hpp"
|
||||
#include "../../../../../std/string.hpp"
|
||||
|
||||
namespace jni
|
||||
{
|
|
@ -1,7 +1,9 @@
|
|||
#include "logging.h"
|
||||
#include "logging.hpp"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include "../../../../../base/assert.hpp"
|
||||
|
||||
namespace jni {
|
||||
|
||||
using namespace my;
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../base/logging.hpp"
|
||||
#include "../../base/assert.hpp"
|
||||
#include "../../../../../base/logging.hpp"
|
||||
|
||||
namespace jni
|
||||
{
|
28
android/jni/com/mapswithme/core/render_context.cpp
Normal file
28
android/jni/com/mapswithme/core/render_context.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* render_context.cpp
|
||||
*
|
||||
* Created on: Oct 14, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
#include "render_context.hpp"
|
||||
|
||||
namespace android
|
||||
{
|
||||
RenderContext::RenderContext()
|
||||
{}
|
||||
|
||||
void RenderContext::makeCurrent()
|
||||
{}
|
||||
|
||||
shared_ptr<yg::gl::RenderContext> RenderContext::createShared()
|
||||
{
|
||||
return make_shared_ptr(new RenderContext());
|
||||
}
|
||||
|
||||
void RenderContext::endThreadDrawing()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
27
android/jni/com/mapswithme/core/render_context.hpp
Normal file
27
android/jni/com/mapswithme/core/render_context.hpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* render_context.hpp
|
||||
*
|
||||
* Created on: Oct 14, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../../../../yg/rendercontext.hpp"
|
||||
|
||||
#include "../../../../../std/shared_ptr.hpp"
|
||||
|
||||
namespace android
|
||||
{
|
||||
class RenderContext : public yg::gl::RenderContext
|
||||
{
|
||||
public:
|
||||
RenderContext();
|
||||
|
||||
virtual void makeCurrent();
|
||||
|
||||
virtual shared_ptr<yg::gl::RenderContext> createShared();
|
||||
|
||||
virtual void endThreadDrawing();
|
||||
};
|
||||
}
|
37
android/jni/com/mapswithme/location/LocationService.cpp
Normal file
37
android/jni/com/mapswithme/location/LocationService.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* LocationService.cpp
|
||||
*
|
||||
* Created on: Oct 13, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include "../maps/Framework.hpp"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// LocationService
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_location_LocationService_nativeEnableLocationService(JNIEnv * env, jobject thiz,
|
||||
jboolean enable)
|
||||
{
|
||||
g_framework->EnableLocation(enable);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_location_LocationService_nativeLocationChanged(JNIEnv * env, jobject thiz,
|
||||
jlong time, jdouble lat, jdouble lon, jfloat accuracy)
|
||||
{
|
||||
g_framework->UpdateLocation(time, lat, lon, accuracy);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_location_LocationService_nativeCompassChanged(JNIEnv * env, jobject thiz,
|
||||
jlong time, jdouble magneticNorth, jdouble trueNorth, jfloat accuracy)
|
||||
{
|
||||
g_framework->UpdateCompass(time, magneticNorth, trueNorth, accuracy);
|
||||
}
|
||||
}
|
50
android/jni/com/mapswithme/maps/DownloadUI.cpp
Normal file
50
android/jni/com/mapswithme/maps/DownloadUI.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* DownloadUI.cpp
|
||||
*
|
||||
* Created on: Oct 13, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include "Framework.hpp"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// DownloadUI
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countriesCount(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
return static_cast<jint>(g_framework->Storage().CountriesCount(storage::TIndex(group, country, region)));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countryName(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
string const name = g_framework->Storage().CountryName(storage::TIndex(group, country, region));
|
||||
return env->NewStringUTF(name.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countrySizeInBytes(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
storage::LocalAndRemoteSizeT const s = g_framework->Storage().CountrySizeInBytes(storage::TIndex(group, country, region));
|
||||
// lower int contains remote size, and upper - local one
|
||||
int64_t mergedSize = s.second;
|
||||
mergedSize |= (s.first << 32);
|
||||
return mergedSize;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countryStatus(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
return static_cast<jint>(g_framework->Storage().CountryStatus(storage::TIndex(group, country, region)));
|
||||
}
|
||||
}
|
||||
|
242
android/jni/com/mapswithme/maps/Framework.cpp
Normal file
242
android/jni/com/mapswithme/maps/Framework.cpp
Normal file
|
@ -0,0 +1,242 @@
|
|||
/*
|
||||
* Framework.cpp
|
||||
*
|
||||
* Created on: Oct 13, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
#include "Framework.hpp"
|
||||
|
||||
#include "../core/jni_helper.hpp"
|
||||
#include "../core/render_context.hpp"
|
||||
|
||||
#include "../../../../../indexer/drawing_rules.hpp"
|
||||
|
||||
#include "../../../../../map/render_policy_st.hpp"
|
||||
#include "../../../../../map/tiling_render_policy_st.hpp"
|
||||
#include "../../../../../map/framework.hpp"
|
||||
|
||||
#include "../../../../../std/shared_ptr.hpp"
|
||||
#include "../../../../../std/bind.hpp"
|
||||
|
||||
|
||||
#include "../../../../../yg/framebuffer.hpp"
|
||||
#include "../../../../../yg/internal/opengl.hpp"
|
||||
|
||||
#include "../../../../../platform/platform.hpp"
|
||||
#include "../../../../../base/logging.hpp"
|
||||
#include "../../../../../base/math.hpp"
|
||||
|
||||
android::Framework * g_framework = 0;
|
||||
|
||||
namespace android
|
||||
{
|
||||
void Framework::CallRepaint()
|
||||
{
|
||||
// Always get current env pointer, it's different for each thread
|
||||
JNIEnv * env;
|
||||
m_jvm->AttachCurrentThread(&env, NULL);
|
||||
env->CallVoidMethod(m_parentView, jni::GetJavaMethodID(env, m_parentView, "requestRender", "()V"));
|
||||
}
|
||||
|
||||
Framework::Framework(JavaVM * jvm)
|
||||
: m_jvm(jvm),
|
||||
m_handle(new WindowHandle()),
|
||||
m_work(m_handle, 0)
|
||||
{
|
||||
ASSERT(g_framework == 0, ());
|
||||
g_framework = this;
|
||||
|
||||
m_work.InitStorage(m_storage);
|
||||
// @TODO refactor storage
|
||||
m_storage.ReInitCountries(false);
|
||||
}
|
||||
|
||||
void Framework::SetParentView(jobject view)
|
||||
{
|
||||
m_parentView = view;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct make_all_invalid
|
||||
{
|
||||
size_t m_threadCount;
|
||||
|
||||
make_all_invalid(size_t threadCount)
|
||||
: m_threadCount(threadCount)
|
||||
{}
|
||||
|
||||
void operator() (int, int, int, drule::BaseRule * p)
|
||||
{
|
||||
for (size_t threadID = 0; threadID < m_threadCount; ++threadID)
|
||||
{
|
||||
p->MakeEmptyID(threadID);
|
||||
p->MakeEmptyID2(threadID);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void Framework::CreateDrawer()
|
||||
{
|
||||
Platform & pl = GetPlatform();
|
||||
|
||||
DrawerYG::params_t p;
|
||||
p.m_resourceManager = m_rm;
|
||||
p.m_glyphCacheID = m_rm->guiThreadGlyphCacheID();
|
||||
p.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(true));
|
||||
p.m_skinName = pl.SkinName();
|
||||
|
||||
m_drawer = make_shared_ptr(new DrawerYG(p));
|
||||
}
|
||||
|
||||
void Framework::CreateResourceManager()
|
||||
{
|
||||
int bigVBSize = pow(2, ceil(log(15000.0 * sizeof(yg::gl::Vertex)) / log(2)));
|
||||
int bigIBSize = pow(2, ceil(log(30000.0 * sizeof(unsigned short)) / log(2)));
|
||||
|
||||
int smallVBSize = pow(2, ceil(log(1500.0 * sizeof(yg::gl::Vertex)) / log(2)));
|
||||
int smallIBSize = pow(2, ceil(log(3000.0 * sizeof(unsigned short)) / log(2)));
|
||||
|
||||
int blitVBSize = pow(2, ceil(log(10.0 * sizeof(yg::gl::AuxVertex)) / log(2)));
|
||||
int blitIBSize = pow(2, ceil(log(10.0 * sizeof(unsigned short)) / log(2)));
|
||||
|
||||
Platform & pl = GetPlatform();
|
||||
m_rm = make_shared_ptr(new yg::ResourceManager(
|
||||
bigVBSize, bigIBSize, 4,
|
||||
smallVBSize, smallIBSize, 10,
|
||||
blitVBSize, blitIBSize, 10,
|
||||
512, 256, 6,
|
||||
512, 256, 4,
|
||||
"unicode_blocks.txt",
|
||||
"fonts_whitelist.txt",
|
||||
"fonts_blacklist.txt",
|
||||
2 * 1024 * 1024,
|
||||
GetPlatform().CpuCores() + 1,
|
||||
yg::Rt8Bpp,
|
||||
false));
|
||||
|
||||
Platform::FilesList fonts;
|
||||
pl.GetFontNames(fonts);
|
||||
m_rm->addFonts(fonts);
|
||||
}
|
||||
|
||||
void Framework::InitRenderer()
|
||||
{
|
||||
LOG(LDEBUG, ("AF::InitRenderer 1"));
|
||||
|
||||
drule::rules().ForEachRule(make_all_invalid(GetPlatform().CpuCores() + 1));
|
||||
|
||||
// temporary workaround
|
||||
m_work.SetRenderPolicy(shared_ptr<RenderPolicy>(new RenderPolicyST(m_handle, bind(&::Framework<model::FeaturesFetcher>::DrawModel, &m_work, _1, _2, _3, _4, _5, false))));
|
||||
|
||||
m_rc = make_shared_ptr(new android::RenderContext());
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 2"));
|
||||
CreateResourceManager();
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 3"));
|
||||
//m_view->setRenderContext(pRC);
|
||||
CreateDrawer();
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 4"));
|
||||
m_work.InitializeGL(m_rc, m_rm);
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 5"));
|
||||
|
||||
m_work.ShowAll();
|
||||
|
||||
LOG(LDEBUG, ("AF::InitRenderer 6"));
|
||||
}
|
||||
|
||||
storage::Storage & Framework::Storage()
|
||||
{
|
||||
return m_storage;
|
||||
}
|
||||
|
||||
void Framework::Resize(int w, int h)
|
||||
{
|
||||
m_drawer->onSize(w, h);
|
||||
m_work.OnSize(w, h);
|
||||
}
|
||||
|
||||
void Framework::DrawFrame()
|
||||
{
|
||||
if (m_work.NeedRedraw())
|
||||
{
|
||||
m_work.SetNeedRedraw(false);
|
||||
|
||||
shared_ptr<PaintEvent> paintEvent(new PaintEvent(m_drawer.get()));
|
||||
|
||||
m_work.BeginPaint(paintEvent);
|
||||
m_work.DoPaint(paintEvent);
|
||||
|
||||
m_work.EndPaint(paintEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::Move(int mode, double x, double y)
|
||||
{
|
||||
DragEvent e(x, y);
|
||||
switch (mode)
|
||||
{
|
||||
case 0: m_work.StartDrag(e); break;
|
||||
case 1: m_work.DoDrag(e); break;
|
||||
case 2: m_work.StopDrag(e); break;
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::Zoom(int mode, double x1, double y1, double x2, double y2)
|
||||
{
|
||||
ScaleEvent e(x1, y1, x2, y2);
|
||||
switch (mode)
|
||||
{
|
||||
case 0: m_work.StartScale(e); break;
|
||||
case 1: m_work.DoScale(e); break;
|
||||
case 2: m_work.StopScale(e); break;
|
||||
}
|
||||
}
|
||||
|
||||
void f()
|
||||
{
|
||||
// empty location stub
|
||||
}
|
||||
|
||||
void Framework::EnableLocation(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
m_work.StartLocationService(bind(&f));
|
||||
else
|
||||
m_work.StopLocationService();
|
||||
}
|
||||
|
||||
void Framework::UpdateLocation(uint64_t timestamp, double lat, double lon, float accuracy)
|
||||
{
|
||||
location::GpsInfo info;
|
||||
info.m_timestamp = static_cast<double>(timestamp);
|
||||
info.m_latitude = lat;
|
||||
info.m_longitude = lon;
|
||||
info.m_horizontalAccuracy = accuracy;
|
||||
info.m_status = location::EAccurateMode;
|
||||
info.m_altitude = 0;
|
||||
info.m_course = 0;
|
||||
info.m_verticalAccuracy = 0;
|
||||
m_work.OnGpsUpdate(info);
|
||||
}
|
||||
|
||||
void Framework::UpdateCompass(uint64_t timestamp, double magneticNorth, double trueNorth, float accuracy)
|
||||
{
|
||||
location::CompassInfo info;
|
||||
info.m_timestamp = static_cast<double>(timestamp);
|
||||
info.m_magneticHeading = magneticNorth;
|
||||
info.m_trueHeading = trueNorth;
|
||||
info.m_accuracy = accuracy;
|
||||
m_work.OnCompassUpdate(info);
|
||||
}
|
||||
|
||||
JavaVM * Framework::javaVM() const
|
||||
{
|
||||
return m_jvm;
|
||||
}
|
||||
}
|
67
android/jni/com/mapswithme/maps/Framework.hpp
Normal file
67
android/jni/com/mapswithme/maps/Framework.hpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Framework.hpp
|
||||
*
|
||||
* Created on: Oct 13, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "../../../../../map/framework.hpp"
|
||||
#include "../../../../../map/drawer_yg.hpp"
|
||||
#include "../../../../../map/window_handle.hpp"
|
||||
#include "../../../../../map/feature_vec_model.hpp"
|
||||
|
||||
#include "../../../../../storage/storage.hpp"
|
||||
|
||||
namespace android
|
||||
{
|
||||
class Framework
|
||||
{
|
||||
private:
|
||||
|
||||
JavaVM * m_jvm;
|
||||
jobject m_parentView;
|
||||
|
||||
shared_ptr<DrawerYG> m_drawer;
|
||||
shared_ptr<WindowHandle> m_handle;
|
||||
shared_ptr<yg::ResourceManager> m_rm;
|
||||
shared_ptr<yg::gl::RenderContext> m_rc;
|
||||
|
||||
::Framework<model::FeaturesFetcher> m_work;
|
||||
storage::Storage m_storage;
|
||||
|
||||
|
||||
void CallRepaint();
|
||||
|
||||
void CreateDrawer();
|
||||
|
||||
void CreateResourceManager();
|
||||
|
||||
public:
|
||||
|
||||
Framework(JavaVM * jvm);
|
||||
|
||||
storage::Storage & Storage();
|
||||
|
||||
void SetParentView(jobject view);
|
||||
|
||||
void InitRenderer();
|
||||
|
||||
void Resize(int w, int h);
|
||||
|
||||
void DrawFrame();
|
||||
|
||||
void Move(int mode, double x, double y);
|
||||
void Zoom(int mode, double x1, double y1, double x2, double y2);
|
||||
|
||||
void EnableLocation(bool enable);
|
||||
void UpdateLocation(uint64_t timestamp, double lat, double lon, float accuracy);
|
||||
void UpdateCompass(uint64_t timestamp, double magneticNorth, double trueNorth, float accuracy);
|
||||
|
||||
JavaVM * javaVM() const;
|
||||
};
|
||||
}
|
||||
|
||||
extern android::Framework * g_framework;
|
29
android/jni/com/mapswithme/maps/GesturesProcessor.cpp
Normal file
29
android/jni/com/mapswithme/maps/GesturesProcessor.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* GesturesProcessor.cpp
|
||||
*
|
||||
* Created on: Oct 13, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include "Framework.hpp"
|
||||
#include "../../../../../base/assert.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_GesturesProcessor_nativeMove(JNIEnv * env,
|
||||
jobject thiz, jint mode, jdouble x, jdouble y)
|
||||
{
|
||||
ASSERT ( g_framework, () );
|
||||
g_framework->Move(mode, x, y);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_GesturesProcessor_nativeZoom(JNIEnv * env,
|
||||
jobject thiz, jint mode, jdouble x1, jdouble y1, jdouble x2, jdouble y2)
|
||||
{
|
||||
ASSERT ( g_framework, () );
|
||||
g_framework->Zoom(mode, x1, y1, x2, y2);
|
||||
}
|
||||
}
|
55
android/jni/com/mapswithme/maps/MWMActivity.cpp
Normal file
55
android/jni/com/mapswithme/maps/MWMActivity.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* MWMActivity.cpp
|
||||
*
|
||||
* Created on: Oct 13, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MWMActivity
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "../core/logging.hpp"
|
||||
|
||||
#include "Framework.hpp"
|
||||
#include "Platform.hpp"
|
||||
|
||||
JavaVM * g_jvm;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT jint JNICALL
|
||||
JNI_OnLoad(JavaVM * jvm, void * reserved)
|
||||
{
|
||||
g_jvm = jvm;
|
||||
jni::InitSystemLog();
|
||||
jni::InitAssertLog();
|
||||
LOG(LDEBUG, ("JNI_OnLoad"));
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNI_OnUnload(JavaVM * vm, void * reserved)
|
||||
{
|
||||
delete g_framework;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject thiz, jstring apkPath, jstring storagePath)
|
||||
{
|
||||
LOG(LDEBUG, ("Java_com_mapswithme_maps_MWMActivity_nativeInit 1"));
|
||||
if (!g_framework)
|
||||
{
|
||||
android::Platform::Instance().Initialize(env, apkPath, storagePath);
|
||||
g_framework = new android::Framework(g_jvm);
|
||||
}
|
||||
|
||||
LOG(LDEBUG, ("Java_com_mapswithme_maps_MWMActivity_nativeInit 2"));
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
|
||||
|
||||
|
48
android/jni/com/mapswithme/maps/MainGLView.cpp
Normal file
48
android/jni/com/mapswithme/maps/MainGLView.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* MainGLView.cpp
|
||||
*
|
||||
* Created on: Oct 13, 2011
|
||||
* Author: siarheirachytski
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include "Framework.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MainGLView
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainGLView_nativeInit(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
ASSERT ( g_framework, () );
|
||||
g_framework->SetParentView(thiz);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MainRenderer
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeInit(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
ASSERT ( g_framework, () );
|
||||
g_framework->InitRenderer();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeResize(JNIEnv * env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
ASSERT ( g_framework, () );
|
||||
g_framework->Resize(w, h);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeDraw(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
ASSERT ( g_framework, () );
|
||||
g_framework->DrawFrame();
|
||||
}
|
||||
}
|
28
android/jni/com/mapswithme/maps/Platform.cpp
Normal file
28
android/jni/com/mapswithme/maps/Platform.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "Platform.hpp"
|
||||
|
||||
#include "../core/jni_string.hpp"
|
||||
|
||||
#include "../../../../../base/logging.hpp"
|
||||
|
||||
namespace android
|
||||
{
|
||||
void Platform::Initialize(JNIEnv * env, jstring apkPath, jstring storagePath)
|
||||
{
|
||||
m_resourcesDir = jni::ToString(env, apkPath);
|
||||
m_writableDir = jni::ToString(env, storagePath);
|
||||
LOG(LDEBUG, ("Apk path = ", m_resourcesDir));
|
||||
LOG(LDEBUG, ("Writable path = ", m_writableDir));
|
||||
}
|
||||
|
||||
Platform & Platform::Instance()
|
||||
{
|
||||
static Platform platform;
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
|
||||
Platform & GetPlatform()
|
||||
{
|
||||
return android::Platform::Instance();
|
||||
}
|
||||
|
18
android/jni/com/mapswithme/maps/Platform.hpp
Normal file
18
android/jni/com/mapswithme/maps/Platform.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "../../../../../platform/platform.hpp"
|
||||
|
||||
namespace android
|
||||
{
|
||||
class Platform : public ::Platform
|
||||
{
|
||||
public:
|
||||
void Initialize(JNIEnv * env, jstring apkPath, jstring storagePath);
|
||||
|
||||
static Platform & Instance();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1,162 +0,0 @@
|
|||
#include "logging.h"
|
||||
#include "android_platform.hpp"
|
||||
#include "android_framework.hpp"
|
||||
|
||||
#include "../../storage/storage.hpp"
|
||||
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
|
||||
static AndroidFramework * g_work = 0;
|
||||
static JavaVM * g_jvm = 0;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MWMActivity
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
JNI_OnLoad(JavaVM * jvm, void * reserved)
|
||||
{
|
||||
g_jvm = jvm;
|
||||
jni::InitSystemLog();
|
||||
jni::InitAssertLog();
|
||||
LOG(LDEBUG, ("JNI_OnLoad"));
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNI_OnUnload(JavaVM * vm, void * reserved)
|
||||
{
|
||||
delete g_work;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject thiz, jstring apkPath, jstring storagePath)
|
||||
{
|
||||
LOG(LDEBUG, ("Java_com_mapswithme_maps_MWMActivity_nativeInit 1"));
|
||||
if (!g_work)
|
||||
{
|
||||
GetAndroidPlatform().Initialize(env, apkPath, storagePath);
|
||||
g_work = new AndroidFramework(g_jvm);
|
||||
}
|
||||
|
||||
LOG(LDEBUG, ("Java_com_mapswithme_maps_MWMActivity_nativeInit 2"));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MainGLView
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainGLView_nativeInit(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
ASSERT ( g_work, () );
|
||||
g_work->SetParentView(thiz);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_GesturesProcessor_nativeMove(JNIEnv * env,
|
||||
jobject thiz, jint mode, jdouble x, jdouble y)
|
||||
{
|
||||
ASSERT ( g_work, () );
|
||||
g_work->Move(mode, x, y);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_GesturesProcessor_nativeZoom(JNIEnv * env,
|
||||
jobject thiz, jint mode, jdouble x1, jdouble y1, jdouble x2, jdouble y2)
|
||||
{
|
||||
ASSERT ( g_work, () );
|
||||
g_work->Zoom(mode, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// MainRenderer
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeInit(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
ASSERT ( g_work, () );
|
||||
g_work->InitRenderer();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeResize(JNIEnv * env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
ASSERT ( g_work, () );
|
||||
g_work->Resize(w, h);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MainRenderer_nativeDraw(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
ASSERT ( g_work, () );
|
||||
g_work->DrawFrame();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// DownloadUI
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countriesCount(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
return static_cast<jint>(g_work->Storage().CountriesCount(storage::TIndex(group, country, region)));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countryName(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
string const name = g_work->Storage().CountryName(storage::TIndex(group, country, region));
|
||||
return env->NewStringUTF(name.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countrySizeInBytes(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
storage::LocalAndRemoteSizeT const s = g_work->Storage().CountrySizeInBytes(storage::TIndex(group, country, region));
|
||||
// lower int contains remote size, and upper - local one
|
||||
int64_t mergedSize = s.second;
|
||||
mergedSize |= (s.first << 32);
|
||||
return mergedSize;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countryStatus(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
return static_cast<jint>(g_work->Storage().CountryStatus(storage::TIndex(group, country, region)));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// LocationService
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_location_LocationService_nativeEnableLocationService(JNIEnv * env, jobject thiz,
|
||||
jboolean enable)
|
||||
{
|
||||
g_work->EnableLocation(enable);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_location_LocationService_nativeLocationChanged(JNIEnv * env, jobject thiz,
|
||||
jlong time, jdouble lat, jdouble lon, jfloat accuracy)
|
||||
{
|
||||
g_work->UpdateLocation(time, lat, lon, accuracy);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_location_LocationService_nativeCompassChanged(JNIEnv * env, jobject thiz,
|
||||
jlong time, jdouble magneticNorth, jdouble trueNorth, jfloat accuracy)
|
||||
{
|
||||
g_work->UpdateCompass(time, magneticNorth, trueNorth, accuracy);
|
||||
}
|
||||
|
||||
} // extern "C"
|
|
@ -1,84 +0,0 @@
|
|||
#include "rendering.h"
|
||||
|
||||
#include "../../yg/framebuffer.hpp"
|
||||
#include "../../yg/internal/opengl.hpp"
|
||||
|
||||
#include "../../platform/platform.hpp"
|
||||
|
||||
#include "../../base/math.hpp"
|
||||
|
||||
|
||||
shared_ptr<yg::ResourceManager> CreateResourceManager()
|
||||
{
|
||||
int bigVBSize = pow(2, ceil(log(15000.0 * sizeof(yg::gl::Vertex)) / log(2)));
|
||||
int bigIBSize = pow(2, ceil(log(30000.0 * sizeof(unsigned short)) / log(2)));
|
||||
|
||||
int smallVBSize = pow(2, ceil(log(1500.0 * sizeof(yg::gl::Vertex)) / log(2)));
|
||||
int smallIBSize = pow(2, ceil(log(3000.0 * sizeof(unsigned short)) / log(2)));
|
||||
|
||||
int blitVBSize = pow(2, ceil(log(10.0 * sizeof(yg::gl::AuxVertex)) / log(2)));
|
||||
int blitIBSize = pow(2, ceil(log(10.0 * sizeof(unsigned short)) / log(2)));
|
||||
|
||||
Platform & pl = GetPlatform();
|
||||
yg::ResourceManager * pRM = new yg::ResourceManager(
|
||||
bigVBSize, bigIBSize, 4,
|
||||
smallVBSize, smallIBSize, 10,
|
||||
blitVBSize, blitIBSize, 10,
|
||||
512, 256, 6,
|
||||
512, 256, 4,
|
||||
"unicode_blocks.txt",
|
||||
"fonts_whitelist.txt",
|
||||
"fonts_blacklist.txt",
|
||||
2 * 1024 * 1024,
|
||||
GetPlatform().CpuCores() + 1,
|
||||
yg::Rt8Bpp,
|
||||
false);
|
||||
|
||||
Platform::FilesList fonts;
|
||||
pl.GetFontNames(fonts);
|
||||
pRM->addFonts(fonts);
|
||||
|
||||
return make_shared_ptr(pRM);
|
||||
}
|
||||
|
||||
shared_ptr<DrawerYG> CreateDrawer(shared_ptr<yg::ResourceManager> pRM)
|
||||
{
|
||||
Platform & pl = GetPlatform();
|
||||
|
||||
DrawerYG::params_t p;
|
||||
p.m_resourceManager = pRM;
|
||||
p.m_glyphCacheID = pRM->guiThreadGlyphCacheID();
|
||||
p.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(true));
|
||||
p.m_skinName = pl.SkinName();
|
||||
|
||||
return make_shared_ptr(new DrawerYG(p));
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class AndroidRenderContext : public yg::gl::RenderContext
|
||||
{
|
||||
public:
|
||||
AndroidRenderContext()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void makeCurrent()
|
||||
{
|
||||
}
|
||||
|
||||
virtual shared_ptr<yg::gl::RenderContext> createShared()
|
||||
{
|
||||
return make_shared_ptr(new AndroidRenderContext());
|
||||
}
|
||||
|
||||
virtual void endThreadDrawing()
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
shared_ptr<yg::gl::RenderContext> CreateRenderContext()
|
||||
{
|
||||
return make_shared_ptr(new AndroidRenderContext());
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../map/drawer_yg.hpp"
|
||||
|
||||
#include "../../yg/rendercontext.hpp"
|
||||
#include "../../yg/resource_manager.hpp"
|
||||
#include "../../std/shared_ptr.hpp"
|
||||
|
||||
|
||||
shared_ptr<yg::ResourceManager> CreateResourceManager();
|
||||
|
||||
shared_ptr<yg::gl::RenderContext> CreateRenderContext();
|
||||
|
||||
shared_ptr<DrawerYG> CreateDrawer(shared_ptr<yg::ResourceManager> pRM);
|
|
@ -1,45 +0,0 @@
|
|||
#include "../../platform/concurrent_runner.hpp"
|
||||
|
||||
#include "../../platform/download_manager.hpp"
|
||||
|
||||
namespace threads
|
||||
{
|
||||
ConcurrentRunner::ConcurrentRunner()
|
||||
{
|
||||
}
|
||||
|
||||
ConcurrentRunner::~ConcurrentRunner()
|
||||
{
|
||||
}
|
||||
|
||||
void ConcurrentRunner::Run(RunnerFuncT const & f) const
|
||||
{
|
||||
}
|
||||
|
||||
void ConcurrentRunner::Join()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class AndroidDownloadManager : public DownloadManager
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void HttpRequest(HttpStartParams const & params)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void CancelDownload(string const & url)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void CancelAllDownloads()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
DownloadManager & GetDownloadManager()
|
||||
{
|
||||
static AndroidDownloadManager manager;
|
||||
return manager;
|
||||
}
|
Loading…
Add table
Reference in a new issue