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