diff options
-rw-r--r-- | bench/nanobench.cpp | 1 | ||||
-rw-r--r-- | dm/DM.cpp | 1 | ||||
-rw-r--r-- | dm/DMGpuSupport.h | 1 | ||||
-rw-r--r-- | include/gpu/gl/angle/SkANGLEGLContext.h | 8 | ||||
-rwxr-xr-x | src/gpu/GrContextFactory.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrContextFactory.h | 3 | ||||
-rw-r--r-- | src/gpu/gl/angle/SkANGLEGLContext.cpp | 54 | ||||
-rw-r--r-- | src/views/win/SkOSWindow_win.cpp | 2 | ||||
-rw-r--r-- | tests/SkpSkGrTest.cpp | 1 |
9 files changed, 50 insertions, 26 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index a5a70d9220..e7019dcb8c 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -443,6 +443,7 @@ static void create_configs(SkTDArray<Config>* configs) { GPU_CONFIG(nullgpu, kNull_GLContextType, 0, false) #ifdef SK_ANGLE GPU_CONFIG(angle, kANGLE_GLContextType, 0, false) + GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, 0, false) #endif #ifdef SK_COMMAND_BUFFER GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, 0, false) @@ -566,6 +566,7 @@ static Sink* create_sink(const char* tag) { SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, true, FLAGS_gpu_threading); #if SK_ANGLE SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading); + SINK("angle-gl", GPUSink, Gr::kANGLE_GL_GLContextType, api, 0, false, FLAGS_gpu_threading); #endif #if SK_COMMAND_BUFFER SINK("commandbuffer", GPUSink, Gr::kCommandBuffer_GLContextType, api, 0, false, FLAGS_gpu_threading); diff --git a/dm/DMGpuSupport.h b/dm/DMGpuSupport.h index 0b9596ebdc..9e10231dda 100644 --- a/dm/DMGpuSupport.h +++ b/dm/DMGpuSupport.h @@ -65,6 +65,7 @@ public: typedef int GLContextType; static const GLContextType kANGLE_GLContextType = 0, + kANGLE_GL_GLContextType = 0, kCommandBuffer_GLContextType = 0, kDebug_GLContextType = 0, kMESA_GLContextType = 0, diff --git a/include/gpu/gl/angle/SkANGLEGLContext.h b/include/gpu/gl/angle/SkANGLEGLContext.h index 6590c765d8..8d5f83041a 100644 --- a/include/gpu/gl/angle/SkANGLEGLContext.h +++ b/include/gpu/gl/angle/SkANGLEGLContext.h @@ -16,11 +16,11 @@ class SkANGLEGLContext : public SkGLContext { public: ~SkANGLEGLContext() override; - static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI) { + static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI, bool useGLBackend) { if (kGL_GrGLStandard == forcedGpuAPI) { return NULL; } - SkANGLEGLContext* ctx = new SkANGLEGLContext; + SkANGLEGLContext* ctx = new SkANGLEGLContext(useGLBackend); if (!ctx->isValid()) { delete ctx; return NULL; @@ -29,10 +29,10 @@ public: } // The param is an EGLNativeDisplayType and the return is an EGLDispay. - static void* GetD3DEGLDisplay(void* nativeDisplay); + static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend); private: - SkANGLEGLContext(); + SkANGLEGLContext(bool preferGLBackend); void destroyGLContext(); void onPlatformMakeCurrent() const override; diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp index 0fe01df16b..acd5d93a04 100755 --- a/src/gpu/GrContextFactory.cpp +++ b/src/gpu/GrContextFactory.cpp @@ -43,7 +43,10 @@ GrContext* GrContextFactory::get(GLContextType type, GrGLStandard forcedGpuAPI) break; #ifdef SK_ANGLE case kANGLE_GLContextType: - glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI)); + glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false)); + break; + case kANGLE_GL_GLContextType: + glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true)); break; #endif #ifdef SK_COMMAND_BUFFER diff --git a/src/gpu/GrContextFactory.h b/src/gpu/GrContextFactory.h index 2accd7329f..130c333dd0 100644 --- a/src/gpu/GrContextFactory.h +++ b/src/gpu/GrContextFactory.h @@ -33,6 +33,7 @@ public: kNative_GLContextType, #if SK_ANGLE kANGLE_GLContextType, + kANGLE_GL_GLContextType, #endif #if SK_COMMAND_BUFFER kCommandBuffer_GLContextType, @@ -70,6 +71,8 @@ public: #if SK_ANGLE case kANGLE_GLContextType: return "angle"; + case kANGLE_GL_GLContextType: + return "angle-gl"; #endif #if SK_COMMAND_BUFFER case kCommandBuffer_GLContextType: diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp index 8ebdcb661e..64a3bdec74 100644 --- a/src/gpu/gl/angle/SkANGLEGLContext.cpp +++ b/src/gpu/gl/angle/SkANGLEGLContext.cpp @@ -15,8 +15,9 @@ #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 #define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207 #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 +#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D -void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay) { +void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend) { PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT; eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT"); @@ -25,29 +26,44 @@ void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay) { return eglGetDisplay(static_cast<EGLNativeDisplayType>(nativeDisplay)); } - // Try for an ANGLE D3D11 context, fall back to D3D9. - EGLint attribs[2][3] = { - { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_NONE - }, - { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, - EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, - EGL_NONE - } - }; - EGLDisplay display = EGL_NO_DISPLAY; - for (int i = 0; i < 2 && display == EGL_NO_DISPLAY; ++i) { + if (useGLBackend) { + // Try for an ANGLE D3D11 context, fall back to D3D9. + EGLint attribs[3] = { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE, + EGL_NONE + }; display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, - nativeDisplay, attribs[i]); + nativeDisplay, attribs); + } else { + // Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL. + EGLint attribs[3][3] = { + { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_NONE + }, + { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE, + EGL_NONE + }, + { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE, + EGL_NONE + } + }; + for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) { + display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, + nativeDisplay, attribs[i]); + } } return display; } -SkANGLEGLContext::SkANGLEGLContext() +SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend) : fContext(EGL_NO_CONTEXT) , fDisplay(EGL_NO_DISPLAY) , fSurface(EGL_NO_SURFACE) { @@ -63,7 +79,7 @@ SkANGLEGLContext::SkANGLEGLContext() EGL_NONE }; - fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY); + fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY, useGLBackend); if (EGL_NO_DISPLAY == fDisplay) { SkDebugf("Could not create EGL display!"); return; diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp index 2fb91554ee..aba5a6f4ae 100644 --- a/src/views/win/SkOSWindow_win.cpp +++ b/src/views/win/SkOSWindow_win.cpp @@ -418,7 +418,7 @@ bool create_ANGLE(EGLNativeWindowType hWnd, EGL_NONE, EGL_NONE }; - EGLDisplay display = SkANGLEGLContext::GetD3DEGLDisplay(GetDC(hWnd)); + EGLDisplay display = SkANGLEGLContext::GetD3DEGLDisplay(GetDC(hWnd), false); if (EGL_NO_DISPLAY == display) { SkDebugf("Could not create ANGLE egl display!\n"); diff --git a/tests/SkpSkGrTest.cpp b/tests/SkpSkGrTest.cpp index da19843a4c..98c54e032c 100644 --- a/tests/SkpSkGrTest.cpp +++ b/tests/SkpSkGrTest.cpp @@ -260,7 +260,6 @@ static SkString make_png_name(const char* filename) { typedef GrContextFactory::GLContextType GLContextType; #ifdef SK_BUILD_FOR_WIN static const GLContextType kAngle = GrContextFactory::kANGLE_GLContextType; -static const GLContextType kCommandBuffer = GrContextFactory::kCommandBuffer_GLContextType; #else static const GLContextType kNative = GrContextFactory::kNative_GLContextType; #endif |