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

Side by Side Diff: src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp

Issue 1459323004: Revert of Initial version of external_oes texture support and unit test (Closed) Base URL: https://skia.googlesource.com/skia.git@target
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 | « src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp ('k') | src/gpu/glsl/GrGLSL.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 2011 Google Inc. 3 * Copyright 2011 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 #include "gl/SkGLContext.h" 8 #include "gl/SkGLContext.h"
9 9
10 #include <GLES2/gl2.h> 10 #include <GLES2/gl2.h>
11 11
12 #define EGL_EGLEXT_PROTOTYPES 12 #define EGL_EGLEXT_PROTOTYPES
13 #include <EGL/egl.h> 13 #include <EGL/egl.h>
14 #include <EGL/eglext.h> 14 #include <EGL/eglext.h>
15 15
16 #include "gl/GrGLDefines.h"
17 #include "gl/GrGLUtil.h"
18
19 namespace { 16 namespace {
20 17
21 // TODO: Share this class with ANGLE if/when it gets support for EGL_KHR_fence_s ync. 18 // TODO: Share this class with ANGLE if/when it gets support for EGL_KHR_fence_s ync.
22 class SkEGLFenceSync : public SkGpuFenceSync { 19 class SkEGLFenceSync : public SkGpuFenceSync {
23 public: 20 public:
24 static SkEGLFenceSync* CreateIfSupported(EGLDisplay); 21 static SkEGLFenceSync* CreateIfSupported(EGLDisplay);
25 22
26 SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override; 23 SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override;
27 bool flushAndWaitFence(SkPlatformGpuFence fence) const override; 24 bool flushAndWaitFence(SkPlatformGpuFence fence) const override;
28 void deleteFence(SkPlatformGpuFence fence) const override; 25 void deleteFence(SkPlatformGpuFence fence) const override;
29 26
30 private: 27 private:
31 SkEGLFenceSync(EGLDisplay display) : fDisplay(display) {} 28 SkEGLFenceSync(EGLDisplay display) : fDisplay(display) {}
32 29
33 EGLDisplay fDisplay; 30 EGLDisplay fDisplay;
34 31
35 typedef SkGpuFenceSync INHERITED; 32 typedef SkGpuFenceSync INHERITED;
36 }; 33 };
37 34
38 class EGLGLContext : public SkGLContext { 35 class EGLGLContext : public SkGLContext {
39 public: 36 public:
40 EGLGLContext(GrGLStandard forcedGpuAPI); 37 EGLGLContext(GrGLStandard forcedGpuAPI);
41 ~EGLGLContext() override; 38 ~EGLGLContext() override;
42 39
43 GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
44 void destroyEGLImage(GrEGLImage) const override;
45 GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
46 SkGLContext* createNew() const override;
47
48 private: 40 private:
49 void destroyGLContext(); 41 void destroyGLContext();
50 42
51 void onPlatformMakeCurrent() const override; 43 void onPlatformMakeCurrent() const override;
52 void onPlatformSwapBuffers() const override; 44 void onPlatformSwapBuffers() const override;
53 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override; 45 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override;
54 46
55 EGLContext fContext; 47 EGLContext fContext;
56 EGLDisplay fDisplay; 48 EGLDisplay fDisplay;
57 EGLSurface fSurface; 49 EGLSurface fSurface;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (fSurface) { 193 if (fSurface) {
202 eglDestroySurface(fDisplay, fSurface); 194 eglDestroySurface(fDisplay, fSurface);
203 fSurface = EGL_NO_SURFACE; 195 fSurface = EGL_NO_SURFACE;
204 } 196 }
205 197
206 //TODO should we close the display? 198 //TODO should we close the display?
207 fDisplay = EGL_NO_DISPLAY; 199 fDisplay = EGL_NO_DISPLAY;
208 } 200 }
209 } 201 }
210 202
211 GrEGLImage EGLGLContext::texture2DToEGLImage(GrGLuint texID) const {
212 if (!this->gl()->hasExtension("EGL_KHR_gl_texture_2D_image")) {
213 return GR_EGL_NO_IMAGE;
214 }
215 GrEGLImage img;
216 GrEGLint attribs[] = { GR_EGL_GL_TEXTURE_LEVEL, 0, GR_EGL_NONE };
217 GrEGLClientBuffer clientBuffer = reinterpret_cast<GrEGLClientBuffer>(texID);
218 GR_GL_CALL_RET(this->gl(), img,
219 EGLCreateImage(fDisplay, fContext, GR_EGL_GL_TEXTURE_2D, clie ntBuffer, attribs));
220 return img;
221 }
222
223 void EGLGLContext::destroyEGLImage(GrEGLImage image) const {
224 GR_GL_CALL(this->gl(), EGLDestroyImage(fDisplay, image));
225 }
226
227 GrGLuint EGLGLContext::eglImageToExternalTexture(GrEGLImage image) const {
228 GrGLClearErr(this->gl());
229 if (!this->gl()->hasExtension("GL_OES_EGL_image_external")) {
230 return 0;
231 }
232 GrGLEGLImageTargetTexture2DProc glEGLImageTargetTexture2D =
233 (GrGLEGLImageTargetTexture2DProc) eglGetProcAddress("glEGLImageTarge tTexture2DOES");
234 if (!glEGLImageTargetTexture2D) {
235 return 0;
236 }
237 GrGLuint texID;
238 glGenTextures(1, &texID);
239 if (!texID) {
240 return 0;
241 }
242 glBindTexture(GR_GL_TEXTURE_EXTERNAL, texID);
243 if (glGetError() != GR_GL_NO_ERROR) {
244 glDeleteTextures(1, &texID);
245 return 0;
246 }
247 glEGLImageTargetTexture2D(GR_GL_TEXTURE_EXTERNAL, image);
248 if (glGetError() != GR_GL_NO_ERROR) {
249 glDeleteTextures(1, &texID);
250 return 0;
251 }
252 return texID;
253 }
254
255 SkGLContext* EGLGLContext::createNew() const {
256 SkGLContext* ctx = SkCreatePlatformGLContext(this->gl()->fStandard);
257 if (ctx) {
258 ctx->makeCurrent();
259 }
260 return ctx;
261 }
262 203
263 void EGLGLContext::onPlatformMakeCurrent() const { 204 void EGLGLContext::onPlatformMakeCurrent() const {
264 if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { 205 if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
265 SkDebugf("Could not set the context.\n"); 206 SkDebugf("Could not set the context.\n");
266 } 207 }
267 } 208 }
268 209
269 void EGLGLContext::onPlatformSwapBuffers() const { 210 void EGLGLContext::onPlatformSwapBuffers() const {
270 if (!eglSwapBuffers(fDisplay, fSurface)) { 211 if (!eglSwapBuffers(fDisplay, fSurface)) {
271 SkDebugf("Could not complete eglSwapBuffers.\n"); 212 SkDebugf("Could not complete eglSwapBuffers.\n");
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 260
320 SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { 261 SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {
321 EGLGLContext* ctx = new EGLGLContext(forcedGpuAPI); 262 EGLGLContext* ctx = new EGLGLContext(forcedGpuAPI);
322 if (!ctx->isValid()) { 263 if (!ctx->isValid()) {
323 delete ctx; 264 delete ctx;
324 return nullptr; 265 return nullptr;
325 } 266 }
326 return ctx; 267 return ctx;
327 } 268 }
328 269
OLDNEW
« no previous file with comments | « src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp ('k') | src/gpu/glsl/GrGLSL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698