forked from organicmaps/organicmaps
[Android] Added surface rendering pause/resume
This commit is contained in:
parent
6d8db510f8
commit
9725169aa3
5 changed files with 43 additions and 9 deletions
|
@ -247,6 +247,24 @@ bool Framework::AttachSurface(JNIEnv * env, jobject jSurface)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Framework::PauseSurfaceRendering()
|
||||
{
|
||||
if (m_contextFactory == nullptr)
|
||||
return;
|
||||
LOG(LINFO, ("Pause surface rendering."));
|
||||
m_contextFactory->setPresentAvailable(false);
|
||||
}
|
||||
|
||||
void Framework::ResumeSurfaceRendering()
|
||||
{
|
||||
if (m_contextFactory == nullptr)
|
||||
return;
|
||||
LOG(LINFO, ("Resume surface rendering."));
|
||||
AndroidOGLContextFactory * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>();
|
||||
if (factory->IsValid())
|
||||
m_contextFactory->setPresentAvailable(true);
|
||||
}
|
||||
|
||||
void Framework::SetMapStyle(MapStyle mapStyle)
|
||||
{
|
||||
m_work.SetMapStyle(mapStyle);
|
||||
|
|
|
@ -92,14 +92,14 @@ namespace android
|
|||
void OnCompassUpdated(location::CompassInfo const & info, bool forceRedraw);
|
||||
void UpdateCompassSensor(int ind, float * arr);
|
||||
|
||||
void Invalidate();
|
||||
|
||||
bool CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi, bool firstLaunch,
|
||||
bool launchByDeepLink);
|
||||
bool IsDrapeEngineCreated();
|
||||
|
||||
void DetachSurface(bool destroyContext);
|
||||
bool AttachSurface(JNIEnv * env, jobject jSurface);
|
||||
void PauseSurfaceRendering();
|
||||
void ResumeSurfaceRendering();
|
||||
|
||||
void SetMapStyle(MapStyle mapStyle);
|
||||
void MarkMapStyle(MapStyle mapStyle);
|
||||
|
|
|
@ -84,6 +84,18 @@ Java_com_mapswithme_maps_MapFragment_nativeDetachSurface(JNIEnv * env, jclass cl
|
|||
g_framework->DetachSurface(destroyContext);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MapFragment_nativePauseSurfaceRendering(JNIEnv *, jclass)
|
||||
{
|
||||
g_framework->PauseSurfaceRendering();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MapFragment_nativeResumeSurfaceRendering(JNIEnv *, jclass)
|
||||
{
|
||||
g_framework->ResumeSurfaceRendering();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MapFragment_nativeSurfaceChanged(JNIEnv * env, jclass clazz, jint w, jint h)
|
||||
{
|
||||
|
|
|
@ -285,9 +285,17 @@ public class MapFragment extends BaseMwmFragment
|
|||
public void onPause()
|
||||
{
|
||||
mUiThemeOnPause = Config.getCurrentUiTheme();
|
||||
nativePauseSurfaceRendering();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
nativeResumeSurfaceRendering();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
|
@ -360,6 +368,8 @@ public class MapFragment extends BaseMwmFragment
|
|||
boolean isLaunchByDeepLink);
|
||||
private static native boolean nativeAttachSurface(Surface surface);
|
||||
private static native void nativeDetachSurface(boolean destroyContext);
|
||||
private static native void nativePauseSurfaceRendering();
|
||||
private static native void nativeResumeSurfaceRendering();
|
||||
private static native void nativeSurfaceChanged(int w, int h);
|
||||
private static native void nativeOnTouch(int actionType, int id1, float x1, float y1, int id2, float x2, float y2, int maskedPointer);
|
||||
private static native void nativeSetupWidget(int widget, float x, float y, int anchor);
|
||||
|
|
|
@ -2026,7 +2026,6 @@ void FrontendRenderer::Routine::Do()
|
|||
double frameTime = 0.0;
|
||||
bool modelViewChanged = true;
|
||||
bool viewportChanged = true;
|
||||
bool invalidContext = false;
|
||||
uint32_t inactiveFramesCounter = 0;
|
||||
bool forceFullRedrawNextFrame = false;
|
||||
uint32_t constexpr kMaxInactiveFrames = 2;
|
||||
|
@ -2055,7 +2054,6 @@ void FrontendRenderer::Routine::Do()
|
|||
{
|
||||
if (context->validate())
|
||||
{
|
||||
invalidContext = false;
|
||||
timer.Reset();
|
||||
|
||||
ScreenBase modelView = m_renderer.ProcessEvents(modelViewChanged, viewportChanged);
|
||||
|
@ -2152,12 +2150,8 @@ void FrontendRenderer::Routine::Do()
|
|||
}
|
||||
else
|
||||
{
|
||||
forceFullRedrawNextFrame = true;
|
||||
inactiveFramesCounter = 0;
|
||||
if (!invalidContext)
|
||||
{
|
||||
LOG(LINFO, ("Invalid context. Rendering is stopped."));
|
||||
invalidContext = true;
|
||||
}
|
||||
}
|
||||
m_renderer.CheckRenderingEnabled();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue