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 | */ |
reed | f9ad558 | 2015-06-25 21:29:25 -0700 | [diff] [blame] | 26 | class GrGLContextInfo : public SkRefCnt { |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 27 | public: |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 28 | GrGLStandard standard() const { return fInterface->fStandard; } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 29 | GrGLVersion version() const { return fGLVersion; } |
| 30 | GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } |
| 31 | GrGLVendor vendor() const { return fVendor; } |
commit-bot@chromium.org | 0694ea7 | 2013-09-18 13:00:28 +0000 | [diff] [blame] | 32 | GrGLRenderer renderer() const { return fRenderer; } |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 33 | /** What driver is running our GL implementation? This is not necessarily related to the vendor. |
| 34 | (e.g. Intel GPU being driven by Mesa) */ |
| 35 | GrGLDriver driver() const { return fDriver; } |
| 36 | GrGLDriverVersion driverVersion() const { return fDriverVersion; } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 37 | const GrGLCaps* caps() const { return fGLCaps.get(); } |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame^] | 38 | GrGLCaps* caps() { return fGLCaps.get(); } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 39 | bool hasExtension(const char* ext) const { |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 40 | return fInterface->hasExtension(ext); |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 41 | } |
| 42 | |
bsalomon | e904c09 | 2014-07-17 10:50:59 -0700 | [diff] [blame] | 43 | const GrGLExtensions& extensions() const { return fInterface->fExtensions; } |
| 44 | |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 45 | virtual ~GrGLContextInfo() {} |
| 46 | |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 47 | protected: |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 48 | struct ConstructorArgs { |
| 49 | const GrGLInterface* fInterface; |
| 50 | GrGLVersion fGLVersion; |
| 51 | GrGLSLGeneration fGLSLGeneration; |
| 52 | GrGLVendor fVendor; |
| 53 | GrGLRenderer fRenderer; |
cdalton | 1acea86 | 2015-06-02 13:05:52 -0700 | [diff] [blame] | 54 | GrGLDriver fDriver; |
| 55 | GrGLDriverVersion fDriverVersion; |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 56 | const GrContextOptions* fContextOptions; |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | GrGLContextInfo(const ConstructorArgs& args); |
| 60 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame^] | 61 | sk_sp<const GrGLInterface> fInterface; |
| 62 | GrGLVersion fGLVersion; |
| 63 | GrGLSLGeneration fGLSLGeneration; |
| 64 | GrGLVendor fVendor; |
| 65 | GrGLRenderer fRenderer; |
| 66 | GrGLDriver fDriver; |
| 67 | GrGLDriverVersion fDriverVersion; |
| 68 | sk_sp<GrGLCaps> fGLCaps; |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | /** |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 72 | * 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] | 73 | */ |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 74 | class GrGLContext : public GrGLContextInfo { |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 75 | public: |
| 76 | /** |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 77 | * Creates a GrGLContext from a GrGLInterface and the currently |
| 78 | * bound OpenGL context accessible by the GrGLInterface. |
| 79 | */ |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 80 | static GrGLContext* Create(const GrGLInterface* interface, const GrContextOptions& options); |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 81 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame^] | 82 | const GrGLInterface* interface() const { return fInterface.get(); } |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 83 | |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 84 | SkSL::Compiler* compiler() const; |
| 85 | |
| 86 | ~GrGLContext() override; |
| 87 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 88 | private: |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 89 | GrGLContext(const ConstructorArgs& args) |
| 90 | : INHERITED(args) |
| 91 | , fCompiler(nullptr) {} |
| 92 | |
| 93 | mutable SkSL::Compiler* fCompiler; |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 94 | |
commit-bot@chromium.org | b1854a8 | 2014-01-16 18:39:04 +0000 | [diff] [blame] | 95 | typedef GrGLContextInfo INHERITED; |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | #endif |