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; |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 18 | namespace SkSL { |
| 19 | class Compiler; |
| 20 | } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 21 | |
| 22 | /** |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 23 | * Encapsulates information about an OpenGL context including the OpenGL |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 24 | * version, the GrGLStandard type of the context, and GLSL version. |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 25 | */ |
Brian Salomon | 8ab1cc4 | 2017-12-07 12:40:00 -0500 | [diff] [blame] | 26 | class GrGLContextInfo { |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 27 | public: |
Brian Salomon | 8ab1cc4 | 2017-12-07 12:40:00 -0500 | [diff] [blame] | 28 | GrGLContextInfo(const GrGLContextInfo&) = delete; |
| 29 | GrGLContextInfo& operator=(const GrGLContextInfo&) = delete; |
| 30 | |
| 31 | virtual ~GrGLContextInfo() {} |
| 32 | |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 33 | GrGLStandard standard() const { return fInterface->fStandard; } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 34 | GrGLVersion version() const { return fGLVersion; } |
| 35 | GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } |
| 36 | GrGLVendor vendor() const { return fVendor; } |
commit-bot@chromium.org | 0694ea7 | 2013-09-18 13:00:28 +0000 | [diff] [blame] | 37 | GrGLRenderer renderer() const { return fRenderer; } |
Brian Salomon | 266ef6d | 2017-09-22 11:27:42 -0400 | [diff] [blame] | 38 | GrGLANGLEBackend angleBackend() const { return fANGLEBackend; } |
| 39 | GrGLANGLEVendor angleVendor() const { return fANGLEVendor; } |
| 40 | GrGLANGLERenderer angleRenderer() const { return fANGLERenderer; } |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 41 | /** What driver is running our GL implementation? This is not necessarily related to the vendor. |
| 42 | (e.g. Intel GPU being driven by Mesa) */ |
| 43 | GrGLDriver driver() const { return fDriver; } |
| 44 | GrGLDriverVersion driverVersion() const { return fDriverVersion; } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 45 | const GrGLCaps* caps() const { return fGLCaps.get(); } |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 46 | GrGLCaps* caps() { return fGLCaps.get(); } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 47 | bool hasExtension(const char* ext) const { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 48 | return fInterface->hasExtension(ext); |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 49 | } |
| 50 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 51 | const GrGLExtensions& extensions() const { return fInterface->fExtensions; } |
| 52 | |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 53 | protected: |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 54 | struct ConstructorArgs { |
Brian Salomon | 8ab1cc4 | 2017-12-07 12:40:00 -0500 | [diff] [blame] | 55 | sk_sp<const GrGLInterface> fInterface; |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 56 | GrGLVersion fGLVersion; |
| 57 | GrGLSLGeneration fGLSLGeneration; |
| 58 | GrGLVendor fVendor; |
| 59 | GrGLRenderer fRenderer; |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 60 | GrGLDriver fDriver; |
| 61 | GrGLDriverVersion fDriverVersion; |
Brian Salomon | 266ef6d | 2017-09-22 11:27:42 -0400 | [diff] [blame] | 62 | GrGLANGLEBackend fANGLEBackend; |
| 63 | GrGLANGLEVendor fANGLEVendor; |
| 64 | GrGLANGLERenderer fANGLERenderer; |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 65 | const GrContextOptions* fContextOptions; |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
Brian Salomon | 8ab1cc4 | 2017-12-07 12:40:00 -0500 | [diff] [blame] | 68 | GrGLContextInfo(ConstructorArgs&&); |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 69 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 70 | sk_sp<const GrGLInterface> fInterface; |
| 71 | GrGLVersion fGLVersion; |
| 72 | GrGLSLGeneration fGLSLGeneration; |
| 73 | GrGLVendor fVendor; |
| 74 | GrGLRenderer fRenderer; |
| 75 | GrGLDriver fDriver; |
| 76 | GrGLDriverVersion fDriverVersion; |
Brian Salomon | 266ef6d | 2017-09-22 11:27:42 -0400 | [diff] [blame] | 77 | GrGLANGLEBackend fANGLEBackend; |
| 78 | GrGLANGLEVendor fANGLEVendor; |
| 79 | GrGLANGLERenderer fANGLERenderer; |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 80 | sk_sp<GrGLCaps> fGLCaps; |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | /** |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 84 | * Extension of GrGLContextInfo that also provides access to GrGLInterface and SkSL::Compiler. |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 85 | */ |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 86 | class GrGLContext : public GrGLContextInfo { |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 87 | public: |
| 88 | /** |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 89 | * Creates a GrGLContext from a GrGLInterface and the currently |
| 90 | * bound OpenGL context accessible by the GrGLInterface. |
| 91 | */ |
Brian Salomon | 8ab1cc4 | 2017-12-07 12:40:00 -0500 | [diff] [blame] | 92 | static std::unique_ptr<GrGLContext> Make(sk_sp<const GrGLInterface>, const GrContextOptions&); |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 93 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 94 | const GrGLInterface* interface() const { return fInterface.get(); } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 95 | |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 96 | SkSL::Compiler* compiler() const; |
| 97 | |
| 98 | ~GrGLContext() override; |
| 99 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 100 | private: |
Brian Salomon | 8ab1cc4 | 2017-12-07 12:40:00 -0500 | [diff] [blame] | 101 | GrGLContext(ConstructorArgs&& args) : INHERITED(std::move(args)), fCompiler(nullptr) {} |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 102 | |
| 103 | mutable SkSL::Compiler* fCompiler; |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 104 | |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 105 | typedef GrGLContextInfo INHERITED; |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | #endif |