michael@0: /* michael@0: * Copyright 2013 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "GrGLContext.h" michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& that) { michael@0: fInterface.reset(SkSafeRef(that.fInterface.get())); michael@0: fGLVersion = that.fGLVersion; michael@0: fGLSLGeneration = that.fGLSLGeneration; michael@0: fVendor = that.fVendor; michael@0: fRenderer = that.fRenderer; michael@0: fIsMesa = that.fIsMesa; michael@0: fIsChromium = that.fIsChromium; michael@0: *fGLCaps = *that.fGLCaps.get(); michael@0: return *this; michael@0: } michael@0: michael@0: bool GrGLContextInfo::initialize(const GrGLInterface* interface) { michael@0: this->reset(); michael@0: // We haven't validated the GrGLInterface yet, so check for GetString michael@0: // function pointer michael@0: if (interface->fFunctions.fGetString) { michael@0: const GrGLubyte* verUByte; michael@0: GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); michael@0: const char* ver = reinterpret_cast(verUByte); michael@0: michael@0: const GrGLubyte* rendererUByte; michael@0: GR_GL_CALL_RET(interface, rendererUByte, GetString(GR_GL_RENDERER)); michael@0: const char* renderer = reinterpret_cast(rendererUByte); michael@0: michael@0: if (interface->validate()) { michael@0: michael@0: fGLVersion = GrGLGetVersionFromString(ver); michael@0: michael@0: fGLSLGeneration = GrGetGLSLGeneration(interface); michael@0: michael@0: fVendor = GrGLGetVendor(interface); michael@0: michael@0: fRenderer = GrGLGetRendererFromString(renderer); michael@0: michael@0: fIsMesa = GrGLIsMesaFromVersionString(ver); michael@0: michael@0: fIsChromium = GrGLIsChromiumFromRendererString(renderer); michael@0: michael@0: // This must occur before caps init. michael@0: fInterface.reset(SkRef(interface)); michael@0: michael@0: fGLCaps->init(*this, interface); michael@0: michael@0: return true; michael@0: } michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: bool GrGLContextInfo::isInitialized() const { michael@0: return NULL != fInterface.get(); michael@0: } michael@0: michael@0: void GrGLContextInfo::reset() { michael@0: fInterface.reset(NULL); michael@0: fGLVersion = GR_GL_VER(0, 0); michael@0: fGLSLGeneration = static_cast(0); michael@0: fVendor = kOther_GrGLVendor; michael@0: fRenderer = kOther_GrGLRenderer; michael@0: fIsMesa = false; michael@0: fIsChromium = false; michael@0: fGLCaps->reset(); michael@0: }