af236b5aa9
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1978573003 Committed: https://skia.googlesource.com/skia/+/56a11e4d6f3d436a3c2497c9c9e71a117d78a93f Review-Url: https://codereview.chromium.org/1978573003
72 lines
1.7 KiB
C++
72 lines
1.7 KiB
C++
/*
|
|
* 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 "Window_android.h"
|
|
|
|
#include "VulkanWindowContext_android.h"
|
|
|
|
namespace sk_app {
|
|
|
|
Window* Window::CreateNativeWindow(void* platformData) {
|
|
Window_android* window = new Window_android();
|
|
if (!window->init((SkiaAndroidApp*)platformData)) {
|
|
delete window;
|
|
return nullptr;
|
|
}
|
|
return window;
|
|
}
|
|
|
|
bool Window_android::init(SkiaAndroidApp* skiaAndroidApp) {
|
|
SkASSERT(skiaAndroidApp);
|
|
fSkiaAndroidApp = skiaAndroidApp;
|
|
fSkiaAndroidApp->fWindow = this;
|
|
return true;
|
|
}
|
|
|
|
const DisplayParams& Window_android::getDisplayParams() {
|
|
if (fWindowContext) {
|
|
return fWindowContext->getDisplayParams();
|
|
} else {
|
|
// fWindowContext doesn't exist because we haven't
|
|
// initDisplay yet.
|
|
return fDisplayParams;
|
|
}
|
|
}
|
|
|
|
void Window_android::setTitle(const char* title) {
|
|
fSkiaAndroidApp->setTitle(title);
|
|
}
|
|
|
|
bool Window_android::attach(BackendType attachType, const DisplayParams& params) {
|
|
if (kVulkan_BackendType != attachType) {
|
|
return false;
|
|
}
|
|
|
|
fDisplayParams = params;
|
|
|
|
// We delay the creation of fTestContext until Android informs us that
|
|
// the native window is ready to use.
|
|
return true;
|
|
}
|
|
|
|
void Window_android::initDisplay(ANativeWindow* window) {
|
|
SkASSERT(window);
|
|
ContextPlatformData_android platformData;
|
|
platformData.fNativeWindow = window;
|
|
fWindowContext = VulkanWindowContext::Create((void*)&platformData, fDisplayParams);
|
|
}
|
|
|
|
void Window_android::onDisplayDestroyed() {
|
|
detach();
|
|
}
|
|
|
|
void Window_android::inval() {
|
|
fSkiaAndroidApp->inval();
|
|
}
|
|
|
|
} // namespace sk_app
|