| OLD | NEW |
| 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 "GLContext_angle.h" | 9 #include "GLTestContext_angle.h" |
| 10 | 10 |
| 11 #include <EGL/egl.h> | 11 #include <EGL/egl.h> |
| 12 #include <EGL/eglext.h> | 12 #include <EGL/eglext.h> |
| 13 | 13 |
| 14 #include "gl/GrGLDefines.h" | 14 #include "gl/GrGLDefines.h" |
| 15 #include "gl/GrGLUtil.h" | 15 #include "gl/GrGLUtil.h" |
| 16 | 16 |
| 17 #include "gl/GrGLInterface.h" | 17 #include "gl/GrGLInterface.h" |
| 18 #include "gl/GrGLAssembleInterface.h" | 18 #include "gl/GrGLAssembleInterface.h" |
| 19 #include "../ports/SkOSLibrary.h" | 19 #include "../ports/SkOSLibrary.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 EGL_NONE | 77 EGL_NONE |
| 78 }, | 78 }, |
| 79 }; | 79 }; |
| 80 for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) { | 80 for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) { |
| 81 display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,nativeDi
splay, attribs[i]); | 81 display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,nativeDi
splay, attribs[i]); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 return display; | 84 return display; |
| 85 } | 85 } |
| 86 | 86 |
| 87 class ANGLEGLContext : public sk_gpu_test::GLContext { | 87 class ANGLEGLContext : public sk_gpu_test::GLTestContext { |
| 88 public: | 88 public: |
| 89 ANGLEGLContext(bool preferGLBackend); | 89 ANGLEGLContext(bool preferGLBackend); |
| 90 ~ANGLEGLContext() override; | 90 ~ANGLEGLContext() override; |
| 91 | 91 |
| 92 GrEGLImage texture2DToEGLImage(GrGLuint texID) const override; | 92 GrEGLImage texture2DToEGLImage(GrGLuint texID) const override; |
| 93 void destroyEGLImage(GrEGLImage) const override; | 93 void destroyEGLImage(GrEGLImage) const override; |
| 94 GrGLuint eglImageToExternalTexture(GrEGLImage) const override; | 94 GrGLuint eglImageToExternalTexture(GrEGLImage) const override; |
| 95 sk_gpu_test::GLContext* createNew() const override; | 95 sk_gpu_test::GLTestContext* createNew() const override; |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 void destroyGLContext(); | 98 void destroyGLContext(); |
| 99 | 99 |
| 100 void onPlatformMakeCurrent() const override; | 100 void onPlatformMakeCurrent() const override; |
| 101 void onPlatformSwapBuffers() const override; | 101 void onPlatformSwapBuffers() const override; |
| 102 GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override; | 102 GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override; |
| 103 | 103 |
| 104 void* fContext; | 104 void* fContext; |
| 105 void* fDisplay; | 105 void* fDisplay; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return 0; | 216 return 0; |
| 217 } | 217 } |
| 218 glEGLImageTargetTexture2D(GR_GL_TEXTURE_EXTERNAL, image); | 218 glEGLImageTargetTexture2D(GR_GL_TEXTURE_EXTERNAL, image); |
| 219 if (GR_GL_GET_ERROR(this->gl()) != GR_GL_NO_ERROR) { | 219 if (GR_GL_GET_ERROR(this->gl()) != GR_GL_NO_ERROR) { |
| 220 GR_GL_CALL(this->gl(), DeleteTextures(1, &texID)); | 220 GR_GL_CALL(this->gl(), DeleteTextures(1, &texID)); |
| 221 return 0; | 221 return 0; |
| 222 } | 222 } |
| 223 return texID; | 223 return texID; |
| 224 } | 224 } |
| 225 | 225 |
| 226 sk_gpu_test::GLContext* ANGLEGLContext::createNew() const { | 226 sk_gpu_test::GLTestContext* ANGLEGLContext::createNew() const { |
| 227 #ifdef SK_BUILD_FOR_WIN | 227 #ifdef SK_BUILD_FOR_WIN |
| 228 sk_gpu_test::GLContext* ctx = fIsGLBackend ? sk_gpu_test::CreateANGLEOpenGLG
LContext() | 228 sk_gpu_test::GLTestContext* ctx = fIsGLBackend? |
| 229 : sk_gpu_test::CreateANGLEDirect3
DGLContext(); | 229 ? sk_gpu_test::CreateANGLEOpenGLGLTestContext() |
| 230 : sk_gpu_test::CreateANGLEDirect3DGLTestContext(); |
| 230 #else | 231 #else |
| 231 sk_gpu_test::GLContext* ctx = sk_gpu_test::CreateANGLEOpenGLGLContext(); | 232 sk_gpu_test::GLTestContext* ctx = sk_gpu_test::CreateANGLEOpenGLGLTestContex
t(); |
| 232 #endif | 233 #endif |
| 233 if (ctx) { | 234 if (ctx) { |
| 234 ctx->makeCurrent(); | 235 ctx->makeCurrent(); |
| 235 } | 236 } |
| 236 return ctx; | 237 return ctx; |
| 237 } | 238 } |
| 238 | 239 |
| 239 void ANGLEGLContext::destroyGLContext() { | 240 void ANGLEGLContext::destroyGLContext() { |
| 240 if (fDisplay) { | 241 if (fDisplay) { |
| 241 eglMakeCurrent(fDisplay, 0, 0, 0); | 242 eglMakeCurrent(fDisplay, 0, 0, 0); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 293 |
| 293 if (nullptr == gLibs.fGLLib || nullptr == gLibs.fEGLLib) { | 294 if (nullptr == gLibs.fGLLib || nullptr == gLibs.fEGLLib) { |
| 294 // We can't setup the interface correctly w/o the so | 295 // We can't setup the interface correctly w/o the so |
| 295 return nullptr; | 296 return nullptr; |
| 296 } | 297 } |
| 297 | 298 |
| 298 return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc); | 299 return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc); |
| 299 } | 300 } |
| 300 | 301 |
| 301 #ifdef SK_BUILD_FOR_WIN | 302 #ifdef SK_BUILD_FOR_WIN |
| 302 GLContext* CreateANGLEDirect3DGLContext() { | 303 GLTestContext* CreateANGLEDirect3DGLTestContext() { |
| 303 ANGLEGLContext* ctx = new ANGLEGLContext(false); | 304 ANGLEGLContext* ctx = new ANGLEGLContext(false); |
| 304 if (!ctx->isValid()) { | 305 if (!ctx->isValid()) { |
| 305 delete ctx; | 306 delete ctx; |
| 306 return NULL; | 307 return NULL; |
| 307 } | 308 } |
| 308 return ctx; | 309 return ctx; |
| 309 } | 310 } |
| 310 #endif | 311 #endif |
| 311 | 312 |
| 312 GLContext* CreateANGLEOpenGLGLContext() { | 313 GLTestContext* CreateANGLEOpenGLGLTestContext() { |
| 313 ANGLEGLContext* ctx = new ANGLEGLContext(true); | 314 ANGLEGLContext* ctx = new ANGLEGLContext(true); |
| 314 if (!ctx->isValid()) { | 315 if (!ctx->isValid()) { |
| 315 delete ctx; | 316 delete ctx; |
| 316 return NULL; | 317 return NULL; |
| 317 } | 318 } |
| 318 return ctx; | 319 return ctx; |
| 319 } | 320 } |
| 320 } // namespace sk_gpu_test | 321 } // namespace sk_gpu_test |
| OLD | NEW |