Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: src/gpu/gl/GrGLCreateNullInterface.cpp

Issue 470993002: Make null gpu context threadsafe(r) and make sure buffer objects are destroyed. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cast back to int when used as tdarray index Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 8
9 #include "gl/GrGLInterface.h" 9 #include "gl/GrGLInterface.h"
10 #include "GrGLDefines.h" 10 #include "GrGLDefines.h"
11 #include "SkTDArray.h" 11 #include "SkTDArray.h"
12 #include "GrGLNoOpInterface.h" 12 #include "GrGLNoOpInterface.h"
13 #include "SkTLS.h"
13 14
14 // Functions not declared in GrGLBogusInterface.h (not common with the Debug GL interface). 15 class BufferObj {
16 public:
17 SK_DECLARE_INST_COUNT_ROOT(BufferObj);
15 18
16 namespace { // added to suppress 'no previous prototype' warning 19 BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) {
17
18 class GrBufferObj {
19 public:
20 GrBufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) {
21 } 20 }
22 ~GrBufferObj() { SkDELETE_ARRAY(fDataPtr); } 21 ~BufferObj() { SkDELETE_ARRAY(fDataPtr); }
23 22
24 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) { 23 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) {
25 if (NULL != fDataPtr) { 24 if (NULL != fDataPtr) {
26 SkASSERT(0 != fSize); 25 SkASSERT(0 != fSize);
27 SkDELETE_ARRAY(fDataPtr); 26 SkDELETE_ARRAY(fDataPtr);
28 } 27 }
29 28
30 fSize = size; 29 fSize = size;
31 fDataPtr = SkNEW_ARRAY(char, size); 30 fDataPtr = SkNEW_ARRAY(char, size);
32 } 31 }
33 32
34 GrGLuint id() const { return fID; } 33 GrGLuint id() const { return fID; }
35 GrGLchar* dataPtr() { return fDataPtr; } 34 GrGLchar* dataPtr() { return fDataPtr; }
36 GrGLsizeiptr size() const { return fSize; } 35 GrGLsizeiptr size() const { return fSize; }
37 36
38 void setMapped(bool mapped) { fMapped = mapped; } 37 void setMapped(bool mapped) { fMapped = mapped; }
39 bool mapped() const { return fMapped; } 38 bool mapped() const { return fMapped; }
40 39
41 private: 40 private:
42 GrGLuint fID; 41 GrGLuint fID;
43 GrGLchar* fDataPtr; 42 GrGLchar* fDataPtr;
44 GrGLsizeiptr fSize; // size in bytes 43 GrGLsizeiptr fSize; // size in bytes
45 bool fMapped; 44 bool fMapped;
46 }; 45 };
47 46
48 // In debug builds we do asserts that ensure we agree with GL about when a buffe r 47 // This class maintains a sparsely populated array of buffer pointers.
49 // is mapped. 48 class BufferManager {
50 static SkTDArray<GrBufferObj*> gBuffers; // slot 0 is reserved for head of free list 49 public:
51 static GrGLuint gCurrArrayBuffer; 50 SK_DECLARE_INST_COUNT_ROOT(BufferManager);
52 static GrGLuint gCurrElementArrayBuffer;
53 51
54 static GrBufferObj* look_up(GrGLuint id) { 52 BufferManager() : fFreeListHead(kFreeListEnd) {}
55 GrBufferObj* buffer = gBuffers[id];
56 SkASSERT(NULL != buffer && buffer->id() == id);
57 return buffer;
58 }
59 53
60 static GrBufferObj* create_buffer() { 54 ~BufferManager() {
61 if (0 == gBuffers.count()) { 55 // NULL out the entries that are really free list links rather than ptrs before deleting.
62 // slot zero is reserved for the head of the free list 56 intptr_t curr = fFreeListHead;
63 *gBuffers.append() = NULL; 57 while (kFreeListEnd != curr) {
58 intptr_t next = reinterpret_cast<intptr_t>(fBuffers[SkToS32(curr)]);
59 fBuffers[SkToS32(curr)] = NULL;
60 curr = next;
61 }
62
63 fBuffers.deleteAll();
64 } 64 }
65 65
66 GrGLuint id; 66 BufferObj* lookUp(GrGLuint id) {
67 GrBufferObj* buffer; 67 BufferObj* buffer = fBuffers[id];
68 68 SkASSERT(NULL != buffer && buffer->id() == id);
69 if (NULL == gBuffers[0]) { 69 return buffer;
70 // no free slots - create a new one
71 id = gBuffers.count();
72 buffer = SkNEW_ARGS(GrBufferObj, (id));
73 gBuffers.append(1, &buffer);
74 } else {
75 // recycle a slot from the free list
76 id = SkTCast<GrGLuint>(gBuffers[0]);
77 gBuffers[0] = gBuffers[id];
78
79 buffer = SkNEW_ARGS(GrBufferObj, (id));
80 gBuffers[id] = buffer;
81 } 70 }
82 71
83 return buffer; 72 BufferObj* create() {
84 } 73 GrGLuint id;
74 BufferObj* buffer;
85 75
86 static void delete_buffer(GrBufferObj* buffer) { 76 if (kFreeListEnd == fFreeListHead) {
87 SkASSERT(gBuffers.count() > 0); 77 // no free slots - create a new one
78 id = fBuffers.count();
79 buffer = SkNEW_ARGS(BufferObj, (id));
80 *fBuffers.append() = buffer;
81 } else {
82 // grab the head of the free list and advance the head to the next f ree slot.
83 id = static_cast<GrGLuint>(fFreeListHead);
84 fFreeListHead = reinterpret_cast<intptr_t>(fBuffers[id]);
88 85
89 GrGLuint id = buffer->id(); 86 buffer = SkNEW_ARGS(BufferObj, (id));
90 SkDELETE(buffer); 87 fBuffers[id] = buffer;
88 }
91 89
92 // Add this slot to the free list 90 return buffer;
93 gBuffers[id] = gBuffers[0]; 91 }
94 gBuffers[0] = SkTCast<GrBufferObj*>((const void*)(intptr_t)id); 92
95 } 93 void free(BufferObj* buffer) {
94 SkASSERT(fBuffers.count() > 0);
95
96 GrGLuint id = buffer->id();
97 SkDELETE(buffer);
98
99 fBuffers[id] = reinterpret_cast<BufferObj*>(fFreeListHead);
100 fFreeListHead = id;
101 }
102
103 private:
104 static const intptr_t kFreeListEnd = -1;
105 // Index of the first entry of fBuffers in the free list. Free slots in fBuf fers are indices to
106 // the next free slot. The last free slot has a value of kFreeListEnd.
107 intptr_t fFreeListHead;
108 SkTDArray<BufferObj*> fBuffers;
109 };
110
111 /**
112 * The global-to-thread state object for the null interface. All null interfaces on the
113 * same thread currently share one of these. This means two null contexts on the same thread
114 * can interfere with each other. It may make sense to more integrate this into SkNullGLContext
115 * and use it's makeCurrent mechanism.
116 */
117 struct ThreadContext {
118 public:
119 SK_DECLARE_INST_COUNT_ROOT(ThreadContext);
120
121 BufferManager fBufferManager;
122 GrGLuint fCurrArrayBuffer;
123 GrGLuint fCurrElementArrayBuffer;
124 GrGLuint fCurrProgramID;
125 GrGLuint fCurrShaderID;
126
127 static ThreadContext* Get() {
128 return reinterpret_cast<ThreadContext*>(SkTLS::Get(Create, Delete));
129 }
130
131 ThreadContext()
132 : fCurrArrayBuffer(0)
133 , fCurrElementArrayBuffer(0)
134 , fCurrProgramID(0)
135 , fCurrShaderID(0) {}
136
137 private:
138 static void* Create() { return SkNEW(ThreadContext ); }
139 static void Delete(void* context) { SkDELETE(reinterpret_cast<ThreadContext *>(context)); }
140 };
141
142 // Functions not declared in GrGLBogusInterface.h (not common with the Debug GL interface).
143
144 namespace { // added to suppress 'no previous prototype' warning
96 145
97 GrGLvoid GR_GL_FUNCTION_TYPE nullGLActiveTexture(GrGLenum texture) {} 146 GrGLvoid GR_GL_FUNCTION_TYPE nullGLActiveTexture(GrGLenum texture) {}
98 GrGLvoid GR_GL_FUNCTION_TYPE nullGLAttachShader(GrGLuint program, GrGLuint shade r) {} 147 GrGLvoid GR_GL_FUNCTION_TYPE nullGLAttachShader(GrGLuint program, GrGLuint shade r) {}
99 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBeginQuery(GrGLenum target, GrGLuint id) {} 148 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBeginQuery(GrGLenum target, GrGLuint id) {}
100 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindAttribLocation(GrGLuint program, GrGLuint index, const char* name) {} 149 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindAttribLocation(GrGLuint program, GrGLuint index, const char* name) {}
101 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindTexture(GrGLenum target, GrGLuint texture ) {} 150 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindTexture(GrGLenum target, GrGLuint texture ) {}
102 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindVertexArray(GrGLuint id) {} 151 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindVertexArray(GrGLuint id) {}
103 152
104 GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenBuffers(GrGLsizei n, GrGLuint* ids) { 153 GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenBuffers(GrGLsizei n, GrGLuint* ids) {
105 154 ThreadContext* ctx = ThreadContext::Get();
106 for (int i = 0; i < n; ++i) { 155 for (int i = 0; i < n; ++i) {
107 GrBufferObj* buffer = create_buffer(); 156 BufferObj* buffer = ctx->fBufferManager.create();
108 ids[i] = buffer->id(); 157 ids[i] = buffer->id();
109 } 158 }
110 } 159 }
111 160
112 GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenerateMipmap(GrGLenum target) {} 161 GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenerateMipmap(GrGLenum target) {}
113 162
114 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferData(GrGLenum target, 163 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferData(GrGLenum target,
115 GrGLsizeiptr size, 164 GrGLsizeiptr size,
116 const GrGLvoid* data, 165 const GrGLvoid* data,
117 GrGLenum usage) { 166 GrGLenum usage) {
167 ThreadContext* ctx = ThreadContext::Get();
118 GrGLuint id = 0; 168 GrGLuint id = 0;
119 169
120 switch (target) { 170 switch (target) {
121 case GR_GL_ARRAY_BUFFER: 171 case GR_GL_ARRAY_BUFFER:
122 id = gCurrArrayBuffer; 172 id = ctx->fCurrArrayBuffer;
123 break; 173 break;
124 case GR_GL_ELEMENT_ARRAY_BUFFER: 174 case GR_GL_ELEMENT_ARRAY_BUFFER:
125 id = gCurrElementArrayBuffer; 175 id = ctx->fCurrElementArrayBuffer;
126 break; 176 break;
127 default: 177 default:
128 SkFAIL("Unexpected target to nullGLBufferData"); 178 SkFAIL("Unexpected target to nullGLBufferData");
129 break; 179 break;
130 } 180 }
131 181
132 if (id > 0) { 182 if (id > 0) {
133 GrBufferObj* buffer = look_up(id); 183 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
134 buffer->allocate(size, (const GrGLchar*) data); 184 buffer->allocate(size, (const GrGLchar*) data);
135 } 185 }
136 } 186 }
137 187
138 GrGLvoid GR_GL_FUNCTION_TYPE nullGLPixelStorei(GrGLenum pname, GrGLint param) {} 188 GrGLvoid GR_GL_FUNCTION_TYPE nullGLPixelStorei(GrGLenum pname, GrGLint param) {}
139 GrGLvoid GR_GL_FUNCTION_TYPE nullGLReadPixels(GrGLint x, GrGLint y, GrGLsizei wi dth, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels) {} 189 GrGLvoid GR_GL_FUNCTION_TYPE nullGLReadPixels(GrGLint x, GrGLint y, GrGLsizei wi dth, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels) {}
140 GrGLvoid GR_GL_FUNCTION_TYPE nullGLUseProgram(GrGLuint program) {} 190 GrGLvoid GR_GL_FUNCTION_TYPE nullGLUseProgram(GrGLuint program) {}
141 GrGLvoid GR_GL_FUNCTION_TYPE nullGLViewport(GrGLint x, GrGLint y, GrGLsizei widt h, GrGLsizei height) {} 191 GrGLvoid GR_GL_FUNCTION_TYPE nullGLViewport(GrGLint x, GrGLint y, GrGLsizei widt h, GrGLsizei height) {}
142 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindFramebuffer(GrGLenum target, GrGLuint fra mebuffer) {} 192 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindFramebuffer(GrGLenum target, GrGLuint fra mebuffer) {}
143 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindRenderbuffer(GrGLenum target, GrGLuint re nderbuffer) {} 193 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindRenderbuffer(GrGLenum target, GrGLuint re nderbuffer) {}
144 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteFramebuffers(GrGLsizei n, const GrGLuin t *framebuffers) {} 194 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteFramebuffers(GrGLsizei n, const GrGLuin t *framebuffers) {}
145 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteRenderbuffers(GrGLsizei n, const GrGLui nt *renderbuffers) {} 195 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteRenderbuffers(GrGLsizei n, const GrGLui nt *renderbuffers) {}
146 GrGLvoid GR_GL_FUNCTION_TYPE nullGLFramebufferRenderbuffer(GrGLenum target, GrGL enum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer) {} 196 GrGLvoid GR_GL_FUNCTION_TYPE nullGLFramebufferRenderbuffer(GrGLenum target, GrGL enum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer) {}
147 GrGLvoid GR_GL_FUNCTION_TYPE nullGLFramebufferTexture2D(GrGLenum target, GrGLenu m attachment, GrGLenum textarget, GrGLuint texture, GrGLint level) {} 197 GrGLvoid GR_GL_FUNCTION_TYPE nullGLFramebufferTexture2D(GrGLenum target, GrGLenu m attachment, GrGLenum textarget, GrGLuint texture, GrGLint level) {}
148 198
149 GrGLuint GR_GL_FUNCTION_TYPE nullGLCreateProgram() { 199 GrGLuint GR_GL_FUNCTION_TYPE nullGLCreateProgram() {
150 static GrGLuint gCurrID = 0; 200 return ++ThreadContext::Get()->fCurrProgramID;
151 return ++gCurrID;
152 } 201 }
153 202
154 GrGLuint GR_GL_FUNCTION_TYPE nullGLCreateShader(GrGLenum type) { 203 GrGLuint GR_GL_FUNCTION_TYPE nullGLCreateShader(GrGLenum type) {
155 static GrGLuint gCurrID = 0; 204 return ++ThreadContext::Get()->fCurrShaderID;
156 return ++gCurrID;
157 } 205 }
158 206
159 // same delete used for shaders and programs 207 // same delete used for shaders and programs
160 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDelete(GrGLuint program) { 208 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDelete(GrGLuint program) {
161 } 209 }
162 210
163 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindBuffer(GrGLenum target, GrGLuint buffer) { 211 GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindBuffer(GrGLenum target, GrGLuint buffer) {
212 ThreadContext* ctx = ThreadContext::Get();
164 switch (target) { 213 switch (target) {
165 case GR_GL_ARRAY_BUFFER: 214 case GR_GL_ARRAY_BUFFER:
166 gCurrArrayBuffer = buffer; 215 ctx->fCurrArrayBuffer = buffer;
167 break; 216 break;
168 case GR_GL_ELEMENT_ARRAY_BUFFER: 217 case GR_GL_ELEMENT_ARRAY_BUFFER:
169 gCurrElementArrayBuffer = buffer; 218 ctx->fCurrElementArrayBuffer = buffer;
170 break; 219 break;
171 } 220 }
172 } 221 }
173 222
174 // deleting a bound buffer has the side effect of binding 0 223 // deleting a bound buffer has the side effect of binding 0
175 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteBuffers(GrGLsizei n, const GrGLuint* id s) { 224 GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteBuffers(GrGLsizei n, const GrGLuint* id s) {
225 ThreadContext* ctx = ThreadContext::Get();
176 for (int i = 0; i < n; ++i) { 226 for (int i = 0; i < n; ++i) {
177 if (ids[i] == gCurrArrayBuffer) { 227 if (ids[i] == ctx->fCurrArrayBuffer) {
178 gCurrArrayBuffer = 0; 228 ctx->fCurrArrayBuffer = 0;
179 } 229 }
180 if (ids[i] == gCurrElementArrayBuffer) { 230 if (ids[i] == ctx->fCurrElementArrayBuffer) {
181 gCurrElementArrayBuffer = 0; 231 ctx->fCurrElementArrayBuffer = 0;
182 } 232 }
183 233
184 GrBufferObj* buffer = look_up(ids[i]); 234 BufferObj* buffer = ctx->fBufferManager.lookUp(ids[i]);
185 delete_buffer(buffer); 235 ctx->fBufferManager.free(buffer);
186 } 236 }
187 } 237 }
188 238
189 GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBufferRange(GrGLenum target, GrGLintptr o ffset, 239 GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBufferRange(GrGLenum target, GrGLintptr o ffset,
190 GrGLsizeiptr length, GrGLbitf ield access) { 240 GrGLsizeiptr length, GrGLbitf ield access) {
241 ThreadContext* ctx = ThreadContext::Get();
191 GrGLuint id = 0; 242 GrGLuint id = 0;
192 switch (target) { 243 switch (target) {
193 case GR_GL_ARRAY_BUFFER: 244 case GR_GL_ARRAY_BUFFER:
194 id = gCurrArrayBuffer; 245 id = ctx->fCurrArrayBuffer;
195 break; 246 break;
196 case GR_GL_ELEMENT_ARRAY_BUFFER: 247 case GR_GL_ELEMENT_ARRAY_BUFFER:
197 id = gCurrElementArrayBuffer; 248 id = ctx->fCurrElementArrayBuffer;
198 break; 249 break;
199 } 250 }
200 251
201 if (id > 0) { 252 if (id > 0) {
202 // We just ignore the offset and length here. 253 // We just ignore the offset and length here.
203 GrBufferObj* buffer = look_up(id); 254 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
204 SkASSERT(!buffer->mapped()); 255 SkASSERT(!buffer->mapped());
205 buffer->setMapped(true); 256 buffer->setMapped(true);
206 return buffer->dataPtr(); 257 return buffer->dataPtr();
207 } 258 }
208 return NULL; 259 return NULL;
209 } 260 }
210 261
211 GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBuffer(GrGLenum target, GrGLenum access) { 262 GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBuffer(GrGLenum target, GrGLenum access) {
263 ThreadContext* ctx = ThreadContext::Get();
212 GrGLuint id = 0; 264 GrGLuint id = 0;
213 switch (target) { 265 switch (target) {
214 case GR_GL_ARRAY_BUFFER: 266 case GR_GL_ARRAY_BUFFER:
215 id = gCurrArrayBuffer; 267 id = ctx->fCurrArrayBuffer;
216 break; 268 break;
217 case GR_GL_ELEMENT_ARRAY_BUFFER: 269 case GR_GL_ELEMENT_ARRAY_BUFFER:
218 id = gCurrElementArrayBuffer; 270 id = ctx->fCurrElementArrayBuffer;
219 break; 271 break;
220 } 272 }
221 273
222 if (id > 0) { 274 if (id > 0) {
223 GrBufferObj* buffer = look_up(id); 275 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
224 SkASSERT(!buffer->mapped()); 276 SkASSERT(!buffer->mapped());
225 buffer->setMapped(true); 277 buffer->setMapped(true);
226 return buffer->dataPtr(); 278 return buffer->dataPtr();
227 } 279 }
228 280
229 SkASSERT(false); 281 SkASSERT(false);
230 return NULL; // no buffer bound to target 282 return NULL; // no buffer bound to target
231 } 283 }
232 284
233 GrGLvoid GR_GL_FUNCTION_TYPE nullGLFlushMappedBufferRange(GrGLenum target, 285 GrGLvoid GR_GL_FUNCTION_TYPE nullGLFlushMappedBufferRange(GrGLenum target,
234 GrGLintptr offset, 286 GrGLintptr offset,
235 GrGLsizeiptr length) { } 287 GrGLsizeiptr length) { }
236 288
237 289
238 GrGLboolean GR_GL_FUNCTION_TYPE nullGLUnmapBuffer(GrGLenum target) { 290 GrGLboolean GR_GL_FUNCTION_TYPE nullGLUnmapBuffer(GrGLenum target) {
291 ThreadContext* ctx = ThreadContext::Get();
239 GrGLuint id = 0; 292 GrGLuint id = 0;
240 switch (target) { 293 switch (target) {
241 case GR_GL_ARRAY_BUFFER: 294 case GR_GL_ARRAY_BUFFER:
242 id = gCurrArrayBuffer; 295 id = ctx->fCurrArrayBuffer;
243 break; 296 break;
244 case GR_GL_ELEMENT_ARRAY_BUFFER: 297 case GR_GL_ELEMENT_ARRAY_BUFFER:
245 id = gCurrElementArrayBuffer; 298 id = ctx->fCurrElementArrayBuffer;
246 break; 299 break;
247 } 300 }
248 if (id > 0) { 301 if (id > 0) {
249 GrBufferObj* buffer = look_up(id); 302 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
250 SkASSERT(buffer->mapped()); 303 SkASSERT(buffer->mapped());
251 buffer->setMapped(false); 304 buffer->setMapped(false);
252 return GR_GL_TRUE; 305 return GR_GL_TRUE;
253 } 306 }
254 307
255 GrAlwaysAssert(false); 308 GrAlwaysAssert(false);
256 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION; 309 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
257 } 310 }
258 311
259 GrGLvoid GR_GL_FUNCTION_TYPE nullGLGetBufferParameteriv(GrGLenum target, GrGLenu m pname, GrGLint* params) { 312 GrGLvoid GR_GL_FUNCTION_TYPE nullGLGetBufferParameteriv(GrGLenum target, GrGLenu m pname, GrGLint* params) {
313 ThreadContext* ctx = ThreadContext::Get();
260 switch (pname) { 314 switch (pname) {
261 case GR_GL_BUFFER_MAPPED: { 315 case GR_GL_BUFFER_MAPPED: {
262 *params = GR_GL_FALSE; 316 *params = GR_GL_FALSE;
263 GrGLuint id = 0; 317 GrGLuint id = 0;
264 switch (target) { 318 switch (target) {
265 case GR_GL_ARRAY_BUFFER: 319 case GR_GL_ARRAY_BUFFER:
266 id = gCurrArrayBuffer; 320 id = ctx->fCurrArrayBuffer;
267 break; 321 break;
268 case GR_GL_ELEMENT_ARRAY_BUFFER: 322 case GR_GL_ELEMENT_ARRAY_BUFFER:
269 id = gCurrElementArrayBuffer; 323 id = ctx->fCurrElementArrayBuffer;
270 break; 324 break;
271 } 325 }
272 if (id > 0) { 326 if (id > 0) {
273 GrBufferObj* buffer = look_up(id); 327 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
274 if (buffer->mapped()) { 328 if (buffer->mapped()) {
275 *params = GR_GL_TRUE; 329 *params = GR_GL_TRUE;
276 } 330 }
277 } 331 }
278 break; } 332 break; }
279 default: 333 default:
280 SkFAIL("Unexpected pname to GetBufferParamateriv"); 334 SkFAIL("Unexpected pname to GetBufferParamateriv");
281 break; 335 break;
282 } 336 }
283 }; 337 };
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 functions->fBlitFramebuffer = noOpGLBlitFramebuffer; 473 functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
420 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuf fer; 474 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuf fer;
421 functions->fMatrixLoadf = noOpGLMatrixLoadf; 475 functions->fMatrixLoadf = noOpGLMatrixLoadf;
422 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity; 476 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
423 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed; 477 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed;
424 478
425 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio ns->fGetStringi, 479 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio ns->fGetStringi,
426 functions->fGetIntegerv); 480 functions->fGetIntegerv);
427 return interface; 481 return interface;
428 } 482 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698