diff options
-rw-r--r-- | bench/SKPBench.cpp | 10 | ||||
-rw-r--r-- | samplecode/SampleApp.cpp | 6 | ||||
-rw-r--r-- | tools/VisualBench/VisualBenchmarkStream.cpp | 10 | ||||
-rw-r--r-- | tools/VisualBench/VisualSKPBench.cpp | 10 |
4 files changed, 36 insertions, 0 deletions
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp index 44261335da..910af6b802 100644 --- a/bench/SKPBench.cpp +++ b/bench/SKPBench.cpp @@ -10,6 +10,10 @@ #include "SkMultiPictureDraw.h" #include "SkSurface.h" +#if SK_SUPPORT_GPU +#include "GrContext.h" +#endif + // These CPU tile sizes are not good per se, but they are similar to what Chrome uses. DEFINE_int32(CPUbenchTileW, 256, "Tile width used for CPU SKP playback."); DEFINE_int32(CPUbenchTileH, 256, "Tile height used for CPU SKP playback."); @@ -115,6 +119,12 @@ void SKPBench::onDraw(int loops, SkCanvas* canvas) { this->drawPicture(); } } +#if SK_SUPPORT_GPU + // Ensure the GrContext doesn't batch across draw loops. + if (GrContext* context = canvas->getGrContext()) { + context->flush(); + } +#endif } void SKPBench::drawMPDPicture() { diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 9be7567ea0..07a7a87b7f 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -2257,6 +2257,12 @@ void SampleView::onDraw(SkCanvas* canvas) { for (int i = 0; i < fRepeatCount; i++) { SkAutoCanvasRestore acr(canvas, true); this->onDrawContent(canvas); +#if SK_SUPPORT_GPU + // Ensure the GrContext doesn't batch across draw loops. + if (GrContext* context = canvas->getGrContext()) { + context->flush(); + } +#endif } } diff --git a/tools/VisualBench/VisualBenchmarkStream.cpp b/tools/VisualBench/VisualBenchmarkStream.cpp index 66e7cb0aab..2efb3c886e 100644 --- a/tools/VisualBench/VisualBenchmarkStream.cpp +++ b/tools/VisualBench/VisualBenchmarkStream.cpp @@ -17,6 +17,10 @@ #include "VisualFlags.h" #include "VisualSKPBench.h" +#if SK_SUPPORT_GPU +#include "GrContext.h" +#endif + DEFINE_bool(cpu, false, "Run in CPU mode?"); DEFINE_string2(match, m, nullptr, "[~][^]substring[$] [...] of bench name to run.\n" @@ -52,6 +56,12 @@ private: for (int i = 0; i < loops; i++) { canvas->drawPath(fPath, paint); canvas->drawRect(rect, perlinPaint); +#if SK_SUPPORT_GPU + // Ensure the GrContext doesn't batch across draw loops. + if (GrContext* context = canvas->getGrContext()) { + context->flush(); + } +#endif } } SkPath fPath; diff --git a/tools/VisualBench/VisualSKPBench.cpp b/tools/VisualBench/VisualSKPBench.cpp index 649d324a66..628265e53e 100644 --- a/tools/VisualBench/VisualSKPBench.cpp +++ b/tools/VisualBench/VisualSKPBench.cpp @@ -8,6 +8,10 @@ #include "VisualSKPBench.h" +#if SK_SUPPORT_GPU +#include "GrContext.h" +#endif + VisualSKPBench::VisualSKPBench(const char* name, const SkPicture* pic) : fPic(SkRef(pic)) , fName(name) { @@ -29,5 +33,11 @@ bool VisualSKPBench::isSuitableFor(Backend backend) { void VisualSKPBench::onDraw(int loops, SkCanvas* canvas) { for (int i = 0; i < loops; i++) { canvas->drawPicture(fPic); +#if SK_SUPPORT_GPU + // Ensure the GrContext doesn't batch across draw loops. + if (GrContext* context = canvas->getGrContext()) { + context->flush(); + } +#endif } } |