robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | |
| 9 | #ifndef GrGLContext_DEFINED |
| 10 | #define GrGLContext_DEFINED |
| 11 | |
| 12 | #include "gl/GrGLExtensions.h" |
| 13 | #include "gl/GrGLInterface.h" |
| 14 | #include "GrGLCaps.h" |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 15 | #include "GrGLUtil.h" |
| 16 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 17 | struct GrContextOptions; |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 18 | |
| 19 | /** |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 20 | * Encapsulates information about an OpenGL context including the OpenGL |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 21 | * version, the GrGLStandard type of the context, and GLSL version. |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 22 | */ |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame] | 23 | class GrGLContextInfo : public SkRefCnt { |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 24 | public: |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 25 | GrGLStandard standard() const { return fInterface->fStandard; } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 26 | GrGLVersion version() const { return fGLVersion; } |
| 27 | GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } |
| 28 | GrGLVendor vendor() const { return fVendor; } |
commit-bot@chromium.org | 0694ea7 | 2013-09-18 13:00:28 +0000 | [diff] [blame] | 29 | GrGLRenderer renderer() const { return fRenderer; } |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 30 | /** What driver is running our GL implementation? This is not necessarily related to the vendor. |
| 31 | (e.g. Intel GPU being driven by Mesa) */ |
| 32 | GrGLDriver driver() const { return fDriver; } |
| 33 | GrGLDriverVersion driverVersion() const { return fDriverVersion; } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 34 | const GrGLCaps* caps() const { return fGLCaps.get(); } |
| 35 | GrGLCaps* caps() { return fGLCaps; } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 36 | bool hasExtension(const char* ext) const { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 37 | return fInterface->hasExtension(ext); |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 38 | } |
| 39 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 40 | const GrGLExtensions& extensions() const { return fInterface->fExtensions; } |
| 41 | |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 42 | protected: |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 43 | struct ConstructorArgs { |
| 44 | const GrGLInterface* fInterface; |
| 45 | GrGLVersion fGLVersion; |
| 46 | GrGLSLGeneration fGLSLGeneration; |
| 47 | GrGLVendor fVendor; |
| 48 | GrGLRenderer fRenderer; |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 49 | GrGLDriver fDriver; |
| 50 | GrGLDriverVersion fDriverVersion; |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 51 | const GrContextOptions* fContextOptions; |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | GrGLContextInfo(const ConstructorArgs& args); |
| 55 | |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 56 | SkAutoTUnref<const GrGLInterface> fInterface; |
| 57 | GrGLVersion fGLVersion; |
| 58 | GrGLSLGeneration fGLSLGeneration; |
| 59 | GrGLVendor fVendor; |
| 60 | GrGLRenderer fRenderer; |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 61 | GrGLDriver fDriver; |
| 62 | GrGLDriverVersion fDriverVersion; |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 63 | SkAutoTUnref<GrGLCaps> fGLCaps; |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | /** |
jvanverth | 9df16b5 | 2016-10-11 10:03:56 -0700 | [diff] [blame^] | 67 | * Extension of GrGLContextInfo that also provides access to GrGLInterface. |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 68 | */ |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 69 | class GrGLContext : public GrGLContextInfo { |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 70 | public: |
| 71 | /** |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 72 | * Creates a GrGLContext from a GrGLInterface and the currently |
| 73 | * bound OpenGL context accessible by the GrGLInterface. |
| 74 | */ |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 75 | static GrGLContext* Create(const GrGLInterface* interface, const GrContextOptions& options); |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 76 | |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 77 | const GrGLInterface* interface() const { return fInterface; } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 78 | |
| 79 | private: |
jvanverth | 9df16b5 | 2016-10-11 10:03:56 -0700 | [diff] [blame^] | 80 | GrGLContext(const ConstructorArgs& args) : INHERITED(args) {} |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 81 | |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 82 | typedef GrGLContextInfo INHERITED; |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | #endif |