diff --git a/bench/AlternatingColorPatternBench.cpp b/bench/AlternatingColorPatternBench.cpp index af06c4b357..cb561e3351 100644 --- a/bench/AlternatingColorPatternBench.cpp +++ b/bench/AlternatingColorPatternBench.cpp @@ -113,7 +113,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { int w = 40; int h = 40; makebm(&fBmp, w, h); diff --git a/bench/Benchmark.cpp b/bench/Benchmark.cpp index bf622b0683..98fec2e7aa 100644 --- a/bench/Benchmark.cpp +++ b/bench/Benchmark.cpp @@ -33,14 +33,22 @@ SkIPoint Benchmark::getSize() { return this->onGetSize(); } -void Benchmark::preDraw() { - this->onPreDraw(); +void Benchmark::delayedSetup() { + this->onDelayedSetup(); } void Benchmark::perCanvasPreDraw(SkCanvas* canvas) { this->onPerCanvasPreDraw(canvas); } +void Benchmark::preDraw(SkCanvas* canvas) { + this->onPreDraw(canvas); +} + +void Benchmark::postDraw(SkCanvas* canvas) { + this->onPostDraw(canvas); +} + void Benchmark::perCanvasPostDraw(SkCanvas* canvas) { this->onPerCanvasPostDraw(canvas); } diff --git a/bench/Benchmark.h b/bench/Benchmark.h index 751172685e..06d42e81d4 100644 --- a/bench/Benchmark.h +++ b/bench/Benchmark.h @@ -70,13 +70,17 @@ public: // Call before draw, allows the benchmark to do setup work outside of the // timer. When a benchmark is repeatedly drawn, this should be called once // before the initial draw. - void preDraw(); + void delayedSetup(); // Called once before and after a series of draw calls to a single canvas. // The setup/break down in these calls is not timed. void perCanvasPreDraw(SkCanvas*); void perCanvasPostDraw(SkCanvas*); + // Called just before and after each call to draw(). Not timed. + void preDraw(SkCanvas*); + void postDraw(SkCanvas*); + // Bench framework can tune loops to be large enough for stable timing. void draw(const int loops, SkCanvas*); @@ -112,9 +116,11 @@ protected: virtual const char* onGetName() = 0; virtual const char* onGetUniqueName() { return this->onGetName(); } - virtual void onPreDraw() {} + virtual void onDelayedSetup() {} virtual void onPerCanvasPreDraw(SkCanvas*) {} virtual void onPerCanvasPostDraw(SkCanvas*) {} + virtual void onPreDraw(SkCanvas*) {} + virtual void onPostDraw(SkCanvas*) {} // Each bench should do its main work in a loop like this: // for (int i = 0; i < loops; i++) { } virtual void onDraw(const int loops, SkCanvas*) = 0; diff --git a/bench/BigPathBench.cpp b/bench/BigPathBench.cpp index f18e3de077..a554b3881b 100644 --- a/bench/BigPathBench.cpp +++ b/bench/BigPathBench.cpp @@ -46,7 +46,7 @@ protected: return SkIPoint::Make(640, 100); } - void onPreDraw() override { + void onDelayedSetup() override { make_path(fPath); } diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp index 8176f38891..260a2c93cc 100644 --- a/bench/BitmapBench.cpp +++ b/bench/BitmapBench.cpp @@ -110,7 +110,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { SkBitmap bm; if (kIndex_8_SkColorType == fColorType) { diff --git a/bench/BitmapRectBench.cpp b/bench/BitmapRectBench.cpp index d95d753a3d..93659c186c 100644 --- a/bench/BitmapRectBench.cpp +++ b/bench/BitmapRectBench.cpp @@ -67,7 +67,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { fBitmap.allocPixels(); fBitmap.setAlphaType(kOpaque_SkAlphaType); fBitmap.eraseColor(SK_ColorBLACK); diff --git a/bench/BitmapRegionDecoderBench.cpp b/bench/BitmapRegionDecoderBench.cpp index 77d342331d..587294227f 100644 --- a/bench/BitmapRegionDecoderBench.cpp +++ b/bench/BitmapRegionDecoderBench.cpp @@ -53,7 +53,7 @@ bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) { return kNonRendering_Backend == backend; } -void BitmapRegionDecoderBench::onPreDraw() { +void BitmapRegionDecoderBench::onDelayedSetup() { SkStreamRewindable* stream = new SkMemoryStream(fData); fBRD.reset(SkBitmapRegionDecoderInterface::CreateBitmapRegionDecoder(stream, fStrategy)); } diff --git a/bench/BitmapRegionDecoderBench.h b/bench/BitmapRegionDecoderBench.h index 7be770f472..4f4d55e060 100644 --- a/bench/BitmapRegionDecoderBench.h +++ b/bench/BitmapRegionDecoderBench.h @@ -34,7 +34,7 @@ protected: const char* onGetName() override; bool isSuitableFor(Backend backend) override; void onDraw(const int n, SkCanvas* canvas) override; - void onPreDraw() override; + void onDelayedSetup() override; private: SkString fName; diff --git a/bench/BitmapScaleBench.cpp b/bench/BitmapScaleBench.cpp index 2bfa312989..b3f0763996 100644 --- a/bench/BitmapScaleBench.cpp +++ b/bench/BitmapScaleBench.cpp @@ -56,7 +56,7 @@ protected: fName.printf( "bitmap_scale_%s_%d_%d", name, fInputSize, fOutputSize ); } - void onPreDraw() override { + void onDelayedSetup() override { fInputBitmap.allocN32Pixels(fInputSize, fInputSize, true); fInputBitmap.eraseColor(SK_ColorWHITE); diff --git a/bench/BlurImageFilterBench.cpp b/bench/BlurImageFilterBench.cpp index 8bfd005f44..d7d3eb2bc3 100644 --- a/bench/BlurImageFilterBench.cpp +++ b/bench/BlurImageFilterBench.cpp @@ -35,7 +35,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { if (!fInitialized) { make_checkerboard(); fInitialized = true; diff --git a/bench/CodecBench.cpp b/bench/CodecBench.cpp index a21aae1f0b..0b457a42ae 100644 --- a/bench/CodecBench.cpp +++ b/bench/CodecBench.cpp @@ -32,7 +32,7 @@ bool CodecBench::isSuitableFor(Backend backend) { return kNonRendering_Backend == backend; } -void CodecBench::onPreDraw() { +void CodecBench::onDelayedSetup() { SkAutoTDelete codec(SkCodec::NewFromData(fData)); fInfo = codec->getInfo().makeColorType(fColorType); diff --git a/bench/CodecBench.h b/bench/CodecBench.h index 0675cca22a..efa3cb2828 100644 --- a/bench/CodecBench.h +++ b/bench/CodecBench.h @@ -26,7 +26,7 @@ protected: const char* onGetName() override; bool isSuitableFor(Backend backend) override; void onDraw(const int n, SkCanvas* canvas) override; - void onPreDraw() override; + void onDelayedSetup() override; private: SkString fName; diff --git a/bench/ColorCubeBench.cpp b/bench/ColorCubeBench.cpp index 65270a85a3..ec0a47b5c6 100644 --- a/bench/ColorCubeBench.cpp +++ b/bench/ColorCubeBench.cpp @@ -31,7 +31,7 @@ protected: return "colorcube"; } - void onPreDraw() override { + void onDelayedSetup() override { if (!SkToBool(fCubeData)) { this->makeCubeData(); this->make_bitmap(); diff --git a/bench/ColorPrivBench.cpp b/bench/ColorPrivBench.cpp index 9c8accebc9..4aa51c41dd 100644 --- a/bench/ColorPrivBench.cpp +++ b/bench/ColorPrivBench.cpp @@ -24,7 +24,7 @@ public: const char* onGetName() override { return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { // A handful of random srcs and dsts. SkRandom rand; for (int i = 0; i < kInputs; i++) { diff --git a/bench/DecodingBench.cpp b/bench/DecodingBench.cpp index 7b6ad2bb0a..0c950944a3 100644 --- a/bench/DecodingBench.cpp +++ b/bench/DecodingBench.cpp @@ -44,7 +44,7 @@ bool DecodingBench::isSuitableFor(Backend backend) { return kNonRendering_Backend == backend; } -void DecodingBench::onPreDraw() { +void DecodingBench::onDelayedSetup() { // Allocate the pixels now, to remove it from the loop. SkAutoTDelete stream(new SkMemoryStream(fData)); SkAutoTDelete decoder(SkImageDecoder::Factory(stream)); diff --git a/bench/DecodingBench.h b/bench/DecodingBench.h index a32bfeaa6e..b30e9720c9 100644 --- a/bench/DecodingBench.h +++ b/bench/DecodingBench.h @@ -28,7 +28,7 @@ protected: const char* onGetName() override; bool isSuitableFor(Backend backend) override; void onDraw(const int n, SkCanvas* canvas) override; - void onPreDraw() override; + void onDelayedSetup() override; private: SkString fName; diff --git a/bench/DisplacementBench.cpp b/bench/DisplacementBench.cpp index b83d0d174f..d9ddc8b095 100644 --- a/bench/DisplacementBench.cpp +++ b/bench/DisplacementBench.cpp @@ -23,7 +23,7 @@ public: } protected: - void onPreDraw() override { + void onDelayedSetup() override { if (!fInitialized) { this->makeBitmap(); this->makeCheckerboard(); diff --git a/bench/DrawBitmapAABench.cpp b/bench/DrawBitmapAABench.cpp index e4e0296860..9d5003b2ec 100644 --- a/bench/DrawBitmapAABench.cpp +++ b/bench/DrawBitmapAABench.cpp @@ -32,7 +32,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { fBitmap.allocN32Pixels(200, 200); fBitmap.eraseARGB(255, 0, 255, 0); } diff --git a/bench/ETCBitmapBench.cpp b/bench/ETCBitmapBench.cpp index d2fc76fac0..db8e37ea1e 100644 --- a/bench/ETCBitmapBench.cpp +++ b/bench/ETCBitmapBench.cpp @@ -144,7 +144,7 @@ protected: } } - void onPreDraw() override { + void onDelayedSetup() override { if (nullptr == fPKMData) { SkDebugf("Failed to load PKM data!\n"); return; diff --git a/bench/FSRectBench.cpp b/bench/FSRectBench.cpp index 03d1504bb3..4c7173bc29 100644 --- a/bench/FSRectBench.cpp +++ b/bench/FSRectBench.cpp @@ -22,7 +22,7 @@ public: protected: const char* onGetName() override { return "fullscreen_rects"; } - void onPreDraw() override { + void onDelayedSetup() override { if (!fInit) { SkRandom rand; static const SkScalar kMinOffset = 0; diff --git a/bench/GLBench.cpp b/bench/GLBench.cpp index a2f7a06447..23dd04f637 100644 --- a/bench/GLBench.cpp +++ b/bench/GLBench.cpp @@ -32,7 +32,7 @@ const GrGLContext* GLBench::getGLContext(SkCanvas* canvas) { return this->onGetGLContext(ctx); } -void GLBench::onPerCanvasPreDraw(SkCanvas* canvas) { +void GLBench::onPreDraw(SkCanvas* canvas) { // This bench exclusively tests GL calls directly const GrGLContext* ctx = this->getGLContext(canvas); if (!ctx) { @@ -41,7 +41,7 @@ void GLBench::onPerCanvasPreDraw(SkCanvas* canvas) { this->setup(ctx); } -void GLBench::onPerCanvasPostDraw(SkCanvas* canvas) { +void GLBench::onPostDraw(SkCanvas* canvas) { // This bench exclusively tests GL calls directly const GrGLContext* ctx = this->getGLContext(canvas); if (!ctx) { diff --git a/bench/GLBench.h b/bench/GLBench.h index 0755c4f1a8..dde0358abc 100644 --- a/bench/GLBench.h +++ b/bench/GLBench.h @@ -29,9 +29,9 @@ public: protected: const GrGLContext* getGLContext(SkCanvas*); virtual const GrGLContext* onGetGLContext(const GrGLContext* ctx) { return ctx; } - void onPerCanvasPreDraw(SkCanvas* canvas) override; + void onPreDraw(SkCanvas*) override; virtual void setup(const GrGLContext*)=0; - void onPerCanvasPostDraw(SkCanvas* canvas) override; + void onPostDraw(SkCanvas* canvas) override; virtual void teardown(const GrGLInterface*)=0; void onDraw(const int loops, SkCanvas*) override; virtual void glDraw(const int loops, const GrGLContext*)=0; diff --git a/bench/GameBench.cpp b/bench/GameBench.cpp index b99440043c..b1edf2ee9a 100644 --- a/bench/GameBench.cpp +++ b/bench/GameBench.cpp @@ -78,7 +78,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { if (!fInitialized) { this->makeCheckerboard(); this->makeAtlas(); diff --git a/bench/GeometryBench.cpp b/bench/GeometryBench.cpp index 99d39dd740..718d6a432b 100644 --- a/bench/GeometryBench.cpp +++ b/bench/GeometryBench.cpp @@ -46,7 +46,7 @@ public: protected: SkRect fRects[2048]; - virtual void onPreDraw() { + virtual void onDelayedSetup() { const SkScalar min = -100; const SkScalar max = 100; SkRandom rand; diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp index ec2f8cabdb..d022f19787 100644 --- a/bench/GrResourceCacheBench.cpp +++ b/bench/GrResourceCacheBench.cpp @@ -115,7 +115,7 @@ protected: return fFullName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { fContext.reset(GrContext::CreateMockContext()); if (!fContext) { return; diff --git a/bench/ImageFilterCollapse.cpp b/bench/ImageFilterCollapse.cpp index 4024750dc3..010149b2bc 100644 --- a/bench/ImageFilterCollapse.cpp +++ b/bench/ImageFilterCollapse.cpp @@ -83,7 +83,7 @@ protected: return "image_filter_collapse_table"; } - virtual void onPreDraw() override { + virtual void onDelayedSetup() override { for (int i = 0; i < 256; ++i) { int n = i >> 5; table1[i] = (n << 5) | (n << 2) | (n >> 1); @@ -139,7 +139,7 @@ protected: return "image_filter_collapse_matrix"; } - virtual void onPreDraw() override { + virtual void onDelayedSetup() override { SkColorFilter* colorFilters[] = { make_brightness(0.1f), make_grayscale(), diff --git a/bench/MagnifierBench.cpp b/bench/MagnifierBench.cpp index 24bd53c88f..c79c66893b 100644 --- a/bench/MagnifierBench.cpp +++ b/bench/MagnifierBench.cpp @@ -26,7 +26,7 @@ protected: return fIsSmall ? "magnifier_small" : "magnifier_large"; } - void onPreDraw() override { + void onDelayedSetup() override { if (!fInitialized) { make_checkerboard(); fInitialized = true; diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp index 75736aa143..9471f18008 100644 --- a/bench/MatrixBench.cpp +++ b/bench/MatrixBench.cpp @@ -146,7 +146,7 @@ public: DecomposeMatrixBench() : INHERITED("decompose") {} protected: - void onPreDraw() override { + void onDelayedSetup() override { for (int i = 0; i < 10; ++i) { SkScalar rot0 = (fRandom.nextBool()) ? fRandom.nextRangeF(-180, 180) : 0.0f; SkScalar sx = fRandom.nextRangeF(-3000.f, 3000.f); diff --git a/bench/MergeBench.cpp b/bench/MergeBench.cpp index 0a2611d207..404f6461b5 100644 --- a/bench/MergeBench.cpp +++ b/bench/MergeBench.cpp @@ -25,7 +25,7 @@ protected: return fIsSmall ? "merge_small" : "merge_large"; } - void onPreDraw() override { + void onDelayedSetup() override { if (!fInitialized) { make_bitmap(); make_checkerboard(); diff --git a/bench/MipMapBench.cpp b/bench/MipMapBench.cpp index 18af1e5f8c..2fb52bb658 100644 --- a/bench/MipMapBench.cpp +++ b/bench/MipMapBench.cpp @@ -22,7 +22,7 @@ protected: const char* onGetName() override { return "mipmap_build"; } - void onPreDraw() override { + void onDelayedSetup() override { fBitmap.allocN32Pixels(1000, 1000, true); fBitmap.eraseColor(SK_ColorWHITE); // so we don't read uninitialized memory } diff --git a/bench/PatchBench.cpp b/bench/PatchBench.cpp index a6f5faae65..26caad04e7 100644 --- a/bench/PatchBench.cpp +++ b/bench/PatchBench.cpp @@ -107,7 +107,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { this->setCubics(); this->setColors(); this->setTexCoords(); diff --git a/bench/PatchGridBench.cpp b/bench/PatchGridBench.cpp index e6b44870a1..dc64b537ac 100644 --- a/bench/PatchGridBench.cpp +++ b/bench/PatchGridBench.cpp @@ -200,7 +200,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { this->setGrid(); switch (fVertexMode) { case kTexCoords_VertexMode: diff --git a/bench/PathBench.cpp b/bench/PathBench.cpp index 8c157119d4..e09fc3ecab 100644 --- a/bench/PathBench.cpp +++ b/bench/PathBench.cpp @@ -325,7 +325,7 @@ protected: return "path_create"; } - void onPreDraw() override { + void onDelayedSetup() override { this->createData(10, 100); } @@ -354,7 +354,7 @@ protected: const char* onGetName() override { return "path_copy"; } - void onPreDraw() override { + void onDelayedSetup() override { this->createData(10, 100); fPaths.reset(kPathCnt); fCopies.reset(kPathCnt); @@ -390,7 +390,7 @@ protected: return fInPlace ? "path_transform_in_place" : "path_transform_copy"; } - void onPreDraw() override { + void onDelayedSetup() override { fMatrix.setScale(5 * SK_Scalar1, 6 * SK_Scalar1); this->createData(10, 100); fPaths.reset(kPathCnt); @@ -438,7 +438,7 @@ protected: return "path_equality_50%"; } - void onPreDraw() override { + void onDelayedSetup() override { fParity = 0; this->createData(10, 100); fPaths.reset(kPathCnt); @@ -501,7 +501,7 @@ protected: } } - void onPreDraw() override { + void onDelayedSetup() override { // reversePathTo assumes a single contour path. bool allowMoves = kReversePathTo_AddType != fType; this->createData(10, 100, allowMoves); @@ -769,7 +769,7 @@ private: } } - void onPreDraw() override { + void onDelayedSetup() override { fQueryRects.setCount(kQueryRectCnt); SkRandom rand; diff --git a/bench/PictureNestingBench.cpp b/bench/PictureNestingBench.cpp index 48f2ef46c5..e315fe6dbd 100644 --- a/bench/PictureNestingBench.cpp +++ b/bench/PictureNestingBench.cpp @@ -139,8 +139,8 @@ public: : INHERITED("playback", maxLevel, maxPictureLevel) { } protected: - void onPreDraw() override { - this->INHERITED::onPreDraw(); + void onDelayedSetup() override { + this->INHERITED::onDelayedSetup(); SkIPoint canvasSize = onGetSize(); SkPictureRecorder recorder; diff --git a/bench/PicturePlaybackBench.cpp b/bench/PicturePlaybackBench.cpp index 04eddc4f4f..6c42a69e4b 100644 --- a/bench/PicturePlaybackBench.cpp +++ b/bench/PicturePlaybackBench.cpp @@ -162,7 +162,7 @@ public: const char* onGetName() override { return fName.c_str(); } SkIPoint onGetSize() override { return SkIPoint::Make(1024,1024); } - void onPreDraw() override { + void onDelayedSetup() override { SkAutoTDelete factory; switch (fBBH) { case kNone: break; diff --git a/bench/PremulAndUnpremulAlphaOpsBench.cpp b/bench/PremulAndUnpremulAlphaOpsBench.cpp index 6e795417a6..a325332de2 100644 --- a/bench/PremulAndUnpremulAlphaOpsBench.cpp +++ b/bench/PremulAndUnpremulAlphaOpsBench.cpp @@ -29,7 +29,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { SkImageInfo info = SkImageInfo::Make(W, H, fColorType, kUnpremul_SkAlphaType); fBmp1.allocPixels(info); // used in writePixels diff --git a/bench/RTreeBench.cpp b/bench/RTreeBench.cpp index 63d8ed9d2c..61aa1542c9 100644 --- a/bench/RTreeBench.cpp +++ b/bench/RTreeBench.cpp @@ -67,7 +67,7 @@ protected: const char* onGetName() override { return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { SkRandom rand; SkAutoTMalloc rects(NUM_QUERY_RECTS); for (int i = 0; i < NUM_QUERY_RECTS; ++i) { diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp index ae8cb7ab7d..456c6f15aa 100644 --- a/bench/RectBench.cpp +++ b/bench/RectBench.cpp @@ -48,7 +48,7 @@ protected: const char* onGetName() override { return computeName("rects"); } - void onPreDraw() override { + void onDelayedSetup() override { SkRandom rand; const SkScalar offset = SK_Scalar1/3; for (int i = 0; i < N; i++) { diff --git a/bench/RectanizerBench.cpp b/bench/RectanizerBench.cpp index fec9bf5839..203da01208 100644 --- a/bench/RectanizerBench.cpp +++ b/bench/RectanizerBench.cpp @@ -72,7 +72,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { SkASSERT(nullptr == fRectanizer.get()); if (kPow2_RectanizerType == fRectanizerType) { diff --git a/bench/RepeatTileBench.cpp b/bench/RepeatTileBench.cpp index 4844f18af7..9b24eee120 100644 --- a/bench/RepeatTileBench.cpp +++ b/bench/RepeatTileBench.cpp @@ -108,7 +108,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { fBitmap.allocPixels(); fBitmap.eraseColor(kOpaque_SkAlphaType == fAlphaType ? SK_ColorWHITE : 0); diff --git a/bench/SkipZeroesBench.cpp b/bench/SkipZeroesBench.cpp index 87d433e422..5382832993 100644 --- a/bench/SkipZeroesBench.cpp +++ b/bench/SkipZeroesBench.cpp @@ -45,7 +45,7 @@ protected: return fName.c_str(); } - void onPreDraw() override { + void onDelayedSetup() override { SkString resourcePath = GetResourcePath(); if (resourcePath.isEmpty()) { fValid = false; diff --git a/bench/SortBench.cpp b/bench/SortBench.cpp index 9d22a45bf8..f621670d16 100644 --- a/bench/SortBench.cpp +++ b/bench/SortBench.cpp @@ -119,7 +119,7 @@ protected: } // Delayed initialization only done if onDraw will be called. - void onPreDraw() override { + void onDelayedSetup() override { fUnsorted.reset(N); gRec[fType].fProc(fUnsorted.get()); } diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp index ee5d5e0db3..cc9537a22b 100644 --- a/bench/TextBench.cpp +++ b/bench/TextBench.cpp @@ -69,7 +69,7 @@ public: } protected: - void onPreDraw() override { + void onDelayedSetup() override { if (fDoColorEmoji) { SkASSERT(kBW == fFQ); fColorEmojiTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf")); diff --git a/bench/TextBlobBench.cpp b/bench/TextBlobBench.cpp index 0ef5eb9654..5f4dbba63d 100644 --- a/bench/TextBlobBench.cpp +++ b/bench/TextBlobBench.cpp @@ -29,7 +29,7 @@ public: } protected: - void onPreDraw() override { + void onDelayedSetup() override { fTypeface.reset(sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal)); // make textblob SkPaint paint; diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 900ba4dfa2..6328aa15ab 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -207,6 +207,7 @@ static double time(int loops, Benchmark* bench, Target* target) { if (canvas) { canvas->clear(SK_ColorWHITE); } + bench->preDraw(canvas); WallTimer timer; timer.start(); canvas = target->beginTiming(canvas); @@ -216,6 +217,7 @@ static double time(int loops, Benchmark* bench, Target* target) { } target->endTiming(); timer.end(); + bench->postDraw(canvas); return timer.fWall; } @@ -1164,7 +1166,7 @@ int nanobench_main() { if (!configs.isEmpty()) { log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSize().fY); - bench->preDraw(); + bench->delayedSetup(); } for (int i = 0; i < configs.count(); ++i) { Target* target = is_enabled(b, configs[i]); diff --git a/tools/VisualBench/VisualInteractiveModule.cpp b/tools/VisualBench/VisualInteractiveModule.cpp index 538dda7a44..af922a92bf 100755 --- a/tools/VisualBench/VisualInteractiveModule.cpp +++ b/tools/VisualBench/VisualInteractiveModule.cpp @@ -98,7 +98,7 @@ bool VisualInteractiveModule::advanceRecordIfNecessary(SkCanvas* canvas) { // clear both buffers fOwner->clear(canvas, SK_ColorWHITE, 2); - fBenchmark->preDraw(); + fBenchmark->delayedSetup(); return true; } @@ -125,6 +125,7 @@ void VisualInteractiveModule::draw(SkCanvas* canvas) { } case kPreTiming_State: { fBenchmark->perCanvasPreDraw(canvas); + fBenchmark->preDraw(canvas); fCurrentFrame = 0; fTimer.start(); fState = kTiming_State; @@ -148,6 +149,7 @@ inline void VisualInteractiveModule::nextState(State nextState) { void VisualInteractiveModule::perCanvasPreDraw(SkCanvas* canvas, State nextState) { fBenchmark->perCanvasPreDraw(canvas); + fBenchmark->preDraw(canvas); fCurrentFrame = 0; this->nextState(nextState); } @@ -206,6 +208,7 @@ void VisualInteractiveModule::recordMeasurement() { } void VisualInteractiveModule::postDraw(SkCanvas* canvas) { + fBenchmark->postDraw(canvas); fBenchmark->perCanvasPostDraw(canvas); fBenchmark.reset(nullptr); fLoops = 1; diff --git a/tools/VisualBench/VisualLightweightBenchModule.cpp b/tools/VisualBench/VisualLightweightBenchModule.cpp index d5e4e5b8b6..d54c788ae7 100644 --- a/tools/VisualBench/VisualLightweightBenchModule.cpp +++ b/tools/VisualBench/VisualLightweightBenchModule.cpp @@ -169,7 +169,7 @@ bool VisualLightweightBenchModule::advanceRecordIfNecessary(SkCanvas* canvas) { fOwner->clear(canvas, SK_ColorWHITE, 2); - fBenchmark->preDraw(); + fBenchmark->delayedSetup(); fRecords.push_back(); // Log bench name @@ -184,6 +184,7 @@ inline void VisualLightweightBenchModule::nextState(State nextState) { void VisualLightweightBenchModule::perCanvasPreDraw(SkCanvas* canvas, State nextState) { fBenchmark->perCanvasPreDraw(canvas); + fBenchmark->preDraw(canvas); fCurrentFrame = 0; this->nextState(nextState); } @@ -293,6 +294,7 @@ void VisualLightweightBenchModule::recordMeasurement() { } void VisualLightweightBenchModule::postDraw(SkCanvas* canvas) { + fBenchmark->postDraw(canvas); fBenchmark->perCanvasPostDraw(canvas); fBenchmark.reset(nullptr); fCurrentSample = 0;