Chromium Code Reviews| 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 fExtensions = ctxInfo.fExtensions; | 16 fExtensions = ctxInfo.fExtensions; |
|
robertphillips
2013/03/25 15:34:09
Shouldn't there be a ref here?
bsalomon
2013/03/25 15:37:27
It's object assignment not pointer assignment. Sin
robertphillips
2013/03/25 22:41:28
Okay - missed that when reading through. Does that
| |
| 17 fGLCaps = ctxInfo.fGLCaps; | 17 *fGLCaps = *ctxInfo.fGLCaps.get(); |
| 18 return *this; | 18 return *this; |
| 19 } | 19 } |
| 20 | 20 |
| 21 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { | 21 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { |
| 22 this->reset(); | 22 this->reset(); |
| 23 // We haven't validated the GrGLInterface yet, so check for GetString | 23 // We haven't validated the GrGLInterface yet, so check for GetString |
| 24 // function pointer | 24 // function pointer |
| 25 if (interface->fGetString) { | 25 if (interface->fGetString) { |
| 26 const GrGLubyte* verUByte; | 26 const GrGLubyte* verUByte; |
| 27 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); | 27 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); |
| 28 const char* ver = reinterpret_cast<const char*>(verUByte); | 28 const char* ver = reinterpret_cast<const char*>(verUByte); |
| 29 GrGLBinding binding = GrGLGetBindingInUseFromString(ver); | 29 GrGLBinding binding = GrGLGetBindingInUseFromString(ver); |
| 30 | 30 |
| 31 if (0 != binding && interface->validate(binding) && fExtensions.init(bin ding, interface)) { | 31 if (0 != binding && interface->validate(binding) && fExtensions.init(bin ding, interface)) { |
| 32 fBindingInUse = binding; | 32 fBindingInUse = binding; |
| 33 | 33 |
| 34 fGLVersion = GrGLGetVersionFromString(ver); | 34 fGLVersion = GrGLGetVersionFromString(ver); |
| 35 | 35 |
| 36 fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface); | 36 fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface); |
| 37 | 37 |
| 38 fVendor = GrGLGetVendor(interface); | 38 fVendor = GrGLGetVendor(interface); |
| 39 fGLCaps.init(*this, interface); | 39 fGLCaps->init(*this, interface); |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 return false; | 43 return false; |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool GrGLContextInfo::isInitialized() const { | 46 bool GrGLContextInfo::isInitialized() const { |
| 47 return kNone_GrGLBinding != fBindingInUse; | 47 return kNone_GrGLBinding != fBindingInUse; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void GrGLContextInfo::reset() { | 50 void GrGLContextInfo::reset() { |
| 51 fBindingInUse = kNone_GrGLBinding; | 51 fBindingInUse = kNone_GrGLBinding; |
| 52 fGLVersion = GR_GL_VER(0, 0); | 52 fGLVersion = GR_GL_VER(0, 0); |
| 53 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); | 53 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); |
| 54 fVendor = kOther_GrGLVendor; | 54 fVendor = kOther_GrGLVendor; |
| 55 fExtensions.reset(); | 55 fExtensions.reset(); |
| 56 fGLCaps.reset(); | 56 fGLCaps->reset(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 //////////////////////////////////////////////////////////////////////////////// | 59 //////////////////////////////////////////////////////////////////////////////// |
| 60 GrGLContext::GrGLContext(const GrGLInterface* interface) { | 60 GrGLContext::GrGLContext(const GrGLInterface* interface) { |
| 61 fInterface = NULL; | 61 fInterface = NULL; |
| 62 this->initialize(interface); | 62 this->initialize(interface); |
| 63 } | 63 } |
| 64 | 64 |
| 65 GrGLContext::GrGLContext(const GrGLContext& ctx) { | 65 GrGLContext::GrGLContext(const GrGLContext& ctx) { |
| 66 fInterface = NULL; | 66 fInterface = NULL; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool GrGLContext::initialize(const GrGLInterface* interface) { | 81 bool GrGLContext::initialize(const GrGLInterface* interface) { |
| 82 if (fInfo.initialize(interface)) { | 82 if (fInfo.initialize(interface)) { |
| 83 fInterface = interface; | 83 fInterface = interface; |
| 84 interface->ref(); | 84 interface->ref(); |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 return false; | 87 return false; |
| 88 } | 88 } |
| OLD | NEW |