jvanverth | c7027ab | 2016-06-16 09:52:35 -0700 | [diff] [blame] | 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 | |
| 15 | SampleSlide::SampleSlide(const SkViewFactory* factory) : fViewFactory(factory) { |
| 16 | SkView* view = (*factory)(); |
| 17 | SampleCode::RequestTitle(view, &fName); |
| 18 | view->unref(); |
| 19 | } |
| 20 | |
| 21 | SampleSlide::~SampleSlide() {} |
| 22 | |
| 23 | void SampleSlide::draw(SkCanvas* canvas) { |
Christopher Dalton | 443ec1b | 2017-02-24 13:22:53 -0700 | [diff] [blame] | 24 | SkASSERT(fView); |
jvanverth | c7027ab | 2016-06-16 09:52:35 -0700 | [diff] [blame] | 25 | fView->draw(canvas); |
| 26 | } |
| 27 | |
| 28 | void SampleSlide::load(SkScalar winWidth, SkScalar winHeight) { |
Christopher Dalton | 443ec1b | 2017-02-24 13:22:53 -0700 | [diff] [blame] | 29 | fView.reset((*fViewFactory)()); |
jvanverth | c7027ab | 2016-06-16 09:52:35 -0700 | [diff] [blame] | 30 | fView->setVisibleP(true); |
| 31 | fView->setClipToBounds(false); |
| 32 | fView->setSize(winWidth, winHeight); |
| 33 | } |
| 34 | |
| 35 | void SampleSlide::unload() { |
Christopher Dalton | 443ec1b | 2017-02-24 13:22:53 -0700 | [diff] [blame] | 36 | fView.reset(); |
jvanverth | c7027ab | 2016-06-16 09:52:35 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Jim Van Verth | 6f44969 | 2017-02-14 15:16:46 -0500 | [diff] [blame] | 39 | bool SampleSlide::onChar(SkUnichar c) { |
Christopher Dalton | 443ec1b | 2017-02-24 13:22:53 -0700 | [diff] [blame] | 40 | if (!fView) { |
| 41 | return false; |
| 42 | } |
Jim Van Verth | 6f44969 | 2017-02-14 15:16:46 -0500 | [diff] [blame] | 43 | SkEvent evt(gCharEvtName); |
| 44 | evt.setFast32(c); |
| 45 | return fView->doQuery(&evt); |
| 46 | } |
| 47 | |
jvanverth | c7027ab | 2016-06-16 09:52:35 -0700 | [diff] [blame] | 48 | #if defined(SK_BUILD_FOR_ANDROID) |
| 49 | // these are normally defined in SkOSWindow_unix, but we don't |
| 50 | // want to include that |
| 51 | void SkEvent::SignalNonEmptyQueue() {} |
| 52 | |
| 53 | void SkEvent::SignalQueueTimer(SkMSec delay) {} |
| 54 | #endif |