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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Window_android.h" 8 #include "Window_android.h"
9 9 #include "../GLWindowContext.h"
10 #include "VulkanWindowContext_android.h" 10 #include "../VulkanWindowContext.h"
11 11
12 namespace sk_app { 12 namespace sk_app {
13 13
14 Window* Window::CreateNativeWindow(void* platformData) { 14 Window* Window::CreateNativeWindow(void* platformData) {
15 Window_android* window = new Window_android(); 15 Window_android* window = new Window_android();
16 if (!window->init((SkiaAndroidApp*)platformData)) { 16 if (!window->init((SkiaAndroidApp*)platformData)) {
17 delete window; 17 delete window;
18 return nullptr; 18 return nullptr;
19 } 19 }
20 return window; 20 return window;
(...skipping 18 matching lines...) Expand all
39 39
40 void Window_android::setTitle(const char* title) { 40 void Window_android::setTitle(const char* title) {
41 fSkiaAndroidApp->setTitle(title); 41 fSkiaAndroidApp->setTitle(title);
42 } 42 }
43 43
44 void Window_android::setUIState(const Json::Value& state) { 44 void Window_android::setUIState(const Json::Value& state) {
45 fSkiaAndroidApp->setUIState(state); 45 fSkiaAndroidApp->setUIState(state);
46 } 46 }
47 47
48 bool Window_android::attach(BackendType attachType, const DisplayParams& params) { 48 bool Window_android::attach(BackendType attachType, const DisplayParams& params) {
49 if (kVulkan_BackendType != attachType) { 49 fBackendType = attachType;
50 return false;
51 }
52
53 fDisplayParams = params; 50 fDisplayParams = params;
54 51
55 // We delay the creation of fTestContext until Android informs us that 52 if (fNativeWindow) {
53 this->initDisplay(fNativeWindow);
54 }
55 // If fNativeWindow is not set,
56 // we delay the creation of fWindowContext until Android informs us that
56 // the native window is ready to use. 57 // the native window is ready to use.
58 // The creation will be done in initDisplay, which is initiated by kSurfaceC reated event.
57 return true; 59 return true;
58 } 60 }
59 61
60 void Window_android::initDisplay(ANativeWindow* window) { 62 void Window_android::initDisplay(ANativeWindow* window) {
61 SkASSERT(window); 63 SkASSERT(window);
64 fNativeWindow = window;
62 ContextPlatformData_android platformData; 65 ContextPlatformData_android platformData;
63 platformData.fNativeWindow = window; 66 platformData.fNativeWindow = window;
64 fWindowContext = VulkanWindowContext::Create((void*)&platformData, fDisplayP arams); 67 switch (fBackendType) {
68 case kNativeGL_BackendType:
69 fWindowContext = GLWindowContext::Create((void*)&platformData, fDisp layParams);
70 break;
71
72 case kVulkan_BackendType:
73 default:
74 fWindowContext = VulkanWindowContext::Create((void*)&platformData, f DisplayParams);
75 break;
76 }
65 } 77 }
66 78
67 void Window_android::onDisplayDestroyed() { 79 void Window_android::onDisplayDestroyed() {
68 detach(); 80 detach();
81 fNativeWindow = nullptr;
69 } 82 }
70 83
71 void Window_android::onInval() { 84 void Window_android::onInval() {
72 fSkiaAndroidApp->postMessage(Message(kContentInvalidated)); 85 fSkiaAndroidApp->postMessage(Message(kContentInvalidated));
73 } 86 }
74 87
75 void Window_android::paintIfNeeded() { 88 void Window_android::paintIfNeeded() {
76 if (fWindowContext) { // Check if initDisplay has already been called 89 if (fWindowContext) { // Check if initDisplay has already been called
77 onPaint(); 90 onPaint();
78 } else { 91 } else {
79 markInvalProcessed(); 92 markInvalProcessed();
80 } 93 }
81 } 94 }
82 95
83 } // namespace sk_app 96 } // namespace sk_app
OLDNEW
« 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