robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | #ifndef SkANGLEGLContext_DEFINED |
| 9 | #define SkANGLEGLContext_DEFINED |
| 10 | |
| 11 | #if SK_ANGLE |
| 12 | |
djsollen | e454521 | 2014-11-13 11:12:41 -0800 | [diff] [blame] | 13 | #include "gl/SkGLContext.h" |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 14 | |
kkinnunen | 9e61bb7 | 2014-10-09 05:24:15 -0700 | [diff] [blame] | 15 | class SkANGLEGLContext : public SkGLContext { |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 16 | public: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 17 | ~SkANGLEGLContext() override; |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 18 | |
hendrikw | eddbefb | 2015-09-11 13:07:29 -0700 | [diff] [blame^] | 19 | static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI, bool useGLBackend) { |
kkinnunen | 30bc88c | 2014-10-15 23:03:54 -0700 | [diff] [blame] | 20 | if (kGL_GrGLStandard == forcedGpuAPI) { |
| 21 | return NULL; |
| 22 | } |
hendrikw | eddbefb | 2015-09-11 13:07:29 -0700 | [diff] [blame^] | 23 | SkANGLEGLContext* ctx = new SkANGLEGLContext(useGLBackend); |
kkinnunen | 30bc88c | 2014-10-15 23:03:54 -0700 | [diff] [blame] | 24 | if (!ctx->isValid()) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 25 | delete ctx; |
kkinnunen | 30bc88c | 2014-10-15 23:03:54 -0700 | [diff] [blame] | 26 | return NULL; |
| 27 | } |
| 28 | return ctx; |
| 29 | } |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 30 | |
bsalomon | 93276c6 | 2015-02-23 10:51:13 -0800 | [diff] [blame] | 31 | // The param is an EGLNativeDisplayType and the return is an EGLDispay. |
hendrikw | eddbefb | 2015-09-11 13:07:29 -0700 | [diff] [blame^] | 32 | static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend); |
bsalomon | 4238017 | 2015-02-23 08:57:23 -0800 | [diff] [blame] | 33 | |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 34 | private: |
hendrikw | eddbefb | 2015-09-11 13:07:29 -0700 | [diff] [blame^] | 35 | SkANGLEGLContext(bool preferGLBackend); |
kkinnunen | 30bc88c | 2014-10-15 23:03:54 -0700 | [diff] [blame] | 36 | void destroyGLContext(); |
| 37 | |
cdalton | d416a5b | 2015-06-23 13:23:44 -0700 | [diff] [blame] | 38 | void onPlatformMakeCurrent() const override; |
| 39 | void onPlatformSwapBuffers() const override; |
| 40 | GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override; |
| 41 | |
bsalomon | 93276c6 | 2015-02-23 10:51:13 -0800 | [diff] [blame] | 42 | void* fContext; |
| 43 | void* fDisplay; |
| 44 | void* fSurface; |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | #endif |
| 48 | |
| 49 | #endif |