Index: gm/shadertext3.cpp |
diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp |
index 48093eb186f815f31f99f3fb5146235d278b8ee8..a1c2d6006b505fd21a7e0884f451497ad13c8313 100644 |
--- a/gm/shadertext3.cpp |
+++ b/gm/shadertext3.cpp |
@@ -47,6 +47,10 @@ struct LabeledMatrix { |
const char* fLabel; |
}; |
+static const char kText[] = "B"; |
+static const int kTextLen = SK_ARRAY_COUNT(kText) - 1; |
mtklein
2014/03/26 20:47:17
I love this. AKA, 1.
bsalomon
2014/03/26 20:49:02
:) I'll leave to you to guess where "B" comes from
|
+static const int kPointSize = 300; |
+ |
class ShaderText3GM : public GM { |
public: |
ShaderText3GM() { |
@@ -55,27 +59,23 @@ public: |
protected: |
- SkString onShortName() { |
+ virtual SkString onShortName() SK_OVERRIDE { |
return SkString("shadertext3"); |
} |
- SkISize onISize() { return make_isize(800, 1000); } |
+ virtual SkISize onISize() SK_OVERRIDE{ return make_isize(800, 1000); } |
- virtual void onDraw(SkCanvas* canvas) { |
- static const char kText[] = "B"; |
- static const int kTextLen = SK_ARRAY_COUNT(kText) - 1; |
- static const int kPointSize = 300; |
+ virtual void onOnceBeforeDraw() SK_OVERRIDE { |
+ makebm(&fBmp, kPointSize / 4, kPointSize / 4); |
+ } |
- static SkBitmap bmp; |
- if (bmp.isNull()) { |
- makebm(&bmp, kPointSize / 4, kPointSize / 4); |
- } |
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
SkPaint bmpPaint; |
bmpPaint.setAntiAlias(true); |
bmpPaint.setFilterLevel(SkPaint::kLow_FilterLevel); |
bmpPaint.setAlpha(0x80); |
- canvas->drawBitmap(bmp, 5.f, 5.f, &bmpPaint); |
+ canvas->drawBitmap(fBmp, 5.f, 5.f, &bmpPaint); |
SkPaint outlinePaint; |
outlinePaint.setAntiAlias(true); |
@@ -100,7 +100,7 @@ protected: |
int i = 0; |
for (size_t tm0 = 0; tm0 < SK_ARRAY_COUNT(kTileModes); ++tm0) { |
for (size_t tm1 = 0; tm1 < SK_ARRAY_COUNT(kTileModes); ++tm1) { |
- SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(bmp, |
+ SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(fBmp, |
kTileModes[tm0], |
kTileModes[tm1])); |
SkMatrix localM; |
@@ -131,6 +131,7 @@ protected: |
} |
private: |
+ SkBitmap fBmp; |
typedef GM INHERITED; |
}; |