aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dm/DM.cpp2
-rw-r--r--gm/gm.cpp4
-rw-r--r--src/core/SkTraceEvent.h7
-rw-r--r--tests/Test.h10
-rw-r--r--tools/ok_test.cpp3
-rw-r--r--tools/ok_vias.cpp3
6 files changed, 24 insertions, 5 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index e8898a4c95..1b8888935b 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -1256,7 +1256,7 @@ static void run_test(skiatest::Test test, const GrContextOptions& grCtxOptions)
if (!FLAGS_dryRun && !is_blacklisted("_", "tests", "_", test.name)) {
start("unit", "test", "", test.name);
GrContextFactory factory(grCtxOptions);
- test.proc(&reporter, &factory);
+ test.run(&reporter, &factory);
}
done("unit", "test", "", test.name);
}
diff --git a/gm/gm.cpp b/gm/gm.cpp
index 1ba571a15b..1c787826c2 100644
--- a/gm/gm.cpp
+++ b/gm/gm.cpp
@@ -8,6 +8,7 @@
#include "gm.h"
#include "sk_tool_utils.h"
#include "SkShader.h"
+#include "SkTraceEvent.h"
using namespace skiagm;
GM::GM() {
@@ -21,11 +22,13 @@ GM::GM() {
GM::~GM() {}
void GM::draw(SkCanvas* canvas) {
+ TRACE_EVENT1("GM", TRACE_FUNC, "name", TRACE_STR_COPY(this->getName()));
this->drawBackground(canvas);
this->drawContent(canvas);
}
void GM::drawContent(SkCanvas* canvas) {
+ TRACE_EVENT0("GM", TRACE_FUNC);
if (!fHaveCalledOnceBeforeDraw) {
fHaveCalledOnceBeforeDraw = true;
this->onOnceBeforeDraw();
@@ -34,6 +37,7 @@ void GM::drawContent(SkCanvas* canvas) {
}
void GM::drawBackground(SkCanvas* canvas) {
+ TRACE_EVENT0("GM", TRACE_FUNC);
if (!fHaveCalledOnceBeforeDraw) {
fHaveCalledOnceBeforeDraw = true;
this->onOnceBeforeDraw();
diff --git a/src/core/SkTraceEvent.h b/src/core/SkTraceEvent.h
index 8b9a15cff4..116330dcb5 100644
--- a/src/core/SkTraceEvent.h
+++ b/src/core/SkTraceEvent.h
@@ -17,6 +17,13 @@
////////////////////////////////////////////////////////////////////////////////
// Implementation specific tracing API definitions.
+// Makes it easier to add traces with a simple TRACE_EVENT0("skia", TRACE_FUNC).
+#if defined(_MSC_VER)
+ #define TRACE_FUNC __FUNCSIG__
+#else
+ #define TRACE_FUNC __PRETTY_FUNCTION__
+#endif
+
// By default, const char* argument values are assumed to have long-lived scope
// and will not be copied. Use this macro to force a const char* to be copied.
#define TRACE_STR_COPY(str) \
diff --git a/tests/Test.h b/tests/Test.h
index db2552b614..c9a381eb12 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -7,10 +7,11 @@
#ifndef skiatest_Test_DEFINED
#define skiatest_Test_DEFINED
-#include "SkString.h"
#include "../tools/Registry.h"
-#include "SkTypes.h"
#include "SkClipOpPriv.h"
+#include "SkString.h"
+#include "SkTraceEvent.h"
+#include "SkTypes.h"
#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
@@ -94,6 +95,11 @@ struct Test {
const char* name;
bool needsGpu;
TestProc proc;
+
+ void run(skiatest::Reporter* r, sk_gpu_test::GrContextFactory* factory) const {
+ TRACE_EVENT1("test", TRACE_FUNC, "name", this->name/*these are static*/);
+ this->proc(r, factory);
+ }
};
typedef sk_tools::Registry<Test> TestRegistry;
diff --git a/tools/ok_test.cpp b/tools/ok_test.cpp
index f5c4f22489..7c020d88e1 100644
--- a/tools/ok_test.cpp
+++ b/tools/ok_test.cpp
@@ -32,7 +32,6 @@ struct TestStream : Stream {
SkISize size() override { return {0,0}; }
Status draw(SkCanvas*) override {
-
struct : public skiatest::Reporter {
Status status = Status::OK;
bool extended, verbose_;
@@ -54,7 +53,7 @@ struct TestStream : Stream {
factory = &a_real_factory;
#endif
- test.proc(&reporter, factory);
+ test.run(&reporter, factory);
return reporter.status;
}
};
diff --git a/tools/ok_vias.cpp b/tools/ok_vias.cpp
index 35e6f1fcab..c3c0bad2d8 100644
--- a/tools/ok_vias.cpp
+++ b/tools/ok_vias.cpp
@@ -10,6 +10,7 @@
#include "SkOSFile.h"
#include "SkPictureRecorder.h"
#include "SkPngEncoder.h"
+#include "SkTraceEvent.h"
#include "ProcStats.h"
#include "Timer.h"
#include "ok.h"
@@ -42,6 +43,7 @@ struct ViaPic : Dst {
}
Status draw(Src* src) override {
+ TRACE_EVENT0("ok", TRACE_FUNC);
SkRTreeFactory factory;
SkPictureRecorder rec;
rec.beginRecording(SkRect::MakeSize(SkSize::Make(src->size())),
@@ -76,6 +78,7 @@ struct Png : Dst {
}
Status draw(Src* src) override {
+ TRACE_EVENT0("ok", TRACE_FUNC);
for (auto status = target->draw(src); status != Status::OK; ) {
return status;
}