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 fExtensions = ctxInfo.fExtensions; | 17 fExtensions = ctxInfo.fExtensions; |
17 fIsMesa = ctxInfo.fIsMesa; | 18 fIsMesa = ctxInfo.fIsMesa; |
18 *fGLCaps = *ctxInfo.fGLCaps.get(); | 19 *fGLCaps = *ctxInfo.fGLCaps.get(); |
19 return *this; | 20 return *this; |
20 } | 21 } |
21 | 22 |
22 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { | 23 bool GrGLContextInfo::initialize(const GrGLInterface* interface) { |
23 this->reset(); | 24 this->reset(); |
24 // We haven't validated the GrGLInterface yet, so check for GetString | 25 // We haven't validated the GrGLInterface yet, so check for GetString |
25 // function pointer | 26 // function pointer |
26 if (interface->fGetString) { | 27 if (interface->fGetString) { |
27 const GrGLubyte* verUByte; | 28 const GrGLubyte* verUByte; |
28 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); | 29 GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION)); |
29 const char* ver = reinterpret_cast<const char*>(verUByte); | 30 const char* ver = reinterpret_cast<const char*>(verUByte); |
30 GrGLBinding binding = GrGLGetBindingInUseFromString(ver); | 31 GrGLBinding binding = GrGLGetBindingInUseFromString(ver); |
31 | 32 |
32 if (0 != binding && interface->validate(binding) && fExtensions.init(bin
ding, interface)) { | 33 if (0 != binding && interface->validate(binding) && fExtensions.init(bin
ding, interface)) { |
33 fBindingInUse = binding; | 34 fBindingInUse = binding; |
34 | 35 |
35 fGLVersion = GrGLGetVersionFromString(ver); | 36 fGLVersion = GrGLGetVersionFromString(ver); |
36 | 37 |
37 fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface); | 38 fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface); |
38 | 39 |
39 fVendor = GrGLGetVendor(interface); | 40 fVendor = GrGLGetVendor(interface); |
40 | 41 |
| 42 fRenderer = GrGLGetRenderer(interface); |
| 43 |
41 fIsMesa = GrGLIsMesaFromVersionString(ver); | 44 fIsMesa = GrGLIsMesaFromVersionString(ver); |
42 | 45 |
43 fGLCaps->init(*this, interface); | 46 fGLCaps->init(*this, interface); |
44 return true; | 47 return true; |
45 } | 48 } |
46 } | 49 } |
47 return false; | 50 return false; |
48 } | 51 } |
49 | 52 |
50 bool GrGLContextInfo::isInitialized() const { | 53 bool GrGLContextInfo::isInitialized() const { |
51 return kNone_GrGLBinding != fBindingInUse; | 54 return kNone_GrGLBinding != fBindingInUse; |
52 } | 55 } |
53 | 56 |
54 void GrGLContextInfo::reset() { | 57 void GrGLContextInfo::reset() { |
55 fBindingInUse = kNone_GrGLBinding; | 58 fBindingInUse = kNone_GrGLBinding; |
56 fGLVersion = GR_GL_VER(0, 0); | 59 fGLVersion = GR_GL_VER(0, 0); |
57 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); | 60 fGLSLGeneration = static_cast<GrGLSLGeneration>(0); |
58 fVendor = kOther_GrGLVendor; | 61 fVendor = kOther_GrGLVendor; |
| 62 fRenderer = kOther_GrGLRenderer; |
59 fIsMesa = false; | 63 fIsMesa = false; |
60 fExtensions.reset(); | 64 fExtensions.reset(); |
61 fGLCaps->reset(); | 65 fGLCaps->reset(); |
62 } | 66 } |
63 | 67 |
64 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
65 GrGLContext::GrGLContext(const GrGLInterface* interface) { | 69 GrGLContext::GrGLContext(const GrGLInterface* interface) { |
66 fInterface = NULL; | 70 fInterface = NULL; |
67 this->initialize(interface); | 71 this->initialize(interface); |
68 } | 72 } |
(...skipping 15 matching lines...) Expand all Loading... |
84 } | 88 } |
85 | 89 |
86 bool GrGLContext::initialize(const GrGLInterface* interface) { | 90 bool GrGLContext::initialize(const GrGLInterface* interface) { |
87 if (fInfo.initialize(interface)) { | 91 if (fInfo.initialize(interface)) { |
88 fInterface = interface; | 92 fInterface = interface; |
89 interface->ref(); | 93 interface->ref(); |
90 return true; | 94 return true; |
91 } | 95 } |
92 return false; | 96 return false; |
93 } | 97 } |
OLD | NEW |