blob: c5f62ff3ce85461a50305155f9c438bea700049d [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
bsalomon10805962014-10-08 04:45:09 -070013#include "SkGLContextHelper.h"
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000014
15#include <GLES2/gl2.h>
16#include <EGL/egl.h>
17
bsalomon10805962014-10-08 04:45:09 -070018class SkANGLEGLContext : public SkGLContextHelper {
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000019public:
20 SkANGLEGLContext();
21
22 virtual ~SkANGLEGLContext();
23
24 virtual void makeCurrent() const SK_OVERRIDE;
djsollen@google.comc9542ca2013-10-09 18:25:38 +000025 virtual void swapBuffers() const SK_OVERRIDE;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000026
bsalomon10805962014-10-08 04:45:09 -070027 class AutoContextRestore {
28 public:
29 AutoContextRestore();
30 ~AutoContextRestore();
31
32 private:
33 EGLContext fOldEGLContext;
34 EGLDisplay fOldDisplay;
35 EGLSurface fOldSurface;
36 };
37
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000038protected:
kkinnunen80549fc2014-06-30 06:36:31 -070039 virtual const GrGLInterface* createGLContext(
40 GrGLStandard forcedGpuAPI) SK_OVERRIDE;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000041 virtual void destroyGLContext() SK_OVERRIDE;
42
43private:
robertphillips@google.comd5c8fe62012-04-02 15:04:16 +000044 EGLContext fContext;
45 EGLDisplay fDisplay;
46 EGLSurface fSurface;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000047};
48
49#endif
50
51#endif