aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/shadertext3.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-26 21:21:40 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-26 21:21:40 +0000
commita54abdccbd9e9b8917f7c7b0af5d9fe39d879a9a (patch)
tree15c49b732a9cf9a3cfc7f9316e2831f533800422 /gm/shadertext3.cpp
parent4362a38563a958083aca2b456aaaa9f756f6f4e1 (diff)
Remove static bmp from shadertext3
R=mtklein@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/212843004 git-svn-id: http://skia.googlecode.com/svn/trunk@13959 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/shadertext3.cpp')
-rw-r--r--gm/shadertext3.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp
index 48093eb186..a1c2d6006b 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;
+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;
};