blob: 6275ced6fcfc6eb78d768da4739bff0aa59a3936 [file] [log] [blame]
bsalomon@google.com74913722011-10-27 20:44:19 +00001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
tomhudson@google.com6bf38b52012-02-14 15:11:59 +00009#include "gl/GrGLInterface.h"
bsalomon@google.com91bcc942012-05-07 17:28:41 +000010#include "GrGLDefines.h"
bsalomon@google.com21cbec42013-01-07 17:23:00 +000011#include "SkTDArray.h"
bsalomon@google.com8f943612013-02-26 14:34:43 +000012#include "GrGLNoOpInterface.h"
bsalomon776d3552014-08-14 08:13:27 -070013#include "SkTLS.h"
bsalomon@google.com8f943612013-02-26 14:34:43 +000014
bsalomon776d3552014-08-14 08:13:27 -070015class BufferObj {
robertphillips@google.comd6543e52013-07-18 17:39:14 +000016public:
bsalomon776d3552014-08-14 08:13:27 -070017 SK_DECLARE_INST_COUNT_ROOT(BufferObj);
18
19 BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) {
robertphillips@google.comd6543e52013-07-18 17:39:14 +000020 }
bsalomon776d3552014-08-14 08:13:27 -070021 ~BufferObj() { SkDELETE_ARRAY(fDataPtr); }
robertphillips@google.comd6543e52013-07-18 17:39:14 +000022
robertphillips@google.comae6b7772013-07-18 18:07:39 +000023 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) {
bsalomon49f085d2014-09-05 13:34:00 -070024 if (fDataPtr) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000025 SkASSERT(0 != fSize);
robertphillips@google.comd6543e52013-07-18 17:39:14 +000026 SkDELETE_ARRAY(fDataPtr);
27 }
28
29 fSize = size;
30 fDataPtr = SkNEW_ARRAY(char, size);
31 }
32
33 GrGLuint id() const { return fID; }
34 GrGLchar* dataPtr() { return fDataPtr; }
robertphillips@google.comae6b7772013-07-18 18:07:39 +000035 GrGLsizeiptr size() const { return fSize; }
robertphillips@google.comd6543e52013-07-18 17:39:14 +000036
37 void setMapped(bool mapped) { fMapped = mapped; }
38 bool mapped() const { return fMapped; }
39
40private:
41 GrGLuint fID;
42 GrGLchar* fDataPtr;
robertphillips@google.comae6b7772013-07-18 18:07:39 +000043 GrGLsizeiptr fSize; // size in bytes
robertphillips@google.comd6543e52013-07-18 17:39:14 +000044 bool fMapped;
45};
46
bsalomon776d3552014-08-14 08:13:27 -070047// This class maintains a sparsely populated array of buffer pointers.
48class BufferManager {
49public:
50 SK_DECLARE_INST_COUNT_ROOT(BufferManager);
robertphillips@google.comd6543e52013-07-18 17:39:14 +000051
bsalomon776d3552014-08-14 08:13:27 -070052 BufferManager() : fFreeListHead(kFreeListEnd) {}
robertphillips@google.comd6543e52013-07-18 17:39:14 +000053
bsalomon776d3552014-08-14 08:13:27 -070054 ~BufferManager() {
55 // NULL out the entries that are really free list links rather than ptrs before deleting.
56 intptr_t curr = fFreeListHead;
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();
robertphillips@google.comd6543e52013-07-18 17:39:14 +000064 }
65
bsalomon776d3552014-08-14 08:13:27 -070066 BufferObj* lookUp(GrGLuint id) {
67 BufferObj* buffer = fBuffers[id];
bsalomon49f085d2014-09-05 13:34:00 -070068 SkASSERT(buffer && buffer->id() == id);
bsalomon776d3552014-08-14 08:13:27 -070069 return buffer;
robertphillips@google.comd6543e52013-07-18 17:39:14 +000070 }
71
bsalomon776d3552014-08-14 08:13:27 -070072 BufferObj* create() {
73 GrGLuint id;
74 BufferObj* buffer;
robertphillips@google.comd6543e52013-07-18 17:39:14 +000075
bsalomon776d3552014-08-14 08:13:27 -070076 if (kFreeListEnd == fFreeListHead) {
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 free slot.
83 id = static_cast<GrGLuint>(fFreeListHead);
84 fFreeListHead = reinterpret_cast<intptr_t>(fBuffers[id]);
robertphillips@google.comd6543e52013-07-18 17:39:14 +000085
bsalomon776d3552014-08-14 08:13:27 -070086 buffer = SkNEW_ARGS(BufferObj, (id));
87 fBuffers[id] = buffer;
88 }
robertphillips@google.comd6543e52013-07-18 17:39:14 +000089
bsalomon776d3552014-08-14 08:13:27 -070090 return buffer;
91 }
92
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
103private:
104 static const intptr_t kFreeListEnd = -1;
105 // Index of the first entry of fBuffers in the free list. Free slots in fBuffers 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 */
117struct ThreadContext {
118public:
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
137private:
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
144namespace { // added to suppress 'no previous prototype' warning
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000145
bsalomon@google.com74913722011-10-27 20:44:19 +0000146GrGLvoid GR_GL_FUNCTION_TYPE nullGLActiveTexture(GrGLenum texture) {}
147GrGLvoid GR_GL_FUNCTION_TYPE nullGLAttachShader(GrGLuint program, GrGLuint shader) {}
148GrGLvoid GR_GL_FUNCTION_TYPE nullGLBeginQuery(GrGLenum target, GrGLuint id) {}
149GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindAttribLocation(GrGLuint program, GrGLuint index, const char* name) {}
150GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindTexture(GrGLenum target, GrGLuint texture) {}
bsalomon@google.comecd84842013-03-01 15:36:02 +0000151GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindVertexArray(GrGLuint id) {}
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000152
153GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenBuffers(GrGLsizei n, GrGLuint* ids) {
bsalomon776d3552014-08-14 08:13:27 -0700154 ThreadContext* ctx = ThreadContext::Get();
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000155 for (int i = 0; i < n; ++i) {
bsalomon776d3552014-08-14 08:13:27 -0700156 BufferObj* buffer = ctx->fBufferManager.create();
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000157 ids[i] = buffer->id();
158 }
159}
160
commit-bot@chromium.orgcffff792013-07-26 16:36:04 +0000161GrGLvoid GR_GL_FUNCTION_TYPE nullGLGenerateMipmap(GrGLenum target) {}
162
skia.committer@gmail.coma7991982013-07-19 07:00:57 +0000163GrGLvoid GR_GL_FUNCTION_TYPE nullGLBufferData(GrGLenum target,
164 GrGLsizeiptr size,
165 const GrGLvoid* data,
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000166 GrGLenum usage) {
bsalomon776d3552014-08-14 08:13:27 -0700167 ThreadContext* ctx = ThreadContext::Get();
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000168 GrGLuint id = 0;
169
170 switch (target) {
171 case GR_GL_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700172 id = ctx->fCurrArrayBuffer;
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000173 break;
174 case GR_GL_ELEMENT_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700175 id = ctx->fCurrElementArrayBuffer;
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000176 break;
177 default:
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000178 SkFAIL("Unexpected target to nullGLBufferData");
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000179 break;
180 }
181
182 if (id > 0) {
bsalomon776d3552014-08-14 08:13:27 -0700183 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000184 buffer->allocate(size, (const GrGLchar*) data);
185 }
186}
187
bsalomon@google.com74913722011-10-27 20:44:19 +0000188GrGLvoid GR_GL_FUNCTION_TYPE nullGLPixelStorei(GrGLenum pname, GrGLint param) {}
bsalomon@google.com74913722011-10-27 20:44:19 +0000189GrGLvoid GR_GL_FUNCTION_TYPE nullGLReadPixels(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels) {}
bsalomon@google.com74913722011-10-27 20:44:19 +0000190GrGLvoid GR_GL_FUNCTION_TYPE nullGLUseProgram(GrGLuint program) {}
bsalomon@google.com74913722011-10-27 20:44:19 +0000191GrGLvoid GR_GL_FUNCTION_TYPE nullGLViewport(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height) {}
192GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindFramebuffer(GrGLenum target, GrGLuint framebuffer) {}
193GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindRenderbuffer(GrGLenum target, GrGLuint renderbuffer) {}
194GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteFramebuffers(GrGLsizei n, const GrGLuint *framebuffers) {}
195GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteRenderbuffers(GrGLsizei n, const GrGLuint *renderbuffers) {}
196GrGLvoid GR_GL_FUNCTION_TYPE nullGLFramebufferRenderbuffer(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer) {}
197GrGLvoid GR_GL_FUNCTION_TYPE nullGLFramebufferTexture2D(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level) {}
bsalomon@google.com74913722011-10-27 20:44:19 +0000198
199GrGLuint GR_GL_FUNCTION_TYPE nullGLCreateProgram() {
bsalomon776d3552014-08-14 08:13:27 -0700200 return ++ThreadContext::Get()->fCurrProgramID;
bsalomon@google.com74913722011-10-27 20:44:19 +0000201}
202
203GrGLuint GR_GL_FUNCTION_TYPE nullGLCreateShader(GrGLenum type) {
bsalomon776d3552014-08-14 08:13:27 -0700204 return ++ThreadContext::Get()->fCurrShaderID;
bsalomon@google.com74913722011-10-27 20:44:19 +0000205}
206
207// same delete used for shaders and programs
208GrGLvoid GR_GL_FUNCTION_TYPE nullGLDelete(GrGLuint program) {
209}
210
bsalomon@google.com74913722011-10-27 20:44:19 +0000211GrGLvoid GR_GL_FUNCTION_TYPE nullGLBindBuffer(GrGLenum target, GrGLuint buffer) {
bsalomon776d3552014-08-14 08:13:27 -0700212 ThreadContext* ctx = ThreadContext::Get();
bsalomon@google.com74913722011-10-27 20:44:19 +0000213 switch (target) {
214 case GR_GL_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700215 ctx->fCurrArrayBuffer = buffer;
bsalomon@google.com74913722011-10-27 20:44:19 +0000216 break;
217 case GR_GL_ELEMENT_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700218 ctx->fCurrElementArrayBuffer = buffer;
bsalomon@google.com74913722011-10-27 20:44:19 +0000219 break;
220 }
221}
222
223// deleting a bound buffer has the side effect of binding 0
224GrGLvoid GR_GL_FUNCTION_TYPE nullGLDeleteBuffers(GrGLsizei n, const GrGLuint* ids) {
bsalomon776d3552014-08-14 08:13:27 -0700225 ThreadContext* ctx = ThreadContext::Get();
bsalomon@google.com74913722011-10-27 20:44:19 +0000226 for (int i = 0; i < n; ++i) {
bsalomon776d3552014-08-14 08:13:27 -0700227 if (ids[i] == ctx->fCurrArrayBuffer) {
228 ctx->fCurrArrayBuffer = 0;
bsalomon@google.com74913722011-10-27 20:44:19 +0000229 }
bsalomon776d3552014-08-14 08:13:27 -0700230 if (ids[i] == ctx->fCurrElementArrayBuffer) {
231 ctx->fCurrElementArrayBuffer = 0;
bsalomon@google.com74913722011-10-27 20:44:19 +0000232 }
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000233
bsalomon776d3552014-08-14 08:13:27 -0700234 BufferObj* buffer = ctx->fBufferManager.lookUp(ids[i]);
235 ctx->fBufferManager.free(buffer);
bsalomon@google.com74913722011-10-27 20:44:19 +0000236 }
237}
238
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000239GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBufferRange(GrGLenum target, GrGLintptr offset,
240 GrGLsizeiptr length, GrGLbitfield access) {
bsalomon776d3552014-08-14 08:13:27 -0700241 ThreadContext* ctx = ThreadContext::Get();
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000242 GrGLuint id = 0;
243 switch (target) {
244 case GR_GL_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700245 id = ctx->fCurrArrayBuffer;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000246 break;
247 case GR_GL_ELEMENT_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700248 id = ctx->fCurrElementArrayBuffer;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000249 break;
250 }
djsollen@google.com53b614b2014-05-02 17:44:34 +0000251
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000252 if (id > 0) {
253 // We just ignore the offset and length here.
bsalomon776d3552014-08-14 08:13:27 -0700254 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000255 SkASSERT(!buffer->mapped());
256 buffer->setMapped(true);
257 return buffer->dataPtr();
258 }
259 return NULL;
260}
261
262GrGLvoid* GR_GL_FUNCTION_TYPE nullGLMapBuffer(GrGLenum target, GrGLenum access) {
bsalomon776d3552014-08-14 08:13:27 -0700263 ThreadContext* ctx = ThreadContext::Get();
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000264 GrGLuint id = 0;
bsalomon@google.com74913722011-10-27 20:44:19 +0000265 switch (target) {
266 case GR_GL_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700267 id = ctx->fCurrArrayBuffer;
bsalomon@google.com74913722011-10-27 20:44:19 +0000268 break;
269 case GR_GL_ELEMENT_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700270 id = ctx->fCurrElementArrayBuffer;
bsalomon@google.com74913722011-10-27 20:44:19 +0000271 break;
272 }
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000273
274 if (id > 0) {
bsalomon776d3552014-08-14 08:13:27 -0700275 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000276 SkASSERT(!buffer->mapped());
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000277 buffer->setMapped(true);
278 return buffer->dataPtr();
bsalomon@google.com74913722011-10-27 20:44:19 +0000279 }
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000280
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000281 SkASSERT(false);
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000282 return NULL; // no buffer bound to target
bsalomon@google.com74913722011-10-27 20:44:19 +0000283}
284
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000285GrGLvoid GR_GL_FUNCTION_TYPE nullGLFlushMappedBufferRange(GrGLenum target,
286 GrGLintptr offset,
287 GrGLsizeiptr length) {}
288
289
bsalomon@google.com74913722011-10-27 20:44:19 +0000290GrGLboolean GR_GL_FUNCTION_TYPE nullGLUnmapBuffer(GrGLenum target) {
bsalomon776d3552014-08-14 08:13:27 -0700291 ThreadContext* ctx = ThreadContext::Get();
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000292 GrGLuint id = 0;
bsalomon@google.com74913722011-10-27 20:44:19 +0000293 switch (target) {
294 case GR_GL_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700295 id = ctx->fCurrArrayBuffer;
bsalomon@google.com74913722011-10-27 20:44:19 +0000296 break;
297 case GR_GL_ELEMENT_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700298 id = ctx->fCurrElementArrayBuffer;
bsalomon@google.com74913722011-10-27 20:44:19 +0000299 break;
300 }
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000301 if (id > 0) {
bsalomon776d3552014-08-14 08:13:27 -0700302 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000303 SkASSERT(buffer->mapped());
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000304 buffer->setMapped(false);
305 return GR_GL_TRUE;
bsalomon@google.com74913722011-10-27 20:44:19 +0000306 }
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000307
308 GrAlwaysAssert(false);
309 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
bsalomon@google.com74913722011-10-27 20:44:19 +0000310}
311
312GrGLvoid GR_GL_FUNCTION_TYPE nullGLGetBufferParameteriv(GrGLenum target, GrGLenum pname, GrGLint* params) {
bsalomon776d3552014-08-14 08:13:27 -0700313 ThreadContext* ctx = ThreadContext::Get();
bsalomon@google.com74913722011-10-27 20:44:19 +0000314 switch (pname) {
315 case GR_GL_BUFFER_MAPPED: {
316 *params = GR_GL_FALSE;
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000317 GrGLuint id = 0;
bsalomon@google.com74913722011-10-27 20:44:19 +0000318 switch (target) {
319 case GR_GL_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700320 id = ctx->fCurrArrayBuffer;
bsalomon@google.com74913722011-10-27 20:44:19 +0000321 break;
322 case GR_GL_ELEMENT_ARRAY_BUFFER:
bsalomon776d3552014-08-14 08:13:27 -0700323 id = ctx->fCurrElementArrayBuffer;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000324 break;
bsalomon@google.com74913722011-10-27 20:44:19 +0000325 }
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000326 if (id > 0) {
bsalomon776d3552014-08-14 08:13:27 -0700327 BufferObj* buffer = ctx->fBufferManager.lookUp(id);
robertphillips@google.comd6543e52013-07-18 17:39:14 +0000328 if (buffer->mapped()) {
329 *params = GR_GL_TRUE;
bsalomon@google.com74913722011-10-27 20:44:19 +0000330 }
331 }
332 break; }
333 default:
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000334 SkFAIL("Unexpected pname to GetBufferParamateriv");
bsalomon@google.com74913722011-10-27 20:44:19 +0000335 break;
336 }
337};
338
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000339} // end anonymous namespace
340
bsalomon@google.com74913722011-10-27 20:44:19 +0000341const GrGLInterface* GrGLCreateNullInterface() {
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000342 GrGLInterface* interface = SkNEW(GrGLInterface);
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000343
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000344 interface->fStandard = kGL_GrGLStandard;
commit-bot@chromium.orgc72425a2014-01-21 16:09:18 +0000345
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000346 GrGLInterface::Functions* functions = &interface->fFunctions;
347 functions->fActiveTexture = nullGLActiveTexture;
348 functions->fAttachShader = nullGLAttachShader;
349 functions->fBeginQuery = nullGLBeginQuery;
350 functions->fBindAttribLocation = nullGLBindAttribLocation;
351 functions->fBindBuffer = nullGLBindBuffer;
352 functions->fBindFragDataLocation = noOpGLBindFragDataLocation;
353 functions->fBindTexture = nullGLBindTexture;
354 functions->fBindVertexArray = nullGLBindVertexArray;
355 functions->fBlendColor = noOpGLBlendColor;
356 functions->fBlendFunc = noOpGLBlendFunc;
357 functions->fBufferData = nullGLBufferData;
358 functions->fBufferSubData = noOpGLBufferSubData;
359 functions->fClear = noOpGLClear;
360 functions->fClearColor = noOpGLClearColor;
361 functions->fClearStencil = noOpGLClearStencil;
362 functions->fColorMask = noOpGLColorMask;
363 functions->fCompileShader = noOpGLCompileShader;
364 functions->fCompressedTexImage2D = noOpGLCompressedTexImage2D;
krajcevski37d20f72014-06-11 10:38:47 -0700365 functions->fCompressedTexSubImage2D = noOpGLCompressedTexSubImage2D;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000366 functions->fCopyTexSubImage2D = noOpGLCopyTexSubImage2D;
367 functions->fCreateProgram = nullGLCreateProgram;
368 functions->fCreateShader = nullGLCreateShader;
369 functions->fCullFace = noOpGLCullFace;
370 functions->fDeleteBuffers = nullGLDeleteBuffers;
371 functions->fDeleteProgram = nullGLDelete;
372 functions->fDeleteQueries = noOpGLDeleteIds;
373 functions->fDeleteShader = nullGLDelete;
374 functions->fDeleteTextures = noOpGLDeleteIds;
375 functions->fDeleteVertexArrays = noOpGLDeleteIds;
376 functions->fDepthMask = noOpGLDepthMask;
377 functions->fDisable = noOpGLDisable;
378 functions->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
379 functions->fDrawArrays = noOpGLDrawArrays;
380 functions->fDrawBuffer = noOpGLDrawBuffer;
381 functions->fDrawBuffers = noOpGLDrawBuffers;
382 functions->fDrawElements = noOpGLDrawElements;
383 functions->fEnable = noOpGLEnable;
384 functions->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray;
385 functions->fEndQuery = noOpGLEndQuery;
386 functions->fFinish = noOpGLFinish;
387 functions->fFlush = noOpGLFlush;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000388 functions->fFlushMappedBufferRange = nullGLFlushMappedBufferRange;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000389 functions->fFrontFace = noOpGLFrontFace;
390 functions->fGenBuffers = nullGLGenBuffers;
391 functions->fGenerateMipmap = nullGLGenerateMipmap;
392 functions->fGenQueries = noOpGLGenIds;
393 functions->fGenTextures = noOpGLGenIds;
394 functions->fGenVertexArrays = noOpGLGenIds;
395 functions->fGetBufferParameteriv = nullGLGetBufferParameteriv;
396 functions->fGetError = noOpGLGetError;
397 functions->fGetIntegerv = noOpGLGetIntegerv;
398 functions->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v;
399 functions->fGetQueryObjectiv = noOpGLGetQueryObjectiv;
400 functions->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v;
401 functions->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv;
402 functions->fGetQueryiv = noOpGLGetQueryiv;
403 functions->fGetProgramInfoLog = noOpGLGetInfoLog;
404 functions->fGetProgramiv = noOpGLGetShaderOrProgramiv;
405 functions->fGetShaderInfoLog = noOpGLGetInfoLog;
406 functions->fGetShaderiv = noOpGLGetShaderOrProgramiv;
407 functions->fGetString = noOpGLGetString;
408 functions->fGetStringi = noOpGLGetStringi;
409 functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
410 functions->fGetUniformLocation = noOpGLGetUniformLocation;
411 functions->fInsertEventMarker = noOpGLInsertEventMarker;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000412 functions->fLineWidth = noOpGLLineWidth;
413 functions->fLinkProgram = noOpGLLinkProgram;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000414 functions->fMapBuffer = nullGLMapBuffer;
415 functions->fMapBufferRange = nullGLMapBufferRange;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000416 functions->fPixelStorei = nullGLPixelStorei;
417 functions->fPopGroupMarker = noOpGLPopGroupMarker;
418 functions->fPushGroupMarker = noOpGLPushGroupMarker;
419 functions->fQueryCounter = noOpGLQueryCounter;
420 functions->fReadBuffer = noOpGLReadBuffer;
421 functions->fReadPixels = nullGLReadPixels;
422 functions->fScissor = noOpGLScissor;
423 functions->fShaderSource = noOpGLShaderSource;
424 functions->fStencilFunc = noOpGLStencilFunc;
425 functions->fStencilFuncSeparate = noOpGLStencilFuncSeparate;
426 functions->fStencilMask = noOpGLStencilMask;
427 functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
428 functions->fStencilOp = noOpGLStencilOp;
429 functions->fStencilOpSeparate = noOpGLStencilOpSeparate;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000430 functions->fTexImage2D = noOpGLTexImage2D;
431 functions->fTexParameteri = noOpGLTexParameteri;
432 functions->fTexParameteriv = noOpGLTexParameteriv;
433 functions->fTexSubImage2D = noOpGLTexSubImage2D;
434 functions->fTexStorage2D = noOpGLTexStorage2D;
435 functions->fDiscardFramebuffer = noOpGLDiscardFramebuffer;
436 functions->fUniform1f = noOpGLUniform1f;
437 functions->fUniform1i = noOpGLUniform1i;
438 functions->fUniform1fv = noOpGLUniform1fv;
439 functions->fUniform1iv = noOpGLUniform1iv;
440 functions->fUniform2f = noOpGLUniform2f;
441 functions->fUniform2i = noOpGLUniform2i;
442 functions->fUniform2fv = noOpGLUniform2fv;
443 functions->fUniform2iv = noOpGLUniform2iv;
444 functions->fUniform3f = noOpGLUniform3f;
445 functions->fUniform3i = noOpGLUniform3i;
446 functions->fUniform3fv = noOpGLUniform3fv;
447 functions->fUniform3iv = noOpGLUniform3iv;
448 functions->fUniform4f = noOpGLUniform4f;
449 functions->fUniform4i = noOpGLUniform4i;
450 functions->fUniform4fv = noOpGLUniform4fv;
451 functions->fUniform4iv = noOpGLUniform4iv;
452 functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
453 functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
454 functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000455 functions->fUnmapBuffer = nullGLUnmapBuffer;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000456 functions->fUseProgram = nullGLUseProgram;
egdaniel27c15212014-10-24 15:00:50 -0700457 functions->fVertexAttrib1f = noOpGLVertexAttrib1f;
458 functions->fVertexAttrib2fv = noOpGLVertexAttrib2fv;
459 functions->fVertexAttrib3fv = noOpGLVertexAttrib3fv;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000460 functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
461 functions->fVertexAttribPointer = noOpGLVertexAttribPointer;
462 functions->fViewport = nullGLViewport;
463 functions->fBindFramebuffer = nullGLBindFramebuffer;
464 functions->fBindRenderbuffer = nullGLBindRenderbuffer;
465 functions->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus;
466 functions->fDeleteFramebuffers = nullGLDeleteFramebuffers;
467 functions->fDeleteRenderbuffers = nullGLDeleteRenderbuffers;
468 functions->fFramebufferRenderbuffer = nullGLFramebufferRenderbuffer;
469 functions->fFramebufferTexture2D = nullGLFramebufferTexture2D;
470 functions->fGenFramebuffers = noOpGLGenIds;
471 functions->fGenRenderbuffers = noOpGLGenIds;
472 functions->fGetFramebufferAttachmentParameteriv = noOpGLGetFramebufferAttachmentParameteriv;
473 functions->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv;
474 functions->fRenderbufferStorage = noOpGLRenderbufferStorage;
475 functions->fRenderbufferStorageMultisample = noOpGLRenderbufferStorageMultisample;
476 functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
477 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuffer;
commit-bot@chromium.orgf6696722014-04-25 06:21:30 +0000478 functions->fMatrixLoadf = noOpGLMatrixLoadf;
479 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
commit-bot@chromium.orgf5355612014-02-28 20:28:50 +0000480 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed;
481
482 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functions->fGetStringi,
483 functions->fGetIntegerv);
484 return interface;
bsalomon@google.com74913722011-10-27 20:44:19 +0000485}