aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-09-04 13:18:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-04 13:18:36 -0700
commitda8cf5accb67d26a7f2e77d15cc918910e594e64 (patch)
treec57d616e37e8752cd054320625345fadcd76a4eb /gm
parent95740981c36266e4595ddde2264aa38e3c7e2d02 (diff)
don't use local static bitmap -- racy and unnecessary
BUG=skia: R=mtklein@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/540993003
Diffstat (limited to 'gm')
-rw-r--r--gm/shadertext.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp
index 468c12b6df..37be71092f 100644
--- a/gm/shadertext.cpp
+++ b/gm/shadertext.cpp
@@ -28,15 +28,6 @@ static void makebm(SkBitmap* bm, int w, int h) {
canvas.drawPaint(paint);
}
-static SkShader* MakeBitmapShader(SkShader::TileMode tx, SkShader::TileMode ty,
- int w, int h) {
- static SkBitmap bmp;
- if (bmp.isNull()) {
- makebm(&bmp, w/2, h/4);
- }
- return SkShader::CreateBitmapShader(bmp, tx, ty);
-}
-
///////////////////////////////////////////////////////////////////////////////
struct GradData {
@@ -115,8 +106,8 @@ protected:
const int textLen = SK_ARRAY_COUNT(text) - 1;
const int pointSize = 36;
- int w = pointSize * textLen;
- int h = pointSize;
+ const int w = pointSize * textLen;
+ const int h = pointSize;
SkPoint pts[2] = {
{ 0, 0 },
@@ -144,11 +135,12 @@ protected:
SkShader::kClamp_TileMode);
}
}
+
+ SkBitmap bm;
+ makebm(&bm, w/16, h/4);
for (size_t tx = 0; tx < SK_ARRAY_COUNT(tileModes); ++tx) {
for (size_t ty = 0; ty < SK_ARRAY_COUNT(tileModes); ++ty) {
- shaders[shdIdx++] = MakeBitmapShader(tileModes[tx],
- tileModes[ty],
- w/8, h);
+ shaders[shdIdx++] = SkShader::CreateBitmapShader(bm, tileModes[tx], tileModes[ty]);
}
}