Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: src/gpu/gl/GrGLContext.h

Issue 140843003: Make GrGLContextInfo have private ptr to GrGLInterface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: tot Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/gpu/gl/GrGLContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 13 matching lines...) Expand all
24 class GrGLContextInfo { 24 class GrGLContextInfo {
25 public: 25 public:
26 /** 26 /**
27 * Default constructor 27 * Default constructor
28 */ 28 */
29 GrGLContextInfo() { 29 GrGLContextInfo() {
30 fGLCaps.reset(SkNEW(GrGLCaps)); 30 fGLCaps.reset(SkNEW(GrGLCaps));
31 this->reset(); 31 this->reset();
32 } 32 }
33 33
34 /** 34 GrGLContextInfo(const GrGLContextInfo& that) {
35 * Copies a GrGLContextInfo 35 fGLCaps.reset(SkNEW(GrGLCaps));
36 */ 36 *this = that;
37 GrGLContextInfo& operator= (const GrGLContextInfo& ctxInfo); 37 }
38
39 GrGLContextInfo& operator= (const GrGLContextInfo&);
38 40
39 /** 41 /**
40 * Initializes a GrGLContextInfo from a GrGLInterface and the currently 42 * Initializes a GrGLContextInfo from a GrGLInterface and the currently
41 * bound OpenGL context accessible by the GrGLInterface. 43 * bound OpenGL context accessible by the GrGLInterface.
42 */ 44 */
43 bool initialize(const GrGLInterface* interface); 45 bool initialize(const GrGLInterface* interface);
44 bool isInitialized() const; 46 bool isInitialized() const;
45 47
46 GrGLStandard standard() const { return fStandard; } 48 GrGLStandard standard() const { return fInterface->fStandard; }
47 GrGLVersion version() const { return fGLVersion; } 49 GrGLVersion version() const { return fGLVersion; }
48 GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } 50 GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
49 GrGLVendor vendor() const { return fVendor; } 51 GrGLVendor vendor() const { return fVendor; }
50 GrGLRenderer renderer() const { return fRenderer; } 52 GrGLRenderer renderer() const { return fRenderer; }
51 /** Is this a mesa-based driver. Does not mean it is the osmesa software ras terizer. */ 53 /** Is this a mesa-based driver. Does not mean it is the osmesa software ras terizer. */
52 bool isMesa() const { return fIsMesa; } 54 bool isMesa() const { return fIsMesa; }
53 /** Are we running inside Chromium (using the command buffer)? We make some different tradeoffs 55 /** Are we running inside Chromium (using the command buffer)? We make some different tradeoffs
54 about what errors to check for because queries are synchronous. We shoul d probably expose 56 about what errors to check for because queries are synchronous. We shoul d probably expose
55 this as an option for clients other than Chromium. */ 57 this as an option for clients other than Chromium. */
56 bool isChromium() const { return fIsChromium; } 58 bool isChromium() const { return fIsChromium; }
57 const GrGLCaps* caps() const { return fGLCaps.get(); } 59 const GrGLCaps* caps() const { return fGLCaps.get(); }
58 GrGLCaps* caps() { return fGLCaps; } 60 GrGLCaps* caps() { return fGLCaps; }
59 const GrGLExtensions& extensions() const { return fExtensions; } 61 const GrGLExtensions& extensions() const { return fExtensions; }
60 62
61 /** 63 /**
62 * Shortcut for extensions().has(ext); 64 * Shortcut for extensions().has(ext)
63 */ 65 */
64 bool hasExtension(const char* ext) const { 66 bool hasExtension(const char* ext) const {
65 if (!this->isInitialized()) { 67 if (!this->isInitialized()) {
66 return false; 68 return false;
67 } 69 }
68 return fExtensions.has(ext); 70 return fExtensions.has(ext);
69 } 71 }
70 72
71 /** 73 /**
72 * Reset the information 74 * Reset the information
73 */ 75 */
74 void reset(); 76 void reset();
75 77
76 private: 78 protected:
77 79 SkAutoTUnref<const GrGLInterface> fInterface;
78 GrGLStandard fStandard; 80 GrGLVersion fGLVersion;
79 GrGLVersion fGLVersion; 81 GrGLSLGeneration fGLSLGeneration;
80 GrGLSLGeneration fGLSLGeneration; 82 GrGLVendor fVendor;
81 GrGLVendor fVendor; 83 GrGLRenderer fRenderer;
82 GrGLRenderer fRenderer; 84 GrGLExtensions fExtensions;
83 GrGLExtensions fExtensions; 85 bool fIsMesa;
84 bool fIsMesa; 86 bool fIsChromium;
85 bool fIsChromium; 87 SkAutoTUnref<GrGLCaps> fGLCaps;
86 SkAutoTUnref<GrGLCaps> fGLCaps;
87 }; 88 };
88 89
89 /** 90 /**
90 * Encapsulates the GrGLInterface used to make GL calls plus information 91 * Extension of GrGLContextInfo that also provides access to GrGLInterface.
91 * about the context (via GrGLContextInfo).
92 */ 92 */
93 class GrGLContext { 93 class GrGLContext : public GrGLContextInfo {
94 public: 94 public:
95 /** 95 /**
96 * Default constructor
97 */
98 GrGLContext() { this->reset(); }
99
100 /**
101 * Creates a GrGLContext from a GrGLInterface and the currently 96 * Creates a GrGLContext from a GrGLInterface and the currently
102 * bound OpenGL context accessible by the GrGLInterface. 97 * bound OpenGL context accessible by the GrGLInterface.
103 */ 98 */
104 explicit GrGLContext(const GrGLInterface* interface); 99 explicit GrGLContext(const GrGLInterface* interface) {
100 this->initialize(interface);
101 }
105 102
106 /** 103 GrGLContext(const GrGLContext& that) : INHERITED(that) {}
107 * Copies a GrGLContext
108 */
109 GrGLContext(const GrGLContext& ctx);
110 104
111 ~GrGLContext() { SkSafeUnref(fInterface); } 105 GrGLContext& operator= (const GrGLContext& that) {
106 this->INHERITED::operator=(that);
107 return *this;
108 }
112 109
113 /** 110 const GrGLInterface* interface() const { return fInterface.get(); }
114 * Copies a GrGLContext
115 */
116 GrGLContext& operator= (const GrGLContext& ctx);
117
118 /**
119 * Initializes a GrGLContext from a GrGLInterface and the currently
120 * bound OpenGL context accessible by the GrGLInterface.
121 */
122 bool initialize(const GrGLInterface* interface);
123 bool isInitialized() const { return fInfo.isInitialized(); }
124
125 const GrGLInterface* interface() const { return fInterface; }
126 const GrGLContextInfo& info() const { return fInfo; }
127 GrGLContextInfo& info() { return fInfo; }
128 111
129 private: 112 private:
130 void reset(); 113 typedef GrGLContextInfo INHERITED;
131
132 const GrGLInterface* fInterface;
133 GrGLContextInfo fInfo;
134 }; 114 };
135 115
136 #endif 116 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698