blob: 8d5f83041a9d4a268fad8432297a281605b2a469 [file] [log] [blame]
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +00001
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
djsollene4545212014-11-13 11:12:41 -080013#include "gl/SkGLContext.h"
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000014
kkinnunen9e61bb72014-10-09 05:24:15 -070015class SkANGLEGLContext : public SkGLContext {
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000016public:
mtklein36352bf2015-03-25 18:17:31 -070017 ~SkANGLEGLContext() override;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000018
hendrikweddbefb2015-09-11 13:07:29 -070019 static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI, bool useGLBackend) {
kkinnunen30bc88c2014-10-15 23:03:54 -070020 if (kGL_GrGLStandard == forcedGpuAPI) {
21 return NULL;
22 }
hendrikweddbefb2015-09-11 13:07:29 -070023 SkANGLEGLContext* ctx = new SkANGLEGLContext(useGLBackend);
kkinnunen30bc88c2014-10-15 23:03:54 -070024 if (!ctx->isValid()) {
halcanary385fe4d2015-08-26 13:07:48 -070025 delete ctx;
kkinnunen30bc88c2014-10-15 23:03:54 -070026 return NULL;
27 }
28 return ctx;
29 }
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000030
bsalomon93276c62015-02-23 10:51:13 -080031 // The param is an EGLNativeDisplayType and the return is an EGLDispay.
hendrikweddbefb2015-09-11 13:07:29 -070032 static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend);
bsalomon42380172015-02-23 08:57:23 -080033
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000034private:
hendrikweddbefb2015-09-11 13:07:29 -070035 SkANGLEGLContext(bool preferGLBackend);
kkinnunen30bc88c2014-10-15 23:03:54 -070036 void destroyGLContext();
37
cdaltond416a5b2015-06-23 13:23:44 -070038 void onPlatformMakeCurrent() const override;
39 void onPlatformSwapBuffers() const override;
40 GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
41
bsalomon93276c62015-02-23 10:51:13 -080042 void* fContext;
43 void* fDisplay;
44 void* fSurface;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000045};
46
47#endif
48
49#endif