virtual bool onEvent(const SkEvent& evt) { if (evt.isType(gReplaceTransitionEvt)) { SkView* prev = fPrev; prev->ref(); fPrev->detachFromParent(); fPrev = (SkView*)SkEventSink::FindSink(evt.getFast32()); (void)SampleView::SetUsePipe(fPrev, SkOSMenu::kOffState); //attach the new fPrev and call unref to balance the ref in onDraw this->attachChildToBack(fPrev)->unref(); this->inval(NULL); SkASSERT(1 == prev->getRefCnt()); prev->unref(); return true; } if (evt.isType("transition-done")) { fNext->setLoc(0, 0); fNext->setClipToBounds(false); SkEvent* evt = new SkEvent(gReplaceTransitionEvt, this->getParent()->getSinkID()); evt->setFast32(fNext->getSinkID()); //increate ref count of fNext so it survives detachAllChildren fNext->ref(); this->detachAllChildren(); evt->post(); return true; } return this->INHERITED::onEvent(evt); }
const char* State::getSlideTitle(int index) const { SkEvent evt(gTitleEvtName); evt.setFast32(index); { SkView* view = fFactory[index](); view->doQuery(&evt); view->unref(); } return evt.findString(gTitleEvtName); }