skia2/tools/viewer/sk_app/android/Window_android.cpp
jvanverth 2884e9c0bd Revert of Add OpenGL context to Viewer. (patchset #7 id:120001 of https://codereview.chromium.org/1978573003/ )
Reason for revert:
sk_app/WindowContext.cpp is missing. Need to add file and resubmit.

Original issue's description:
> Add OpenGL context to Viewer.
>
> 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

TBR=brianosman@google.com,bsalomon@google.com,djsollen@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review-Url: https://codereview.chromium.org/1990893002
2016-05-18 07:01:16 -07:00

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