diff options
author | Derek Sollenberger <djsollen@google.com> | 2011-03-14 11:20:24 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2011-03-14 16:33:36 -0400 |
commit | 05b6b4d746867a9fb02e14edfe1bf3685abeb813 (patch) | |
tree | 34b121f598d1693c014df48ee70bffa382b0cc23 /gm/shadows.cpp | |
parent | 6210a7c68844602ee390bcce61dbb637910a3c6b (diff) | |
download | external_skia-05b6b4d746867a9fb02e14edfe1bf3685abeb813.zip external_skia-05b6b4d746867a9fb02e14edfe1bf3685abeb813.tar.gz external_skia-05b6b4d746867a9fb02e14edfe1bf3685abeb813.tar.bz2 |
Skia Merge (revision 922)
Change-Id: I7ed57d10905d8bad6486a4d7410165eec1cc2b4f
Diffstat (limited to 'gm/shadows.cpp')
-rw-r--r-- | gm/shadows.cpp | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/gm/shadows.cpp b/gm/shadows.cpp new file mode 100644 index 0000000..5afde49 --- /dev/null +++ b/gm/shadows.cpp @@ -0,0 +1,99 @@ +#include "gm.h" +#include "SkPicture.h" +#include "SkRectShape.h" +#include "SkBlurDrawLooper.h" + +namespace skiagm { + +/////////////////////////////////////////////////////////////////////////////// + +class ShadowsGM : public GM { + +public: + SkPath fCirclePath; + SkPaint fPaint; + SkRectShape fRectShape; + ShadowsGM() { + fCirclePath.addCircle(SkIntToScalar(20), SkIntToScalar(20), SkIntToScalar(10) ); + fPaint.setStrokeWidth(SkIntToScalar(4)); + fPaint.setAntiAlias(true); + fPaint.setColor(0xFF00FF00); + fPaint.setStyle(SkPaint::kStroke_Style); + SkRect rect; + rect.set(SkIntToScalar(10), SkIntToScalar(10), + SkIntToScalar(30), SkIntToScalar(30)); + fRectShape.setRect(rect); + fRectShape.paint().setColor(SK_ColorRED); + } + + virtual ~ShadowsGM() { + } + +protected: + virtual SkString onShortName() { + return SkString("shadows"); + } + + virtual SkISize onISize() { + return make_isize(200, 80); + } + + void drawBG(SkCanvas* canvas) { + canvas->drawColor(0xFFDDDDDD); + } + + virtual void onDraw(SkCanvas* canvas) { + this->drawBG(canvas); + + SkBlurDrawLooper* shadowLoopers[5]; + shadowLoopers[0] = + new SkBlurDrawLooper (10, 5, 10, 0xFF0000FF, + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag ); + SkAutoUnref aurL0(shadowLoopers[0]); + shadowLoopers[1] = + new SkBlurDrawLooper (10, 5, 10, 0xFF0000FF, + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag ); + SkAutoUnref aurL1(shadowLoopers[1]); + shadowLoopers[2] = + new SkBlurDrawLooper (5, 5, 10, 0xFF000000, + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag ); + SkAutoUnref aurL2(shadowLoopers[2]); + shadowLoopers[3] = + new SkBlurDrawLooper (5, -5 ,-10, 0x7FFF0000, + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag ); + SkAutoUnref aurL3(shadowLoopers[3]); + shadowLoopers[4] = + new SkBlurDrawLooper (0, 5, 5, 0xFF000000, + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag ); + SkAutoUnref aurL4(shadowLoopers[4]); + + for (int looper = 0; looper < 5; looper ++) + { + fRectShape.paint().setLooper(shadowLoopers[looper]); + canvas->resetMatrix(); + canvas->translate(SkIntToScalar(looper*40), SkIntToScalar(0)); + canvas->drawShape(&fRectShape); + fPaint.setLooper(shadowLoopers[looper]); + canvas->translate(SkIntToScalar(0), SkIntToScalar(40)); + canvas->drawPath(fCirclePath, fPaint); + } +} + +private: + typedef GM INHERITED; +}; + +/////////////////////////////////////////////////////////////////////////////// + +static GM* MyFactory(void*) { return new ShadowsGM; } +static GMRegistry reg(MyFactory); + +} |