Fix ChartBench crash.
git-svn-id: http://skia.googlecode.com/svn/trunk@7826 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/ChartBench.cpp b/bench/ChartBench.cpp
index 0693f49..0a692cf 100644
--- a/bench/ChartBench.cpp
+++ b/bench/ChartBench.cpp
@@ -94,6 +94,8 @@
ChartBench(void* param, bool aa) : SkBenchmark(param) {
fShift = 0;
fAA = aa;
+ fSize.fWidth = -1;
+ fSize.fHeight = -1;
}
protected:
@@ -115,18 +117,17 @@
SkScalar ySpread = SkIntToScalar(fSize.fHeight / 20);
SkScalar height = SkIntToScalar(fSize.fHeight);
+ if (sizeChanged) {
+ int dataPointCount = SkMax32(fSize.fWidth / kPixelsPerTick + 1, 2);
+
+ 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);
+ }
+ }
for (int frame = 0; frame < kFramesPerRun; ++frame) {
- if (sizeChanged) {
- int dataPointCount = SkMax32(fSize.fWidth / kPixelsPerTick + 1, 2);
-
- 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);
- }
- sizeChanged = false;
- }
canvas->clear(0xFFE0F0E0);