blob: 172cd8b86402a597659da979c1579a005afb0fbb (
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrGLContext_DEFINED
#define GrGLContext_DEFINED
#include "gl/GrGLExtensions.h"
#include "gl/GrGLInterface.h"
#include "GrGLCaps.h"
#include "GrGLSL.h"
#include "GrGLUtil.h"
#include "SkString.h"
/**
* Encapsulates information about an OpenGL context including the OpenGL
* version, the GrGLBinding type of the context, and GLSL version.
*/
class GrGLContextInfo {
public:
/**
* Default constructor
*/
GrGLContextInfo() {
fGLCaps.reset(SkNEW(GrGLCaps));
this->reset();
}
/**
* Copies a GrGLContextInfo
*/
GrGLContextInfo& operator= (const GrGLContextInfo& ctxInfo);
/**
* Initializes a GrGLContextInfo from a GrGLInterface and the currently
* bound OpenGL context accessible by the GrGLInterface.
*/
bool initialize(const GrGLInterface* interface);
bool isInitialized() const;
GrGLBinding binding() const { return fBindingInUse; }
GrGLVersion version() const { return fGLVersion; }
GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
GrGLVendor vendor() const { return fVendor; }
const GrGLCaps* caps() const { return fGLCaps.get(); }
GrGLCaps* caps() { return fGLCaps; }
const GrGLExtensions& extensions() const { return fExtensions; }
/**
* Shortcut for extensions().has(ext);
*/
bool hasExtension(const char* ext) const {
if (!this->isInitialized()) {
return false;
}
return fExtensions.has(ext);
}
/**
* Reset the information
*/
void reset();
private:
GrGLBinding fBindingInUse;
GrGLVersion fGLVersion;
GrGLSLGeneration fGLSLGeneration;
GrGLVendor fVendor;
GrGLExtensions fExtensions;
SkAutoTUnref<GrGLCaps> fGLCaps;
};
/**
* Encapsulates the GrGLInterface used to make GL calls plus information
* about the context (via GrGLContextInfo).
*/
class GrGLContext {
public:
/**
* Default constructor
*/
GrGLContext() { this->reset(); }
/**
* Creates a GrGLContext from a GrGLInterface and the currently
* bound OpenGL context accessible by the GrGLInterface.
*/
explicit GrGLContext(const GrGLInterface* interface);
/**
* Copies a GrGLContext
*/
GrGLContext(const GrGLContext& ctx);
~GrGLContext() { GrSafeUnref(fInterface); }
/**
* Copies a GrGLContext
*/
GrGLContext& operator= (const GrGLContext& ctx);
/**
* Initializes a GrGLContext from a GrGLInterface and the currently
* bound OpenGL context accessible by the GrGLInterface.
*/
bool initialize(const GrGLInterface* interface);
bool isInitialized() const { return fInfo.isInitialized(); }
const GrGLInterface* interface() const { return fInterface; }
const GrGLContextInfo& info() const { return fInfo; }
GrGLContextInfo& info() { return fInfo; }
private:
void reset();
const GrGLInterface* fInterface;
GrGLContextInfo fInfo;
};
#endif
|