From 0fe39bae6b370bfa5ce27fbf9d9d9c3bccdc9f56 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Fri, 28 Dec 2018 11:12:50 -0500 Subject: [PATCH] move work out of GM ctor Change-Id: I6e29e08a1bfaeafe98c8a61f8ce5c279839f4b3c Reviewed-on: https://skia-review.googlesource.com/c/180301 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- gm/textblobshader.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gm/textblobshader.cpp b/gm/textblobshader.cpp index 3d1b0a5f23..971f6288fa 100644 --- a/gm/textblobshader.cpp +++ b/gm/textblobshader.cpp @@ -19,16 +19,18 @@ // This GM exercises drawTextBlob offset vs. shader space behavior. class TextBlobShaderGM : public skiagm::GM { public: - TextBlobShaderGM(const char* txt) { - SkFont font(sk_tool_utils::create_portable_typeface()); - size_t txtLen = strlen(txt); - fGlyphs.append(font.countText(txt, txtLen, kUTF8_SkTextEncoding)); - font.textToGlyphs(txt, txtLen, kUTF8_SkTextEncoding, fGlyphs.begin(), fGlyphs.count()); - } - -protected: + TextBlobShaderGM() {} +private: void onOnceBeforeDraw() override { + { + SkFont font(sk_tool_utils::create_portable_typeface()); + const char* txt = "Blobber"; + size_t txtLen = strlen(txt); + fGlyphs.append(font.countText(txt, txtLen, kUTF8_SkTextEncoding)); + font.textToGlyphs(txt, txtLen, kUTF8_SkTextEncoding, fGlyphs.begin(), fGlyphs.count()); + } + SkFont font; font.setSubpixel(true); font.setEdging(SkFont::Edging::kAntiAlias); @@ -101,7 +103,6 @@ protected: } } -private: SkTDArray fGlyphs; sk_sp fBlob; sk_sp fShader; @@ -109,4 +110,4 @@ private: typedef skiagm::GM INHERITED; }; -DEF_GM(return new TextBlobShaderGM("Blobber");) +DEF_GM(return new TextBlobShaderGM;)