diff options
author | Derek Sollenberger <djsollen@google.com> | 2011-01-07 13:32:14 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2011-02-23 14:59:05 -0500 |
commit | 40528743dbb9ce7f39f093e0cdc47849ac8887cf (patch) | |
tree | 9f27d91d1210746846b76e2ab85a82258243fe1f /gm/gradients.cpp | |
parent | dd3f189dfde60f95f6be0517f1c28ad2879973a1 (diff) | |
download | external_skia-40528743dbb9ce7f39f093e0cdc47849ac8887cf.zip external_skia-40528743dbb9ce7f39f093e0cdc47849ac8887cf.tar.gz external_skia-40528743dbb9ce7f39f093e0cdc47849ac8887cf.tar.bz2 |
Skia Merge (revision 808)
This merge has companion changes in the following projects in order
to be compatible with changes to skia interfaces and practices:
1. /frameworks/base
2. /external/webkit
Change-Id: I54092971305579e81a8fdb27bbe04ec340792e3b
Diffstat (limited to 'gm/gradients.cpp')
-rw-r--r-- | gm/gradients.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/gm/gradients.cpp b/gm/gradients.cpp index aed4e0b..26eee9d 100644 --- a/gm/gradients.cpp +++ b/gm/gradients.cpp @@ -31,7 +31,7 @@ static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCount, tm, mapper); } - + static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm, SkUnitMapper* mapper) { SkPoint center; @@ -50,10 +50,23 @@ static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, data.fPos, data.fCount, mapper); } +static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, + SkShader::TileMode tm, SkUnitMapper* mapper) { + SkPoint center0, center1; + center0.set(SkScalarAve(pts[0].fX, pts[1].fX), + SkScalarAve(pts[0].fY, pts[1].fY)); + center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), + SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); + return SkGradientShader::CreateTwoPointRadial( + center1, (pts[1].fX - pts[0].fX) / 7, + center0, (pts[1].fX - pts[0].fX) / 2, + data.fColors, data.fPos, data.fCount, tm, mapper); +} + typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, SkUnitMapper* mapper); + SkShader::TileMode tm, SkUnitMapper* mapper); static const GradMaker gGradMakers[] = { - MakeLinear, MakeRadial, MakeSweep + MakeLinear, MakeRadial, MakeSweep, Make2Radial }; /////////////////////////////////////////////////////////////////////////////// @@ -67,7 +80,7 @@ protected: return SkString("gradients"); } - SkISize onISize() { return make_isize(640, 380); } + SkISize onISize() { return make_isize(640, 510); } void drawBG(SkCanvas* canvas) { canvas->drawColor(0xFFDDDDDD); |