c0bd9f9fe5
Current strategy: everything from the top Things to look at first are the manual changes: - added tools/rewrite_includes.py - removed -Idirectives from BUILD.gn - various compile.sh simplifications - tweak tools/embed_resources.py - update gn/find_headers.py to write paths from the top - update gn/gn_to_bp.py SkUserConfig.h layout so that #include "include/config/SkUserConfig.h" always gets the header we want. No-Presubmit: true Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
86 lines
2.4 KiB
C++
86 lines
2.4 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 "tools/sk_app/WindowContext.h"
|
|
#include "tools/sk_app/android/WindowContextFactory_android.h"
|
|
#include "tools/sk_app/android/Window_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;
|
|
}
|
|
|
|
void Window_android::setTitle(const char* title) {
|
|
fSkiaAndroidApp->setTitle(title);
|
|
}
|
|
|
|
void Window_android::setUIState(const char* state) {
|
|
fSkiaAndroidApp->setUIState(state);
|
|
}
|
|
|
|
bool Window_android::attach(BackendType attachType) {
|
|
fBackendType = attachType;
|
|
|
|
// We delay the creation of fWindowContext until Android informs us that
|
|
// the native window is ready to use.
|
|
// The creation will be done in initDisplay, which is initiated by kSurfaceCreated event.
|
|
return true;
|
|
}
|
|
|
|
void Window_android::initDisplay(ANativeWindow* window) {
|
|
SkASSERT(window);
|
|
switch (fBackendType) {
|
|
case kNativeGL_BackendType:
|
|
default:
|
|
fWindowContext = window_context_factory::NewGLForAndroid(window,
|
|
fRequestedDisplayParams);
|
|
break;
|
|
case kRaster_BackendType:
|
|
fWindowContext = window_context_factory::NewRasterForAndroid(window,
|
|
fRequestedDisplayParams);
|
|
break;
|
|
#ifdef SK_VULKAN
|
|
case kVulkan_BackendType:
|
|
fWindowContext = window_context_factory::NewVulkanForAndroid(window,
|
|
fRequestedDisplayParams);
|
|
break;
|
|
#endif
|
|
}
|
|
this->onBackendCreated();
|
|
}
|
|
|
|
void Window_android::onDisplayDestroyed() {
|
|
detach();
|
|
}
|
|
|
|
void Window_android::onInval() {
|
|
fSkiaAndroidApp->postMessage(Message(kContentInvalidated));
|
|
}
|
|
|
|
void Window_android::paintIfNeeded() {
|
|
if (fWindowContext) { // Check if initDisplay has already been called
|
|
onPaint();
|
|
} else {
|
|
markInvalProcessed();
|
|
}
|
|
}
|
|
|
|
} // namespace sk_app
|