Chromium Code Reviews| Index: src/gpu/gl/GrGLContext.h |
| diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h |
| index a418121f49d7b19419f3d24a009a353a7382eae3..eb40b36cf38821df523c9ae215dde693da08978e 100644 |
| --- a/src/gpu/gl/GrGLContext.h |
| +++ b/src/gpu/gl/GrGLContext.h |
| @@ -31,10 +31,12 @@ public: |
| this->reset(); |
| } |
| - /** |
| - * Copies a GrGLContextInfo |
| - */ |
| - GrGLContextInfo& operator= (const GrGLContextInfo& ctxInfo); |
| + GrGLContextInfo(const GrGLContextInfo& that) { |
| + fGLCaps.reset(SkNEW(GrGLCaps)); |
| + *this = that; |
| + } |
| + |
| + GrGLContextInfo& operator= (const GrGLContextInfo&); |
| /** |
| * Initializes a GrGLContextInfo from a GrGLInterface and the currently |
| @@ -43,7 +45,7 @@ public: |
| bool initialize(const GrGLInterface* interface); |
| bool isInitialized() const; |
| - GrGLStandard standard() const { return fStandard; } |
| + GrGLStandard standard() const { return fInterface->fStandard; } |
| GrGLVersion version() const { return fGLVersion; } |
| GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } |
| GrGLVendor vendor() const { return fVendor; } |
| @@ -59,7 +61,7 @@ public: |
| const GrGLExtensions& extensions() const { return fExtensions; } |
| /** |
| - * Shortcut for extensions().has(ext); |
| + * Shortcut for extensions().has(ext) |
| */ |
| bool hasExtension(const char* ext) const { |
| if (!this->isInitialized()) { |
| @@ -73,64 +75,42 @@ public: |
| */ |
| void reset(); |
| -private: |
| - |
| - GrGLStandard fStandard; |
| - GrGLVersion fGLVersion; |
| - GrGLSLGeneration fGLSLGeneration; |
| - GrGLVendor fVendor; |
| - GrGLRenderer fRenderer; |
| - GrGLExtensions fExtensions; |
| - bool fIsMesa; |
| - bool fIsChromium; |
| - SkAutoTUnref<GrGLCaps> fGLCaps; |
| +protected: |
| + SkAutoTUnref<const GrGLInterface> fInterface; |
| + GrGLVersion fGLVersion; |
| + GrGLSLGeneration fGLSLGeneration; |
| + GrGLVendor fVendor; |
| + GrGLRenderer fRenderer; |
| + GrGLExtensions fExtensions; |
| + bool fIsMesa; |
| + bool fIsChromium; |
| + SkAutoTUnref<GrGLCaps> fGLCaps; |
| }; |
| /** |
| - * Encapsulates the GrGLInterface used to make GL calls plus information |
| - * about the context (via GrGLContextInfo). |
| + * Extension of GrGLContextInfo that also provides access to GrGLInterface. |
| */ |
| -class GrGLContext { |
| +class GrGLContext : public GrGLContextInfo { |
| public: |
| /** |
| - * Default constructor |
| - */ |
| - GrGLContext() { this->reset(); } |
| - |
| - /** |
| * Creates a GrGLContext from a GrGLInterface and the currently |
| * bound OpenGL context accessible by the GrGLInterface. |
| */ |
| - explicit GrGLContext(const GrGLInterface* interface); |
| - |
| - /** |
| - * Copies a GrGLContext |
| - */ |
| - GrGLContext(const GrGLContext& ctx); |
| - |
| - ~GrGLContext() { SkSafeUnref(fInterface); } |
| + explicit GrGLContext(const GrGLInterface* interface) { |
| + this->initialize(interface); |
| + } |
|
robertphillips
2014/01/16 15:48:49
: INHERITED(that) ?
bsalomon
2014/01/16 17:57:34
Done.
|
| - /** |
| - * Copies a GrGLContext |
| - */ |
| - GrGLContext& operator= (const GrGLContext& ctx); |
| + GrGLContext(const GrGLContext& that) : GrGLContextInfo(that) {} |
|
robertphillips
2014/01/16 15:48:49
Do we even need this?
bsalomon
2014/01/16 17:57:34
The copy cons is necessary, it seemed sensible me
|
| - /** |
| - * Initializes a GrGLContext from a GrGLInterface and the currently |
| - * bound OpenGL context accessible by the GrGLInterface. |
| - */ |
| - bool initialize(const GrGLInterface* interface); |
| - bool isInitialized() const { return fInfo.isInitialized(); } |
| + GrGLContext& operator= (const GrGLContext& that) { |
| + this->INHERITED::operator=(that); |
| + return *this; |
| + } |
| - const GrGLInterface* interface() const { return fInterface; } |
| - const GrGLContextInfo& info() const { return fInfo; } |
| - GrGLContextInfo& info() { return fInfo; } |
| + const GrGLInterface* interface() const { return fInterface.get(); } |
| private: |
| - void reset(); |
| - |
| - const GrGLInterface* fInterface; |
| - GrGLContextInfo fInfo; |
| + typedef GrGLContextInfo INHERITED; |
| }; |
| #endif |