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 | 11 |
12 GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& that) { | 12 GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& that) { |
13 fInterface.reset(SkSafeRef(that.fInterface.get())); | 13 fInterface.reset(SkSafeRef(that.fInterface.get())); |
14 fGLVersion = that.fGLVersion; | 14 fGLVersion = that.fGLVersion; |
15 fGLSLGeneration = that.fGLSLGeneration; | 15 fGLSLGeneration = that.fGLSLGeneration; |
16 fVendor = that.fVendor; | 16 fVendor = that.fVendor; |
17 fRenderer = that.fRenderer; | 17 fRenderer = that.fRenderer; |
18 fExtensions = that.fExtensions; | |
19 fIsMesa = that.fIsMesa; | 18 fIsMesa = that.fIsMesa; |
20 fIsChromium = that.fIsChromium; | 19 fIsChromium = that.fIsChromium; |
21 *fGLCaps = *that.fGLCaps.get(); | 20 *fGLCaps = *that.fGLCaps.get(); |
22 return *this; | 21 return *this; |
23 } | 22 } |
24 | 23 |
25 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { | 24 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { |
26 this->reset(); | 25 this->reset(); |
27 // We haven't validated the GrGLInterface yet, so check for GetString | 26 // We haven't validated the GrGLInterface yet, so check for GetString |
28 // function pointer | 27 // function pointer |
29 if (interface->fGetString) { | 28 if (interface->fGetString) { |
30 const GrGLubyte* verUByte; | 29 const GrGLubyte* verUByte; |
31 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); | 30 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); |
32 const char* ver = reinterpret_cast<const char*>(verUByte); | 31 const char* ver = reinterpret_cast<const char*>(verUByte); |
33 | 32 |
34 const GrGLubyte* rendererUByte; | 33 const GrGLubyte* rendererUByte; |
35 GR_GL_CALL_RET(interface, rendererUByte, GetString(GR_GL_RENDERER)); | 34 GR_GL_CALL_RET(interface, rendererUByte, GetString(GR_GL_RENDERER)); |
36 const char* renderer = reinterpret_cast<const char*>(rendererUByte); | 35 const char* renderer = reinterpret_cast<const char*>(rendererUByte); |
37 | 36 |
38 if (interface->validate() && fExtensions.init(interface)) { | 37 if (interface->validate()) { |
39 | 38 |
40 fGLVersion = GrGLGetVersionFromString(ver); | 39 fGLVersion = GrGLGetVersionFromString(ver); |
41 | 40 |
42 fGLSLGeneration = GrGetGLSLGeneration(interface); | 41 fGLSLGeneration = GrGetGLSLGeneration(interface); |
43 | 42 |
44 fVendor = GrGLGetVendor(interface); | 43 fVendor = GrGLGetVendor(interface); |
45 | 44 |
46 fRenderer = GrGLGetRendererFromString(renderer); | 45 fRenderer = GrGLGetRendererFromString(renderer); |
47 | 46 |
48 fIsMesa = GrGLIsMesaFromVersionString(ver); | 47 fIsMesa = GrGLIsMesaFromVersionString(ver); |
(...skipping 16 matching lines...) Expand all Loading... |
65 } | 64 } |
66 | 65 |
67 void GrGLContextInfo::reset() { | 66 void GrGLContextInfo::reset() { |
68 fInterface.reset(NULL); | 67 fInterface.reset(NULL); |
69 fGLVersion = GR_GL_VER(0, 0); | 68 fGLVersion = GR_GL_VER(0, 0); |
70 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); | 69 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); |
71 fVendor = kOther_GrGLVendor; | 70 fVendor = kOther_GrGLVendor; |
72 fRenderer = kOther_GrGLRenderer; | 71 fRenderer = kOther_GrGLRenderer; |
73 fIsMesa = false; | 72 fIsMesa = false; |
74 fIsChromium = false; | 73 fIsChromium = false; |
75 fExtensions.reset(); | |
76 fGLCaps->reset(); | 74 fGLCaps->reset(); |
77 } | 75 } |
OLD | NEW |