2016-06-16 16:52:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SampleSlide.h"
|
|
|
|
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkCommonFlags.h"
|
|
|
|
#include "SkOSFile.h"
|
|
|
|
#include "SkStream.h"
|
|
|
|
|
|
|
|
SampleSlide::SampleSlide(const SkViewFactory* factory) : fViewFactory(factory) {
|
|
|
|
SkView* view = (*factory)();
|
|
|
|
SampleCode::RequestTitle(view, &fName);
|
|
|
|
view->unref();
|
|
|
|
}
|
|
|
|
|
|
|
|
SampleSlide::~SampleSlide() {}
|
|
|
|
|
|
|
|
void SampleSlide::draw(SkCanvas* canvas) {
|
2017-02-24 20:22:53 +00:00
|
|
|
SkASSERT(fView);
|
2016-06-16 16:52:35 +00:00
|
|
|
fView->draw(canvas);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SampleSlide::load(SkScalar winWidth, SkScalar winHeight) {
|
2017-02-24 20:22:53 +00:00
|
|
|
fView.reset((*fViewFactory)());
|
2016-06-16 16:52:35 +00:00
|
|
|
fView->setVisibleP(true);
|
|
|
|
fView->setClipToBounds(false);
|
|
|
|
fView->setSize(winWidth, winHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SampleSlide::unload() {
|
2017-02-24 20:22:53 +00:00
|
|
|
fView.reset();
|
2016-06-16 16:52:35 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 20:16:46 +00:00
|
|
|
bool SampleSlide::onChar(SkUnichar c) {
|
2017-02-24 20:22:53 +00:00
|
|
|
if (!fView) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-02-14 20:16:46 +00:00
|
|
|
SkEvent evt(gCharEvtName);
|
|
|
|
evt.setFast32(c);
|
|
|
|
return fView->doQuery(&evt);
|
|
|
|
}
|
|
|
|
|
2016-06-16 16:52:35 +00:00
|
|
|
#if defined(SK_BUILD_FOR_ANDROID)
|
|
|
|
// these are normally defined in SkOSWindow_unix, but we don't
|
|
|
|
// want to include that
|
|
|
|
void SkEvent::SignalNonEmptyQueue() {}
|
|
|
|
|
|
|
|
void SkEvent::SignalQueueTimer(SkMSec delay) {}
|
|
|
|
#endif
|