From 956f41c5db82a527ac8bc8e53ff1ff9f41a50e76 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Thu, 24 Sep 2015 16:58:58 +0300 Subject: [PATCH] Rebase fixes after migration to github --- android/UnitTests/jni/mock.cpp | 5 - android/jni/com/mapswithme/maps/Framework.cpp | 15 +- android/jni/com/mapswithme/maps/Framework.hpp | 1 + .../jni/com/mapswithme/maps/LocationState.cpp | 2 + .../jni/com/mapswithme/maps/SearchEngine.cpp | 11 +- .../src/com/mapswithme/maps/Framework.java | 4 - .../src/com/mapswithme/maps/MwmActivity.java | 9 +- .../com/mapswithme/maps/RenderFragment.java | 2 +- .../maps/widget/placepage/PlacePageView.java | 1 - .../com/nvidia/devtech/BaseEglWrapper.java | 110 ---- .../src/com/nvidia/devtech/Egl10Wrapper.java | 383 -------------- .../src/com/nvidia/devtech/Egl14Wrapper.java | 361 ------------- .../src/com/nvidia/devtech/EglWrapper.java | 82 --- .../nvidia/devtech/NvEventQueueFragment.java | 316 ----------- drape/symbols_texture.cpp | 2 +- drape_frontend/drape_engine.cpp | 12 + drape_frontend/drape_engine.hpp | 1 + drape_frontend/frontend_renderer.cpp | 10 + drape_frontend/line_shape_helper.cpp | 20 +- drape_frontend/line_shape_helper.hpp | 4 +- drape_frontend/message.hpp | 1 + drape_frontend/message_subclasses.hpp | 32 +- .../Maps/Classes/MWMPlacePageViewManager.mm | 3 + iphone/Maps/Classes/MapViewController.mm | 21 +- map/bookmark.cpp | 2 +- map/bookmark_manager.cpp | 36 +- map/bookmark_manager.hpp | 2 + map/country_status_display.cpp | 496 ------------------ map/country_status_display.hpp | 87 --- map/framework.cpp | 36 +- map/framework.hpp | 1 + map/information_display.cpp | 93 ---- map/information_display.hpp | 44 -- map/location_state.cpp | 404 -------------- map/location_state.hpp | 61 --- map/move_screen_task.cpp | 35 -- map/move_screen_task.hpp | 25 - map/navigator_utils.cpp | 27 - map/navigator_utils.hpp | 15 - map/qgl_render_context.cpp | 70 --- map/qgl_render_context.hpp | 41 -- map/route_track.cpp | 323 ------------ map/route_track.hpp | 42 -- 43 files changed, 133 insertions(+), 3115 deletions(-) delete mode 100644 android/src/com/nvidia/devtech/BaseEglWrapper.java delete mode 100644 android/src/com/nvidia/devtech/Egl10Wrapper.java delete mode 100644 android/src/com/nvidia/devtech/Egl14Wrapper.java delete mode 100644 android/src/com/nvidia/devtech/EglWrapper.java delete mode 100644 android/src/com/nvidia/devtech/NvEventQueueFragment.java delete mode 100644 map/country_status_display.cpp delete mode 100644 map/country_status_display.hpp delete mode 100644 map/information_display.cpp delete mode 100644 map/information_display.hpp delete mode 100644 map/location_state.cpp delete mode 100644 map/location_state.hpp delete mode 100644 map/move_screen_task.cpp delete mode 100644 map/move_screen_task.hpp delete mode 100644 map/navigator_utils.cpp delete mode 100644 map/navigator_utils.hpp delete mode 100644 map/qgl_render_context.cpp delete mode 100644 map/qgl_render_context.hpp delete mode 100644 map/route_track.cpp delete mode 100644 map/route_track.hpp diff --git a/android/UnitTests/jni/mock.cpp b/android/UnitTests/jni/mock.cpp index 2177ea92a2..6004160caf 100644 --- a/android/UnitTests/jni/mock.cpp +++ b/android/UnitTests/jni/mock.cpp @@ -189,11 +189,6 @@ namespace android_tests bool HasAvailableSpaceForWriting(uint64_t size) const{ return true; } - static void RunOnGuiThreadImpl(TFunctor const & fn, bool blocking = false) - { - ASSERT(false, ()); - } - static Platform & Instance() { static Platform platform; diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 20944564c9..e7d2a42914 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -478,6 +478,11 @@ location::EMyPositionMode Framework::GetMyPositionMode() const return m_currentMode; } +void Framework::SetMyPositionMode(location::EMyPositionMode mode) +{ + m_currentMode = mode; +} + ////////////////////////////////////////////////////////////////////////////////////////// void Framework::ItemStatusChanged(int childPosition) { @@ -1333,16 +1338,6 @@ extern "C" frm()->SetRouteFinishPoint(m2::PointD(MercatorBounds::FromLatLon(lat, lon)), static_cast(valid)); } - JNIEXPORT void JNICALL - Java_com_mapswithme_maps_Framework_setWidgetPivot(JNIEnv * env, jclass thiz, jint widget, jint pivotX, jint pivotY) - { -//TODO (UVR) -// using WidgetType = InformationDisplay::WidgetType; -// WidgetType const widgetType = static_cast(widget); -// m2::PointD const pivot = m2::PointD(pivotX, pivotY); -// android::Platform::RunOnGuiThreadImpl(bind(&Framework::SetWidgetPivot, frm(), widgetType, pivot)); - } - JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeRegisterMaps(JNIEnv * env, jclass thiz) { diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index 8364b3ea0d..cfdff2a79c 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -166,6 +166,7 @@ namespace android void SetMyPositionModeListener(location::TMyPositionModeChanged const & fn); location::EMyPositionMode GetMyPositionMode() const; + void SetMyPositionMode(location::EMyPositionMode mode); // Fills mapobject's metadata from UserMark void InjectMetadata(JNIEnv * env, jclass clazz, jobject const mapObject, UserMark const * userMark); diff --git a/android/jni/com/mapswithme/maps/LocationState.cpp b/android/jni/com/mapswithme/maps/LocationState.cpp index 0f2940a2c9..319261b198 100644 --- a/android/jni/com/mapswithme/maps/LocationState.cpp +++ b/android/jni/com/mapswithme/maps/LocationState.cpp @@ -20,6 +20,8 @@ extern "C" void LocationStateModeChanged(location::EMyPositionMode mode, shared_ptr const & obj) { + g_framework->SetMyPositionMode(mode); + JNIEnv * env = jni::GetEnv(); env->CallVoidMethod(*obj.get(), jni::GetJavaMethodID(env, *obj.get(), "onMyPositionModeChangedCallback", "(I)V"), static_cast(mode)); } diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp index 0dd6f178ff..7ec30d3e29 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.cpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp @@ -204,10 +204,7 @@ extern "C" g_framework->DontLoadState(); Result const & result = g_results.GetResult(index); - android::Platform::RunOnGuiThreadImpl([result]() - { - g_framework->NativeFramework()->ShowSearchResult(result); - }); + g_framework->NativeFramework()->ShowSearchResult(result); } JNIEXPORT void JNICALL @@ -215,11 +212,7 @@ extern "C" { lock_guard guard(g_resultsMutex); g_framework->DontLoadState(); - - android::Platform::RunOnGuiThreadImpl([results=g_results]() - { - g_framework->NativeFramework()->ShowAllSearchResults(results); - }); + g_framework->NativeFramework()->ShowAllSearchResults(g_results); } JNIEXPORT void JNICALL diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java index 44c9b4e865..e25dda3a2c 100644 --- a/android/src/com/mapswithme/maps/Framework.java +++ b/android/src/com/mapswithme/maps/Framework.java @@ -101,8 +101,6 @@ public class Framework public native static void injectData(SearchResult searchResult, long index); - public native static void invalidate(); - public native static void deactivatePopup(); public native static String[] nativeGetMovableFilesExts(); @@ -180,8 +178,6 @@ public class Framework public native static void nativeSetRouteEndPoint(double lat, double lon, boolean valid); - public native static void setWidgetPivot(int widget, int pivotX, int pivotY); - /** * Registers all maps(.mwms). Adds them to the models, generates indexes and does all necessary stuff. */ diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 893c276b13..2e6d19881a 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -165,13 +165,8 @@ public class MwmActivity extends BaseMwmFragmentActivity @Override public void onRenderingInitialized() { - runOnUiThread(new Runnable() { - @Override - public void run() { - checkMeasurementSystem(); - checkKitkatMigrationMove(); - } - }); + checkMeasurementSystem(); + checkKitkatMigrationMove(); runTasks(); } diff --git a/android/src/com/mapswithme/maps/RenderFragment.java b/android/src/com/mapswithme/maps/RenderFragment.java index ac73d7b85b..d0e981de08 100644 --- a/android/src/com/mapswithme/maps/RenderFragment.java +++ b/android/src/com/mapswithme/maps/RenderFragment.java @@ -49,8 +49,8 @@ public abstract class RenderFragment extends BaseMwmFragment if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || getActivity() == null || !getActivity().isChangingConfigurations()) { - MwmApplication.get().clearFunctorsOnUiThread(); destroyEngine(); + MwmApplication.get().clearFunctorsOnUiThread(); } else { diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index a21b145230..4234e7f4f2 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -818,7 +818,6 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene } }); } - Framework.invalidate(); } private void selectBookmarkSet() diff --git a/android/src/com/nvidia/devtech/BaseEglWrapper.java b/android/src/com/nvidia/devtech/BaseEglWrapper.java deleted file mode 100644 index 2c8156f50f..0000000000 --- a/android/src/com/nvidia/devtech/BaseEglWrapper.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.nvidia.devtech; - -import android.opengl.EGL14; - -import javax.microedition.khronos.egl.EGL10; - -abstract public class BaseEglWrapper extends EglWrapper -{ - private static final int EGL_RENDERABLE_TYPE = 0x3040; - private static final int EGL_OPENGL_ES2_BIT = 0x0004; - private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098; - - // The number of bits requested for the red component - private static int redSize = 5; - // The number of bits requested for the green component - private static int greenSize = 6; - // The number of bits requested for the blue component - private static int blueSize = 5; - // The number of bits requested for the alpha component - private static int alphaSize = 0; - // The number of bits requested for the stencil component - private static int stencilSize = 0; - // The number of bits requested for the depth component - private static int depthSize = 16; - - protected int[] GetConfigAttributes10() - { - final int[] configAttributes = new int[]{EGL10.EGL_RED_SIZE, redSize, - EGL10.EGL_GREEN_SIZE, greenSize, - EGL10.EGL_BLUE_SIZE, blueSize, - EGL10.EGL_ALPHA_SIZE, alphaSize, - EGL10.EGL_STENCIL_SIZE, stencilSize, - EGL10.EGL_DEPTH_SIZE, depthSize, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL10.EGL_NONE}; - - return configAttributes; - } - - protected int[] GetSurfaceAttributes10() - { - return new int[]{EGL10.EGL_NONE}; - } - - protected int[] GetContextAttributes10() - { - return new int[]{EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE}; - } - - protected int[] GetConfigAttributes14() - { - final int[] configAttributes = new int[]{EGL14.EGL_RED_SIZE, redSize, - EGL14.EGL_GREEN_SIZE, greenSize, - EGL14.EGL_BLUE_SIZE, blueSize, - EGL14.EGL_ALPHA_SIZE, alphaSize, - EGL14.EGL_STENCIL_SIZE, stencilSize, - EGL14.EGL_DEPTH_SIZE, depthSize, - EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, - EGL14.EGL_NONE}; - - return configAttributes; - } - - protected int[] GetSurfaceAttributes14() - { - return new int[]{EGL14.EGL_NONE}; - } - - protected int[] GetContextAttributes14() - { - return new int[]{EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE}; - } - - protected boolean ValidateSurfaceSize() - { - return GetSurfaceWidth() * GetSurfaceWidth() != 0; - } - - public class ConfigComparatorBase - { - private int EglNone; - private int EglSlowConfig; - private int EglNonConformantConfig; - - public ConfigComparatorBase(int eglNone, int eglSlow, int eglNonComformant) - { - EglNone = eglNone; - EglSlowConfig = eglSlow; - EglNonConformantConfig = eglNonComformant; - } - - public int CompareConfigs(int rCav, int lCav) - { - if (lCav != rCav) - return GetCaveatValue(lCav) - GetCaveatValue(rCav); - - return 0; - } - - int GetCaveatValue(int cav) - { - if (cav == EglSlowConfig) - return 1; - else if (cav == EglNonConformantConfig) - return 2; - - return 0; - } - } -} diff --git a/android/src/com/nvidia/devtech/Egl10Wrapper.java b/android/src/com/nvidia/devtech/Egl10Wrapper.java deleted file mode 100644 index 1f4b6c8d9d..0000000000 --- a/android/src/com/nvidia/devtech/Egl10Wrapper.java +++ /dev/null @@ -1,383 +0,0 @@ -package com.nvidia.devtech; - -import android.os.Build; -import android.view.SurfaceHolder; - -import com.mapswithme.util.log.Logger; - -import java.util.Arrays; -import java.util.Comparator; - -import javax.microedition.khronos.egl.EGL10; -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.egl.EGLContext; -import javax.microedition.khronos.egl.EGLDisplay; -import javax.microedition.khronos.egl.EGLSurface; - -public class Egl10Wrapper extends BaseEglWrapper -{ - private static final String TAG = "Egl10Wrapper"; - - final private EGL10 mEgl = (EGL10) EGLContext.getEGL(); - - private EGLDisplay mDisplay = EGL10.EGL_NO_DISPLAY; - private EGLContext mContext = EGL10.EGL_NO_CONTEXT; - private EGLSurface mSurface = EGL10.EGL_NO_SURFACE; - private EGLConfig mConfig = null; - - private EGLConfig[] mConfigs = new EGLConfig[40]; - - private int mChoosenConfigIndex = 0; - private int mActualConfigsNumber[] = new int[]{0}; - - private Logger mLog = null; - - public Egl10Wrapper(Logger logger) - { - mLog = logger; - } - - private class EGLConfigComparator extends ConfigComparatorBase - implements Comparator - { - EGLConfigComparator() - { - super(EGL10.EGL_NONE, EGL10.EGL_SLOW_CONFIG, EGL10.EGL_NON_CONFORMANT_CONFIG); - } - - @Override - public int compare(EGLConfig l, EGLConfig r) - { - final int[] value = new int[1]; - - /// splitting by EGL_CONFIG_CAVEAT, - /// firstly selecting EGL_NONE, then EGL_SLOW_CONFIG - /// and then EGL_NON_CONFORMANT_CONFIG - mEgl.eglGetConfigAttrib(mDisplay, l, EGL10.EGL_CONFIG_CAVEAT, value); - final int lcav = value[0]; - - mEgl.eglGetConfigAttrib(mDisplay, r, EGL10.EGL_CONFIG_CAVEAT, value); - final int rcav = value[0]; - - return CompareConfigs(rcav, lcav); - } - } - - ; - - @Override - public boolean InitEGL() - { - mDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); - if (mDisplay == EGL10.EGL_NO_DISPLAY) - { - LogIt("eglGetDisplay failed"); - return false; - } - - int[] version = new int[2]; - if (!mEgl.eglInitialize(mDisplay, version)) - { - LogIt("eglInitialize failed"); - return false; - } - - if (version[0] != 1 && version[1] >= 4 && Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) - { - LogIt("Incorrect EGL wrapper choosed"); - return false; - } - - if (!mEgl.eglChooseConfig(mDisplay, GetConfigAttributes10(), mConfigs, mConfigs.length, mActualConfigsNumber)) - { - LogEgl("eglChooseConfig failed with error "); - return false; - } - - if (mActualConfigsNumber[0] == 0) - { - LogIt("eglChooseConfig returned zero configs"); - return false; - } - - Arrays.sort(mConfigs, 0, mActualConfigsNumber[0], new EGLConfigComparator()); - mChoosenConfigIndex = 0; - - while (true) - { - mConfig = mConfigs[mChoosenConfigIndex]; - - // Debug print - LogIt("Matched egl configs:"); - for (int i = 0; i < mActualConfigsNumber[0]; ++i) - LogIt((i == mChoosenConfigIndex ? "*" : " ") + i + ": " + eglConfigToString(mConfigs[i])); - - mContext = mEgl.eglCreateContext(mDisplay, mConfig, EGL10.EGL_NO_CONTEXT, GetContextAttributes10()); - if (mContext == EGL10.EGL_NO_CONTEXT) - { - LogEgl("eglCreateContext failed with error "); - mChoosenConfigIndex++; - } - else - break; - - if (mChoosenConfigIndex == mConfigs.length) - { - LogIt("No more configs left to choose"); - return false; - } - } - - return true; - } - - @Override - public boolean IsInitialized() - { - return mContext != EGL10.EGL_NO_CONTEXT; - } - - @Override - public boolean TerminateEGL() - { - LogIt("CleanupEGL"); - - if (!IsInitialized()) - return false; - - if (!DestroySurfaceEGL()) - return false; - - if (mDisplay != EGL10.EGL_NO_DISPLAY) - mEgl.eglMakeCurrent(mDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - - if (mContext != EGL10.EGL_NO_CONTEXT) - mEgl.eglDestroyContext(mDisplay, mContext); - - mEgl.eglTerminate(mDisplay); - - mDisplay = EGL10.EGL_NO_DISPLAY; - mContext = EGL10.EGL_NO_CONTEXT; - mConfig = null; - - return true; - } - - @Override - public boolean CreateSurfaceEGL(SurfaceHolder holder) - { - if (holder == null) - { - LogIt("createEGLSurface failed, mCachedSurfaceHolder is null"); - return false; - } - - if (!IsInitialized()) - InitEGL(); - - if (!IsInitialized()) - { - LogIt("createEGLSurface failed, cannot initialize EGL"); - return false; - } - - if (mDisplay == EGL10.EGL_NO_DISPLAY) - { - LogIt("createEGLSurface: display is null"); - return false; - } - else if (mConfig == null) - { - LogIt("createEGLSurface: config is null"); - return false; - } - - int choosenSurfaceConfigIndex = mChoosenConfigIndex; - - while (true) - { - /// trying to create window surface with one of the EGL configs, recreating the m_eglConfig if necessary - - mSurface = mEgl.eglCreateWindowSurface(mDisplay, mConfigs[choosenSurfaceConfigIndex], holder, GetSurfaceAttributes10()); - - final boolean surfaceCreated = (mSurface != EGL10.EGL_NO_SURFACE); - final boolean surfaceValidated = surfaceCreated ? ValidateSurfaceSize() : false; - - if (surfaceCreated && !surfaceValidated) - mEgl.eglDestroySurface(mDisplay, mSurface); - - if (!surfaceCreated || !surfaceValidated) - { - LogIt("eglCreateWindowSurface failed for config : " + eglConfigToString(mConfigs[choosenSurfaceConfigIndex])); - choosenSurfaceConfigIndex += 1; - if (choosenSurfaceConfigIndex == mActualConfigsNumber[0]) - { - mSurface = EGL10.EGL_NO_SURFACE; - LogIt("no eglConfigs left"); - break; - } - else - LogIt("trying : " + eglConfigToString(mConfigs[choosenSurfaceConfigIndex])); - } - else - break; - } - - if ((choosenSurfaceConfigIndex != mChoosenConfigIndex) && (mSurface != null)) - { - LogIt("window surface is created for eglConfig : " + eglConfigToString(mConfigs[choosenSurfaceConfigIndex])); - - // unbinding context - if (mDisplay != null) - mEgl.eglMakeCurrent(mDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - - // destroying context - if (mContext != null) - mEgl.eglDestroyContext(mDisplay, mContext); - - // recreating context with same eglConfig as eglWindowSurface has - mContext = mEgl.eglCreateContext(mDisplay, mConfigs[choosenSurfaceConfigIndex], EGL10.EGL_NO_CONTEXT, GetContextAttributes10()); - if (mContext == EGL10.EGL_NO_CONTEXT) - { - LogEgl("context recreation failed with error "); - return false; - } - - mChoosenConfigIndex = choosenSurfaceConfigIndex; - mConfig = mConfigs[mChoosenConfigIndex]; - } - - return true; - } - - @Override - public boolean DestroySurfaceEGL() - { - if (mDisplay != EGL10.EGL_NO_DISPLAY && mSurface != EGL10.EGL_NO_SURFACE) - mEgl.eglMakeCurrent(mDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, mContext); - if (mSurface != EGL10.EGL_NO_SURFACE) - mEgl.eglDestroySurface(mDisplay, mSurface); - mSurface = EGL10.EGL_NO_SURFACE; - - return true; - } - - @Override - public boolean SwapBuffersEGL() - { - if (mSurface == EGL10.EGL_NO_SURFACE) - { - LogIt("Surface is NULL"); - return false; - } - - if (mDisplay == EGL10.EGL_NO_DISPLAY) - { - LogIt("Display is NULL"); - return false; - } - - if (!mEgl.eglSwapBuffers(mDisplay, mSurface)) - { - LogEgl("eglSwapBuffer: "); - return false; - } - return true; - } - - @Override - public int GetSurfaceWidth() - { - final int sizes[] = new int[1]; - mEgl.eglQuerySurface(mDisplay, mSurface, EGL10.EGL_WIDTH, sizes); - return sizes[0]; - } - - @Override - public int GetSurfaceHeight() - { - final int sizes[] = new int[1]; - mEgl.eglQuerySurface(mDisplay, mSurface, EGL10.EGL_HEIGHT, sizes); - return sizes[0]; - } - - @Override - public boolean Bind() - { - if (mContext == EGL10.EGL_NO_CONTEXT) - { - LogIt("m_eglContext is NULL"); - return false; - } - else if (mSurface == EGL10.EGL_NO_SURFACE) - { - LogIt("m_eglSurface is NULL"); - return false; - } - else if (!mEgl.eglMakeCurrent(mDisplay, mSurface, mSurface, mContext)) - { - LogEgl("eglMakeCurrent err: "); - return false; - } - - return true; - } - - @Override - public boolean Unbind() - { - if (mDisplay == EGL10.EGL_NO_DISPLAY) - return false; - - return mEgl.eglMakeCurrent(mDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - } - - @Override - public int GetErrorEGL() - { - return mEgl.eglGetError(); - } - - private void LogIt(String message) - { - mLog.d(TAG, message); - } - - private void LogEgl(String message) - { - mLog.d(TAG, message + mEgl.eglGetError()); - } - - String eglConfigToString(final EGLConfig config) - { - final int[] value = new int[1]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_RED_SIZE, value); - final int red = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_GREEN_SIZE, value); - final int green = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_BLUE_SIZE, value); - final int blue = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_ALPHA_SIZE, value); - final int alpha = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_STENCIL_SIZE, value); - final int stencil = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_DEPTH_SIZE, value); - final int depth = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_CONFIG_CAVEAT, value); - final String caveat = (value[0] == EGL10.EGL_NONE) ? "EGL_NONE" : - (value[0] == EGL10.EGL_SLOW_CONFIG) ? "EGL_SLOW_CONFIG" : "EGL_NON_CONFORMANT_CONFIG"; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_BUFFER_SIZE, value); - final int buffer = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_LEVEL, value); - final int level = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_SAMPLE_BUFFERS, value); - final int sampleBuffers = value[0]; - mEgl.eglGetConfigAttrib(mDisplay, config, EGL10.EGL_SAMPLES, value); - final int samples = value[0]; - - return "R" + red + "G" + green + "B" + blue + "A" + alpha + - " Stencil:" + stencil + " Depth:" + depth + " Caveat:" + caveat + - " BufferSize:" + buffer + " Level:" + level + " SampleBuffers:" + sampleBuffers + - " Samples:" + samples; - } -} diff --git a/android/src/com/nvidia/devtech/Egl14Wrapper.java b/android/src/com/nvidia/devtech/Egl14Wrapper.java deleted file mode 100644 index e5918e62a1..0000000000 --- a/android/src/com/nvidia/devtech/Egl14Wrapper.java +++ /dev/null @@ -1,361 +0,0 @@ -package com.nvidia.devtech; - -import android.opengl.EGL14; -import android.opengl.EGLConfig; -import android.opengl.EGLContext; -import android.opengl.EGLDisplay; -import android.opengl.EGLSurface; -import android.view.SurfaceHolder; - -import com.mapswithme.util.log.Logger; - -import java.util.Arrays; -import java.util.Comparator; - -public class Egl14Wrapper extends BaseEglWrapper -{ - private static final String TAG = "Egl14Wrapper"; - private Logger mLog = null; - - private EGLDisplay mDisplay = EGL14.EGL_NO_DISPLAY; - private EGLContext mContext = EGL14.EGL_NO_CONTEXT; - private EGLSurface mSurface = EGL14.EGL_NO_SURFACE; - private EGLConfig mConfig = null; - - private EGLConfig[] mConfigs = new EGLConfig[40]; - - private int mChoosenConfigIndex = 0; - private int mActualConfigsNumber[] = new int[]{0}; - - private class EGLConfigComparator extends ConfigComparatorBase - implements Comparator - { - EGLConfigComparator() - { - super(EGL14.EGL_NONE, EGL14.EGL_SLOW_CONFIG, EGL14.EGL_NON_CONFORMANT_CONFIG); - } - - @Override - public int compare(EGLConfig l, EGLConfig r) - { - final int[] value = new int[2]; - - EGL14.eglGetConfigAttrib(mDisplay, l, EGL14.EGL_CONFIG_CAVEAT, value, 0); - EGL14.eglGetConfigAttrib(mDisplay, r, EGL14.EGL_CONFIG_CAVEAT, value, 1); - - return CompareConfigs(value[1], value[0]); - } - } - - ; - - public Egl14Wrapper(Logger logger) - { - mLog = logger; - } - - @Override - public boolean IsInitialized() - { - return mContext != EGL14.EGL_NO_CONTEXT; - } - - @Override - public boolean InitEGL() - { - mDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); - if (mDisplay == EGL14.EGL_NO_DISPLAY) - { - LogIt("eglGetDisplay failed"); - return false; - } - - int[] version = new int[2]; - if (!EGL14.eglInitialize(mDisplay, version, 0, version, 1)) - { - LogIt("eglInitialize failed"); - return false; - } - - if (version[0] != 1 && version[1] < 4) - { - LogIt("Incorrect EGL wrapper choosed"); - return false; - } - - if (!EGL14.eglChooseConfig(mDisplay, GetConfigAttributes14(), 0, mConfigs, 0, mConfigs.length, mActualConfigsNumber, 0)) - { - LogEgl("eglChooseConfig failed with error "); - return false; - } - - if (mActualConfigsNumber[0] == 0) - { - LogIt("eglChooseConfig returned zero configs"); - return false; - } - - Arrays.sort(mConfigs, 0, mActualConfigsNumber[0], new EGLConfigComparator()); - mChoosenConfigIndex = 0; - - while (true) - { - mConfig = mConfigs[mChoosenConfigIndex]; - - // Debug print - LogIt("Matched egl configs:"); - for (int i = 0; i < mActualConfigsNumber[0]; ++i) - LogIt((i == mChoosenConfigIndex ? "*" : " ") + i + ": " + eglConfigToString(mConfigs[i])); - - mContext = EGL14.eglCreateContext(mDisplay, mConfig, EGL14.EGL_NO_CONTEXT, GetContextAttributes14(), 0); - if (mContext == EGL14.EGL_NO_CONTEXT) - { - LogEgl("eglCreateContext failed with error "); - mChoosenConfigIndex++; - } - else - break; - - if (mChoosenConfigIndex == mConfigs.length) - { - LogIt("No more configs left to choose"); - return false; - } - } - - return true; - } - - @Override - public boolean TerminateEGL() - { - LogIt("CleanupEGL"); - - if (!IsInitialized()) - return false; - if (!DestroySurfaceEGL()) - return false; - - if (mDisplay != EGL14.EGL_NO_DISPLAY) - EGL14.eglMakeCurrent(mDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT); - - if (mContext != EGL14.EGL_NO_CONTEXT) - EGL14.eglDestroyContext(mDisplay, mContext); - - EGL14.eglTerminate(mDisplay); - - mDisplay = EGL14.EGL_NO_DISPLAY; - mContext = EGL14.EGL_NO_CONTEXT; - mConfig = null; - - return true; - } - - @Override - public boolean CreateSurfaceEGL(SurfaceHolder holder) - { - if (holder == null) - { - LogIt("createEGLSurface failed, mCachedSurfaceHolder is null"); - return false; - } - - if (!IsInitialized()) - InitEGL(); - - if (!IsInitialized()) - { - LogIt("createEGLSurface failed, cannot initialize EGL"); - return false; - } - - if (mDisplay == EGL14.EGL_NO_DISPLAY) - { - LogIt("createEGLSurface: display is null"); - return false; - } - else if (mConfig == null) - { - LogIt("createEGLSurface: config is null"); - return false; - } - - int choosenSurfaceConfigIndex = mChoosenConfigIndex; - - while (true) - { - /// trying to create window surface with one of the EGL configs, recreating the mEglConfig if necessary - mSurface = EGL14.eglCreateWindowSurface(mDisplay, mConfigs[choosenSurfaceConfigIndex], holder, GetSurfaceAttributes14(), 0); - - final boolean surfaceCreated = (mSurface != EGL14.EGL_NO_SURFACE); - final boolean surfaceValidated = surfaceCreated ? ValidateSurfaceSize() : false; - - if (surfaceCreated && !surfaceValidated) - EGL14.eglDestroySurface(mDisplay, mSurface); - - if (!surfaceCreated || !surfaceValidated) - { - LogIt("eglCreateWindowSurface failed for config : " + eglConfigToString(mConfigs[choosenSurfaceConfigIndex])); - choosenSurfaceConfigIndex += 1; - if (choosenSurfaceConfigIndex == mActualConfigsNumber[0]) - { - mSurface = EGL14.EGL_NO_SURFACE; - LogIt("no eglConfigs left"); - break; - } - else - LogIt("trying : " + eglConfigToString(mConfigs[choosenSurfaceConfigIndex])); - } - else - break; - } - - if ((choosenSurfaceConfigIndex != mChoosenConfigIndex) && (mSurface != EGL14.EGL_NO_SURFACE)) - { - LogIt("window surface is created for eglConfig : " + eglConfigToString(mConfigs[choosenSurfaceConfigIndex])); - - // unbinding context - if (mDisplay != null) - EGL14.eglMakeCurrent(mDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT); - - // destroying context - if (mContext != null) - EGL14.eglDestroyContext(mDisplay, mContext); - - // recreating context with same eglConfig as eglWindowSurface has - mContext = EGL14.eglCreateContext(mDisplay, mConfigs[choosenSurfaceConfigIndex], EGL14.EGL_NO_CONTEXT, GetContextAttributes14(), 0); - if (mContext == EGL14.EGL_NO_CONTEXT) - { - LogEgl("context recreation failed with error "); - return false; - } - - mChoosenConfigIndex = choosenSurfaceConfigIndex; - mConfig = mConfigs[mChoosenConfigIndex]; - } - - return true; - } - - @Override - public boolean DestroySurfaceEGL() - { - if (mDisplay != EGL14.EGL_NO_DISPLAY && mSurface != EGL14.EGL_NO_SURFACE) - EGL14.eglMakeCurrent(mDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, mContext); - if (mSurface != EGL14.EGL_NO_SURFACE) - EGL14.eglDestroySurface(mDisplay, mSurface); - - mSurface = EGL14.EGL_NO_SURFACE; - - return true; - } - - @Override - public boolean SwapBuffersEGL() - { - if (mSurface == EGL14.EGL_NO_SURFACE) - { - LogIt("Surface is NULL"); - return false; - } - - if (mDisplay == EGL14.EGL_NO_DISPLAY) - { - LogIt("Display is NULL"); - return false; - } - - if (!EGL14.eglSwapBuffers(mDisplay, mSurface)) - { - LogEgl("eglSwapBuffer: "); - return false; - } - return true; - } - - @Override - public boolean Bind() - { - if (mContext == EGL14.EGL_NO_CONTEXT) - { - LogIt("m_eglContext is NULL"); - return false; - } - else if (mSurface == EGL14.EGL_NO_SURFACE) - { - LogIt("m_eglSurface is NULL"); - return false; - } - else if (!EGL14.eglMakeCurrent(mDisplay, mSurface, mSurface, mContext)) - { - LogEgl("eglMakeCurrent err: "); - return false; - } - - return true; - } - - @Override - public boolean Unbind() - { - if (mDisplay == EGL14.EGL_NO_DISPLAY) - return false; - - return EGL14.eglMakeCurrent(mDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT); - } - - @Override - public int GetErrorEGL() - { - return EGL14.eglGetError(); - } - - @Override - public int GetSurfaceWidth() - { - final int sizes[] = new int[1]; - EGL14.eglQuerySurface(mDisplay, mSurface, EGL14.EGL_WIDTH, sizes, 0); - return sizes[0]; - } - - @Override - public int GetSurfaceHeight() - { - final int sizes[] = new int[1]; - EGL14.eglQuerySurface(mDisplay, mSurface, EGL14.EGL_HEIGHT, sizes, 0); - return sizes[0]; - } - - private void LogIt(String message) - { - mLog.d(message); - } - - private void LogEgl(String message) - { - mLog.d(message + EGL14.eglGetError()); - } - - String eglConfigToString(final EGLConfig config) - { - final int[] value = new int[11]; - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_RED_SIZE, value, 0); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_GREEN_SIZE, value, 1); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_BLUE_SIZE, value, 2); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_ALPHA_SIZE, value, 3); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_STENCIL_SIZE, value, 4); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_DEPTH_SIZE, value, 5); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_CONFIG_CAVEAT, value, 6); - final String caveat = (value[6] == EGL14.EGL_NONE) ? "EGL_NONE" : - (value[6] == EGL14.EGL_SLOW_CONFIG) ? "EGL_SLOW_CONFIG" : "EGL_NON_CONFORMANT_CONFIG"; - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_BUFFER_SIZE, value, 7); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_LEVEL, value, 8); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_SAMPLE_BUFFERS, value, 9); - EGL14.eglGetConfigAttrib(mDisplay, config, EGL14.EGL_SAMPLES, value, 10); - - return "R" + value[0] + "G" + value[1] + "B" + value[2] + "A" + value[3] + - " Stencil:" + value[4] + " Depth:" + value[5] + " Caveat:" + caveat + - " BufferSize:" + value[7] + " Level:" + value[8] + " SampleBuffers:" + value[9] + - " Samples:" + value[10]; - } -} diff --git a/android/src/com/nvidia/devtech/EglWrapper.java b/android/src/com/nvidia/devtech/EglWrapper.java deleted file mode 100644 index 315c812a81..0000000000 --- a/android/src/com/nvidia/devtech/EglWrapper.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.nvidia.devtech; - -import android.opengl.EGL14; -import android.opengl.EGLDisplay; -import android.os.Build; -import android.view.SurfaceHolder; - -import com.mapswithme.util.Utils; -import com.mapswithme.util.log.Logger; - -abstract public class EglWrapper -{ - public abstract boolean InitEGL(); - - public abstract boolean TerminateEGL(); - - public abstract boolean CreateSurfaceEGL(SurfaceHolder holder); - - public abstract boolean DestroySurfaceEGL(); - - public abstract boolean SwapBuffersEGL(); - - public abstract int GetSurfaceWidth(); - - public abstract int GetSurfaceHeight(); - - public abstract boolean IsInitialized(); - - public abstract boolean Bind(); - - public abstract boolean Unbind(); - - public abstract int GetErrorEGL(); - - enum EglVersion - { - NonEgl, - Egl, - Egl14 - } - - static public EglWrapper GetEgl(Logger logger) - { - EglVersion version = QueryEglVersion(); - switch (version) - { - case Egl: - return new Egl10Wrapper(logger); - case Egl14: - return new Egl14Wrapper(logger); - } - - return null; - } - - static private EglVersion QueryEglVersion() - { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) - return EglVersion.Egl; - - EglVersion result = EglVersion.NonEgl; - EGLDisplay display = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); - if (display != EGL14.EGL_NO_DISPLAY) - { - final int[] version = new int[2]; - if (EGL14.eglInitialize(display, version, 0, version, 1)) - { - if (version[0] >= 1) - { - if (version[1] < 4) - result = EglVersion.Egl; - else - result = EglVersion.Egl14; - } - } - - EGL14.eglTerminate(display); - } - - return result; - } -} diff --git a/android/src/com/nvidia/devtech/NvEventQueueFragment.java b/android/src/com/nvidia/devtech/NvEventQueueFragment.java deleted file mode 100644 index 05dec223bb..0000000000 --- a/android/src/com/nvidia/devtech/NvEventQueueFragment.java +++ /dev/null @@ -1,316 +0,0 @@ -package com.nvidia.devtech; - -import android.annotation.SuppressLint; -import android.os.Build; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.SurfaceHolder; -import android.view.SurfaceHolder.Callback; -import android.view.SurfaceView; -import android.view.View; -import android.view.ViewGroup; - -import com.mapswithme.maps.R; -import com.mapswithme.maps.base.BaseMwmFragment; -import com.mapswithme.util.log.Logger; -import com.mapswithme.util.log.StubLogger; - -public abstract class NvEventQueueFragment extends BaseMwmFragment implements View.OnTouchListener, View.OnFocusChangeListener -{ - private static final String TAG = NvEventQueueFragment.class.getSimpleName(); - - private final Logger mLog = StubLogger.get(); - - private boolean mIsRenderingInitialized; - private EglWrapper mEglWrapper; - protected SurfaceHolder mCachedSurfaceHolder; - protected int mSurfaceWidth; - protected int mSurfaceHeight; - - private int mDisplayDensity; - - private boolean mIsNativeLaunched; - - private int mLastPointerId; - - public int getSurfaceWidth() - { - return mSurfaceWidth; - } - - public int getSurfaceHeight() - { - return mSurfaceHeight; - } - - protected native boolean onCreateNative(); - - protected native boolean onStartNative(); - - protected native boolean onRestartNative(); - - protected native boolean onResumeNative(); - - protected native boolean onSurfaceCreatedNative(int w, int h, int density); - - protected native boolean onFocusChangedNative(boolean focused); - - protected native boolean onSurfaceChangedNative(int w, int h, int density); - - protected native boolean onSurfaceDestroyedNative(); - - protected native boolean onPauseNative(); - - protected native boolean onStopNative(); - - protected native boolean onDestroyNative(); - - public native boolean multiTouchEvent(int action, boolean hasFirst, - boolean hasSecond, int x0, int y0, int x1, int y1, MotionEvent event); - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - - final DisplayMetrics dm = getActivity().getResources().getDisplayMetrics(); - final float exactDensityDpi = (dm.xdpi + dm.ydpi) / 2; - mDisplayDensity = (int)exactDensityDpi; - - mIsNativeLaunched = true; - onCreateNative(); - if (getActivity().isChangingConfigurations()) - mIsRenderingInitialized = true; - } - - @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) - { - return super.onCreateView(inflater, container, savedInstanceState); - } - - @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) - { - super.onViewCreated(view, savedInstanceState); - final SurfaceView surfaceView = (SurfaceView) view.findViewById(R.id.map_surfaceview); - surfaceView.setOnFocusChangeListener(this); - - final SurfaceHolder holder = surfaceView.getHolder(); - holder.addCallback(new Callback() - { - @Override - public void surfaceCreated(SurfaceHolder holder) - { - mCachedSurfaceHolder = holder; - onSurfaceCreatedNative(mSurfaceWidth, mSurfaceHeight, mDisplayDensity); - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) - { - mCachedSurfaceHolder = holder; - mSurfaceWidth = width; - mSurfaceHeight = height; - onSurfaceChangedNative(mSurfaceWidth, mSurfaceHeight, mDisplayDensity); - if (mIsRenderingInitialized) - applyWidgetPivots(); - } - - @Override - public void surfaceDestroyed(SurfaceHolder holder) - { - mCachedSurfaceHolder = null; - onSurfaceDestroyedNative(); - } - }); - } - - /** - * Implement to position map widgets. - */ - protected abstract void applyWidgetPivots(); - - @Override - public void onStart() - { - super.onStart(); - onStartNative(); - } - - @Override - public void onResume() - { - super.onResume(); - onResumeNative(); - onFocusChangedNative(true); - } - - @Override - public void onFocusChange(View v, boolean hasFocus) - { - onFocusChangedNative(hasFocus); - } - - @Override - public void onPause() - { - super.onPause(); - onPauseNative(); - onFocusChangedNative(getActivity().hasWindowFocus()); - } - - @Override - public void onStop() - { - super.onStop(); - if (!getActivity().isChangingConfigurations()) - { - // if configuration is changed - EGL shouldn't be reinitialized - mIsRenderingInitialized = false; - onStopNative(); - } - } - - @Override - public void onDestroy() - { - super.onDestroy(); - onStopNative(); - onDestroyNative(); - CleanupEGL(); - } - - @Override - public boolean onTouch(View v, MotionEvent event) - { - // TODO refactor ? - final int count = event.getPointerCount(); - - if (!mIsNativeLaunched || count == 0) - return false; - - switch (count) - { - case 1: - { - mLastPointerId = event.getPointerId(0); - - final int x0 = (int) event.getX(); - final int y0 = (int) event.getY(); - - return multiTouchEvent(event.getAction(), true, false, x0, y0, 0, 0, event); - } - default: - { - final int x0 = (int) event.getX(0); - final int y0 = (int) event.getY(0); - - final int x1 = (int) event.getX(1); - final int y1 = (int) event.getY(1); - - if (event.getPointerId(0) == mLastPointerId) - return multiTouchEvent(event.getAction(), true, true, - x0, y0, x1, y1, event); - else - return multiTouchEvent(event.getAction(), true, true, x1, y1, x0, y0, event); - } - } - } - - /** - * Called to initialize EGL. This function should not be called by the - * inheriting activity, but can be overridden if needed. - * - * @return True if successful - */ - @SuppressWarnings("UnusedDeclaration") - protected boolean InitEGL() - { - mEglWrapper = EglWrapper.GetEgl(mLog); - return mEglWrapper.InitEGL(); - } - - /** - * Called to clean up EGL. This function should not be called by the - * inheriting fragment, but can be overridden if needed. - */ - protected boolean CleanupEGL() - { - return mEglWrapper != null && mEglWrapper.TerminateEGL(); - } - - @SuppressWarnings("UnusedDeclaration") - protected boolean CreateSurfaceEGL() - { - if (!mEglWrapper.CreateSurfaceEGL(mCachedSurfaceHolder)) - return false; - - mSurfaceHeight = mEglWrapper.GetSurfaceHeight(); - mSurfaceWidth = mEglWrapper.GetSurfaceWidth(); - return true; - } - - /** - * Destroys the EGLSurface used for rendering. This function should not be - * called by the inheriting activity, but can be overridden if needed. - */ - @SuppressWarnings("UnusedDeclaration") - protected boolean DestroySurfaceEGL() - { - return mEglWrapper.DestroySurfaceEGL(); - } - - @SuppressWarnings("UnusedDeclaration") - public boolean BindSurfaceAndContextEGL() - { - return mEglWrapper.Bind(); - } - - @SuppressWarnings("UnusedDeclaration") - public boolean UnbindSurfaceAndContextEGL() - { - return mEglWrapper.Unbind(); - } - - @SuppressWarnings("UnusedDeclaration") - public boolean SwapBuffersEGL() - { - return mEglWrapper.SwapBuffersEGL(); - } - - @SuppressWarnings("UnusedDeclaration") - public int GetErrorEGL() - { - return mEglWrapper.GetErrorEGL(); - } - - @SuppressWarnings("UnusedDeclaration") - public void OnRenderingInitialized() - { - mIsRenderingInitialized = true; - applyWidgetPivots(); - } - - public boolean isRenderingInitialized() - { - return mIsRenderingInitialized; - } - - @SuppressWarnings("UnusedDeclaration") - public void ReportUnsupported() - { - Log.i(TAG, "this phone GPU is unsupported"); - } - - @SuppressWarnings("UnusedDeclaration") - public void finish() - { - if (isAdded()) - getActivity().finish(); - } -} diff --git a/drape/symbols_texture.cpp b/drape/symbols_texture.cpp index 9c0aa48e48..98efbf724e 100644 --- a/drape/symbols_texture.cpp +++ b/drape/symbols_texture.cpp @@ -244,7 +244,7 @@ ref_ptr SymbolsTexture::FindResource(Texture::Key const & string const & symbolName = static_cast(key).GetSymbolName(); TSymDefinition::iterator it = m_definition.find(symbolName); - ASSERT(it != m_definition.end(), ()); + ASSERT(it != m_definition.end(), (symbolName)); return make_ref(&it->second); } diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index daade4062d..584f290483 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -316,6 +316,18 @@ void DrapeEngine::DeselectObject() MessagePriority::High); } +SelectionShape::ESelectedObject DrapeEngine::GetSelectedObject() +{ + SelectionShape::ESelectedObject object; + BaseBlockingMessage::Blocker blocker; + m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, + make_unique_dp(blocker, object), + MessagePriority::High); + + blocker.Wait(); + return object; +} + bool DrapeEngine::GetMyPosition(m2::PointD & myPosition) { bool hasPosition = false; diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index d213bbb08d..36eb960ddc 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -98,6 +98,7 @@ public: void SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt, bool isAnim); void DeselectObject(); bool GetMyPosition(m2::PointD & myPosition); + SelectionShape::ESelectedObject GetSelectedObject(); void AddRoute(m2::PolylineD const & routePolyline, vector const & turns, dp::Color const & color); void RemoveRoute(bool deactivateFollowing); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 6dcd83bbe0..026f2e6979 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -299,6 +299,16 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) break; } + case Message::GetSelectedObject: + { + ref_ptr msg = message; + if (m_selectionShape != nullptr) + msg->SetSelectedObject(m_selectionShape->GetSelectedObject()); + else + msg->SetSelectedObject(SelectionShape::OBJECT_EMPTY); + break; + } + case Message::GetMyPosition: { ref_ptr msg = message; diff --git a/drape_frontend/line_shape_helper.cpp b/drape_frontend/line_shape_helper.cpp index 5244a73c75..cdb06f512a 100644 --- a/drape_frontend/line_shape_helper.cpp +++ b/drape_frontend/line_shape_helper.cpp @@ -89,30 +89,28 @@ void CalculateTangentAndNormals(glsl::vec2 const & pt0, glsl::vec2 const & pt1, void ConstructLineSegments(vector const & path, vector & segments) { - ASSERT(path.size() > 1, ()); - - float const eps = 1e-5; + ASSERT_LESS(1, path.size(), ()); m2::PointD prevPoint = path[0]; for (size_t i = 1; i < path.size(); ++i) { - // filter the same points - if (prevPoint.EqualDxDy(path[i], eps)) + m2::PointF const p1 = m2::PointF(prevPoint.x, prevPoint.y); + m2::PointF const p2 = m2::PointF(path[i].x, path[i].y); + if (p1.EqualDxDy(p2, 1.0E-5)) continue; - LineSegment segment; + // Important! Do emplace_back first and fill parameters later. + // Fill parameters first and push_back later will cause ugly bug in clang 3.6 -O3 optimization. + segments.emplace_back(glsl::ToVec2(p1), glsl::ToVec2(p2)); + LineSegment & segment = segments.back(); - segment.m_points[StartPoint] = glsl::ToVec2(prevPoint); - segment.m_points[EndPoint] = glsl::ToVec2(path[i]); - CalculateTangentAndNormals(segment.m_points[StartPoint], segment.m_points[EndPoint], segment.m_tangent, + CalculateTangentAndNormals(glsl::ToVec2(p1), glsl::ToVec2(p2), segment.m_tangent, segment.m_leftBaseNormal, segment.m_rightBaseNormal); segment.m_leftNormals[StartPoint] = segment.m_leftNormals[EndPoint] = segment.m_leftBaseNormal; segment.m_rightNormals[StartPoint] = segment.m_rightNormals[EndPoint] = segment.m_rightBaseNormal; prevPoint = path[i]; - - segments.push_back(segment); } } diff --git a/drape_frontend/line_shape_helper.hpp b/drape_frontend/line_shape_helper.hpp index 9f16decf37..6b30061195 100644 --- a/drape_frontend/line_shape_helper.hpp +++ b/drape_frontend/line_shape_helper.hpp @@ -35,8 +35,10 @@ struct LineSegment bool m_hasLeftJoin[PointsCount]; bool m_generateJoin; - LineSegment() + LineSegment(glsl::vec2 const & p1, glsl::vec2 const & p2) { + m_points[StartPoint] = p1; + m_points[EndPoint] = p2; m_leftWidthScalar[StartPoint] = m_leftWidthScalar[EndPoint] = glsl::vec2(1.0f, 0.0f); m_rightWidthScalar[StartPoint] = m_rightWidthScalar[EndPoint] = glsl::vec2(1.0f, 0.0f); m_hasLeftJoin[StartPoint] = m_hasLeftJoin[EndPoint] = true; diff --git a/drape_frontend/message.hpp b/drape_frontend/message.hpp index 67830c57ba..9eea910f6a 100644 --- a/drape_frontend/message.hpp +++ b/drape_frontend/message.hpp @@ -32,6 +32,7 @@ public: GpsInfo, FindVisiblePOI, SelectObject, + GetSelectedObject, GetMyPosition, AddRoute, RemoveRoute, diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index 02ecdaa237..5132550228 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -419,8 +419,7 @@ public: : BaseBlockingMessage(blocker) , m_pt(glbPt) , m_featureID(featureID) - { - } + {} Type GetType() const override { return FindVisiblePOI; } @@ -441,13 +440,11 @@ public: struct DismissTag {}; SelectObjectMessage(DismissTag) : SelectObjectMessage(SelectionShape::OBJECT_EMPTY, m2::PointD::Zero(), false, true) - { - } + {} SelectObjectMessage(SelectionShape::ESelectedObject selectedObject, m2::PointD const & glbPoint, bool isAnim) : SelectObjectMessage(selectedObject, glbPoint, isAnim, false) - { - } + {} Type GetType() const override { return SelectObject; } m2::PointD const & GetPosition() const { return m_glbPoint; } @@ -461,9 +458,7 @@ private: , m_glbPoint(pt) , m_isAnim(isAnim) , m_isDismiss(isDismiss) - { - - } + {} private: SelectionShape::ESelectedObject m_selected; @@ -472,6 +467,25 @@ private: bool m_isDismiss; }; +class GetSelectedObjectMessage : public BaseBlockingMessage +{ +public: + GetSelectedObjectMessage(Blocker & blocker, SelectionShape::ESelectedObject & object) + : BaseBlockingMessage(blocker) + , m_object(object) + {} + + Type GetType() const override { return GetSelectedObject; } + + void SetSelectedObject(SelectionShape::ESelectedObject const & object) + { + m_object = object; + } + +private: + SelectionShape::ESelectedObject & m_object; +}; + class GetMyPositionMessage : public BaseBlockingMessage { public: diff --git a/iphone/Maps/Classes/MWMPlacePageViewManager.mm b/iphone/Maps/Classes/MWMPlacePageViewManager.mm index abc7aee84c..e976495765 100644 --- a/iphone/Maps/Classes/MWMPlacePageViewManager.mm +++ b/iphone/Maps/Classes/MWMPlacePageViewManager.mm @@ -67,11 +67,14 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState) - (void)dismissPlacePage { + if (!m_userMark) + return; [self.delegate placePageDidClose]; self.state = MWMPlacePageManagerStateClosed; [self.placePage dismiss]; [[MapsAppDelegate theApp].m_locationManager stop:self]; m_userMark = nullptr; + GetFramework().DeactivateUserMark(); self.entity = nil; self.placePage = nil; } diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 72ba14870f..c6463f96e9 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -216,21 +216,18 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) - (void)onUserMarkClicked:(unique_ptr)mark { if (mark == nullptr) + { [self dismissPlacePage]; + + auto & f = GetFramework(); + if (!f.HasActiveUserMark() && self.controlsManager.searchHidden && !f.IsRouteNavigable()) + self.controlsManager.hidden = !self.controlsManager.hidden; + } else + { + self.controlsManager.hidden = NO; [self.controlsManager showPlacePageWithUserMark:move(mark)]; - - //TODO(@kuznetsov) - /* - UserMark const * userMark = f.GetUserMark(pxClicked, isLongClick); - if (f.HasActiveUserMark() == false && self.controlsManager.searchHidden && !f.IsRouteNavigable()) - { - if (userMark == nullptr) - self.controlsManager.hidden = !self.controlsManager.hidden; - else - self.controlsManager.hidden = NO; - } - */ + } } - (void)onMyPositionClicked:(id)sender diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 89f771b864..39bdc3181f 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -151,7 +151,7 @@ Track const * BookmarkCategory::GetTrack(size_t index) const } BookmarkCategory::BookmarkCategory(string const & name, Framework & framework) - : TBase(0.0/*graphics::bookmarkDepth*/, UserMarkType::BOOKMARK_MARK, framework) + : TBase(0.0 /* bookmarkDepth */, UserMarkType::BOOKMARK_MARK, framework) , m_name(name) { } diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 72b5667940..48f021a657 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -19,10 +19,9 @@ BookmarkManager::BookmarkManager(Framework & f) : m_framework(f) { m_userMarkLayers.reserve(3); - ///@TODO UVR - m_userMarkLayers.push_back(new SearchUserMarkContainer(0.0/*graphics::activePinDepth*/, m_framework)); - m_userMarkLayers.push_back(new ApiUserMarkContainer(0.0/*graphics::activePinDepth*/, m_framework)); - //m_userMarkLayers.push_back(new DebugUserMarkContainer(graphics::debugDepth, m_framework)); + m_userMarkLayers.push_back(new SearchUserMarkContainer(0.0 /* activePinDepth */, m_framework)); + m_userMarkLayers.push_back(new ApiUserMarkContainer(0.0 /* activePinDepth */, m_framework)); + m_userMarkLayers.push_back(new DebugUserMarkContainer(0.0 /* debugDepth */, m_framework)); UserMarkContainer::InitStaticMarks(FindUserMarksContainer(UserMarkType::SEARCH_MARK)); } @@ -79,6 +78,15 @@ void BookmarkManager::LoadBookmark(string const & filePath) m_categories.push_back(cat); } +void BookmarkManager::InitBookmarks() +{ + for (auto it = m_categories.begin(); it != m_categories.end(); ++it) + { + BookmarkCategory * cat = *it; + BookmarkCategory::Guard guard(*cat); + } +} + size_t BookmarkManager::AddBookmark(size_t categoryIndex, m2::PointD const & ptOrg, BookmarkData & bm) { bm.SetTimeStamp(time(0)); @@ -100,14 +108,20 @@ size_t BookmarkManager::AddBookmark(size_t categoryIndex, m2::PointD const & ptO size_t BookmarkManager::MoveBookmark(size_t bmIndex, size_t curCatIndex, size_t newCatIndex) { - BookmarkCategory * cat = m_framework.GetBmCategory(curCatIndex); - BookmarkCategory::Guard guard(*cat); - Bookmark const * bm = static_cast(guard.m_controller.GetUserMark(bmIndex)); - BookmarkData data = bm->GetData(); - m2::PointD ptOrg = bm->GetPivot(); + BookmarkData data; + m2::PointD ptOrg; + + // guard must be released before AddBookmark to prevent deadlock + { + BookmarkCategory * cat = m_framework.GetBmCategory(curCatIndex); + BookmarkCategory::Guard guard(*cat); + Bookmark const * bm = static_cast(guard.m_controller.GetUserMark(bmIndex)); + data = bm->GetData(); + ptOrg = bm->GetPivot(); - guard.m_controller.DeleteUserMark(bmIndex); - cat->SaveToKMLFile(); + guard.m_controller.DeleteUserMark(bmIndex); + cat->SaveToKMLFile(); + } return AddBookmark(newCatIndex, ptOrg, data); } diff --git a/map/bookmark_manager.hpp b/map/bookmark_manager.hpp index 9a46cac721..3a3f521d7c 100644 --- a/map/bookmark_manager.hpp +++ b/map/bookmark_manager.hpp @@ -36,6 +36,8 @@ public: void LoadBookmarks(); void LoadBookmark(string const & filePath); + void InitBookmarks(); + /// Client should know where it adds bookmark size_t AddBookmark(size_t categoryIndex, m2::PointD const & ptOrg, BookmarkData & bm); /// Client should know where it moves bookmark diff --git a/map/country_status_display.cpp b/map/country_status_display.cpp deleted file mode 100644 index 040e0bf1a3..0000000000 --- a/map/country_status_display.cpp +++ /dev/null @@ -1,496 +0,0 @@ -#include "map/country_status_display.hpp" -#include "map/framework.hpp" - -#include "gui/controller.hpp" -#include "gui/button.hpp" -#include "gui/text_view.hpp" - -#include "graphics/overlay_renderer.hpp" -#include "graphics/display_list.hpp" - -#include "platform/platform.hpp" - -#include "base/thread.hpp" -#include "base/string_format.hpp" - -#include "3party/Alohalytics/src/alohalytics.h" - -#include "std/bind.hpp" -#include "std/sstream.hpp" - - -using namespace storage; - -CountryStatusDisplay::CountryStatusDisplay(Params const & p) - : gui::Element(p) - , m_activeMaps(p.m_activeMaps) -{ - m_activeMapsSlotID = m_activeMaps.AddListener(this); - gui::Button::Params bp; - - bp.m_depth = depth(); - bp.m_minWidth = 260; - bp.m_minHeight = 56; - bp.m_position = graphics::EPosCenter; - - auto createButtonFn = [this] (gui::Button::Params const & params, - graphics::Color const & activeButtonColor, graphics::Color const & pressedButtonColor) - { - gui::Button * result = new gui::Button(params); - result->setIsVisible(false); - result->setOnClickListener(bind(&CountryStatusDisplay::OnButtonClicked, this, _1)); - - result->setFont(EActive, graphics::FontDesc(15, graphics::Color(255, 255, 255, 255))); - result->setFont(EPressed, graphics::FontDesc(15, graphics::Color(255, 255, 255, 255))); - - result->setColor(EActive, activeButtonColor); - result->setColor(EPressed, pressedButtonColor); - - return result; - }; - - m_primaryButton.reset(createButtonFn(bp, graphics::Color(32, 152, 82, 255), - graphics::Color(24, 128, 68, 255))); - uint8_t constexpr activeAlpha = static_cast(0.44 * 255); - uint8_t constexpr pressedAlpha = static_cast(0.72 * 255); - m_secondaryButton.reset(createButtonFn(bp, graphics::Color(0, 0, 0, activeAlpha), - graphics::Color(0, 0, 0, pressedAlpha))); - - gui::TextView::Params tp; - tp.m_depth = depth(); - tp.m_position = graphics::EPosCenter; - - m_label.reset(new gui::TextView(tp)); - m_label->setIsVisible(false); - m_label->setFont(gui::Element::EActive, graphics::FontDesc(18)); - - setIsVisible(false); -} - -CountryStatusDisplay::~CountryStatusDisplay() -{ - m_activeMaps.RemoveListener(m_activeMapsSlotID); -} - -void CountryStatusDisplay::SetCountryIndex(TIndex const & idx) -{ - if (m_countryIdx != idx) - { - Lock(); - m_countryIdx = idx; - - if (m_countryIdx.IsValid()) - { - m_countryStatus = m_activeMaps.GetCountryStatus(m_countryIdx); - m_displayMapName = m_activeMaps.GetFormatedCountryName(m_countryIdx); - } - - Repaint(); - Unlock(); - } -} - -void CountryStatusDisplay::setIsVisible(bool isVisible) const -{ - if (isVisible && isVisible != TBase::isVisible()) - { - Lock(); - Repaint(); - Unlock(); - } - - TBase::setIsVisible(isVisible); -} - -void CountryStatusDisplay::setIsDirtyLayout(bool isDirty) const -{ - TBase::setIsDirtyLayout(isDirty); - m_label->setIsDirtyLayout(isDirty); - m_primaryButton->setIsDirtyLayout(isDirty); - m_secondaryButton->setIsDirtyLayout(isDirty); - - if (isDirty) - SetVisibilityForState(); -} - -void CountryStatusDisplay::draw(graphics::OverlayRenderer * r, - math::Matrix const & m) const -{ - if (isVisible()) - { - Lock(); - checkDirtyLayout(); - - m_label->draw(r, m); - m_primaryButton->draw(r, m); - m_secondaryButton->draw(r, m); - Unlock(); - } -} - -void CountryStatusDisplay::layout() -{ - if (!isVisible()) - return; - SetContentForState(); - - auto layoutFn = [] (gui::Element * e) - { - if (e->isVisible()) - e->layout(); - }; - - layoutFn(m_label.get()); - layoutFn(m_primaryButton.get()); - layoutFn(m_secondaryButton.get()); - - ComposeElementsForState(); - - // !!!! Hack !!!! - // ComposeElementsForState modify pivot point of elements. - // After setPivot all elements must be relayouted. - // For reduce "cache" operations we call layout secondary - layoutFn(m_label.get()); - layoutFn(m_primaryButton.get()); - layoutFn(m_secondaryButton.get()); -} - -void CountryStatusDisplay::purge() -{ - m_label->purge(); - m_primaryButton->purge(); - m_secondaryButton->purge(); -} - -void CountryStatusDisplay::cache() -{ - auto cacheFn = [] (gui::Element * e) - { - if (e->isVisible()) - e->cache(); - }; - - cacheFn(m_label.get()); - cacheFn(m_primaryButton.get()); - cacheFn(m_secondaryButton.get()); -} - -m2::RectD CountryStatusDisplay::GetBoundRect() const -{ - ASSERT(isVisible(), ()); - m2::RectD r(pivot(), pivot()); - - if (m_primaryButton->isVisible()) - r.Add(m_primaryButton->GetBoundRect()); - if (m_secondaryButton->isVisible()) - r.Add(m_secondaryButton->GetBoundRect()); - - return r; -} - -void CountryStatusDisplay::setController(gui::Controller * controller) -{ - Element::setController(controller); - m_label->setController(controller); - m_primaryButton->setController(controller); - m_secondaryButton->setController(controller); -} - -bool CountryStatusDisplay::onTapStarted(m2::PointD const & pt) -{ - return OnTapAction(bind(&gui::Button::onTapStarted, _1, _2), pt); -} - -bool CountryStatusDisplay::onTapMoved(m2::PointD const & pt) -{ - return OnTapAction(bind(&gui::Button::onTapMoved, _1, _2), pt); -} - -bool CountryStatusDisplay::onTapEnded(m2::PointD const & pt) -{ - return OnTapAction(bind(&gui::Button::onTapEnded, _1, _2), pt); -} - -bool CountryStatusDisplay::onTapCancelled(m2::PointD const & pt) -{ - return OnTapAction(bind(&gui::Button::onTapCancelled, _1, _2), pt); -} - -void CountryStatusDisplay::CountryStatusChanged(ActiveMapsLayout::TGroup const & group, int position, - TStatus const & /*oldStatus*/, TStatus const & newStatus) -{ - TIndex index = m_activeMaps.GetCoreIndex(group, position); - if (m_countryIdx == index) - { - Lock(); - m_countryStatus = newStatus; - if (m_countryStatus == TStatus::EDownloading) - m_progressSize = m_activeMaps.GetDownloadableCountrySize(m_countryIdx); - else - m_progressSize = LocalAndRemoteSizeT(0, 0); - Repaint(); - Unlock(); - } -} - -void CountryStatusDisplay::DownloadingProgressUpdate(ActiveMapsLayout::TGroup const & group, int position, LocalAndRemoteSizeT const & progress) -{ - TIndex index = m_activeMaps.GetCoreIndex(group, position); - if (m_countryIdx == index) - { - Lock(); - m_countryStatus = m_activeMaps.GetCountryStatus(index); - m_progressSize = progress; - Repaint(); - Unlock(); - } -} - -template -string CountryStatusDisplay::FormatStatusMessage(string const & msgID, T1 const * t1, T2 const * t2) -{ - string msg = m_controller->GetStringsBundle()->GetString(msgID); - if (t1) - { - if (t2) - msg = strings::Format(msg, *t1, *t2); - else - { - msg = strings::Format(msg, *t1); - - size_t const count = msg.size(); - if (count > 0) - { - if (msg[count-1] == '\n') - msg.erase(count-1, 1); - } - } - } - - return msg; -} - -void CountryStatusDisplay::SetVisibilityForState() const -{ - uint8_t visibilityFlags = 0; - uint8_t const labelVisibility = 0x1; - uint8_t const primeVisibility = 0x2; - uint8_t const secondaryVisibility = 0x4; - - if (m_countryIdx.IsValid()) - { - switch (m_countryStatus) - { - case TStatus::EDownloadFailed: - visibilityFlags |= labelVisibility; - visibilityFlags |= primeVisibility; - break; - case TStatus::EDownloading: - case TStatus::EInQueue: - visibilityFlags |= labelVisibility; - break; - case TStatus::ENotDownloaded: - visibilityFlags |= labelVisibility; - visibilityFlags |= primeVisibility; - visibilityFlags |= secondaryVisibility; - break; - default: - break; - } - } - - m_label->setIsVisible(visibilityFlags & labelVisibility); - m_primaryButton->setIsVisible(visibilityFlags & primeVisibility); - m_secondaryButton->setIsVisible(visibilityFlags & secondaryVisibility); - - TBase::setIsVisible(m_label->isVisible() || m_primaryButton->isVisible() || m_secondaryButton->isVisible()); -} - -void CountryStatusDisplay::SetContentForState() -{ - if (!isVisible()) - return; - - switch (m_countryStatus) - { - case TStatus::EDownloadFailed: - case TStatus::EOutOfMemFailed: - SetContentForError(); - break; - case TStatus::ENotDownloaded: - SetContentForDownloadPropose(); - break; - case TStatus::EDownloading: - SetContentForProgress(); - break; - case TStatus::EInQueue: - SetContentForInQueue(); - break; - default: - break; - } -} - -namespace -{ - void FormatMapSize(uint64_t sizeInBytes, string & units, uint64_t & sizeToDownload) - { - int const mbInBytes = 1024 * 1024; - int const kbInBytes = 1024; - if (sizeInBytes < mbInBytes) - { - sizeToDownload = (sizeInBytes + kbInBytes / 2) / kbInBytes; - units = "KB"; - } - else - { - sizeToDownload = (sizeInBytes + mbInBytes / 2) / mbInBytes; - units = "MB"; - } - } -} - -void CountryStatusDisplay::SetContentForDownloadPropose() -{ - ASSERT(m_label->isVisible(), ()); - ASSERT(m_primaryButton->isVisible(), ()); - ASSERT(m_secondaryButton->isVisible(), ()); - - LocalAndRemoteSizeT mapAndRoutingSize = m_activeMaps.GetRemoteCountrySizes(m_countryIdx); - - m_label->setText(m_displayMapName); - uint64_t sizeToDownload; - string units; - FormatMapSize(mapAndRoutingSize.first + mapAndRoutingSize.second, units, sizeToDownload); - m_primaryButton->setText(FormatStatusMessage("country_status_download", &sizeToDownload, &units)); - - FormatMapSize(mapAndRoutingSize.first, units, sizeToDownload); - m_secondaryButton->setText(FormatStatusMessage("country_status_download_without_routing", - &sizeToDownload, &units)); -} - -void CountryStatusDisplay::SetContentForProgress() -{ - ASSERT(m_label->isVisible(), ()); - int percent = 0; - if (m_progressSize.second != 0) - percent = static_cast(m_progressSize.first * 100 / m_progressSize.second); - m_label->setText(FormatStatusMessage("country_status_downloading", &m_displayMapName, &percent)); -} - -void CountryStatusDisplay::SetContentForInQueue() -{ - ASSERT(m_label->isVisible(), ()); - m_label->setText(FormatStatusMessage("country_status_added_to_queue", &m_displayMapName)); -} - -void CountryStatusDisplay::SetContentForError() -{ - ASSERT(m_label->isVisible(), ()); - ASSERT(m_primaryButton->isVisible(), ()); - - if (m_countryStatus == TStatus::EDownloadFailed) - m_label->setText(FormatStatusMessage("country_status_download_failed", &m_displayMapName)); - else - m_label->setText(FormatStatusMessage("not_enough_free_space_on_sdcard")); - - m_primaryButton->setText(m_controller->GetStringsBundle()->GetString("try_again")); -} - -void CountryStatusDisplay::ComposeElementsForState() -{ - ASSERT(isVisible(), ()); - int visibleCount = 0; - auto visibleCheckFn = [&visibleCount] (gui::Element const * e) - { - if (e->isVisible()) - ++visibleCount; - }; - - visibleCheckFn(m_label.get()); - visibleCheckFn(m_primaryButton.get()); - visibleCheckFn(m_secondaryButton.get()); - - ASSERT(visibleCount > 0, ()); - - m2::PointD const & pv = pivot(); - size_t const emptySpace = 16 * visualScale(); - if (visibleCount == 1) - m_label->setPivot(pv); - - else if (visibleCount == 2) - { - size_t const labelHeight = m_label->GetBoundRect().SizeY(); - size_t const buttonHeight = m_primaryButton->GetBoundRect().SizeY(); - size_t const commonHeight = buttonHeight + labelHeight + emptySpace; - - m_label->setPivot(m2::PointD(pv.x, pv.y - commonHeight / 2 + labelHeight / 2)); - m_primaryButton->setPivot(m2::PointD(pv.x, pv.y + commonHeight / 2 - buttonHeight / 2)); - } - else - { - size_t const labelHeight = m_label->GetBoundRect().SizeY(); - size_t const primButtonHeight = m_primaryButton->GetBoundRect().SizeY(); - size_t const secButtonHeight = m_secondaryButton->GetBoundRect().SizeY(); - - double const offsetFromCenter = (primButtonHeight / 2 + emptySpace); - - m_label->setPivot(m2::PointD(pv.x, pv.y - offsetFromCenter - labelHeight / 2)); - m_primaryButton->setPivot(pv); - m_secondaryButton->setPivot(m2::PointD(pv.x, pv.y + offsetFromCenter + secButtonHeight / 2.0)); - } -} - -bool CountryStatusDisplay::OnTapAction(TTapActionFn const & action, const m2::PointD & pt) -{ - bool result = false; - if (m_primaryButton->isVisible() && m_primaryButton->hitTest(pt)) - result |= action(m_primaryButton, pt); - else if (m_secondaryButton->isVisible() && m_secondaryButton->hitTest(pt)) - result |= action(m_secondaryButton, pt); - - return result; -} - -void CountryStatusDisplay::OnButtonClicked(gui::Element const * button) -{ - ASSERT(m_countryIdx.IsValid(), ()); - - MapOptions options = MapOptions::Map; - if (button == m_primaryButton.get()) - options = SetOptions(options, MapOptions::CarRouting); - - ASSERT(m_downloadCallback, ()); - int opt = static_cast(options); - if (IsStatusFailed()) - opt = -1; - - m_downloadCallback(m_countryIdx, opt); - - alohalytics::LogEvent("CountryStatusDisplay::OnButtonClicked", DebugPrint(options)); -} - -void CountryStatusDisplay::Repaint() const -{ - setIsDirtyLayout(true); - const_cast(this)->invalidate(); -} - -bool CountryStatusDisplay::IsStatusFailed() const -{ - return m_countryStatus == TStatus::EOutOfMemFailed || m_countryStatus == TStatus::EDownloadFailed; -} - -void CountryStatusDisplay::Lock() const -{ -#ifdef OMIM_OS_ANDROID - m_mutex.Lock(); -#endif -} - -void CountryStatusDisplay::Unlock() const -{ -#ifdef OMIM_OS_ANDROID - m_mutex.Unlock(); -#endif -} diff --git a/map/country_status_display.hpp b/map/country_status_display.hpp deleted file mode 100644 index cfe993325e..0000000000 --- a/map/country_status_display.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once - -#include "map/active_maps_layout.hpp" - -#include "storage/storage_defines.hpp" - -#include "std/unique_ptr.hpp" -#include "std/target_os.hpp" - -class Framework; - -namespace storage { struct TIndex; } - -/// This class is a composite GUI element to display -/// an on-screen GUI for the country, which is not downloaded yet. -class CountryStatusDisplay : public storage::ActiveMapsLayout::ActiveMapsListener -{ -public: - struct Params - { - Params(storage::ActiveMapsLayout & activeMaps) : m_activeMaps(activeMaps) {} - - storage::ActiveMapsLayout & m_activeMaps; - }; - - CountryStatusDisplay(Params const & p); - ~CountryStatusDisplay(); - - /// set current country name - void SetCountryIndex(storage::TIndex const & idx); - typedef function TDownloadCountryFn; - void SetDownloadCountryListener(TDownloadCountryFn const & fn) { m_downloadCallback = fn; } - - /// @name Override from graphics::OverlayElement and gui::Element. - //@{ - virtual void setIsVisible(bool isVisible) const; - virtual void setIsDirtyLayout(bool isDirty) const; - - void cache(); - void purge(); - void layout(); - //@} - -private: - virtual void CountryGroupChanged(storage::ActiveMapsLayout::TGroup const & oldGroup, int oldPosition, - storage::ActiveMapsLayout::TGroup const & newGroup, int newPosition) {} - virtual void CountryStatusChanged(storage::ActiveMapsLayout::TGroup const & group, int position, - storage::TStatus const & oldStatus, storage::TStatus const & newStatus); - virtual void CountryOptionsChanged(storage::ActiveMapsLayout::TGroup const & group, int position, - MapOptions const & oldOpt, MapOptions const & newOpt) - { - } - virtual void DownloadingProgressUpdate(storage::ActiveMapsLayout::TGroup const & group, int position, - storage::LocalAndRemoteSizeT const & progress); - - template - string FormatStatusMessage(string const & msgID, T1 const * t1 = 0, T2 const * t2 = 0); - - void FormatDisplayName(string const & mapName, string const & groupName); - - void SetVisibilityForState() const; - void SetContentForState(); - void SetContentForDownloadPropose(); - void SetContentForProgress(); - void SetContentForInQueue(); - void SetContentForError(); - - void ComposeElementsForState(); - - ///@TODO UVR - //typedef function const &, m2::PointD const &)> TTapActionFn; - //bool OnTapAction(TTapActionFn const & action, m2::PointD const & pt); - //void OnButtonClicked(Element const * button); - - bool IsStatusFailed() const; - -private: - storage::ActiveMapsLayout & m_activeMaps; - int m_activeMapsSlotID = 0; - - string m_displayMapName; - mutable storage::TStatus m_countryStatus = storage::TStatus::EUnknown; - storage::TIndex m_countryIdx; - storage::LocalAndRemoteSizeT m_progressSize; - - TDownloadCountryFn m_downloadCallback; -}; diff --git a/map/framework.cpp b/map/framework.cpp index b1e345773a..bc6166b984 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -229,10 +229,6 @@ Framework::Framework() m_stringsBundle.SetDefaultString("routing_failed_route_not_found", "There is no route found between the selected origin and destination.Please select a different start or end point."); m_stringsBundle.SetDefaultString("routing_failed_internal_error", "Internal error occurred. Please try to delete and download the map again. If problem persist please contact us at support@maps.me."); -#ifdef DRAW_TOUCH_POINTS - m_informationDisplay.enableDebugPoints(true); -#endif - m_model.InitClassificator(); m_model.SetOnMapDeregisteredCallback(bind(&Framework::OnMapDeregistered, this, _1)); LOG(LDEBUG, ("Classificator initialized")); @@ -1094,9 +1090,6 @@ size_t Framework::ShowAllSearchResults(search::Results const & results) FillSearchResultsMarks(results); m_fixedSearchResults = count; - ///@TODO UVR - //shared_ptr state = GetLocationState(); - //state->SetFixedZoom(); // Setup viewport according to results. m2::AnyRectD viewport = m_currentMovelView.GlobalRect(); m2::PointD const center = viewport.Center(); @@ -1258,6 +1251,8 @@ void Framework::CreateDrapeEngine(ref_ptr contextFactory, m_drapeEngine->SetMyPositionModeListener(m_myPositionListener); InvalidateMyPosition(); + + m_bmManager.InitBookmarks(); } ref_ptr Framework::GetDrapeEngine() @@ -1326,9 +1321,6 @@ bool Framework::ShowMapForURL(string const & url) enum ResultT { FAILED, NEED_CLICK, NO_NEED_CLICK }; ResultT result = FAILED; - // always hide current balloon here - DeactivateUserMark(); - using namespace url_scheme; using namespace strings; @@ -1379,6 +1371,9 @@ bool Framework::ShowMapForURL(string const & url) if (result != FAILED) { + // always hide current balloon here + DeactivateUserMark(); + // set viewport and stop follow mode if any StopLocationFollow(); ShowRect(rect); @@ -1399,13 +1394,11 @@ bool Framework::ShowMapForURL(string const & url) ActivateUserMark(mark, false); } } - else - DeactivateUserMark(); return true; } - else - return false; + + return false; } bool Framework::GetVisiblePOI(m2::PointD const & glbPoint, search::AddressInfo & info, feature::Metadata & metadata) const @@ -1564,6 +1557,14 @@ void Framework::DeactivateUserMark() ActivateUserMark(nullptr, true); } +bool Framework::HasActiveUserMark() +{ + if (m_drapeEngine == nullptr) + return false; + + return m_drapeEngine->GetSelectedObject() != df::SelectionShape::OBJECT_EMPTY; +} + void Framework::OnTapEvent(m2::PointD pxPoint, bool isLong, bool isMyPosition, FeatureID feature) { UserMark const * mark = OnTapEventImpl(pxPoint, isLong, isMyPosition, feature); @@ -1837,8 +1838,8 @@ void Framework::SetRouterImpl(RouterType type) void Framework::RemoveRoute(bool deactivateFollowing) { ASSERT_THREAD_CHECKER(m_threadChecker, ("RemoveRoute")); - ASSERT(m_drapeEngine != nullptr, ()); - m_drapeEngine->RemoveRoute(deactivateFollowing); + if (m_drapeEngine != nullptr) + m_drapeEngine->RemoveRoute(deactivateFollowing); } void Framework::CloseRouting() @@ -1851,7 +1852,8 @@ void Framework::CloseRouting() void Framework::InsertRoute(Route const & route) { ASSERT_THREAD_CHECKER(m_threadChecker, ("InsertRoute")); - ASSERT(m_drapeEngine != nullptr, ()); + if (m_drapeEngine == nullptr) + return; if (route.GetPoly().GetSize() < 2) { diff --git a/map/framework.hpp b/map/framework.hpp index 1aa137038d..031d91dee1 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -254,6 +254,7 @@ public: void ActivateUserMark(UserMark const * mark, bool needAnim); void DeactivateUserMark(); + bool HasActiveUserMark(); PoiMarkPoint * GetAddressMark(m2::PointD const & globalPoint) const; using TActivateCallbackFn = function mark)>; diff --git a/map/information_display.cpp b/map/information_display.cpp deleted file mode 100644 index f91ed26197..0000000000 --- a/map/information_display.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "map/information_display.hpp" -#include "map/compass_arrow.hpp" -#include "map/framework.hpp" -#include "map/alfa_animation_task.hpp" - -#include "anim/task.hpp" -#include "anim/controller.hpp" - -#include "platform/platform.hpp" - -#include "geometry/transformations.hpp" - -void InformationDisplay::InitLocationState() -{ - ///@TODO UVR -// location::State::Params p; - -// p.m_position = EPosCenter; -// p.m_depth = locationDepth; -// p.m_pivot = m2::PointD(0, 0); -// p.m_locationAreaColor = Color(0x51, 0xA3, 0xDC, 0x46); -// p.m_framework = fw; - -// m_locationState.reset(new location::State(p)); -} - -shared_ptr const & InformationDisplay::locationState() const -{ - ///@TODO UVR - return nullptr; //m_locationState; -} - -void InformationDisplay::measurementSystemChanged() -{ - ///@TODO UVR - //m_ruler->setIsDirtyLayout(true); -} - -void InformationDisplay::ResetRouteMatchingInfo() -{ - m_locationState->ResetRouteMatchingInfo(); -} - -void InformationDisplay::SetWidgetPivot(WidgetType widget, m2::PointD const & pivot) -{ - auto const setPivotFn = [](shared_ptr e, m2::PointD const & point) - { - if (e) - e->setPivot(point); - }; - - switch(widget) - { - case WidgetType::Ruler: - setPivotFn(m_ruler, pivot); - return; - case WidgetType::CopyrightLabel: - setPivotFn(m_copyrightLabel, pivot); - return; - case WidgetType::CountryStatusDisplay: - setPivotFn(m_countryStatusDisplay, pivot); - return; - case WidgetType::CompassArrow: - setPivotFn(m_compassArrow, pivot); - return; - case WidgetType::DebugLabel: - setPivotFn(m_debugLabel, pivot); - return; - default: - ASSERT(false, ()); - } -} - -m2::PointD InformationDisplay::GetWidgetSize(WidgetType widget) const -{ - m2::RectD boundRect; - switch(widget) - { - case WidgetType::Ruler: - if (m_ruler) - boundRect = m_ruler->GetBoundRect(); - break; - case WidgetType::CompassArrow: - if (m_compassArrow) - return m_compassArrow->GetPixelSize(); - case WidgetType::DebugLabel: - case WidgetType::CountryStatusDisplay: - case WidgetType::CopyrightLabel: - default: - ASSERT(false, ()); - } - return m2::PointD(boundRect.SizeX(), boundRect.SizeY()); -} diff --git a/map/information_display.hpp b/map/information_display.hpp deleted file mode 100644 index 4d62eaffe9..0000000000 --- a/map/information_display.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include "storage/index.hpp" - -#include "geometry/point2d.hpp" -#include "geometry/rect2d.hpp" - -#include "base/timer.hpp" - -#include "std/shared_ptr.hpp" - - -namespace location -{ - class State; -} - -/// Class, which displays additional information on the primary layer like: -/// rules, coordinates, GPS position and heading, compass, Download button, etc. -class InformationDisplay -{ - shared_ptr m_locationState; - - void InitLocationState(); -public: - enum class WidgetType { - Ruler = 0, - CopyrightLabel, - CountryStatusDisplay, - CompassArrow, - DebugLabel - }; - - void setDisplayRect(m2::RectI const & rect); - - void measurementSystemChanged(); - - shared_ptr const & locationState() const; - - void ResetRouteMatchingInfo(); - - void SetWidgetPivot(WidgetType widget, m2::PointD const & pivot); - m2::PointD GetWidgetSize(WidgetType widget) const; -}; diff --git a/map/location_state.cpp b/map/location_state.cpp deleted file mode 100644 index c964c48b5e..0000000000 --- a/map/location_state.cpp +++ /dev/null @@ -1,404 +0,0 @@ -#include "map/location_state.hpp" -#include "map/framework.hpp" - -#include "indexer/mercator.hpp" -#include "indexer/scales.hpp" - -#include "platform/location.hpp" -#include "platform/settings.hpp" - -#include "geometry/rect2d.hpp" -#include "geometry/transformations.hpp" -#include "3party/Alohalytics/src/alohalytics.h" - - -namespace location -{ - -namespace -{ - -//static const int POSITION_Y_OFFSET = 120; -//static const double POSITION_TOLERANCE = 1.0E-6; // much less than coordinates coding error -//static const double ANGLE_TOLERANCE = my::DegToRad(3.0); - -//class RotateAndFollowAnim : public anim::Task -//{ -//public: -// RotateAndFollowAnim(Framework * fw, m2::PointD const & srcPos, -// double srcAngle, -// m2::PointD const & srcPixelBinding, -// m2::PointD const & dstPixelbinding) -// : m_fw(fw) -// , m_hasPendingAnimation(false) -// { -// //@TODO UVR -//// m_angleAnim.reset(new anim::SafeAngleInterpolation(srcAngle, srcAngle, 1.0)); -//// m_posAnim.reset(new anim::SafeSegmentInterpolation(srcPos, srcPos, 1.0)); -//// m2::PointD const srcInverted = InvertPxBinding(srcPixelBinding); -//// m2::PointD const dstInverted = InvertPxBinding(dstPixelbinding); -//// m_pxBindingAnim.reset(new anim::SafeSegmentInterpolation(srcInverted, dstInverted, -//// m_fw->GetNavigator().ComputeMoveSpeed(srcInverted, dstInverted))); -// } - -// void SetDestinationParams(m2::PointD const & dstPos, double dstAngle) -// { -// ASSERT(m_angleAnim != nullptr, ()); -// ASSERT(m_posAnim != nullptr, ()); - -// if (IsVisual() || m_idleFrames > 0) -// { -// //Store new params even if animation is active but don't interrupt the current one. -// //New animation to the pending params will be made after all. -// m_hasPendingAnimation = true; -// m_pendingDstPos = dstPos; -// m_pendingAngle = dstAngle; -// } -// else -// SetParams(dstPos, dstAngle); -// } - -// void Update() -// { -// if (!IsVisual() && m_hasPendingAnimation && m_idleFrames == 0) -// { -// m_hasPendingAnimation = false; -// SetParams(m_pendingDstPos, m_pendingAngle); -// ///@TODO UVR -// //m_fw->Invalidate(); -// } -// else if (m_idleFrames > 0) -// { -// --m_idleFrames; -// ///@TODO UVR -// //m_fw->Invalidate(); -// } -// } - -// m2::PointD const & GetPositionForDraw() -// { -// return m_posAnim->GetCurrentValue(); -// } - -// virtual void OnStep(double ts) -// { -// if (m_idleFrames > 0) -// return; - -// ASSERT(m_angleAnim != nullptr, ()); -// ASSERT(m_posAnim != nullptr, ()); -// ASSERT(m_pxBindingAnim != nullptr, ()); - -// bool updateViewPort = false; -// updateViewPort |= OnStep(m_angleAnim.get(), ts); -// updateViewPort |= OnStep(m_posAnim.get(), ts); -// updateViewPort |= OnStep(m_pxBindingAnim.get(), ts); - -// if (updateViewPort) -// { -// UpdateViewport(); -// if (!IsVisual()) -// m_idleFrames = 5; -// } -// } - -// virtual bool IsVisual() const -// { -// ASSERT(m_posAnim != nullptr, ()); -// ASSERT(m_angleAnim != nullptr, ()); -// ASSERT(m_pxBindingAnim != nullptr, ()); - -// return m_posAnim->IsRunning() || -// m_angleAnim->IsRunning() || -// m_pxBindingAnim->IsRunning(); -// } - -//private: -// void UpdateViewport() -// { -// ASSERT(m_posAnim != nullptr, ()); -// ASSERT(m_angleAnim != nullptr, ()); -// ASSERT(m_pxBindingAnim != nullptr, ()); - -// m2::PointD const & pxBinding = m_pxBindingAnim->GetCurrentValue(); -// m2::PointD const & currentPosition = m_posAnim->GetCurrentValue(); -// double currentAngle = m_angleAnim->GetCurrentValue(); - -// //@{ pixel coord system -// m2::PointD const pxCenter = GetPixelRect().Center(); -// m2::PointD vectorToCenter = pxCenter - pxBinding; -// if (!vectorToCenter.IsAlmostZero()) -// vectorToCenter = vectorToCenter.Normalize(); -// m2::PointD const vectorToTop = m2::PointD(0.0, 1.0); -// double sign = m2::CrossProduct(vectorToTop, vectorToCenter) > 0 ? 1 : -1; -// double angle = sign * acos(m2::DotProduct(vectorToTop, vectorToCenter)); -// //@} - -// //@{ global coord system -// double offset = (m_fw->PtoG(pxCenter) - m_fw->PtoG(pxBinding)).Length(); -// m2::PointD const viewPoint = currentPosition.Move(1.0, currentAngle + my::DegToRad(90.0)); -// m2::PointD const viewVector = viewPoint - currentPosition; -// m2::PointD rotateVector = viewVector; -// rotateVector.Rotate(angle); -// rotateVector.Normalize(); -// rotateVector *= offset; -// //@} - -// ///@TODO UVR -//// m_fw->SetViewportCenter(currentPosition + rotateVector); -//// m_fw->GetNavigator().SetAngle(currentAngle); -// //m_fw->Invalidate(); -// } - -// void SetParams(m2::PointD const & dstPos, double dstAngle) -// { -// ///@TODO UVR -//// double const angleDist = fabs(ang::GetShortestDistance(m_angleAnim->GetCurrentValue(), dstAngle)); -//// if (dstPos.EqualDxDy(m_posAnim->GetCurrentValue(), POSITION_TOLERANCE) && angleDist < ANGLE_TOLERANCE) -//// return; - -//// double const posSpeed = 2 * m_fw->GetNavigator().ComputeMoveSpeed(m_posAnim->GetCurrentValue(), dstPos); -//// double const angleSpeed = angleDist < 1.0 ? 1.5 : m_fw->GetAnimator().GetRotationSpeed(); -//// m_angleAnim->ResetDestParams(dstAngle, angleSpeed); -//// m_posAnim->ResetDestParams(dstPos, posSpeed); -// } - -// bool OnStep(anim::Task * task, double ts) -// { -// if (!task->IsReady() && !task->IsRunning()) -// return false; - -// if (task->IsReady()) -// { -// task->Start(); -// task->OnStart(ts); -// } - -// if (task->IsRunning()) -// task->OnStep(ts); - -// if (task->IsEnded()) -// task->OnEnd(ts); - -// return true; -// } - -//private: -// m2::PointD InvertPxBinding(m2::PointD const & px) const -// { -// return m2::PointD(px.x, GetPixelRect().maxY() - px.y); -// } - -// m2::RectD const & GetPixelRect() const -// { -// ///@TODO UVR -// return m2::RectD(); -// //return m_fw->GetNavigator().Screen().PixelRect(); -// } - -//private: -// Framework * m_fw; - -// unique_ptr m_angleAnim; -// unique_ptr m_posAnim; -// unique_ptr m_pxBindingAnim; - -// bool m_hasPendingAnimation; -// m2::PointD m_pendingDstPos; -// double m_pendingAngle; -// // When map has active animation, backgroung rendering pausing -// // By this beetwen animations we wait some frames to release background rendering -// int m_idleFrames = 0; -//}; - -} - -//void State::RouteBuilded() -//{ -// StopAllAnimations(); -// SetModeInfo(IncludeModeBit(m_modeInfo, RoutingSessionBit)); - -// Mode const mode = GetMode(); -// if (mode > NotFollow) -// SetModeInfo(ChangeMode(m_modeInfo, NotFollow)); -// else if (mode == UnknownPosition) -// { -// m_afterPendingMode = NotFollow; -// SetModeInfo(ChangeMode(m_modeInfo, PendingPosition)); -// } -//} - -//void State::StartRouteFollow() -//{ -// ASSERT(IsInRouting(), ()); -// ASSERT(IsModeHasPosition(), ()); - -// m2::PointD const size(m_errorRadius, m_errorRadius); -// m_framework->ShowRect(m2::RectD(m_position - size, m_position + size), -// scales::GetNavigationScale()); - -// SetModeInfo(ChangeMode(m_modeInfo, NotFollow)); -// SetModeInfo(ChangeMode(m_modeInfo, IsRotationActive() ? RotateAndFollow : Follow)); -//} - -//void State::StopRoutingMode() -//{ -// if (IsInRouting()) -// { -// SetModeInfo(ChangeMode(ExcludeModeBit(m_modeInfo, RoutingSessionBit), GetMode() == RotateAndFollow ? Follow : NotFollow)); -// RotateOnNorth(); -// AnimateFollow(); -// } -//} - - -//m2::PointD const State::GetModeDefaultPixelBinding(State::Mode mode) const -//{ -// switch (mode) -// { -// case Follow: return m_framework->GetPixelCenter(); -// case RotateAndFollow: return GetRaFModeDefaultPxBind(); -// default: return m2::PointD(0.0, 0.0); -// } -//} - -//bool State::FollowCompass() -//{ -// if (!IsRotationActive() || GetMode() != RotateAndFollow || m_animTask == nullptr) -// return false; - -// RotateAndFollowAnim * task = static_cast(m_animTask.get()); -// task->SetDestinationParams(Position(), -m_drawDirection); -// return true; -//} - -//m2::PointD const State::GetRaFModeDefaultPxBind() const -//{ -// return m2::PointD(); -// ///@TODO UVR -//// m2::RectD const & pixelRect = GetModelView().PixelRect(); -//// return m2::PointD(pixelRect.Center().x, -//// pixelRect.maxY() - POSITION_Y_OFFSET * visualScale()); -//} - -//void State::DragStarted() -//{ -// m_dragModeInfo = m_modeInfo; -// m_afterPendingMode = NotFollow; -// StopLocationFollow(); -//} - -//void State::DragEnded() -//{ -// // reset GPS centering mode if we have dragged far from current location -// ScreenBase const & s = GetModelView(); -// m2::PointD const defaultPxBinding = GetModeDefaultPixelBinding(ExcludeAllBits(m_dragModeInfo)); -// m2::PointD const pxPosition = s.GtoP(Position()); - -// if (ExcludeAllBits(m_dragModeInfo) > NotFollow && -// defaultPxBinding.Length(pxPosition) < s.GetMinPixelRectSize() / 5.0) -// { -// SetModeInfo(m_dragModeInfo); -// } - -// m_dragModeInfo = 0; -//} - -//void State::ScaleStarted() -//{ -// m_scaleModeInfo = m_modeInfo; -//} - -//void State::CorrectScalePoint(m2::PointD & pt) const -//{ -// if (IsModeChangeViewport() || ExcludeAllBits(m_scaleModeInfo) > NotFollow) -// pt = m_framework->GtoP(Position()); -//} - -//void State::CorrectScalePoint(m2::PointD & pt1, m2::PointD & pt2) const -//{ -// if (IsModeChangeViewport() || ExcludeAllBits(m_scaleModeInfo) > NotFollow) -// { -// m2::PointD const ptDiff = m_framework->GtoP(Position()) - (pt1 + pt2) / 2; -// pt1 += ptDiff; -// pt2 += ptDiff; -// } -//} - -//void State::ScaleEnded() -//{ -// m_scaleModeInfo = 0; -//} - -//void State::Rotated() -//{ -// m_afterPendingMode = NotFollow; -// EndAnimation(); -// if (GetMode() == RotateAndFollow) -// SetModeInfo(ChangeMode(m_modeInfo, NotFollow)); -//} - -//void State::OnCompassTaped() -//{ -// StopCompassFollowing(); -// RotateOnNorth(); -// AnimateFollow(); -//} - -//void State::OnSize() -//{ -// if (GetMode() == RotateAndFollow) -// { -// EndAnimation(); -// CreateAnimTask(m_framework->GtoP(Position()), GetModeDefaultPixelBinding(GetMode())); -// } -//} - -//void State::AnimateStateTransition(Mode oldMode, Mode newMode) -//{ -// StopAllAnimations(); - -// if (oldMode == PendingPosition && newMode == Follow) -// { -// if (!TestModeBit(m_modeInfo, FixedZoomBit)) -// { -// m2::PointD const size(m_errorRadius, m_errorRadius); -// m_framework->ShowRect(m2::RectD(m_position - size, m_position + size), -// scales::GetUpperComfortScale()); -// } -// } -// else if (newMode == RotateAndFollow) -// { -// CreateAnimTask(); -// } -// else if (oldMode == RotateAndFollow && newMode == UnknownPosition) -// { -// RotateOnNorth(); -// } -// else if (oldMode == NotFollow && newMode == Follow) -// { -// m2::AnyRectD screenRect = GetModelView().GlobalRect(); -// m2::RectD const & clipRect = GetModelView().ClipRect(); -// screenRect.Inflate(clipRect.SizeX() / 2.0, clipRect.SizeY() / 2.0); -// if (!screenRect.IsPointInside(m_position)) -// m_framework->SetViewportCenter(m_position); -// } - -// AnimateFollow(); -//} - -//void State::AnimateFollow() -//{ -// if (!IsModeChangeViewport()) -// return; - -// SetModeInfo(ExcludeModeBit(m_modeInfo, FixedZoomBit)); - -// if (!FollowCompass()) -// { -// ///@TODO UVR -//// if (!m_position.EqualDxDy(m_framework->GetViewportCenter(), POSITION_TOLERANCE)) -//// m_framework->SetViewportCenterAnimated(m_position); -// } -//} -} diff --git a/map/location_state.hpp b/map/location_state.hpp deleted file mode 100644 index e5029533da..0000000000 --- a/map/location_state.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include "geometry/point2d.hpp" - -#include "base/timer.hpp" - -#include "routing/turns.hpp" - -#include "platform/location.hpp" - -#include "std/function.hpp" -#include "std/shared_ptr.hpp" -#include "std/unique_ptr.hpp" -#include "std/map.hpp" - -class Framework; -class ScreenBase; - -namespace location -{ - class GpsInfo; - class CompassInfo; - - // Class, that handles position and compass updates, - // centers, scales and rotates map according to this updates - // and draws location and compass marks. - class State - { - - public: -// void RouteBuilded(); -// void StartRouteFollow(); -// void StopRoutingMode(); - -// /// @name User input notification block -// //@{ -// void DragStarted(); -// void DragEnded(); - -// void ScaleStarted(); -// void CorrectScalePoint(m2::PointD & pt) const; -// void CorrectScalePoint(m2::PointD & pt1, m2::PointD & pt2) const; -// void ScaleEnded(); - -// void Rotated(); -// //@} - -// void OnCompassTaped(); - -// void OnSize(); - - private: - - //m2::PointD const GetModeDefaultPixelBinding(Mode mode) const; - //m2::PointD const GetRaFModeDefaultPxBind() const; - - private: - uint16_t m_dragModeInfo = 0; - uint16_t m_scaleModeInfo = 0; - }; -} diff --git a/map/move_screen_task.cpp b/map/move_screen_task.cpp deleted file mode 100644 index bc92ebb8e6..0000000000 --- a/map/move_screen_task.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "map/move_screen_task.hpp" - -#include "map/framework.hpp" - -MoveScreenTask::MoveScreenTask(Framework * framework, - m2::PointD const & startPt, - m2::PointD const & endPt, - double interval) - : anim::SegmentInterpolation(startPt, - endPt, - interval, - m_outPt), - m_framework(framework) -{} - -void MoveScreenTask::OnStep(double ts) -{ - m2::PointD oldPt = m_outPt; - anim::SegmentInterpolation::OnStep(ts); -// Navigator & nav = m_framework->GetNavigator(); -// nav.SetOrg(nav.Screen().GetOrg() + m_outPt - oldPt); -} - -void MoveScreenTask::OnEnd(double ts) -{ - anim::SegmentInterpolation::OnEnd(ts); -// Navigator & nav = m_framework->GetNavigator(); -// nav.SetOrg(m_outPt); - m_framework->UpdateUserViewportChanged(); -} - -bool MoveScreenTask::IsVisual() const -{ - return true; -} diff --git a/map/move_screen_task.hpp b/map/move_screen_task.hpp deleted file mode 100644 index cbcc24fe10..0000000000 --- a/map/move_screen_task.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "anim/segment_interpolation.hpp" - -class Framework; - -class MoveScreenTask : public anim::SegmentInterpolation -{ -private: - - Framework * m_framework; - m2::PointD m_outPt; - -public: - - MoveScreenTask(Framework * framework, - m2::PointD const & startPt, - m2::PointD const & endPt, - double interval); - - void OnStep(double ts); - void OnEnd(double ts); - - bool IsVisual() const; -}; diff --git a/map/navigator_utils.cpp b/map/navigator_utils.cpp deleted file mode 100644 index 7bdb8c70ee..0000000000 --- a/map/navigator_utils.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "navigator_utils.hpp" - -namespace navi -{ - -m2::AnyRectD ToRotated(m2::RectD const & rect, Navigator const & navigator) -{ - double const dx = rect.SizeX(); - double const dy = rect.SizeY(); - - return m2::AnyRectD(rect.Center(), - navigator.Screen().GetAngle(), - m2::RectD(-dx/2, -dy/2, dx/2, dy/2)); -} - -void SetRectFixedAR(m2::AnyRectD const & rect, const ScalesProcessor & scales, Navigator & navigator) -{ - double const halfSize = scales.GetTileSize() / 2.0; - m2::RectD etalonRect(-halfSize, -halfSize, halfSize, halfSize); - - m2::PointD const pxCenter = navigator.Screen().PixelRect().Center(); - etalonRect.Offset(pxCenter); - - navigator.SetFromRects(rect, etalonRect); -} - -} // namespace navi diff --git a/map/navigator_utils.hpp b/map/navigator_utils.hpp deleted file mode 100644 index 4e76113499..0000000000 --- a/map/navigator_utils.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "navigator.hpp" - -#include "render/scales_processor.hpp" - -#include "geometry/any_rect2d.hpp" - -namespace navi -{ - -m2::AnyRectD ToRotated(m2::RectD const & rect, Navigator const & navigator); -void SetRectFixedAR(m2::AnyRectD const & rect, ScalesProcessor const & scales, Navigator & navigator); - -} // namespace navi diff --git a/map/qgl_render_context.cpp b/map/qgl_render_context.cpp deleted file mode 100644 index 9a2b008f25..0000000000 --- a/map/qgl_render_context.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "base/SRC_FIRST.hpp" - -#include "map/qgl_render_context.hpp" - -#include "base/assert.hpp" -#include "base/logging.hpp" - -#include -#include -#include - - -namespace qt -{ - namespace gl - { - struct null_deleter - { - template void operator()(T*) {} - }; - - /// Create compatible render context - RenderContext::RenderContext(QGLWidget * widget) - { - /// Dirty hack, but we'll use it with caution, I promise. - m_context = shared_ptr(const_cast(widget->context()), null_deleter()); - } - - void RenderContext::makeCurrent() - { - m_context->makeCurrent(); - } - - graphics::RenderContext * RenderContext::createShared() - { - graphics::gl::RenderContext * res = new RenderContext(this); - res->setResourceManager(resourceManager()); - return res; - } - - void RenderContext::endThreadDrawing(unsigned threadSlot) - { - m_context.reset(); - graphics::gl::RenderContext::endThreadDrawing(threadSlot); - } - - RenderContext::RenderContext(RenderContext * renderContext) - { - QGLFormat const format = renderContext->context()->format(); - m_parent = make_shared(); - m_context = make_shared(format, m_parent.get()); - bool sharedContextCreated = m_context->create(renderContext->context().get()); - bool isSharing = m_context->isSharing(); - ASSERT(sharedContextCreated && isSharing, ("cannot create shared opengl context")); - if (!sharedContextCreated || !isSharing) - m_context.reset(); - } - - RenderContext::~RenderContext() - { - m_context.reset(); - m_parent.reset(); - } - - shared_ptr RenderContext::context() const - { - return m_context; - } - } -} diff --git a/map/qgl_render_context.hpp b/map/qgl_render_context.hpp deleted file mode 100644 index bb628e1c4a..0000000000 --- a/map/qgl_render_context.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include "graphics/opengl/gl_render_context.hpp" - -#include "std/shared_ptr.hpp" - -class QWidget; -class QGLContext; -class QGLWidget; - -namespace qt -{ - namespace gl - { - class RenderContext : public graphics::gl::RenderContext - { - private: - shared_ptr m_context; - shared_ptr m_parent; - - /// Creates a rendering context, which shares - /// data(textures, display lists e.t.c) with renderContext. - /// Used in rendering thread. - RenderContext(RenderContext * renderContext); - - public: - RenderContext(QGLWidget * widget); - ~RenderContext(); - - /// Make this rendering context current - void makeCurrent(); - - graphics::RenderContext * createShared(); - - /// Leave previous logic, but fix thread widget deletion error. - void endThreadDrawing(unsigned threadSlot); - - shared_ptr context() const; - }; - } -} diff --git a/map/route_track.cpp b/map/route_track.cpp deleted file mode 100644 index 1144157497..0000000000 --- a/map/route_track.cpp +++ /dev/null @@ -1,323 +0,0 @@ -#include "map/route_track.hpp" - -#include "indexer/scales.hpp" - -#include "std/array.hpp" - -namespace -{ - pair ShiftArrow(pair const & arrowDirection) - { - return pair(arrowDirection.first - (arrowDirection.second - arrowDirection.first), - arrowDirection.first); - } - -// void DrawArrowTriangle(graphics::Screen * dlScreen, pair const & arrowDirection, -// double arrowWidth, double arrowLength, graphics::Color arrowColor, double arrowDepth) -// { -// ASSERT(dlScreen, ()); - -// array arrow; -// m2::GetArrowPoints(arrowDirection.first, arrowDirection.second, arrowWidth, arrowLength, arrow); -// dlScreen->drawConvexPolygon(&arrow[0], arrow.size(), arrowColor, arrowDepth); -// } -} - -bool ClipArrowBodyAndGetArrowDirection(vector & ptsTurn, pair & arrowDirection, - size_t turnIndex, double beforeTurn, double afterTurn, double arrowLength) -{ - size_t const ptsTurnSz = ptsTurn.size(); - ASSERT_LESS(turnIndex, ptsTurnSz, ()); - ASSERT_GREATER(ptsTurnSz, 1, ()); - - /// Clipping after turnIndex - size_t i = turnIndex; - double len = 0, vLen = 0; - while (len < afterTurn) - { - if (i > ptsTurnSz - 2) - return false; - vLen = ptsTurn[i + 1].Length(ptsTurn[i]); - len += vLen; - i += 1; - } - if (my::AlmostEqualULPs(vLen, 0.)) - return false; - - double lenForArrow = len - afterTurn; - double vLenForArrow = lenForArrow; - size_t j = i; - while (lenForArrow < arrowLength) - { - if (j > ptsTurnSz - 2) - return false; - vLenForArrow = ptsTurn[j + 1].Length(ptsTurn[j]); - lenForArrow += vLenForArrow; - j += 1; - } - ASSERT_GREATER(j, 0, ()); - if (m2::AlmostEqualULPs(ptsTurn[j - 1], ptsTurn[j])) - return false; - m2::PointD arrowEnd = m2::PointAtSegment(ptsTurn[j - 1], ptsTurn[j], vLenForArrow - (lenForArrow - arrowLength)); - - if (my::AlmostEqualULPs(len, afterTurn)) - ptsTurn.resize(i + 1); - else - { - if (!m2::AlmostEqualULPs(ptsTurn[i], ptsTurn[i - 1])) - { - m2::PointD const p = m2::PointAtSegment(ptsTurn[i - 1], ptsTurn[i], vLen - (len - afterTurn)); - ptsTurn[i] = p; - ptsTurn.resize(i + 1); - } - else - ptsTurn.resize(i); - } - - // Calculating arrow direction - arrowDirection.first = ptsTurn.back(); - arrowDirection.second = arrowEnd; - arrowDirection = ShiftArrow(arrowDirection); - - /// Clipping before turnIndex - i = turnIndex; - len = 0; - while (len < beforeTurn) - { - if (i < 1) - return false; - vLen = ptsTurn[i - 1].Length(ptsTurn[i]); - len += vLen; - i -= 1; - } - if (my::AlmostEqualULPs(vLen, 0.)) - return false; - - if (my::AlmostEqualULPs(len, beforeTurn)) - { - if (i != 0) - { - ptsTurn.erase(ptsTurn.begin(), ptsTurn.begin() + i); - return true; - } - } - else - { - if (!m2::AlmostEqualULPs(ptsTurn[i], ptsTurn[i + 1])) - { - m2::PointD const p = m2::PointAtSegment(ptsTurn[i + 1], ptsTurn[i], vLen - (len - beforeTurn)); - ptsTurn[i] = p; - if (i != 0) - { - ptsTurn.erase(ptsTurn.begin(), ptsTurn.begin() + i); - return true; - } - } - else - { - ptsTurn.erase(ptsTurn.begin(), ptsTurn.begin() + i); - return true; - } - } - return true; -} - -bool MergeArrows(vector & ptsCurrentTurn, vector const & ptsNextTurn, double bodyLen, double arrowLen) -{ - ASSERT_GREATER_OR_EQUAL(ptsCurrentTurn.size(), 2, ()); - ASSERT_GREATER_OR_EQUAL(ptsNextTurn.size(), 2, ()); - ASSERT_GREATER(bodyLen, 0, ()); - ASSERT_GREATER(arrowLen, 0, ()); - ASSERT_GREATER(bodyLen, arrowLen, ()); - - double const distBetweenBodies = ptsCurrentTurn.back().Length(ptsNextTurn.front()); - /// The most likely the function returns here because the arrows are usually far to each other - if (distBetweenBodies > bodyLen) - return false; - - /// The arrows are close to each other or intersected - double const distBetweenBodies2 = ptsCurrentTurn[ptsCurrentTurn.size() - 2].Length(ptsNextTurn[1]); - if (distBetweenBodies < distBetweenBodies2) - { - /// The arrows bodies are not intersected - if (distBetweenBodies > arrowLen) - return false; - else - { - ptsCurrentTurn.push_back(ptsNextTurn.front()); - return true; - } - } - else - { - /// The arrows bodies are intersected. Make ptsCurrentTurn shorter if possible to prevent double rendering. - /// ptsNextTurn[0] is not a point of route network graph. It is generated while clipping. - /// The first point of route network graph is ptsNextTurn[1]. The same with the end of ptsCurrentTurn - m2::PointD const pivotPnt = ptsNextTurn[1]; - auto const currentTurnBeforeEnd = ptsCurrentTurn.end() - 1; - for (auto t = ptsCurrentTurn.begin() + 1; t != currentTurnBeforeEnd; ++t) - { - if (m2::AlmostEqualULPs(*t, pivotPnt)) - { - ptsCurrentTurn.erase(t + 1, ptsCurrentTurn.end()); - return true; - } - } - return true; - } -} - -/* -void RouteTrack::CreateDisplayListArrows(graphics::Screen * dlScreen, MatrixT const & matrix, double visualScale) const -{ - double const beforeTurn = 13. * visualScale; - double const afterTurn = 13. * visualScale; - double const arrowWidth = 10. * visualScale; - double const arrowLength = 19. * visualScale; - double const arrowBodyWidth = 8. * visualScale; - double const arrowDepth = graphics::arrowDepth; - - pair arrowDirection; - vector ptsTurn, ptsNextTurn; - - ptsTurn.reserve(m_turnsGeom.size()); - bool drawArrowHead = true; - auto turnsGeomEnd = m_turnsGeom.rend(); - for (auto t = m_turnsGeom.rbegin(); t != turnsGeomEnd; ++t) - { - if (t->m_indexInRoute < m_relevantMatchedInfo.GetIndexInRoute()) - continue; - ptsTurn.clear(); - if (t->m_points.empty()) - continue; - transform(t->m_points.begin(), t->m_points.end(), back_inserter(ptsTurn), DoLeftProduct(matrix)); - - if (!ClipArrowBodyAndGetArrowDirection(ptsTurn, arrowDirection, t->m_turnIndex, beforeTurn, afterTurn, arrowLength)) - continue; - if (ptsTurn.size() < 2) - continue; - - if (!ptsNextTurn.empty()) - drawArrowHead = !MergeArrows(ptsTurn, ptsNextTurn, beforeTurn + afterTurn, arrowLength); - - graphics::Pen::Info const outlineInfo(m_arrowColor, arrowBodyWidth); - uint32_t const outlineId = dlScreen->mapInfo(outlineInfo); - dlScreen->drawPath(&ptsTurn[0], ptsTurn.size(), 0, outlineId, arrowDepth); - - if (drawArrowHead) - DrawArrowTriangle(dlScreen, arrowDirection, arrowWidth, arrowLength, m_arrowColor, arrowDepth); - ptsNextTurn = ptsTurn; - } -} -*/ - -/// @todo there are some ways to optimize the code bellow. -/// 1. Call CreateDisplayListArrows only after passing the next arrow while driving -/// 2. Use several closest segments intead of one to recreate Display List for the most part of the track -/// -//void RouteTrack::CreateDisplayList(graphics::Screen * dlScreen, MatrixT const & matrix, bool isScaleChanged, -// int drawScale, double visualScale, -// location::RouteMatchingInfo const & matchingInfo) const -//{ -// if (HasDisplayLists() && !isScaleChanged && -// m_relevantMatchedInfo.GetPosition() == matchingInfo.GetPosition()) -// return; - -// PolylineD const & fullPoly = GetPolyline(); -// size_t const formerIndex = m_relevantMatchedInfo.GetIndexInRoute(); - -// if (matchingInfo.IsMatched()) -// m_relevantMatchedInfo = matchingInfo; -// size_t const currentIndex = m_relevantMatchedInfo.GetIndexInRoute(); - -// size_t const fullPolySz = fullPoly.GetSize(); -// if (currentIndex + 2 >= fullPolySz || fullPolySz < 2) -// { -// DeleteDisplayList(); -// DeleteClosestSegmentDisplayList(); -// return; -// } -// DeleteClosestSegmentDisplayList(); -// auto const curSegIter = fullPoly.Begin() + currentIndex; - -// //the most part of the route and symbols -// if (formerIndex != currentIndex || -// !HasDisplayLists() || isScaleChanged) -// { -// DeleteDisplayList(); -// dlScreen->beginFrame(); - -// graphics::DisplayList * dList = dlScreen->createDisplayList(); -// dlScreen->setDisplayList(dList); -// SetDisplayList(dList); - -// PolylineD mostPartPoly(curSegIter + 1, fullPoly.End()); -// PointContainerT ptsMostPart; -// ptsMostPart.reserve(mostPartPoly.GetSize()); -// TransformAndSymplifyPolyline(mostPartPoly, matrix, GetMainWidth(), ptsMostPart); -// CreateDisplayListPolyline(dlScreen, ptsMostPart); - -// PolylineD sym(vector({fullPoly.Front(), fullPoly.Back()})); -// PointContainerT ptsSym; -// TransformPolyline(sym, matrix, ptsSym); -// CreateDisplayListSymbols(dlScreen, ptsSym); - -// //arrows on the route -// if (drawScale >= scales::GetNavigationScale()) -// CreateDisplayListArrows(dlScreen, matrix, visualScale); -// } -// else -// dlScreen->beginFrame(); - -// //closest route segment -// m_closestSegmentDL = dlScreen->createDisplayList(); -// dlScreen->setDisplayList(m_closestSegmentDL); -// PolylineD closestPoly(m_relevantMatchedInfo.IsMatched() ? -// vector({m_relevantMatchedInfo.GetPosition(), fullPoly.GetPoint(currentIndex + 1)}) : -// vector({fullPoly.GetPoint(currentIndex), fullPoly.GetPoint(currentIndex + 1)})); -// PointContainerT pts; -// pts.reserve(closestPoly.GetSize()); -// TransformPolyline(closestPoly, matrix, pts); -// CreateDisplayListPolyline(dlScreen, pts); - -// dlScreen->setDisplayList(0); -// dlScreen->endFrame(); -//} - -void RouteTrack::DeleteClosestSegmentDisplayList() const -{ -// delete m_closestSegmentDL; -// m_closestSegmentDL = nullptr; -} - -//void RouteTrack::Draw(graphics::Screen * pScreen, MatrixT const & matrix) const -//{ -// Track::Draw(pScreen, matrix); -// pScreen->drawDisplayList(m_closestSegmentDL, matrix); -//} - -void RouteTrack::AddClosingSymbol(bool isBeginSymbol, string const & symbolName, dp::Anchor pos, double depth) -{ - if (isBeginSymbol) - m_beginSymbols.push_back(ClosingSymbol(symbolName, pos, depth)); - else - m_endSymbols.push_back(ClosingSymbol(symbolName, pos, depth)); -} - -//void RouteTrack::CreateDisplayListSymbols(graphics::Screen * dlScreen, PointContainerT const & pts) const -//{ -// ASSERT(!pts.empty(), ()); -// if (!m_beginSymbols.empty() || !m_endSymbols.empty()) -// { -// m2::PointD pivot = pts.front(); -// auto symDrawer = [&dlScreen, &pivot] (ClosingSymbol const & symbol) -// { -// dlScreen->drawSymbol(pivot, symbol.m_iconName, symbol.m_position, symbol.m_depth); -// }; - -// for_each(m_beginSymbols.begin(), m_beginSymbols.end(), symDrawer); - -// pivot = pts.back(); -// for_each(m_endSymbols.begin(), m_endSymbols.end(), symDrawer); -// } -//} diff --git a/map/route_track.hpp b/map/route_track.hpp deleted file mode 100644 index d768e78090..0000000000 --- a/map/route_track.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include "map/track.hpp" - -#include "platform/location.hpp" - -#include "routing/turns.hpp" -#include "drape/drape_global.hpp" - -#include "platform/location.hpp" - -class RouteTrack : public Track -{ -public: - explicit RouteTrack(PolylineD const & polyline) : Track(polyline, Params()) {} - - void AddClosingSymbol(bool isBeginSymbol, string const & symbolName, - dp::Anchor pos, double depth); - - void SetArrowColor(graphics::Color color) { m_arrowColor = color; } - -private: - void DeleteClosestSegmentDisplayList() const; - - struct ClosingSymbol - { - ClosingSymbol(string const & iconName, dp::Anchor pos, double depth) - : m_iconName(iconName), m_position(pos), m_depth(depth) {} - string m_iconName; - dp::Anchor m_position; - double m_depth; - }; - - vector m_beginSymbols; - vector m_endSymbols; - - mutable location::RouteMatchingInfo m_relevantMatchedInfo; -}; - -bool ClipArrowBodyAndGetArrowDirection(vector & ptsTurn, pair & arrowDirection, - size_t turnIndex, double beforeTurn, double afterTurn, double arrowLength); -bool MergeArrows(vector & ptsCurrentTurn, vector const & ptsNextTurn, double bodyLen, double arrowLen);