mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1189881 - Move GeckoJavaSampler::getProfilerTime out of AndroidJNI.cpp. r=jchen
This commit is contained in:
parent
6c4dfd053e
commit
21d90bf297
@ -22,6 +22,7 @@ public class GeckoJavaSampler {
|
||||
|
||||
// Use the same timer primitive as the profiler
|
||||
// to get a perfect sample syncing.
|
||||
@WrapForJNI
|
||||
private static native double getProfilerTime();
|
||||
|
||||
private static class Sample {
|
||||
@ -208,6 +209,3 @@ public class GeckoJavaSampler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -35,6 +35,10 @@
|
||||
#include "AndroidBridge.h"
|
||||
#endif
|
||||
|
||||
#ifdef SPS_OS_android
|
||||
#include "GeneratedJNINatives.h"
|
||||
#endif
|
||||
|
||||
#ifndef SPS_STANDALONE
|
||||
#if defined(SPS_PLAT_amd64_linux) || defined(SPS_PLAT_x86_linux)
|
||||
# define USE_LUL_STACKWALK
|
||||
@ -43,6 +47,22 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SPS_OS_android
|
||||
class GeckoJavaSampler : public widget::GeckoJavaSampler::Natives<GeckoJavaSampler>
|
||||
{
|
||||
private:
|
||||
GeckoJavaSampler();
|
||||
|
||||
public:
|
||||
static double GetProfilerTime() {
|
||||
if (!profiler_is_active()) {
|
||||
return 0.0;
|
||||
}
|
||||
return profiler_time();
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
mozilla::ThreadLocal<PseudoStack *> tlsPseudoStack;
|
||||
mozilla::ThreadLocal<GeckoSampler *> tlsTicker;
|
||||
mozilla::ThreadLocal<void *> tlsStackTop;
|
||||
@ -473,6 +493,12 @@ void mozilla_sampler_init(void* stackTop)
|
||||
set_stderr_callback(mozilla_sampler_log);
|
||||
#endif
|
||||
|
||||
#ifdef SPS_OS_android
|
||||
if (mozilla::jni::IsAvailable()) {
|
||||
GeckoJavaSampler::Init();
|
||||
}
|
||||
#endif
|
||||
|
||||
// We can't open pref so we use an environment variable
|
||||
// to know if we should trigger the profiler on startup
|
||||
// NOTE: Default
|
||||
|
@ -680,7 +680,7 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyFilePickerResult(JNIEnv* jenv, jclass
|
||||
{
|
||||
class NotifyFilePickerResultRunnable : public nsRunnable {
|
||||
public:
|
||||
NotifyFilePickerResultRunnable(nsString& fileDir, long callback) :
|
||||
NotifyFilePickerResultRunnable(nsString& fileDir, long callback) :
|
||||
mFileDir(fileDir), mCallback(callback) {}
|
||||
|
||||
NS_IMETHODIMP Run() {
|
||||
@ -694,7 +694,7 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyFilePickerResult(JNIEnv* jenv, jclass
|
||||
long mCallback;
|
||||
};
|
||||
nsString path = nsJNIString(filePath, jenv);
|
||||
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new NotifyFilePickerResultRunnable(path, (long)callback);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
@ -767,7 +767,7 @@ Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits(JNIEnv* jenv, jclass, jobjec
|
||||
for (int i = 0; i < srcHeight; i++) {
|
||||
memcpy(bitsCopy + ((dstHeight - i - 1) * dstWidth * bpp), bits + (i * srcStride * bpp), srcStride * bpp);
|
||||
}
|
||||
|
||||
|
||||
if (!jSurfaceBitsClass) {
|
||||
jSurfaceBitsClass = (jclass)jenv->NewGlobalRef(jenv->FindClass("org/mozilla/gecko/SurfaceBits"));
|
||||
jSurfaceBitsCtor = jenv->GetMethodID(jSurfaceBitsClass, "<init>", "()V");
|
||||
@ -852,15 +852,6 @@ Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure(JNIEnv* jenv, jclass
|
||||
NS_DispatchMemoryPressure(MemPressure_New);
|
||||
}
|
||||
|
||||
NS_EXPORT jdouble JNICALL
|
||||
Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime(JNIEnv *jenv, jclass jc)
|
||||
{
|
||||
if (!profiler_is_active()) {
|
||||
return 0.0;
|
||||
}
|
||||
return profiler_time();
|
||||
}
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation(JNIEnv* env, jobject instance)
|
||||
{
|
||||
|
@ -36,6 +36,21 @@ public:
|
||||
template<class Impl>
|
||||
constexpr JNINativeMethod ANRReporter::Natives<Impl>::methods[];
|
||||
|
||||
template<class Impl>
|
||||
class GeckoJavaSampler::Natives : public mozilla::jni::NativeImpl<GeckoJavaSampler, Impl>
|
||||
{
|
||||
public:
|
||||
static constexpr JNINativeMethod methods[] = {
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoJavaSampler::GetProfilerTime_t>(
|
||||
mozilla::jni::NativeStub<GeckoJavaSampler::GetProfilerTime_t, Impl>
|
||||
::template Wrap<&Impl::GetProfilerTime>)
|
||||
};
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
constexpr JNINativeMethod GeckoJavaSampler::Natives<Impl>::methods[];
|
||||
|
||||
template<class Impl>
|
||||
class GeckoThread::Natives : public mozilla::jni::NativeImpl<GeckoThread, Impl>
|
||||
{
|
||||
|
@ -715,6 +715,9 @@ auto GeckoJavaSampler::GetFrameNameJavaProfilingWrapper(int32_t a0, int32_t a1,
|
||||
return mozilla::jni::Method<GetFrameNameJavaProfilingWrapper_t>::Call(nullptr, nullptr, a0, a1, a2);
|
||||
}
|
||||
|
||||
constexpr char GeckoJavaSampler::GetProfilerTime_t::name[];
|
||||
constexpr char GeckoJavaSampler::GetProfilerTime_t::signature[];
|
||||
|
||||
constexpr char GeckoJavaSampler::GetSampleTimeJavaProfiling_t::name[];
|
||||
constexpr char GeckoJavaSampler::GetSampleTimeJavaProfiling_t::signature[];
|
||||
|
||||
|
@ -1694,6 +1694,21 @@ public:
|
||||
|
||||
static auto GetFrameNameJavaProfilingWrapper(int32_t, int32_t, int32_t) -> mozilla::jni::String::LocalRef;
|
||||
|
||||
public:
|
||||
struct GetProfilerTime_t {
|
||||
typedef GeckoJavaSampler Owner;
|
||||
typedef double ReturnType;
|
||||
typedef double SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "getProfilerTime";
|
||||
static constexpr char signature[] =
|
||||
"()D";
|
||||
static const bool isStatic = true;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
public:
|
||||
struct GetSampleTimeJavaProfiling_t {
|
||||
typedef GeckoJavaSampler Owner;
|
||||
@ -1801,6 +1816,8 @@ public:
|
||||
|
||||
static auto UnpauseJavaProfiling() -> void;
|
||||
|
||||
public:
|
||||
template<class Impl> class Natives;
|
||||
};
|
||||
|
||||
class GeckoThread : public mozilla::jni::Class<GeckoThread>
|
||||
|
@ -19,6 +19,7 @@ EXPORTS += [
|
||||
'AndroidBridge.h',
|
||||
'AndroidJavaWrappers.h',
|
||||
'AndroidJNIWrapper.h',
|
||||
'GeneratedJNINatives.h',
|
||||
'GeneratedJNIWrappers.h',
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user