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

Side by Side Diff: platform_tools/android/apps/visualbench/src/main/jni/SkOSWindow_AndroidNative.cpp

Issue 1416123003: Fix visualbench exiting on startup on android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkOSWindow_Android.h" 8 #include "SkOSWindow_Android.h"
9 9
10 #include <GLES/gl.h> 10 #include <GLES/gl.h>
11 11
12 SkOSWindow::SkOSWindow(void* hwnd) { 12 SkOSWindow::SkOSWindow(void* hwnd) {
13 fWindow.fDisplay = EGL_NO_DISPLAY; 13 fWindow.fDisplay = EGL_NO_DISPLAY;
14 fWindow.fContext = EGL_NO_CONTEXT; 14 fWindow.fContext = EGL_NO_CONTEXT;
15 fWindow.fSurface = EGL_NO_SURFACE; 15 fWindow.fSurface = EGL_NO_SURFACE;
16 fNativeWindow = (ANativeWindow*)hwnd; 16 fNativeWindow = (ANativeWindow*)hwnd;
17 fDestroyRequested = false; 17 fDestroyRequested = false;
18 } 18 }
19 19
20 SkOSWindow::~SkOSWindow() { 20 SkOSWindow::~SkOSWindow() {
21 if (fWindow.fDisplay != EGL_NO_DISPLAY) { 21 this->detach();
22 eglMakeCurrent(fWindow.fDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_ CONTEXT);
23 if (fWindow.fContext != EGL_NO_CONTEXT) {
24 eglDestroyContext(fWindow.fDisplay, fWindow.fContext);
25 }
26 if (fWindow.fSurface != EGL_NO_SURFACE) {
27 eglDestroySurface(fWindow.fDisplay, fWindow.fSurface);
28 }
29 eglTerminate(fWindow.fDisplay);
30 }
31 fWindow.fDisplay = EGL_NO_DISPLAY;
32 fWindow.fContext = EGL_NO_CONTEXT;
33 fWindow.fSurface = EGL_NO_SURFACE;
34 } 22 }
35 23
36 bool SkOSWindow::attach(SkBackEndTypes attachType, 24 bool SkOSWindow::attach(SkBackEndTypes attachType,
37 int /*msaaSampleCount*/, 25 int /*msaaSampleCount*/,
38 AttachmentInfo* info) { 26 AttachmentInfo* info) {
39 static const EGLint kEGLContextAttribsForOpenGL[] = { 27 static const EGLint kEGLContextAttribsForOpenGL[] = {
40 EGL_NONE 28 EGL_NONE
41 }; 29 };
42 30
43 static const EGLint kEGLContextAttribsForOpenGLES[] = { 31 static const EGLint kEGLContextAttribsForOpenGLES[] = {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 128
141 // We retrieve the fullscreen width and height 129 // We retrieve the fullscreen width and height
142 this->setSize((SkScalar)w, (SkScalar)h); 130 this->setSize((SkScalar)w, (SkScalar)h);
143 return true; 131 return true;
144 } else { 132 } else {
145 return false; 133 return false;
146 } 134 }
147 } 135 }
148 136
149 void SkOSWindow::detach() { 137 void SkOSWindow::detach() {
150 fDestroyRequested = true; 138 if (fWindow.fDisplay != EGL_NO_DISPLAY) {
139 eglMakeCurrent(fWindow.fDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_ CONTEXT);
140 if (fWindow.fContext != EGL_NO_CONTEXT) {
141 eglDestroyContext(fWindow.fDisplay, fWindow.fContext);
142 }
143 if (fWindow.fSurface != EGL_NO_SURFACE) {
144 eglDestroySurface(fWindow.fDisplay, fWindow.fSurface);
145 }
146 eglTerminate(fWindow.fDisplay);
147 }
148 fWindow.fDisplay = EGL_NO_DISPLAY;
149 fWindow.fContext = EGL_NO_CONTEXT;
150 fWindow.fSurface = EGL_NO_SURFACE;
151 } 151 }
152 152
153 void SkOSWindow::present() { 153 void SkOSWindow::present() {
154 if (fWindow.fDisplay != EGL_NO_DISPLAY && fWindow.fContext != EGL_NO_CONTEXT ) { 154 if (fWindow.fDisplay != EGL_NO_DISPLAY && fWindow.fContext != EGL_NO_CONTEXT ) {
155 eglSwapBuffers(fWindow.fDisplay, fWindow.fSurface); 155 eglSwapBuffers(fWindow.fDisplay, fWindow.fSurface);
156 } 156 }
157 } 157 }
158 158
159 void SkOSWindow::closeWindow() { 159 void SkOSWindow::closeWindow() {
160 fDestroyRequested = true; 160 fDestroyRequested = true;
(...skipping 17 matching lines...) Expand all
178 178
179 /////////////////////////////////////////// 179 ///////////////////////////////////////////
180 /////////////// SkEvent impl ////////////// 180 /////////////// SkEvent impl //////////////
181 /////////////////////////////////////////// 181 ///////////////////////////////////////////
182 182
183 void SkEvent::SignalQueueTimer(SkMSec ms) { 183 void SkEvent::SignalQueueTimer(SkMSec ms) {
184 } 184 }
185 185
186 void SkEvent::SignalNonEmptyQueue() { 186 void SkEvent::SignalNonEmptyQueue() {
187 } 187 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698