Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: tools/viewer/sk_app/android/Window_android.cpp

Issue 2032623002: Implement OpenGL backend in Android viewer app (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tools/viewer/Viewer.cpp ('K') | « tools/viewer/sk_app/android/Window_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/sk_app/android/Window_android.cpp
diff --git a/tools/viewer/sk_app/android/Window_android.cpp b/tools/viewer/sk_app/android/Window_android.cpp
index 4f33870c1ae225e122215e579b0295d0fa4493ec..926c7cd17d09433b3c600ba2077242dc8e076c15 100644
--- a/tools/viewer/sk_app/android/Window_android.cpp
+++ b/tools/viewer/sk_app/android/Window_android.cpp
@@ -6,8 +6,8 @@
*/
#include "Window_android.h"
-
-#include "VulkanWindowContext_android.h"
+#include "../GLWindowContext.h"
+#include "../VulkanWindowContext.h"
namespace sk_app {
@@ -46,26 +46,39 @@ void Window_android::setUIState(const Json::Value& state) {
}
bool Window_android::attach(BackendType attachType, const DisplayParams& params) {
- if (kVulkan_BackendType != attachType) {
- return false;
- }
-
+ fBackendType = attachType;
fDisplayParams = params;
- // We delay the creation of fTestContext until Android informs us that
+ if (fNativeWindow) {
+ this->initDisplay(fNativeWindow);
+ }
+ // If fNativeWindow is not set,
+ // 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);
+ fNativeWindow = window;
ContextPlatformData_android platformData;
platformData.fNativeWindow = window;
- fWindowContext = VulkanWindowContext::Create((void*)&platformData, fDisplayParams);
+ switch (fBackendType) {
+ case kNativeGL_BackendType:
+ fWindowContext = GLWindowContext::Create((void*)&platformData, fDisplayParams);
+ break;
+
+ case kVulkan_BackendType:
+ default:
+ fWindowContext = VulkanWindowContext::Create((void*)&platformData, fDisplayParams);
+ break;
+ }
}
void Window_android::onDisplayDestroyed() {
detach();
+ fNativeWindow = nullptr;
}
void Window_android::onInval() {
« tools/viewer/Viewer.cpp ('K') | « tools/viewer/sk_app/android/Window_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698