| OLD | NEW |
| 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 #include "GrGLContext.h" | 8 #include "GrGLContext.h" |
| 9 | 9 |
| 10 //////////////////////////////////////////////////////////////////////////////// | 10 //////////////////////////////////////////////////////////////////////////////// |
| 11 GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) { | 11 GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) { |
| 12 fBindingInUse = ctxInfo.fBindingInUse; | 12 fBindingInUse = ctxInfo.fBindingInUse; |
| 13 fGLVersion = ctxInfo.fGLVersion; | 13 fGLVersion = ctxInfo.fGLVersion; |
| 14 fGLSLGeneration = ctxInfo.fGLSLGeneration; | 14 fGLSLGeneration = ctxInfo.fGLSLGeneration; |
| 15 fVendor = ctxInfo.fVendor; | 15 fVendor = ctxInfo.fVendor; |
| 16 fRenderer = ctxInfo.fRenderer; | 16 fRenderer = ctxInfo.fRenderer; |
| 17 fExtensions = ctxInfo.fExtensions; | 17 fExtensions = ctxInfo.fExtensions; |
| 18 fIsMesa = ctxInfo.fIsMesa; | 18 fIsMesa = ctxInfo.fIsMesa; |
| 19 fIsChromium = ctxInfo.fIsChromium; |
| 19 *fGLCaps = *ctxInfo.fGLCaps.get(); | 20 *fGLCaps = *ctxInfo.fGLCaps.get(); |
| 20 return *this; | 21 return *this; |
| 21 } | 22 } |
| 22 | 23 |
| 23 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { | 24 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { |
| 24 this->reset(); | 25 this->reset(); |
| 25 // We haven't validated the GrGLInterface yet, so check for GetString | 26 // We haven't validated the GrGLInterface yet, so check for GetString |
| 26 // function pointer | 27 // function pointer |
| 27 if (interface->fGetString) { | 28 if (interface->fGetString) { |
| 28 const GrGLubyte* verUByte; | 29 const GrGLubyte* verUByte; |
| 29 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); | 30 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); |
| 30 const char* ver = reinterpret_cast<const char*>(verUByte); | 31 const char* ver = reinterpret_cast<const char*>(verUByte); |
| 32 |
| 33 const GrGLubyte* rendererUByte; |
| 34 GR_GL_CALL_RET(interface, rendererUByte, GetString(GR_GL_RENDERER)); |
| 35 const char* renderer = reinterpret_cast<const char*>(rendererUByte); |
| 36 |
| 31 GrGLBinding binding = GrGLGetBindingInUseFromString(ver); | 37 GrGLBinding binding = GrGLGetBindingInUseFromString(ver); |
| 32 | 38 |
| 33 if (0 != binding && interface->validate(binding) && fExtensions.init(bin
ding, interface)) { | 39 if (0 != binding && interface->validate(binding) && fExtensions.init(bin
ding, interface)) { |
| 34 fBindingInUse = binding; | 40 fBindingInUse = binding; |
| 35 | 41 |
| 36 fGLVersion = GrGLGetVersionFromString(ver); | 42 fGLVersion = GrGLGetVersionFromString(ver); |
| 37 | 43 |
| 38 fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface); | 44 fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface); |
| 39 | 45 |
| 40 fVendor = GrGLGetVendor(interface); | 46 fVendor = GrGLGetVendor(interface); |
| 41 | 47 |
| 42 fRenderer = GrGLGetRenderer(interface); | 48 fRenderer = GrGLGetRendererFromString(renderer); |
| 43 | 49 |
| 44 fIsMesa = GrGLIsMesaFromVersionString(ver); | 50 fIsMesa = GrGLIsMesaFromVersionString(ver); |
| 45 | 51 |
| 52 fIsChromium = GrGLIsChromiumFromRendererString(renderer); |
| 53 |
| 46 fGLCaps->init(*this, interface); | 54 fGLCaps->init(*this, interface); |
| 47 return true; | 55 return true; |
| 48 } | 56 } |
| 49 } | 57 } |
| 50 return false; | 58 return false; |
| 51 } | 59 } |
| 52 | 60 |
| 53 bool GrGLContextInfo::isInitialized() const { | 61 bool GrGLContextInfo::isInitialized() const { |
| 54 return kNone_GrGLBinding != fBindingInUse; | 62 return kNone_GrGLBinding != fBindingInUse; |
| 55 } | 63 } |
| 56 | 64 |
| 57 void GrGLContextInfo::reset() { | 65 void GrGLContextInfo::reset() { |
| 58 fBindingInUse = kNone_GrGLBinding; | 66 fBindingInUse = kNone_GrGLBinding; |
| 59 fGLVersion = GR_GL_VER(0, 0); | 67 fGLVersion = GR_GL_VER(0, 0); |
| 60 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); | 68 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); |
| 61 fVendor = kOther_GrGLVendor; | 69 fVendor = kOther_GrGLVendor; |
| 62 fRenderer = kOther_GrGLRenderer; | 70 fRenderer = kOther_GrGLRenderer; |
| 63 fIsMesa = false; | 71 fIsMesa = false; |
| 72 fIsChromium = false; |
| 64 fExtensions.reset(); | 73 fExtensions.reset(); |
| 65 fGLCaps->reset(); | 74 fGLCaps->reset(); |
| 66 } | 75 } |
| 67 | 76 |
| 68 //////////////////////////////////////////////////////////////////////////////// | 77 //////////////////////////////////////////////////////////////////////////////// |
| 69 GrGLContext::GrGLContext(const GrGLInterface* interface) { | 78 GrGLContext::GrGLContext(const GrGLInterface* interface) { |
| 70 fInterface = NULL; | 79 fInterface = NULL; |
| 71 this->initialize(interface); | 80 this->initialize(interface); |
| 72 } | 81 } |
| 73 | 82 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 88 } | 97 } |
| 89 | 98 |
| 90 bool GrGLContext::initialize(const GrGLInterface* interface) { | 99 bool GrGLContext::initialize(const GrGLInterface* interface) { |
| 91 if (fInfo.initialize(interface)) { | 100 if (fInfo.initialize(interface)) { |
| 92 fInterface = interface; | 101 fInterface = interface; |
| 93 interface->ref(); | 102 interface->ref(); |
| 94 return true; | 103 return true; |
| 95 } | 104 } |
| 96 return false; | 105 return false; |
| 97 } | 106 } |
| OLD | NEW |