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
This commit is contained in:
parent
c1e710140b
commit
b59d1bc7a8
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -7,7 +7,8 @@
|
||||
*/
|
||||
#include "gl/SkGLContext.h"
|
||||
|
||||
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI) {
|
||||
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
|
||||
SkASSERT(!shareContext);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user