OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrGLContext_DEFINED | 9 #ifndef GrGLContext_DEFINED |
10 #define GrGLContext_DEFINED | 10 #define GrGLContext_DEFINED |
11 | 11 |
12 #include "gl/GrGLExtensions.h" | 12 #include "gl/GrGLExtensions.h" |
13 #include "gl/GrGLInterface.h" | 13 #include "gl/GrGLInterface.h" |
14 #include "GrGLCaps.h" | 14 #include "GrGLCaps.h" |
15 #include "GrGLUtil.h" | 15 #include "GrGLUtil.h" |
16 | 16 |
17 struct GrContextOptions; | 17 struct GrContextOptions; |
18 namespace SkSL { | |
19 class Compiler; | |
20 } | |
21 | 18 |
22 /** | 19 /** |
23 * Encapsulates information about an OpenGL context including the OpenGL | 20 * Encapsulates information about an OpenGL context including the OpenGL |
24 * version, the GrGLStandard type of the context, and GLSL version. | 21 * version, the GrGLStandard type of the context, and GLSL version. |
25 */ | 22 */ |
26 class GrGLContextInfo : public SkRefCnt { | 23 class GrGLContextInfo : public SkRefCnt { |
27 public: | 24 public: |
28 GrGLStandard standard() const { return fInterface->fStandard; } | 25 GrGLStandard standard() const { return fInterface->fStandard; } |
29 GrGLVersion version() const { return fGLVersion; } | 26 GrGLVersion version() const { return fGLVersion; } |
30 GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } | 27 GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } |
31 GrGLVendor vendor() const { return fVendor; } | 28 GrGLVendor vendor() const { return fVendor; } |
32 GrGLRenderer renderer() const { return fRenderer; } | 29 GrGLRenderer renderer() const { return fRenderer; } |
33 /** What driver is running our GL implementation? This is not necessarily re
lated to the vendor. | 30 /** What driver is running our GL implementation? This is not necessarily re
lated to the vendor. |
34 (e.g. Intel GPU being driven by Mesa) */ | 31 (e.g. Intel GPU being driven by Mesa) */ |
35 GrGLDriver driver() const { return fDriver; } | 32 GrGLDriver driver() const { return fDriver; } |
36 GrGLDriverVersion driverVersion() const { return fDriverVersion; } | 33 GrGLDriverVersion driverVersion() const { return fDriverVersion; } |
37 const GrGLCaps* caps() const { return fGLCaps.get(); } | 34 const GrGLCaps* caps() const { return fGLCaps.get(); } |
38 GrGLCaps* caps() { return fGLCaps; } | 35 GrGLCaps* caps() { return fGLCaps; } |
39 bool hasExtension(const char* ext) const { | 36 bool hasExtension(const char* ext) const { |
40 return fInterface->hasExtension(ext); | 37 return fInterface->hasExtension(ext); |
41 } | 38 } |
42 | 39 |
43 const GrGLExtensions& extensions() const { return fInterface->fExtensions; } | 40 const GrGLExtensions& extensions() const { return fInterface->fExtensions; } |
44 | 41 |
45 virtual ~GrGLContextInfo() {} | |
46 | |
47 protected: | 42 protected: |
48 struct ConstructorArgs { | 43 struct ConstructorArgs { |
49 const GrGLInterface* fInterface; | 44 const GrGLInterface* fInterface; |
50 GrGLVersion fGLVersion; | 45 GrGLVersion fGLVersion; |
51 GrGLSLGeneration fGLSLGeneration; | 46 GrGLSLGeneration fGLSLGeneration; |
52 GrGLVendor fVendor; | 47 GrGLVendor fVendor; |
53 GrGLRenderer fRenderer; | 48 GrGLRenderer fRenderer; |
54 GrGLDriver fDriver; | 49 GrGLDriver fDriver; |
55 GrGLDriverVersion fDriverVersion; | 50 GrGLDriverVersion fDriverVersion; |
56 const GrContextOptions* fContextOptions; | 51 const GrContextOptions* fContextOptions; |
57 }; | 52 }; |
58 | 53 |
59 GrGLContextInfo(const ConstructorArgs& args); | 54 GrGLContextInfo(const ConstructorArgs& args); |
60 | 55 |
61 SkAutoTUnref<const GrGLInterface> fInterface; | 56 SkAutoTUnref<const GrGLInterface> fInterface; |
62 GrGLVersion fGLVersion; | 57 GrGLVersion fGLVersion; |
63 GrGLSLGeneration fGLSLGeneration; | 58 GrGLSLGeneration fGLSLGeneration; |
64 GrGLVendor fVendor; | 59 GrGLVendor fVendor; |
65 GrGLRenderer fRenderer; | 60 GrGLRenderer fRenderer; |
66 GrGLDriver fDriver; | 61 GrGLDriver fDriver; |
67 GrGLDriverVersion fDriverVersion; | 62 GrGLDriverVersion fDriverVersion; |
68 SkAutoTUnref<GrGLCaps> fGLCaps; | 63 SkAutoTUnref<GrGLCaps> fGLCaps; |
69 }; | 64 }; |
70 | 65 |
71 /** | 66 /** |
72 * Extension of GrGLContextInfo that also provides access to GrGLInterface and S
kSL::Compiler. | 67 * Extension of GrGLContextInfo that also provides access to GrGLInterface. |
73 */ | 68 */ |
74 class GrGLContext : public GrGLContextInfo { | 69 class GrGLContext : public GrGLContextInfo { |
75 public: | 70 public: |
76 /** | 71 /** |
77 * Creates a GrGLContext from a GrGLInterface and the currently | 72 * Creates a GrGLContext from a GrGLInterface and the currently |
78 * bound OpenGL context accessible by the GrGLInterface. | 73 * bound OpenGL context accessible by the GrGLInterface. |
79 */ | 74 */ |
80 static GrGLContext* Create(const GrGLInterface* interface, const GrContextOp
tions& options); | 75 static GrGLContext* Create(const GrGLInterface* interface, const GrContextOp
tions& options); |
81 | 76 |
82 const GrGLInterface* interface() const { return fInterface; } | 77 const GrGLInterface* interface() const { return fInterface; } |
83 | 78 |
84 SkSL::Compiler* compiler(); | |
85 | |
86 ~GrGLContext() override; | |
87 | |
88 private: | 79 private: |
89 GrGLContext(const ConstructorArgs& args) | 80 GrGLContext(const ConstructorArgs& args) : INHERITED(args) {} |
90 : INHERITED(args) | |
91 , fCompiler(nullptr) {} | |
92 | |
93 SkSL::Compiler* fCompiler; | |
94 | 81 |
95 typedef GrGLContextInfo INHERITED; | 82 typedef GrGLContextInfo INHERITED; |
96 }; | 83 }; |
97 | 84 |
98 #endif | 85 #endif |
OLD | NEW |