diff options
Diffstat (limited to 'src/gpu/gl')
6 files changed, 34 insertions, 13 deletions
diff --git a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp b/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp index 3b2488dfc6..821e040261 100644 --- a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp +++ b/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp @@ -317,7 +317,11 @@ void SkEGLFenceSync::deleteFence(SkPlatformGpuFence platformFence) const { } // anonymous namespace -SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { +SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) { + SkASSERT(!shareContext); + if (shareContext) { + return nullptr; + } EGLGLContext* ctx = new EGLGLContext(forcedGpuAPI); if (!ctx->isValid()) { delete ctx; diff --git a/src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp b/src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp index 8c58a53702..51b8ce9e60 100644 --- a/src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp +++ b/src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp @@ -46,7 +46,7 @@ static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) { class GLXGLContext : public SkGLContext { public: - GLXGLContext(GrGLStandard forcedGpuAPI); + GLXGLContext(GrGLStandard forcedGpuAPI, GLXGLContext* shareList); ~GLXGLContext() override; private: @@ -62,14 +62,15 @@ private: GLXPixmap fGlxPixmap; }; -GLXGLContext::GLXGLContext(GrGLStandard forcedGpuAPI) +GLXGLContext::GLXGLContext(GrGLStandard forcedGpuAPI, GLXGLContext* shareContext) : fContext(nullptr) , fDisplay(nullptr) , fPixmap(0) , fGlxPixmap(0) { - fDisplay = XOpenDisplay(0); + GLXContext glxShareContext = shareContext ? shareContext->fContext : nullptr; + if (!fDisplay) { SkDebugf("Failed to open X display.\n"); this->destroyGLContext(); @@ -189,7 +190,7 @@ GLXGLContext::GLXGLContext(GrGLStandard forcedGpuAPI) GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EXT, None }; - fContext = glXCreateContextAttribsARB(fDisplay, bestFbc, 0, True, + fContext = glXCreateContextAttribsARB(fDisplay, bestFbc, glxShareContext, True, context_attribs_gles); } } else { @@ -211,7 +212,8 @@ GLXGLContext::GLXGLContext(GrGLStandard forcedGpuAPI) None }; fContext = - glXCreateContextAttribsARB(fDisplay, bestFbc, 0, True, context_attribs_gl); + glXCreateContextAttribsARB(fDisplay, bestFbc, glxShareContext, True, + context_attribs_gl); // Sync to ensure any errors generated are processed. XSync(fDisplay, False); @@ -237,7 +239,7 @@ GLXGLContext::GLXGLContext(GrGLStandard forcedGpuAPI) ctxErrorOccurred = false; - fContext = glXCreateContextAttribsARB(fDisplay, bestFbc, 0, True, + fContext = glXCreateContextAttribsARB(fDisplay, bestFbc, glxShareContext, True, context_attribs_gl_fallback); } } @@ -331,8 +333,9 @@ GrGLFuncPtr GLXGLContext::onPlatformGetProcAddress(const char* procName) const { } // anonymous namespace -SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { - GLXGLContext *ctx = new GLXGLContext(forcedGpuAPI); +SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) { + GLXGLContext* glxShareContext = reinterpret_cast<GLXGLContext*>(shareContext); + GLXGLContext *ctx = new GLXGLContext(forcedGpuAPI, glxShareContext); if (!ctx->isValid()) { delete ctx; return nullptr; diff --git a/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm b/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm index b90948af44..5be351f52e 100644 --- a/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm +++ b/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm @@ -89,7 +89,11 @@ GrGLFuncPtr IOSGLContext::onPlatformGetProcAddress(const char* procName) const { } // anonymous namespace -SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { +SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) { + SkASSERT(!shareContext); + if (shareContext) { + return NULL; + } if (kGL_GrGLStandard == forcedGpuAPI) { return NULL; } diff --git a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp b/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp index 41585c8632..d1826a49e3 100644 --- a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp +++ b/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp @@ -109,7 +109,12 @@ GrGLFuncPtr MacGLContext::onPlatformGetProcAddress(const char* procName) const { } // anonymous namespace -SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { +SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) { + SkASSERT(!shareContext); + if (shareContext) { + return nullptr; + } + if (kGLES_GrGLStandard == forcedGpuAPI) { return nullptr; } diff --git a/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp b/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp index 21f30019a9..e064aec726 100644 --- a/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp +++ b/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp @@ -7,7 +7,8 @@ */ #include "gl/SkGLContext.h" -SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { +SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) { + SkASSERT(!shareContext); return nullptr; } diff --git a/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp b/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp index f795f52554..6cc11439bf 100644 --- a/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp +++ b/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp @@ -187,7 +187,11 @@ GrGLFuncPtr WinGLContext::onPlatformGetProcAddress(const char* name) const { } // anonymous namespace -SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) { +SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) { + SkASSERT(!shareContext); + if (shareContext) { + return nullptr; + } WinGLContext* ctx = new WinGLContext(forcedGpuAPI); if (!ctx->isValid()) { delete ctx; |