Use onOnceBeforeDraw instead of constructor for glyphs.

The PathText samples extracted glyph paths in the constructor, which
means that this is done when the sample is created instead of when it is
actually going to be drawn. This interferes with debugging other
samples, so delay extracting the glyph paths until onOnceBeforeDraw.

Change-Id: I342cc728b79426203273e5a19fb5ba3718c50fd6
Reviewed-on: https://skia-review.googlesource.com/155000
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp
index cf09708..9ad6301 100644
--- a/samplecode/SamplePathText.cpp
+++ b/samplecode/SamplePathText.cpp
@@ -23,7 +23,15 @@
     constexpr static int kNumPaths = 1500;
     virtual const char* getName() const { return "PathText"; }
 
-    PathText() {
+    PathText() {}
+
+    virtual void reset() {
+        for (Glyph& glyph : fGlyphs) {
+            glyph.reset(fRand, this->width(), this->height());
+        }
+    }
+
+    void onOnceBeforeDraw() final {
         SkPaint defaultPaint;
         auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(defaultPaint);
         SkPath glyphPaths[52];
@@ -38,15 +46,10 @@
             const SkPath& p = glyphPaths[i % 52];
             fGlyphs[i].init(fRand, p);
         }
-    }
 
-    virtual void reset() {
-        for (Glyph& glyph : fGlyphs) {
-            glyph.reset(fRand, this->width(), this->height());
-        }
+        this->INHERITED::onOnceBeforeDraw();
+        this->reset();
     }
-
-    void onOnceBeforeDraw() final { this->INHERITED::onOnceBeforeDraw(); this->reset(); }
     void onSizeChange() final { this->INHERITED::onSizeChange(); this->reset(); }
 
     bool onQuery(Sample::Event* evt) final {