Adding Skia Recorder to Render Engine
To start recording run:
adb shell setprop debug.renderengine.capture_skia_ms 1000
File will be stored in the /data directory on the device:
adb shell ls -al /data/user/
adb pull /data/user/re_skiacapture_<timestamp>.mskp
The recording will stop after MS specified. To reset the
recording, set the capture_skia_ms flag to a new time.
When recording is finished, the capture_skia_ms flag will
be set to 0 to avoid circular recording.
Bug: 173805658
Test: Turn on the flag. Turn off the flag. Pull the file from
the device. Open it in Skia Debugger.
Change-Id: Iea478245c267fb4b26f980417d96acd7273bfb55
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.cpp b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
index be6b081..4e9c5af 100644
--- a/libs/renderengine/skia/SkiaGLRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
@@ -15,19 +15,19 @@
*/
//#define LOG_NDEBUG 0
+#undef LOG_TAG
+#define LOG_TAG "RenderEngine"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+
#include <cstdint>
#include <memory>
#include "SkImageInfo.h"
#include "log/log_main.h"
#include "system/graphics-base-v1.0.h"
-#undef LOG_TAG
-#define LOG_TAG "RenderEngine"
-#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
#include <sync/sync.h>
#include <ui/BlurRegion.h>
#include <ui/GraphicBuffer.h>
@@ -35,6 +35,8 @@
#include "../gl/GLExtensions.h"
#include "SkiaGLRenderEngine.h"
#include "filters/BlurFilter.h"
+#include "filters/LinearEffect.h"
+#include "skia/debug/SkiaCapture.h"
#include <GrContextOptions.h>
#include <SkCanvas.h>
@@ -46,17 +48,9 @@
#include <SkShadowUtils.h>
#include <SkSurface.h>
#include <gl/GrGLInterface.h>
-#include <sync/sync.h>
-#include <ui/GraphicBuffer.h>
-#include <utils/Trace.h>
#include <cmath>
-#include "../gl/GLExtensions.h"
-#include "SkiaGLRenderEngine.h"
-#include "filters/BlurFilter.h"
-#include "filters/LinearEffect.h"
-
bool checkGlError(const char* op, int lineNumber);
namespace android {
@@ -482,7 +476,7 @@
: ui::Dataspace::SRGB,
mGrContext.get());
- auto canvas = surface->getCanvas();
+ SkCanvas* canvas = mCapture.tryCapture(surface.get());
// Clear the entire canvas with a transparent black to prevent ghost images.
canvas->clear(SK_ColorTRANSPARENT);
canvas->save();
@@ -663,11 +657,12 @@
canvas->restore();
}
+ canvas->restore();
+ mCapture.endCapture();
{
ATRACE_NAME("flush surface");
surface->flush();
}
- canvas->restore();
if (drawFence != nullptr) {
*drawFence = flush();