Commit 617f23d1 by Jiacheng Lu Committed by Commit Bot

Fix frame capture build for Android

Bug: angleproject:3611 Change-Id: I65018823a8d7223de0f63ea5bd6a573f62f1c24b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1748884 Commit-Queue: Jiacheng Lu <lujc@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 24456989
...@@ -818,22 +818,29 @@ template("angle_libGLESv2") { ...@@ -818,22 +818,29 @@ template("angle_libGLESv2") {
} }
angle_libGLESv2("libGLESv2") { angle_libGLESv2("libGLESv2") {
deps = [
":libANGLE",
]
if (angle_with_capture_by_default) { if (angle_with_capture_by_default) {
output_name = "libGLESv2_no_capture" deps = [
":libANGLE_with_capture",
]
} else {
deps = [
":libANGLE",
]
} }
} }
angle_libGLESv2("libGLESv2_with_capture") { # Output capture lib when `angle_with_capture_by_default` disabled, vice versa.
deps = [ angle_libGLESv2("libGLESv2_capture_complement") {
":libANGLE_with_capture", if (angle_with_capture_by_default) {
] deps = [
":libANGLE",
if (!angle_with_capture_by_default) { ]
output_name = "libGLESv2_with_capture" output_name += "_no_capture"
} else {
deps = [
":libANGLE_with_capture",
]
output_name += "_with_capture"
} }
} }
......
...@@ -9,12 +9,48 @@ ...@@ -9,12 +9,48 @@
#include "libANGLE/FrameCapture.h" #include "libANGLE/FrameCapture.h"
#include <cerrno>
#include <cstring>
#include <string> #include <string>
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/VertexArray.h" #include "libANGLE/VertexArray.h"
#include "libANGLE/gl_enum_utils_autogen.h" #include "libANGLE/gl_enum_utils_autogen.h"
#ifdef ANGLE_PLATFORM_ANDROID
# define ANGLE_CAPTURE_PATH ("/sdcard/Android/data/" + CurrentAPKName() + "/")
std::string CurrentAPKName()
{
static char sApplicationId[512] = {0};
if (!sApplicationId[0])
{
// Linux interface to get application id of the running process
FILE *cmdline = fopen("/proc/self/cmdline", "r");
if (cmdline)
{
fread(sApplicationId, 1, sizeof(sApplicationId), cmdline);
fclose(cmdline);
// Some package may have application id as <app_name>:<cmd_name>
char *colonSep = strchr(sApplicationId, ':');
if (colonSep)
{
*colonSep = '\0';
}
}
else
{
WARN() << "not able to lookup application id";
}
}
return std::string(sApplicationId);
}
#else
# define ANGLE_CAPTURE_PATH "./"
#endif // ANGLE_PLATFORM_ANDROID
namespace angle namespace angle
{ {
#if !ANGLE_CAPTURE_ENABLED #if !ANGLE_CAPTURE_ENABLED
...@@ -33,7 +69,7 @@ std::string GetCaptureFileName(size_t frameIndex, const char *suffix) ...@@ -33,7 +69,7 @@ std::string GetCaptureFileName(size_t frameIndex, const char *suffix)
std::stringstream fnameStream; std::stringstream fnameStream;
fnameStream << "angle_capture_frame" << std::setfill('0') << std::setw(3) << frameIndex fnameStream << "angle_capture_frame" << std::setfill('0') << std::setw(3) << frameIndex
<< suffix; << suffix;
return fnameStream.str(); return ANGLE_CAPTURE_PATH + fnameStream.str();
} }
void WriteParamStaticVarName(const CallCapture &call, void WriteParamStaticVarName(const CallCapture &call,
...@@ -446,6 +482,10 @@ void FrameCapture::saveCapturedFrameAsCpp() ...@@ -446,6 +482,10 @@ void FrameCapture::saveCapturedFrameAsCpp()
std::string fname = GetCaptureFileName(mFrameIndex, ".angledata"); std::string fname = GetCaptureFileName(mFrameIndex, ".angledata");
FILE *fp = fopen(fname.c_str(), "wb"); FILE *fp = fopen(fname.c_str(), "wb");
if (!fp)
{
FATAL() << "file " << fname << " can not be created!: " << strerror(errno);
}
fwrite(binaryData.data(), 1, binaryData.size(), fp); fwrite(binaryData.data(), 1, binaryData.size(), fp);
fclose(fp); fclose(fp);
...@@ -474,6 +514,10 @@ void FrameCapture::saveCapturedFrameAsCpp() ...@@ -474,6 +514,10 @@ void FrameCapture::saveCapturedFrameAsCpp()
std::string fname = GetCaptureFileName(mFrameIndex, ".cpp"); std::string fname = GetCaptureFileName(mFrameIndex, ".cpp");
FILE *fp = fopen(fname.c_str(), "w"); FILE *fp = fopen(fname.c_str(), "w");
if (!fp)
{
FATAL() << "file " << fname << " can not be created!: " << strerror(errno);
}
fprintf(fp, "%s\n\n%s", headerString.c_str(), outString.c_str()); fprintf(fp, "%s\n\n%s", headerString.c_str(), outString.c_str());
fclose(fp); fclose(fp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment