From b1854a85095f9924947bc00e665da47b0c0bdfb9 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Thu, 16 Jan 2014 18:39:04 +0000 Subject: Make GrGLContextInfo have private ptr to GrGLInterface BUG=skia:2042 R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/140843003 git-svn-id: http://skia.googlecode.com/svn/trunk@13111 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/gl/GrGLContext.h | 80 ++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 50 deletions(-) (limited to 'src/gpu/gl/GrGLContext.h') diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h index a418121f49..13c94a902d 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 fGLCaps; +protected: + SkAutoTUnref fInterface; + GrGLVersion fGLVersion; + GrGLSLGeneration fGLSLGeneration; + GrGLVendor fVendor; + GrGLRenderer fRenderer; + GrGLExtensions fExtensions; + bool fIsMesa; + bool fIsChromium; + SkAutoTUnref 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); + } - /** - * Copies a GrGLContext - */ - GrGLContext& operator= (const GrGLContext& ctx); + GrGLContext(const GrGLContext& that) : INHERITED(that) {} - /** - * 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 -- cgit v1.2.3