diff options
author | Brian Salomon <bsalomon@google.com> | 2017-02-22 13:49:09 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-22 19:28:12 +0000 |
commit | bc9956de31da06529b540918832f2435f884ac26 (patch) | |
tree | 2cfb21a296383c5a8de810f6d5a06ec4e9a53d46 /gm/shadowutils.cpp | |
parent | e522f4c455d0d5dbe813f38d16c0d4cd46fa5dee (diff) |
Attempt to stabilize shadow_utils GM for replay configs
Change-Id: I0ed15ab102fa1e0a364d5f3a953bedd8afbda3c3
Reviewed-on: https://skia-review.googlesource.com/8853
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'gm/shadowutils.cpp')
-rw-r--r-- | gm/shadowutils.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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<SkPath> paths; paths.push_back().addRoundRect(SkRect::MakeWH(50, 50), 10, 10); SkRRect oddRRect; |