diff options
author | anatoly@google.com <anatoly@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-04-12 13:51:28 +0000 |
---|---|---|
committer | anatoly@google.com <anatoly@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-04-12 13:51:28 +0000 |
commit | a956e4fe2e7a6701f778c632ff11e8a0ed01168f (patch) | |
tree | dc730414d788edc6ad7faa654ef25b8d68981a28 /bench/RectBench.cpp | |
parent | 229d9b3953a84365e0cf4848556c0795af4446da (diff) |
Use hairline when line width <= 1.0, instead of < 1.0.
This speeds line drawing up considerably when drawing with
default linewidth on canvas.
Review: http://codereview.appspot.com/883047/show
git-svn-id: http://skia.googlecode.com/svn/trunk@538 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/RectBench.cpp')
-rw-r--r-- | bench/RectBench.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp index 6f34eb5638..3874bb3fc7 100644 --- a/bench/RectBench.cpp +++ b/bench/RectBench.cpp @@ -89,14 +89,20 @@ public: protected: virtual void onDraw(SkCanvas* canvas) { - static const SkScalar gSizes[] = { + SkScalar gSizes[] = { SkIntToScalar(7), 0 }; + size_t sizes = SK_ARRAY_COUNT(gSizes); + + if (this->hasStrokeWidth()) { + gSizes[0] = this->getStrokeWidth(); + sizes = 1; + } SkPaint paint; paint.setStrokeCap(SkPaint::kRound_Cap); - - for (size_t i = 0; i < SK_ARRAY_COUNT(gSizes); i++) { + + for (size_t i = 0; i < sizes; i++) { paint.setStrokeWidth(gSizes[i]); this->setupPaint(&paint); canvas->drawPoints(fMode, N * 2, @@ -132,4 +138,3 @@ static BenchRegistry gRRectReg2(RRectFactory2); static BenchRegistry gPointsReg(PointsFactory); static BenchRegistry gLinesReg(LinesFactory); static BenchRegistry gPolygonReg(PolygonFactory); - |