diff options
author | joshualitt <joshualitt@chromium.org> | 2016-01-20 08:07:01 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-20 08:07:02 -0800 |
commit | b59d1bc7a8596f346d57a9cfcd461dddc6d75edb (patch) | |
tree | 802ae32d377784134f621307ede9fff2b2adfb34 | |
parent | c1e710140b652509822a42872c4d4dd058393582 (diff) |
Add ability to wire up sharelist in glcontext creation
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1604993005
Review URL: https://codereview.chromium.org/1604993005
-rw-r--r-- | include/gpu/gl/SkGLContext.h | 16 | ||||
-rw-r--r-- | src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp | 19 | ||||
-rw-r--r-- | src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm | 6 | ||||
-rw-r--r-- | src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp | 7 | ||||
-rw-r--r-- | src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp | 6 |
7 files changed, 43 insertions, 20 deletions
diff --git a/include/gpu/gl/SkGLContext.h b/include/gpu/gl/SkGLContext.h index 77fd325dd8..63c3e9ca7b 100644 --- a/include/gpu/gl/SkGLContext.h +++ b/include/gpu/gl/SkGLContext.h @@ -113,14 +113,16 @@ private: friend class GLFenceSync; // For onPlatformGetProcAddress. }; -/** Creates platform-dependent GL context object - * Returns a valid gl context object or NULL if such can not be created. - * Note: If Skia embedder needs a custom GL context that sets up the GL - * interface, this function should be implemented by the embedder. - * Otherwise, the default implementation for the platform should be compiled in - * the library. +/** Creates platform-dependent GL context object. The shareContext parameter is in an optional + * context with which to share display lists. This should be a pointer to an SkGLContext created + * with SkCreatePlatformGLContext. NULL indicates that no sharing is to take place. Returns a valid + * gl context object or NULL if such can not be created. + * Note: If Skia embedder needs a custom GL context that sets up the GL interface, this function + * should be implemented by the embedder. Otherwise, the default implementation for the platform + * should be compiled in the library. */ -SK_API SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI); +SK_API SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, + SkGLContext* shareContext = nullptr); /** * Helper macros for using the GL context through the GrGLInterface. Example: 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; |