diff options
author | 2014-06-30 06:36:31 -0700 | |
---|---|---|
committer | 2014-06-30 06:36:31 -0700 | |
commit | 80549fcdd50269d7e069d6db02b395fca128056c (patch) | |
tree | f190d563157d1e5e41f26e0bc1cf724b17a7f3c4 /src/gpu/gl/win | |
parent | b8562be65510ea2703e1e34029da8c8f501c340c (diff) |
Support using OpenGL ES context on desktop
Support using OpenGL ES context on desktop for unix and Android platforms. This
is mainly useful in development.
Add --gpuAPI flag to gm, dm, bench, bench_pictures and render_pictures. The
possible parameters for the flag are "gl" and "gles".
R=bsalomon@google.com, mtklein@google.com, robertphillips@google.com
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/319043005
Diffstat (limited to 'src/gpu/gl/win')
-rw-r--r-- | src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp | 22 | ||||
-rw-r--r-- | src/gpu/gl/win/SkNativeGLContext_win.cpp | 10 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp index 6adaf1964f..d63dfbbcd6 100644 --- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp +++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp @@ -8,9 +8,21 @@ #include "gl/GrGLInterface.h" #include "gl/GrGLAssembleInterface.h" +#include "gl/GrGLUtil.h" #define WIN32_LEAN_AND_MEAN #include <windows.h> +#include <GL/gl.h> + +#define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F) +#define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F #S) +#define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl" #F) + +#define GET_LINKED GET_PROC +#define GET_LINKED_SUFFIX GET_PROC_SUFFIX + +#include "gl/GrGLAssembleGLESInterface.h" + class AutoLibraryUnload { public: AutoLibraryUnload(const char* moduleName) { @@ -70,5 +82,13 @@ const GrGLInterface* GrGLCreateNativeInterface() { return NULL; } - return GrGLAssembleGLInterface(&getter, win_get_gl_proc); + const char* verStr = reinterpret_cast<const char*>(glGetString(GR_GL_VERSION)); + GrGLStandard standard = GrGLGetStandardInUseFromString(verStr); + + if (kGLES_GrGLStandard == standard) { + return GrGLAssembleGLESInterface(&getter, win_get_gl_proc); + } else if (kGL_GrGLStandard == standard) { + return GrGLAssembleGLInterface(&getter, win_get_gl_proc); + } + return NULL; } diff --git a/src/gpu/gl/win/SkNativeGLContext_win.cpp b/src/gpu/gl/win/SkNativeGLContext_win.cpp index bae97a780c..f085fdc6ee 100644 --- a/src/gpu/gl/win/SkNativeGLContext_win.cpp +++ b/src/gpu/gl/win/SkNativeGLContext_win.cpp @@ -47,7 +47,7 @@ void SkNativeGLContext::destroyGLContext() { } } -const GrGLInterface* SkNativeGLContext::createGLContext() { +const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) { HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL); if (!gWC) { @@ -85,9 +85,13 @@ const GrGLInterface* SkNativeGLContext::createGLContext() { this->destroyGLContext(); return NULL; } + // Requesting a Core profile would bar us from using NVPR. So we request + // compatibility profile or GL ES. + SkWGLContextRequest contextType = + kGLES_GrGLStandard == forcedGpuAPI ? + kGLES_SkWGLContextRequest : kGLPreferCompatibilityProfile_SkWGLContextRequest; - // Requesting a Core profile would bar us from using NVPR. So we pass false. - if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, false))) { + if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, contextType))) { SkDebugf("Could not create rendering context.\n"); this->destroyGLContext(); return NULL; |