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

Side by Side Diff: src/gpu/gl/angle/SkANGLEGLContext.cpp

Issue 1194783003: Implement SkGLContext swapBuffers with fence syncs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows build Created 5 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 | « src/gpu/gl/SkNullGLContext.cpp ('k') | src/gpu/gl/debug/SkDebugGLContext.h » ('j') | 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 "gl/angle/SkANGLEGLContext.h" 9 #include "gl/angle/SkANGLEGLContext.h"
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 static const EGLint surfaceAttribs[] = { 89 static const EGLint surfaceAttribs[] = {
90 EGL_WIDTH, 1, 90 EGL_WIDTH, 1,
91 EGL_HEIGHT, 1, 91 EGL_HEIGHT, 1,
92 EGL_NONE 92 EGL_NONE
93 }; 93 };
94 94
95 fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs); 95 fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, surfaceAttribs);
96 96
97 eglMakeCurrent(fDisplay, fSurface, fSurface, fContext); 97 eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);
98 98
99 fGL.reset(GrGLCreateANGLEInterface()); 99 SkAutoTUnref<const GrGLInterface> gl(GrGLCreateANGLEInterface());
100 if (NULL == fGL.get()) { 100 if (NULL == gl.get()) {
101 SkDebugf("Could not create ANGLE GL interface!\n"); 101 SkDebugf("Could not create ANGLE GL interface!\n");
102 this->destroyGLContext(); 102 this->destroyGLContext();
103 return; 103 return;
104 } 104 }
105 if (!fGL->validate()) { 105 if (!gl->validate()) {
106 SkDebugf("Could not validate ANGLE GL interface!\n"); 106 SkDebugf("Could not validate ANGLE GL interface!\n");
107 this->destroyGLContext(); 107 this->destroyGLContext();
108 return; 108 return;
109 } 109 }
110
111 this->init(gl.detach());
110 } 112 }
111 113
112 SkANGLEGLContext::~SkANGLEGLContext() { 114 SkANGLEGLContext::~SkANGLEGLContext() {
115 this->teardown();
113 this->destroyGLContext(); 116 this->destroyGLContext();
114 } 117 }
115 118
116 void SkANGLEGLContext::destroyGLContext() { 119 void SkANGLEGLContext::destroyGLContext() {
117 fGL.reset(NULL);
118 if (fDisplay) { 120 if (fDisplay) {
119 eglMakeCurrent(fDisplay, 0, 0, 0); 121 eglMakeCurrent(fDisplay, 0, 0, 0);
120 122
121 if (fContext) { 123 if (fContext) {
122 eglDestroyContext(fDisplay, fContext); 124 eglDestroyContext(fDisplay, fContext);
123 fContext = EGL_NO_CONTEXT; 125 fContext = EGL_NO_CONTEXT;
124 } 126 }
125 127
126 if (fSurface) { 128 if (fSurface) {
127 eglDestroySurface(fDisplay, fSurface); 129 eglDestroySurface(fDisplay, fSurface);
128 fSurface = EGL_NO_SURFACE; 130 fSurface = EGL_NO_SURFACE;
129 } 131 }
130 132
131 //TODO should we close the display? 133 //TODO should we close the display?
132 fDisplay = EGL_NO_DISPLAY; 134 fDisplay = EGL_NO_DISPLAY;
133 } 135 }
134 } 136 }
135 137
136 void SkANGLEGLContext::makeCurrent() const { 138 void SkANGLEGLContext::onPlatformMakeCurrent() const {
137 if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { 139 if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
138 SkDebugf("Could not set the context.\n"); 140 SkDebugf("Could not set the context.\n");
139 } 141 }
140 } 142 }
141 143
142 void SkANGLEGLContext::swapBuffers() const { 144 void SkANGLEGLContext::onPlatformSwapBuffers() const {
143 if (!eglSwapBuffers(fDisplay, fSurface)) { 145 if (!eglSwapBuffers(fDisplay, fSurface)) {
144 SkDebugf("Could not complete eglSwapBuffers.\n"); 146 SkDebugf("Could not complete eglSwapBuffers.\n");
145 } 147 }
146 } 148 }
149
150 GrGLFuncPtr SkANGLEGLContext::onPlatformGetProcAddress(const char* name) const {
151 return eglGetProcAddress(name);
152 }
OLDNEW
« no previous file with comments | « src/gpu/gl/SkNullGLContext.cpp ('k') | src/gpu/gl/debug/SkDebugGLContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698