Index: gm/typeface.cpp |
diff --git a/gm/typeface.cpp b/gm/typeface.cpp |
index 4114d2cc3344ae557568e47c7fcbc1b0baace683..5ddc338449cad4671b732ea5b52e4b110f1d7dbf 100644 |
--- a/gm/typeface.cpp |
+++ b/gm/typeface.cpp |
@@ -21,21 +21,27 @@ static const char* gFaces[] = { |
class TypefaceGM : public skiagm::GM { |
public: |
- TypefaceGM() { |
- fFaces = new SkTypeface*[SK_ARRAY_COUNT(gFaces)]; |
- for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { |
- fFaces[i] = sk_tool_utils::create_portable_typeface(gFaces[i], SkTypeface::kNormal); |
- } |
+ TypefaceGM() |
+ : fFaces(NULL) { |
} |
virtual ~TypefaceGM() { |
- for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { |
- SkSafeUnref(fFaces[i]); |
+ if (fFaces) { |
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { |
+ SkSafeUnref(fFaces[i]); |
+ } |
+ delete [] fFaces; |
} |
- delete [] fFaces; |
} |
protected: |
+ void onOnceBeforeDraw() override { |
+ fFaces = new SkTypeface*[SK_ARRAY_COUNT(gFaces)]; |
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { |
+ fFaces[i] = sk_tool_utils::create_portable_typeface(gFaces[i], SkTypeface::kNormal); |
+ } |
+ } |
+ |
SkString onShortName() override { |
return SkString("typeface"); |
} |
@@ -157,11 +163,9 @@ class TypefaceStylesGM : public skiagm::GM { |
bool fApplyKerning; |
public: |
- TypefaceStylesGM(bool applyKerning) : fApplyKerning(applyKerning) { |
- for (int i = 0; i < gFaceStylesCount; i++) { |
- fFaces[i] = sk_tool_utils::create_portable_typeface(gFaceStyles[i].fName, |
- gFaceStyles[i].fStyle); |
- } |
+ TypefaceStylesGM(bool applyKerning) |
+ : fApplyKerning(applyKerning) { |
+ memset(fFaces, 0, sizeof(fFaces)); |
mtklein
2015/05/21 13:09:25
Just FYI, we usually use sk_bzero for this so we d
|
} |
virtual ~TypefaceStylesGM() { |
@@ -171,6 +175,13 @@ public: |
} |
protected: |
+ void onOnceBeforeDraw() override { |
+ for (int i = 0; i < gFaceStylesCount; i++) { |
+ fFaces[i] = sk_tool_utils::create_portable_typeface(gFaceStyles[i].fName, |
+ gFaceStyles[i].fStyle); |
+ } |
+ } |
+ |
SkString onShortName() override { |
SkString name("typefacestyles"); |
if (fApplyKerning) { |