mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 20:28:32 +09:00
[Fix] (trace-replay): use ANGLE for DirectGLES APK retrace
This commit is contained in:
@@ -74,6 +74,17 @@ bool Exists(const std::string& path) {
|
||||
return !path.empty() && stat(path.c_str(), &st) == 0 && S_ISREG(st.st_mode);
|
||||
}
|
||||
|
||||
bool UseAngleForRequest(const Request& request) {
|
||||
if (request.backend != "DirectGLES") {
|
||||
return false;
|
||||
}
|
||||
if (request.useAngle) {
|
||||
return true;
|
||||
}
|
||||
const char* value = getenv("MOBILEGL_RETRACE_USE_ANGLE");
|
||||
return value != nullptr && strcmp(value, "1") == 0;
|
||||
}
|
||||
|
||||
bool EnsureDirectory(const std::string& path) {
|
||||
if (path.empty()) {
|
||||
return false;
|
||||
@@ -116,6 +127,9 @@ bool LoadMobileGL(const Request& request, std::string& error) {
|
||||
setenv("MOBILEGL_BACKEND_TYPE", request.backend.c_str(), 1);
|
||||
setenv("MOBILEGL_TRACE_LIBRARY", request.mobileGlLibrary.c_str(), 1);
|
||||
setenv("MOBILEGL_TRACE_SKIP_AUTODESTROY", "1", 1);
|
||||
if (UseAngleForRequest(request)) {
|
||||
setenv("MOBILEGL_RETRACE_USE_ANGLE", "1", 1);
|
||||
}
|
||||
|
||||
void* handle = dlopen(request.mobileGlLibrary.c_str(), RTLD_NOW | RTLD_GLOBAL);
|
||||
if (handle == nullptr) {
|
||||
@@ -734,6 +748,7 @@ bool WriteResultJson(const Request& request, const Result& result) {
|
||||
file << " \"cropHeight\": " << request.cropHeight << ",\n";
|
||||
file << " \"tolerance\": " << request.tolerance << ",\n";
|
||||
file << " \"fuzzPercent\": " << request.fuzzPercent << ",\n";
|
||||
file << " \"useAngle\": " << (UseAngleForRequest(request) ? "true" : "false") << ",\n";
|
||||
file << " \"mismatchPixels\": " << result.mismatchPixels << "\n";
|
||||
file << "}\n";
|
||||
return true;
|
||||
|
||||
@@ -33,6 +33,7 @@ struct Request {
|
||||
int cropHeight = 0;
|
||||
int tolerance = 0;
|
||||
int fuzzPercent = 20;
|
||||
bool useAngle = false;
|
||||
};
|
||||
|
||||
struct Result {
|
||||
|
||||
@@ -98,7 +98,8 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
|
||||
jint cropY,
|
||||
jint cropWidth,
|
||||
jint cropHeight,
|
||||
jint fuzzPercent) {
|
||||
jint fuzzPercent,
|
||||
jboolean useAngle) {
|
||||
mobilegl_trace::Request request;
|
||||
request.tracePath = ToString(env, tracePath);
|
||||
request.goldenPath = ToString(env, goldenPath);
|
||||
@@ -119,6 +120,7 @@ Java_top_mobilegl_plugin_trace_TraceReplayActivity_nativeRunTraceReplay(JNIEnv*
|
||||
request.cropWidth = cropWidth;
|
||||
request.cropHeight = cropHeight;
|
||||
request.fuzzPercent = fuzzPercent;
|
||||
request.useAngle = useAngle == JNI_TRUE;
|
||||
|
||||
ScopedTraceReplayState replayState;
|
||||
mobilegl_trace_set_requested_size(request.width, request.height);
|
||||
|
||||
+10
-4
@@ -110,7 +110,8 @@ public final class TraceReplayActivity extends Activity {
|
||||
request.cropY,
|
||||
request.cropWidth,
|
||||
request.cropHeight,
|
||||
request.fuzzPercent
|
||||
request.fuzzPercent,
|
||||
request.useAngle
|
||||
);
|
||||
Log.i(TAG, result.toString());
|
||||
TraceReplayResult finalResult = result;
|
||||
@@ -137,7 +138,8 @@ public final class TraceReplayActivity extends Activity {
|
||||
int cropY,
|
||||
int cropWidth,
|
||||
int cropHeight,
|
||||
int fuzzPercent
|
||||
int fuzzPercent,
|
||||
boolean useAngle
|
||||
);
|
||||
|
||||
private static final class TraceReplayRequest {
|
||||
@@ -157,6 +159,7 @@ public final class TraceReplayActivity extends Activity {
|
||||
final int cropWidth;
|
||||
final int cropHeight;
|
||||
final int fuzzPercent;
|
||||
final boolean useAngle;
|
||||
|
||||
private TraceReplayRequest(
|
||||
String tracePath,
|
||||
@@ -174,7 +177,8 @@ public final class TraceReplayActivity extends Activity {
|
||||
int cropY,
|
||||
int cropWidth,
|
||||
int cropHeight,
|
||||
int fuzzPercent
|
||||
int fuzzPercent,
|
||||
boolean useAngle
|
||||
) {
|
||||
this.tracePath = tracePath;
|
||||
this.goldenPath = goldenPath;
|
||||
@@ -192,6 +196,7 @@ public final class TraceReplayActivity extends Activity {
|
||||
this.cropWidth = cropWidth;
|
||||
this.cropHeight = cropHeight;
|
||||
this.fuzzPercent = fuzzPercent;
|
||||
this.useAngle = useAngle;
|
||||
}
|
||||
|
||||
static TraceReplayRequest from(Intent intent, File filesDir, String defaultBackend) {
|
||||
@@ -213,7 +218,8 @@ public final class TraceReplayActivity extends Activity {
|
||||
intent.getIntExtra("crop_y", 0),
|
||||
intent.getIntExtra("crop_width", 0),
|
||||
intent.getIntExtra("crop_height", 0),
|
||||
intent.getIntExtra("fuzz_percent", 20)
|
||||
intent.getIntExtra("fuzz_percent", 20),
|
||||
intent.getBooleanExtra("use_angle", false)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user