diff options
author | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-09-26 15:03:55 +0000 |
---|---|---|
committer | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-09-26 15:03:55 +0000 |
commit | 5ea050f6620fa9e675a1c801f738e946fa993e14 (patch) | |
tree | 917a10b9f137d853c3fd63de7ff4c43e90af2035 /gm | |
parent | b01ced0042997af4574ab276e37041f1412fd744 (diff) |
Optimize software radial gradients (remove branches from the inner loop where
we can, because an entire row is conservatively either outside or inside the
gradient.) Change the gradient benchmark to capture both cases, and add new
gm to detect errors in these optimized paths.
git-svn-id: http://skia.googlecode.com/svn/trunk@2327 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r-- | gm/gradients.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gm/gradients.cpp b/gm/gradients.cpp index 219e7a06eb..2737bfc87b 100644 --- a/gm/gradients.cpp +++ b/gm/gradients.cpp @@ -178,6 +178,45 @@ private: typedef GM INHERITED; }; +/// Tests correctness of *optimized* codepaths in gradients. + +class ClampedGradientsGM : public GM { +public: + ClampedGradientsGM() {} + +protected: + SkString onShortName() { return SkString("clamped_gradients"); } + + virtual SkISize onISize() { return make_isize(640, 510); } + + void drawBG(SkCanvas* canvas) { + canvas->drawColor(0xFFDDDDDD); + } + + virtual void onDraw(SkCanvas* canvas) { + this->drawBG(canvas); + + SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(300) }; + SkPaint paint; + paint.setAntiAlias(true); + + SkPoint center; + center.iset(0, 300); + canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); + SkShader* shader = SkGradientShader::CreateRadial( + SkPoint(center), + 200, gColors, NULL, 5, + SkShader::kClamp_TileMode, NULL); + paint.setShader(shader); + canvas->drawRect(r, paint); + shader->unref(); + } + +private: + typedef GM INHERITED; +}; + + /////////////////////////////////////////////////////////////////////////////// static GM* MyFactory(void*) { return new GradientsGM; } @@ -186,5 +225,8 @@ static GMRegistry reg(MyFactory); static GM* MyFactory2(void*) { return new GradientsDegenrate2PointGM; } static GMRegistry reg2(MyFactory2); +static GM* MyFactory3(void*) { return new ClampedGradientsGM; } +static GMRegistry reg3(MyFactory3); + } |