blob: 93a495eb8c79e2bfbb9a974f768262d53085752b [file] [log] [blame]
jvanverthc7027ab2016-06-16 09:52:35 -07001/*
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
15SampleSlide::SampleSlide(const SkViewFactory* factory) : fViewFactory(factory) {
16 SkView* view = (*factory)();
17 SampleCode::RequestTitle(view, &fName);
18 view->unref();
19}
20
21SampleSlide::~SampleSlide() {}
22
23void SampleSlide::draw(SkCanvas* canvas) {
Christopher Dalton443ec1b2017-02-24 13:22:53 -070024 SkASSERT(fView);
jvanverthc7027ab2016-06-16 09:52:35 -070025 fView->draw(canvas);
26}
27
28void SampleSlide::load(SkScalar winWidth, SkScalar winHeight) {
Christopher Dalton443ec1b2017-02-24 13:22:53 -070029 fView.reset((*fViewFactory)());
jvanverthc7027ab2016-06-16 09:52:35 -070030 fView->setVisibleP(true);
31 fView->setClipToBounds(false);
32 fView->setSize(winWidth, winHeight);
33}
34
35void SampleSlide::unload() {
Christopher Dalton443ec1b2017-02-24 13:22:53 -070036 fView.reset();
jvanverthc7027ab2016-06-16 09:52:35 -070037}
38
Jim Van Verth6f449692017-02-14 15:16:46 -050039bool SampleSlide::onChar(SkUnichar c) {
Christopher Dalton443ec1b2017-02-24 13:22:53 -070040 if (!fView) {
41 return false;
42 }
Jim Van Verth6f449692017-02-14 15:16:46 -050043 SkEvent evt(gCharEvtName);
44 evt.setFast32(c);
45 return fView->doQuery(&evt);
46}
47
jvanverthc7027ab2016-06-16 09:52:35 -070048#if defined(SK_BUILD_FOR_ANDROID)
49// these are normally defined in SkOSWindow_unix, but we don't
50// want to include that
51void SkEvent::SignalNonEmptyQueue() {}
52
53void SkEvent::SignalQueueTimer(SkMSec delay) {}
54#endif