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

Unified Diff: gm/shadertext.cpp

Issue 540993003: don't use local static bitmap -- racy and unnecessary (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/shadertext.cpp
diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp
index 468c12b6df6af3c3fd3f3599935285bccd965ecd..37be71092f9e823494eaff5422e8718253310106 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]);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698