diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-05-12 22:08:24 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-05-12 22:08:24 +0000 |
commit | a6ff4dc22d5006dc588769aa20c8b0bb4fde6d43 (patch) | |
tree | 94b611f0c3c182b582c567bee346daac4acb1c1c /samplecode | |
parent | 12ad3aa49b8fae2a09a668414b0b908baf47c846 (diff) |
add 'p' to toggle on/off testing the pipe
git-svn-id: http://skia.googlecode.com/svn/trunk@1317 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 16 | ||||
-rw-r--r-- | samplecode/SampleCode.h | 1 | ||||
-rw-r--r-- | samplecode/SampleFilter.cpp | 14 |
3 files changed, 24 insertions, 7 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index bbde4144ed..9b35be81b9 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -1039,6 +1039,7 @@ bool SampleWindow::onHandleChar(SkUnichar uni) { break; case 'p': fUsePipe = !fUsePipe; + this->updateTitle(); this->inval(NULL); break; case 'r': @@ -1283,6 +1284,12 @@ void SampleWindow::updateTitle() { if (fMeasureFPS) { title.appendf(" %4d ms", fMeasureFPS_Time); } + if (fUsePipe && SampleView::IsSampleView(view)) { + title.prepend("<P> "); + } + if (SampleView::IsSampleView(view)) { + title.prepend("! "); + } this->setTitle(title.c_str()); } @@ -1321,9 +1328,15 @@ void SampleWindow::onSizeChange() { /////////////////////////////////////////////////////////////////////////////// +static const char is_sample_view_tag[] = "sample-is-sample-view"; static const char repeat_count_tag[] = "sample-set-repeat-count"; static const char set_use_pipe_tag[] = "sample-set-use-pipe"; +bool SampleView::IsSampleView(SkView* view) { + SkEvent evt(is_sample_view_tag); + return view->doQuery(&evt); +} + bool SampleView::SetRepeatDraw(SkView* view, int count) { SkEvent evt(repeat_count_tag); evt.setFast32(count); @@ -1349,6 +1362,9 @@ bool SampleView::onEvent(const SkEvent& evt) { } bool SampleView::onQuery(SkEvent* evt) { + if (evt->isType(is_sample_view_tag)) { + return true; + } return this->INHERITED::onQuery(evt); } diff --git a/samplecode/SampleCode.h b/samplecode/SampleCode.h index de40d1e025..c42ee25801 100644 --- a/samplecode/SampleCode.h +++ b/samplecode/SampleCode.h @@ -55,6 +55,7 @@ public: void setBGColor(SkColor color) { fBGColor = color; } + static bool IsSampleView(SkView*); static bool SetRepeatDraw(SkView*, int count); static bool SetUsePipe(SkView*, bool); diff --git a/samplecode/SampleFilter.cpp b/samplecode/SampleFilter.cpp index 244fe511fd..a9089fa344 100644 --- a/samplecode/SampleFilter.cpp +++ b/samplecode/SampleFilter.cpp @@ -36,17 +36,17 @@ static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm, canvas->drawBitmap(bm, x, y, paint); return SkIntToScalar(bm.width()) * 5/4; #else - SkRect r; - - r.set(x, y, - x + SkIntToScalar(bm.width() * 2), - y + SkIntToScalar(bm.height() * 2)); + SkAutoCanvasRestore acr(canvas, true); + canvas->translate(x, y); + + SkScalar w = SkIntToScalar(bm.width()); + SkScalar h = SkIntToScalar(bm.height()); SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); paint->setShader(s)->unref(); - canvas->drawRect(r, *paint); + canvas->drawRect(SkRect::MakeWH(w, h), *paint); paint->setShader(NULL); - return r.width() * 5/4; + return w * 5/4; #endif } |