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

Side by Side Diff: tools/viewer/sk_app/android/Window_android.cpp

Issue 2041193004: Implement Raster Backend on Android Viewer App (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merge 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
« no previous file with comments | « tools/viewer/sk_app/android/Window_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "../GLWindowContext.h" 9 #include "../GLWindowContext.h"
10 #include "../VulkanWindowContext.h" 10 #include "../VulkanWindowContext.h"
11 #include "../RasterWindowContext.h"
11 12
12 namespace sk_app { 13 namespace sk_app {
13 14
14 Window* Window::CreateNativeWindow(void* platformData) { 15 Window* Window::CreateNativeWindow(void* platformData) {
15 Window_android* window = new Window_android(); 16 Window_android* window = new Window_android();
16 if (!window->init((SkiaAndroidApp*)platformData)) { 17 if (!window->init((SkiaAndroidApp*)platformData)) {
17 delete window; 18 delete window;
18 return nullptr; 19 return nullptr;
19 } 20 }
20 return window; 21 return window;
(...skipping 21 matching lines...) Expand all
42 } 43 }
43 44
44 void Window_android::setUIState(const Json::Value& state) { 45 void Window_android::setUIState(const Json::Value& state) {
45 fSkiaAndroidApp->setUIState(state); 46 fSkiaAndroidApp->setUIState(state);
46 } 47 }
47 48
48 bool Window_android::attach(BackendType attachType, const DisplayParams& params) { 49 bool Window_android::attach(BackendType attachType, const DisplayParams& params) {
49 fBackendType = attachType; 50 fBackendType = attachType;
50 fDisplayParams = params; 51 fDisplayParams = params;
51 52
52 if (fNativeWindow) { 53 // We delay the creation of fWindowContext until Android informs us that
53 this->initDisplay(fNativeWindow);
54 }
55 // If fNativeWindow is not set,
56 // we delay the creation of fWindowContext until Android informs us that
57 // the native window is ready to use. 54 // the native window is ready to use.
58 // The creation will be done in initDisplay, which is initiated by kSurfaceC reated event. 55 // The creation will be done in initDisplay, which is initiated by kSurfaceC reated event.
59 return true; 56 return true;
60 } 57 }
61 58
62 void Window_android::initDisplay(ANativeWindow* window) { 59 void Window_android::initDisplay(ANativeWindow* window) {
63 SkASSERT(window); 60 SkASSERT(window);
64 fNativeWindow = window;
65 ContextPlatformData_android platformData; 61 ContextPlatformData_android platformData;
66 platformData.fNativeWindow = window; 62 platformData.fNativeWindow = window;
67 switch (fBackendType) { 63 switch (fBackendType) {
68 case kNativeGL_BackendType: 64 case kNativeGL_BackendType:
69 fWindowContext = GLWindowContext::Create((void*)&platformData, fDisp layParams); 65 fWindowContext = GLWindowContext::Create((void*)&platformData, fDisp layParams);
70 break; 66 break;
71 67 case kRaster_BackendType:
68 fWindowContext = RasterWindowContext::Create((void*)&platformData, f DisplayParams);
69 break;
72 case kVulkan_BackendType: 70 case kVulkan_BackendType:
73 default: 71 default:
74 fWindowContext = VulkanWindowContext::Create((void*)&platformData, f DisplayParams); 72 fWindowContext = VulkanWindowContext::Create((void*)&platformData, f DisplayParams);
75 break; 73 break;
76 } 74 }
77 } 75 }
78 76
79 void Window_android::onDisplayDestroyed() { 77 void Window_android::onDisplayDestroyed() {
80 detach(); 78 detach();
81 fNativeWindow = nullptr;
82 } 79 }
83 80
84 void Window_android::onInval() { 81 void Window_android::onInval() {
85 fSkiaAndroidApp->postMessage(Message(kContentInvalidated)); 82 fSkiaAndroidApp->postMessage(Message(kContentInvalidated));
86 } 83 }
87 84
88 void Window_android::paintIfNeeded() { 85 void Window_android::paintIfNeeded() {
89 if (fWindowContext) { // Check if initDisplay has already been called 86 if (fWindowContext) { // Check if initDisplay has already been called
90 onPaint(); 87 onPaint();
91 } else { 88 } else {
92 markInvalProcessed(); 89 markInvalProcessed();
93 } 90 }
94 } 91 }
95 92
96 } // namespace sk_app 93 } // namespace sk_app
OLDNEW
« no previous file with comments | « 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