diff options
author | 2009-08-14 16:08:38 +0000 | |
---|---|---|
committer | 2009-08-14 16:08:38 +0000 | |
commit | 6c5f6f25b43f1210decb48956c1a2fbe5b58f889 (patch) | |
tree | 6e807d72d62fc739ac46dbff4e606556a0ae124d /samplecode | |
parent | a2b2c4ba5351b8cee0f03b5a9eeeb430862bbc7d (diff) |
add 'r' (rotate) 's' (scale) options to SampleApp to test those matrix ops on
all slides
add beforeChild/afterChild methods for parents to wack the canvas before/after
it draws. These are called after the std child-view translate and clip, unlike
beforeChildren/afterChildren
git-svn-id: http://skia.googlecode.com/svn/trunk@324 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 635fde1dc0..263b898639 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -134,7 +134,9 @@ protected: virtual SkCanvas* beforeChildren(SkCanvas*); virtual void afterChildren(SkCanvas*); - + virtual void beforeChild(SkView* child, SkCanvas* canvas); + virtual void afterChild(SkView* child, SkCanvas* canvas); + virtual bool onEvent(const SkEvent& evt); #if 0 @@ -164,6 +166,8 @@ private: bool fUseClip; bool fRepeatDrawing; bool fAnimating; + bool fRotate; + bool fScale; int fScrollTestX, fScrollTestY; @@ -205,6 +209,8 @@ SampleWindow::SampleWindow(void* hwnd) : INHERITED(hwnd) { fUseClip = false; fRepeatDrawing = false; fAnimating = false; + fRotate = false; + fScale = false; fScrollTestX = fScrollTestY = 0; @@ -344,6 +350,27 @@ void SampleWindow::afterChildren(SkCanvas* orig) { } } +void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) { + if (fScale) { + SkScalar scale = SK_Scalar1 * 7 / 10; + SkScalar cx = this->width() / 2; + SkScalar cy = this->height() / 2; + canvas->translate(cx, cy); + canvas->scale(scale, scale); + canvas->translate(-cx, -cy); + } + if (fRotate) { + SkScalar cx = this->width() / 2; + SkScalar cy = this->height() / 2; + canvas->translate(cx, cy); + canvas->rotate(SkIntToScalar(30)); + canvas->translate(-cx, -cy); + } +} + +void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) { +} + static SkBitmap::Config gConfigCycle[] = { SkBitmap::kNo_Config, // none -> none SkBitmap::kNo_Config, // a1 -> none @@ -443,6 +470,16 @@ bool SampleWindow::onHandleChar(SkUnichar uni) { } return true; } + case 'r': + fRotate = !fRotate; + this->inval(NULL); + this->updateTitle(); + return true; + case 's': + fScale = !fScale; + this->inval(NULL); + this->updateTitle(); + return true; default: break; } @@ -545,7 +582,13 @@ void SampleWindow::updateTitle() { if (fAnimating) { title.prepend("<A> "); } - + if (fScale) { + title.prepend("<S> "); + } + if (fRotate) { + title.prepend("<R> "); + } + this->setTitle(title.c_str()); } |