1 /* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "SampleSlide.h" 9 10 #include "SkCanvas.h" 11 #include "SkCommonFlags.h" 12 #include "SkOSFile.h" 13 #include "SkStream.h" 14 SampleSlide(const SkViewFactory * factory)15SampleSlide::SampleSlide(const SkViewFactory* factory) : fViewFactory(factory) { 16 SkView* view = (*factory)(); 17 SampleCode::RequestTitle(view, &fName); 18 view->unref(); 19 } 20 ~SampleSlide()21SampleSlide::~SampleSlide() {} 22 draw(SkCanvas * canvas)23void SampleSlide::draw(SkCanvas* canvas) { 24 SkASSERT(fView); 25 fView->draw(canvas); 26 } 27 load(SkScalar winWidth,SkScalar winHeight)28void SampleSlide::load(SkScalar winWidth, SkScalar winHeight) { 29 fView.reset((*fViewFactory)()); 30 fView->setVisibleP(true); 31 fView->setClipToBounds(false); 32 fView->setSize(winWidth, winHeight); 33 } 34 unload()35void SampleSlide::unload() { 36 fView.reset(); 37 } 38 onChar(SkUnichar c)39bool SampleSlide::onChar(SkUnichar c) { 40 if (!fView) { 41 return false; 42 } 43 SkEvent evt(gCharEvtName); 44 evt.setFast32(c); 45 return fView->doQuery(&evt); 46 } 47 48 #if defined(SK_BUILD_FOR_ANDROID) 49 // these are normally defined in SkOSWindow_unix, but we don't 50 // want to include that SignalNonEmptyQueue()51void SkEvent::SignalNonEmptyQueue() {} 52 SignalQueueTimer(SkMSec delay)53void SkEvent::SignalQueueTimer(SkMSec delay) {} 54 #endif 55