blob: 1d0a01fc8725c0400eae99d95e4c3b821c97e29f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrGLContext.h"
////////////////////////////////////////////////////////////////////////////////
GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) {
fBindingInUse = ctxInfo.fBindingInUse;
fGLVersion = ctxInfo.fGLVersion;
fGLSLGeneration = ctxInfo.fGLSLGeneration;
fVendor = ctxInfo.fVendor;
fExtensions = ctxInfo.fExtensions;
fIsMesa = ctxInfo.fIsMesa;
*fGLCaps = *ctxInfo.fGLCaps.get();
return *this;
}
bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
this->reset();
// We haven't validated the GrGLInterface yet, so check for GetString
// function pointer
if (interface->fGetString) {
const GrGLubyte* verUByte;
GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION));
const char* ver = reinterpret_cast<const char*>(verUByte);
GrGLBinding binding = GrGLGetBindingInUseFromString(ver);
if (0 != binding && interface->validate(binding) && fExtensions.init(binding, interface)) {
fBindingInUse = binding;
fGLVersion = GrGLGetVersionFromString(ver);
fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface);
fVendor = GrGLGetVendor(interface);
fIsMesa = GrGLIsMesaFromVersionString(ver);
fGLCaps->init(*this, interface);
return true;
}
}
return false;
}
bool GrGLContextInfo::isInitialized() const {
return kNone_GrGLBinding != fBindingInUse;
}
void GrGLContextInfo::reset() {
fBindingInUse = kNone_GrGLBinding;
fGLVersion = GR_GL_VER(0, 0);
fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
fVendor = kOther_GrGLVendor;
fIsMesa = false;
fExtensions.reset();
fGLCaps->reset();
}
////////////////////////////////////////////////////////////////////////////////
GrGLContext::GrGLContext(const GrGLInterface* interface) {
fInterface = NULL;
this->initialize(interface);
}
GrGLContext::GrGLContext(const GrGLContext& ctx) {
fInterface = NULL;
*this = ctx;
}
GrGLContext& GrGLContext::operator = (const GrGLContext& ctx) {
GrSafeAssign(fInterface, ctx.fInterface);
fInfo = ctx.fInfo;
return *this;
}
void GrGLContext::reset() {
GrSafeSetNull(fInterface);
fInfo.reset();
}
bool GrGLContext::initialize(const GrGLInterface* interface) {
if (fInfo.initialize(interface)) {
fInterface = interface;
interface->ref();
return true;
}
return false;
}
|