From 8a2151f0ae19bae6c7ce09382079fce67dc5526c Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Thu, 8 May 2014 15:12:43 +0000 Subject: Remove global SkRandoms from ChartBench. TSAN picked them up while running DM. BUG=skia:1792 R=bsalomon@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/278523005 git-svn-id: http://skia.googlecode.com/svn/trunk@14641 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/ChartBench.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'bench/ChartBench.cpp') diff --git a/bench/ChartBench.cpp b/bench/ChartBench.cpp index 47fe7527c7..9dae5b8070 100644 --- a/bench/ChartBench.cpp +++ b/bench/ChartBench.cpp @@ -16,11 +16,11 @@ */ // Generates y values for the chart plots. -static void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray* dataPts) { +static void gen_data(SkScalar yAvg, SkScalar ySpread, int count, + SkRandom* random, SkTDArray* dataPts) { dataPts->setCount(count); - static SkRandom gRandom; for (int i = 0; i < count; ++i) { - (*dataPts)[i] = gRandom.nextRangeScalar(yAvg - SkScalarHalf(ySpread), + (*dataPts)[i] = random->nextRangeScalar(yAvg - SkScalarHalf(ySpread), yAvg + SkScalarHalf(ySpread)); } } @@ -115,25 +115,24 @@ protected: if (sizeChanged) { int dataPointCount = SkMax32(fSize.fWidth / kPixelsPerTick + 1, 2); + SkRandom random; for (int i = 0; i < kNumGraphs; ++i) { SkScalar y = (kNumGraphs - i) * (height - ySpread) / (kNumGraphs + 1); fData[i].reset(); - gen_data(y, ySpread, dataPointCount, fData + i); + gen_data(y, ySpread, dataPointCount, &random, fData + i); } } + SkRandom colorRand; + SkColor colors[kNumGraphs]; + for (int i = 0; i < kNumGraphs; ++i) { + colors[i] = colorRand.nextU() | 0xff000000; + } + for (int frame = 0; frame < loops; ++frame) { canvas->clear(0xFFE0F0E0); - static SkRandom colorRand; - static SkColor gColors[kNumGraphs] = { 0x0 }; - if (0 == gColors[0]) { - for (int i = 0; i < kNumGraphs; ++i) { - gColors[i] = colorRand.nextU() | 0xff000000; - } - } - SkPath plotPath; SkPath fillPath; @@ -160,10 +159,10 @@ protected: &fillPath); // Make the fills partially transparent - fillPaint.setColor((gColors[i] & 0x00ffffff) | 0x80000000); + fillPaint.setColor((colors[i] & 0x00ffffff) | 0x80000000); canvas->drawPath(fillPath, fillPaint); - plotPaint.setColor(gColors[i]); + plotPaint.setColor(colors[i]); canvas->drawPath(plotPath, plotPaint); prevData = fData + i; -- cgit v1.2.3