Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: gm/textblob.cpp

Issue 1144023002: Move font loading in gm tests and benches out of constructors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gm/textblob.cpp
diff --git a/gm/textblob.cpp b/gm/textblob.cpp
index 7c0fd875462cba46574636a53e7a94355649f159..e85571f898f8a2a9038f69fa5256c6c56b47aa82 100644
--- a/gm/textblob.cpp
+++ b/gm/textblob.cpp
@@ -67,17 +67,21 @@ const SkScalar kFontSize = 16;
class TextBlobGM : public skiagm::GM {
public:
TextBlobGM(const char* txt)
- : fTypeface(sk_tool_utils::create_portable_typeface("Times", SkTypeface::kNormal)) {
+ : fText(txt) {
+ }
+
+protected:
+ void onOnceBeforeDraw() override {
+ fTypeface.reset(sk_tool_utils::create_portable_typeface("Times", SkTypeface::kNormal));
SkPaint p;
p.setTypeface(fTypeface);
- size_t txtLen = strlen(txt);
- int glyphCount = p.textToGlyphs(txt, txtLen, NULL);
+ size_t txtLen = strlen(fText);
+ int glyphCount = p.textToGlyphs(fText, txtLen, NULL);
fGlyphs.append(glyphCount);
- p.textToGlyphs(txt, txtLen, fGlyphs.begin());
+ p.textToGlyphs(fText, txtLen, fGlyphs.begin());
}
-protected:
SkString onShortName() override {
return SkString("textblob");
}
@@ -178,7 +182,7 @@ private:
SkTDArray<uint16_t> fGlyphs;
SkAutoTUnref<SkTypeface> fTypeface;
-
+ const char* fText;
typedef skiagm::GM INHERITED;
};

Powered by Google App Engine
This is Rietveld 408576698