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

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

Issue 2050613003: Support resize in Android Viewer App (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Nits 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 /* 2 /*
3 * Copyright 2016 Google Inc. 3 * Copyright 2016 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include <GLES/gl.h> 9 #include <GLES/gl.h>
10 10
(...skipping 25 matching lines...) Expand all
36 // any config code here (particularly for msaa)? 36 // any config code here (particularly for msaa)?
37 37
38 this->initializeContext(platformData, params); 38 this->initializeContext(platformData, params);
39 } 39 }
40 40
41 GLWindowContext_android::~GLWindowContext_android() { 41 GLWindowContext_android::~GLWindowContext_android() {
42 this->destroyContext(); 42 this->destroyContext();
43 } 43 }
44 44
45 void GLWindowContext_android::onInitializeContext(void* platformData, const Disp layParams& params) { 45 void GLWindowContext_android::onInitializeContext(void* platformData, const Disp layParams& params) {
46 ContextPlatformData_android* androidPlatformData = 46 if (platformData != nullptr) {
47 reinterpret_cast<ContextPlatformData_android*>(platformData); 47 ContextPlatformData_android* androidPlatformData =
48 reinterpret_cast<ContextPlatformData_android*>(platformData);
49 fNativeWindow = androidPlatformData->fNativeWindow;
50 } else {
51 SkASSERT(fNativeWindow);
52 }
48 53
49 fWidth = ANativeWindow_getWidth(androidPlatformData->fNativeWindow); 54
50 fHeight = ANativeWindow_getHeight(androidPlatformData->fNativeWindow); 55 fWidth = ANativeWindow_getWidth(fNativeWindow);
56 fHeight = ANativeWindow_getHeight(fNativeWindow);
51 57
52 fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); 58 fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
53 59
54 EGLint majorVersion; 60 EGLint majorVersion;
55 EGLint minorVersion; 61 EGLint minorVersion;
56 eglInitialize(fDisplay, &majorVersion, &minorVersion); 62 eglInitialize(fDisplay, &majorVersion, &minorVersion);
57 63
58 SkAssertResult(eglBindAPI(EGL_OPENGL_ES_API)); 64 SkAssertResult(eglBindAPI(EGL_OPENGL_ES_API));
59 65
60 EGLint numConfigs = 0; 66 EGLint numConfigs = 0;
(...skipping 13 matching lines...) Expand all
74 80
75 static const EGLint kEGLContextAttribsForOpenGLES[] = { 81 static const EGLint kEGLContextAttribsForOpenGLES[] = {
76 EGL_CONTEXT_CLIENT_VERSION, 2, 82 EGL_CONTEXT_CLIENT_VERSION, 2,
77 EGL_NONE 83 EGL_NONE
78 }; 84 };
79 fEGLContext = eglCreateContext( 85 fEGLContext = eglCreateContext(
80 fDisplay, surfaceConfig, nullptr, kEGLContextAttribsForOpenGLES); 86 fDisplay, surfaceConfig, nullptr, kEGLContextAttribsForOpenGLES);
81 SkASSERT(EGL_NO_CONTEXT != fEGLContext); 87 SkASSERT(EGL_NO_CONTEXT != fEGLContext);
82 88
83 fSurface = eglCreateWindowSurface( 89 fSurface = eglCreateWindowSurface(
84 fDisplay, surfaceConfig, androidPlatformData->fNativeWindow, nullptr ); 90 fDisplay, surfaceConfig, fNativeWindow, nullptr);
85 SkASSERT(EGL_NO_SURFACE != fSurface); 91 SkASSERT(EGL_NO_SURFACE != fSurface);
86 92
87 SkAssertResult(eglMakeCurrent(fDisplay, fSurface, fSurface, fEGLContext)); 93 SkAssertResult(eglMakeCurrent(fDisplay, fSurface, fSurface, fEGLContext));
88 // GLWindowContext::initializeContext will call GrGLCreateNativeInterface so we 94 // GLWindowContext::initializeContext will call GrGLCreateNativeInterface so we
89 // won't call it here. 95 // won't call it here.
90 96
91 glClearStencil(0); 97 glClearStencil(0);
92 glClearColor(0, 0, 0, 0); 98 glClearColor(0, 0, 0, 0);
93 glStencilMask(0xffffffff); 99 glStencilMask(0xffffffff);
94 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 100 glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
(...skipping 18 matching lines...) Expand all
113 fSurface = EGL_NO_SURFACE; 119 fSurface = EGL_NO_SURFACE;
114 } 120 }
115 121
116 void GLWindowContext_android::onSwapBuffers() { 122 void GLWindowContext_android::onSwapBuffers() {
117 if (fDisplay && fEGLContext && fSurface) { 123 if (fDisplay && fEGLContext && fSurface) {
118 eglSwapBuffers(fDisplay, fSurface); 124 eglSwapBuffers(fDisplay, fSurface);
119 } 125 }
120 } 126 }
121 127
122 } 128 }
OLDNEW
« no previous file with comments | « tools/viewer/sk_app/android/GLWindowContext_android.h ('k') | tools/viewer/sk_app/android/RasterWindowContext_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698