add 'p' to toggle on/off testing the pipe

git-svn-id: http://skia.googlecode.com/svn/trunk@1317 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-05-12 22:08:24 +00:00
parent 12ad3aa49b
commit a6ff4dc22d
3 changed files with 24 additions and 7 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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
}