| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "GrGLContextInfo.h" | 8 #include "GrGLContextInfo.h" |
| 9 | 9 |
| 10 GrGLContextInfo::~GrGLContextInfo() { | 10 GrGLContextInfo::~GrGLContextInfo() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 fInterface = NULL; | 24 fInterface = NULL; |
| 25 *this = ctx; | 25 *this = ctx; |
| 26 } | 26 } |
| 27 | 27 |
| 28 GrGLContextInfo& GrGLContextInfo::operator = (const GrGLContextInfo& ctx) { | 28 GrGLContextInfo& GrGLContextInfo::operator = (const GrGLContextInfo& ctx) { |
| 29 GrSafeAssign(fInterface, ctx.fInterface); | 29 GrSafeAssign(fInterface, ctx.fInterface); |
| 30 fBindingInUse = ctx.fBindingInUse; | 30 fBindingInUse = ctx.fBindingInUse; |
| 31 fGLVersion = ctx.fGLVersion; | 31 fGLVersion = ctx.fGLVersion; |
| 32 fGLSLGeneration = ctx.fGLSLGeneration; | 32 fGLSLGeneration = ctx.fGLSLGeneration; |
| 33 fVendor = ctx.fVendor; | 33 fVendor = ctx.fVendor; |
| 34 fExtensionString = ctx.fExtensionString; | 34 fExtensions = ctx.fExtensions; |
| 35 fGLCaps = ctx.fGLCaps; | 35 fGLCaps = ctx.fGLCaps; |
| 36 return *this; | 36 return *this; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void GrGLContextInfo::reset() { | 39 void GrGLContextInfo::reset() { |
| 40 GrSafeSetNull(fInterface); | 40 GrSafeSetNull(fInterface); |
| 41 fBindingInUse = kNone_GrGLBinding; | 41 fBindingInUse = kNone_GrGLBinding; |
| 42 fGLVersion = GR_GL_VER(0, 0); | 42 fGLVersion = GR_GL_VER(0, 0); |
| 43 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); | 43 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); |
| 44 fVendor = kOther_GrGLVendor; | 44 fVendor = kOther_GrGLVendor; |
| 45 fExtensionString = ""; | 45 fExtensions.reset(); |
| 46 fGLCaps.reset(); | 46 fGLCaps.reset(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { | 49 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { |
| 50 this->reset(); | 50 this->reset(); |
| 51 // We haven't validated the GrGLInterface yet, so check for GetString | 51 // We haven't validated the GrGLInterface yet, so check for GetString |
| 52 // function pointer | 52 // function pointer |
| 53 if (NULL != interface->fGetString) { | 53 if (interface->fGetString) { |
| 54 | |
| 55 const GrGLubyte* verUByte; | 54 const GrGLubyte* verUByte; |
| 56 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); | 55 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); |
| 57 const char* ver = reinterpret_cast<const char*>(verUByte); | 56 const char* ver = reinterpret_cast<const char*>(verUByte); |
| 58 GrGLBinding binding = GrGLGetBindingInUseFromString(ver); | 57 GrGLBinding binding = GrGLGetBindingInUseFromString(ver); |
| 59 | 58 |
| 60 if (interface->validate(binding)) { | 59 if (0 != binding && interface->validate(binding) && fExtensions.init(bin
ding, interface)) { |
| 61 | 60 |
| 62 fInterface = interface; | 61 fInterface = interface; |
| 63 interface->ref(); | 62 interface->ref(); |
| 64 | 63 |
| 65 fBindingInUse = binding; | 64 fBindingInUse = binding; |
| 66 | 65 |
| 67 fGLVersion = GrGLGetVersionFromString(ver); | 66 fGLVersion = GrGLGetVersionFromString(ver); |
| 68 | 67 |
| 69 fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, | 68 fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, |
| 70 this->interface()); | 69 this->interface()); |
| 71 | 70 |
| 72 const GrGLubyte* ext; | |
| 73 GR_GL_CALL_RET(interface, ext, GetString(GR_GL_EXTENSIONS)); | |
| 74 fExtensionString = reinterpret_cast<const char*>(ext); | |
| 75 fVendor = GrGLGetVendor(interface); | 71 fVendor = GrGLGetVendor(interface); |
| 76 fGLCaps.init(*this); | 72 fGLCaps.init(*this); |
| 77 return true; | 73 return true; |
| 78 } | 74 } |
| 79 } | 75 } |
| 80 return false; | 76 return false; |
| 81 } | 77 } |
| 82 | 78 |
| 83 bool GrGLContextInfo::isInitialized() const { | 79 bool GrGLContextInfo::isInitialized() const { |
| 84 return kNone_GrGLBinding != fBindingInUse; | 80 return kNone_GrGLBinding != fBindingInUse; |
| 85 } | 81 } |
| OLD | NEW |