From bc9956de31da06529b540918832f2435f884ac26 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Wed, 22 Feb 2017 13:49:09 -0500 Subject: Attempt to stabilize shadow_utils GM for replay configs Change-Id: I0ed15ab102fa1e0a364d5f3a953bedd8afbda3c3 Reviewed-on: https://skia-review.googlesource.com/8853 Commit-Queue: Brian Salomon Reviewed-by: Mike Klein --- gm/shadowutils.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gm/shadowutils.cpp') diff --git a/gm/shadowutils.cpp b/gm/shadowutils.cpp index 96554f10e7..fd02d92133 100644 --- a/gm/shadowutils.cpp +++ b/gm/shadowutils.cpp @@ -8,6 +8,7 @@ #include "gm.h" #include "SkCanvas.h" #include "SkPath.h" +#include "SkMutex.h" #include "SkShadowUtils.h" void draw_shadow(SkCanvas* canvas, const SkPath& path, int height, SkColor color, SkPoint3 lightPos, @@ -22,6 +23,14 @@ static constexpr int kW = 700; static constexpr int kH = 800; DEF_SIMPLE_GM(shadow_utils, canvas, kW, kH) { + // SkShadowUtils uses a cache of SkVertices meshes. The vertices are created in a local + // coordinate system and then translated when reused. The coordinate system depends on + // parameters to the generating draw. To avoid slight rendering differences due to this property + // we only allow one thread into this GM at a time and we reset the cache before each run. + static SkMutex gMutex; + SkAutoMutexAcquire mutexLock(&gMutex); + SkShadowUtils::ClearCache(); + SkTArray paths; paths.push_back().addRoundRect(SkRect::MakeWH(50, 50), 10, 10); SkRRect oddRRect; -- cgit v1.2.3