OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 | |
6 #include "ui/gl/gl_bindings_skia_in_process.h" | |
7 | |
8 #include "base/logging.h" | |
9 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | |
10 #include "ui/gl/gl_bindings.h" | |
11 #include "ui/gl/gl_implementation.h" | |
12 | |
13 namespace { | |
14 | |
15 extern "C" { | |
16 // The following stub functions are required because the glXXX routines exported | |
17 // via gl_bindings.h use call-type GL_BINDING_CALL, which on Windows is stdcall. | |
18 // Skia has been built such that its GrGLInterface GL pointers are __cdecl. | |
19 | |
20 GLvoid GR_GL_FUNCTION_TYPE StubGLActiveTexture(GLenum texture) { | |
21 glActiveTexture(texture); | |
22 } | |
23 | |
24 GLvoid GR_GL_FUNCTION_TYPE StubGLAttachShader(GLuint program, GLuint shader) { | |
25 glAttachShader(program, shader); | |
26 } | |
27 | |
28 GLvoid GR_GL_FUNCTION_TYPE StubGLBeginQuery(GLenum target, GLuint id) { | |
29 glBeginQuery(target, id); | |
30 } | |
31 | |
32 GLvoid GR_GL_FUNCTION_TYPE StubGLBindAttribLocation(GLuint program, | |
33 GLuint index, | |
34 const char* name) { | |
35 glBindAttribLocation(program, index, name); | |
36 } | |
37 | |
38 GLvoid GR_GL_FUNCTION_TYPE StubGLBindBuffer(GLenum target, GLuint buffer) { | |
39 glBindBuffer(target, buffer); | |
40 } | |
41 | |
42 GLvoid GR_GL_FUNCTION_TYPE StubGLBindFragDataLocation(GLuint program, | |
43 GLuint colorNumber, | |
44 const GLchar* name) { | |
45 glBindFragDataLocation(program, colorNumber, name); | |
46 } | |
47 | |
48 GLvoid GR_GL_FUNCTION_TYPE | |
49 StubGLBindFragDataLocationIndexed(GLuint program, | |
50 GLuint colorNumber, | |
51 GLuint index, | |
52 const GLchar* name) { | |
53 glBindFragDataLocationIndexed(program, colorNumber, index, name); | |
54 } | |
55 | |
56 GLvoid GR_GL_FUNCTION_TYPE StubGLBindFramebuffer(GLenum target, | |
57 GLuint framebuffer) { | |
58 glBindFramebufferEXT(target, framebuffer); | |
59 } | |
60 | |
61 GLvoid GR_GL_FUNCTION_TYPE StubGLBindRenderbuffer(GLenum target, | |
62 GLuint renderbuffer) { | |
63 glBindRenderbufferEXT(target, renderbuffer); | |
64 } | |
65 | |
66 GLvoid GR_GL_FUNCTION_TYPE StubGLBindTexture(GLenum target, GLuint texture) { | |
67 glBindTexture(target, texture); | |
68 } | |
69 | |
70 GLvoid GR_GL_FUNCTION_TYPE StubGLBindVertexArray(GLuint array) { | |
71 glBindVertexArrayOES(array); | |
72 } | |
73 | |
74 GLvoid GR_GL_FUNCTION_TYPE StubGLBlendBarrier() { | |
75 glBlendBarrierKHR(); | |
76 } | |
77 | |
78 GLvoid GR_GL_FUNCTION_TYPE StubGLBlendColor(GLclampf red, | |
79 GLclampf green, | |
80 GLclampf blue, | |
81 GLclampf alpha) { | |
82 glBlendColor(red, green, blue, alpha); | |
83 } | |
84 | |
85 GLvoid GR_GL_FUNCTION_TYPE StubGLBlendEquation(GLenum mode) { | |
86 glBlendEquation(mode); | |
87 } | |
88 | |
89 GLvoid GR_GL_FUNCTION_TYPE StubGLBlendFunc(GLenum sfactor, GLenum dfactor) { | |
90 glBlendFunc(sfactor, dfactor); | |
91 } | |
92 | |
93 GLvoid GR_GL_FUNCTION_TYPE StubGLBlitFramebuffer(GLint srcX0, | |
94 GLint srcY0, | |
95 GLint srcX1, | |
96 GLint srcY1, | |
97 GLint dstX0, | |
98 GLint dstY0, | |
99 GLint dstX1, | |
100 GLint dstY1, | |
101 GLbitfield mask, | |
102 GLenum filter) { | |
103 glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, | |
104 mask, filter); | |
105 } | |
106 | |
107 GLvoid GR_GL_FUNCTION_TYPE StubGLBufferData(GLenum target, | |
108 GLsizeiptr size, | |
109 const void* data, | |
110 GLenum usage) { | |
111 glBufferData(target, size, data, usage); | |
112 } | |
113 | |
114 GLvoid GR_GL_FUNCTION_TYPE StubGLBufferSubData(GLenum target, | |
115 GLintptr offset, | |
116 GLsizeiptr size, | |
117 const void* data) { | |
118 glBufferSubData(target, offset, size, data); | |
119 } | |
120 | |
121 GLenum GR_GL_FUNCTION_TYPE StubGLCheckFramebufferStatus(GLenum target) { | |
122 return glCheckFramebufferStatusEXT(target); | |
123 } | |
124 | |
125 GLvoid GR_GL_FUNCTION_TYPE StubGLClear(GLbitfield mask) { | |
126 glClear(mask); | |
127 } | |
128 | |
129 GLvoid GR_GL_FUNCTION_TYPE StubGLClearColor(GLclampf red, | |
130 GLclampf green, | |
131 GLclampf blue, | |
132 GLclampf alpha) { | |
133 glClearColor(red, green, blue, alpha); | |
134 } | |
135 | |
136 GLvoid GR_GL_FUNCTION_TYPE StubGLClearStencil(GLint s) { | |
137 glClearStencil(s); | |
138 } | |
139 | |
140 GLvoid GR_GL_FUNCTION_TYPE StubGLColorMask(GLboolean red, | |
141 GLboolean green, | |
142 GLboolean blue, | |
143 GLboolean alpha) { | |
144 glColorMask(red, green, blue, alpha); | |
145 } | |
146 | |
147 GLvoid GR_GL_FUNCTION_TYPE StubGLCompileShader(GLuint shader) { | |
148 glCompileShader(shader); | |
149 } | |
150 | |
151 GLvoid GR_GL_FUNCTION_TYPE StubGLCompressedTexImage2D(GLenum target, | |
152 GLint level, | |
153 GLenum internalformat, | |
154 GLsizei width, | |
155 GLsizei height, | |
156 GLint border, | |
157 GLsizei imageSize, | |
158 const void* data) { | |
159 glCompressedTexImage2D(target, level, internalformat, width, height, border, | |
160 imageSize, data); | |
161 } | |
162 | |
163 GLvoid GR_GL_FUNCTION_TYPE StubGLCopyTexSubImage2D(GLenum target, | |
164 GLint level, | |
165 GLint xoffset, | |
166 GLint yoffset, | |
167 GLint x, | |
168 GLint y, | |
169 GLsizei width, | |
170 GLsizei height) { | |
171 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); | |
172 } | |
173 | |
174 GLuint GR_GL_FUNCTION_TYPE StubGLCreateProgram(void) { | |
175 return glCreateProgram(); | |
176 } | |
177 | |
178 GLuint GR_GL_FUNCTION_TYPE StubGLCreateShader(GLenum type) { | |
179 return glCreateShader(type); | |
180 } | |
181 | |
182 GLvoid GR_GL_FUNCTION_TYPE StubGLCullFace(GLenum mode) { | |
183 glCullFace(mode); | |
184 } | |
185 | |
186 GLvoid GR_GL_FUNCTION_TYPE StubGLDeleteBuffers(GLsizei n, | |
187 const GLuint* buffers) { | |
188 glDeleteBuffersARB(n, buffers); | |
189 } | |
190 | |
191 GLvoid GR_GL_FUNCTION_TYPE | |
192 StubGLDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) { | |
193 glDeleteFramebuffersEXT(n, framebuffers); | |
194 } | |
195 | |
196 GLvoid GR_GL_FUNCTION_TYPE StubGLDeleteQueries(GLsizei n, const GLuint* ids) { | |
197 glDeleteQueries(n, ids); | |
198 } | |
199 | |
200 GLvoid GR_GL_FUNCTION_TYPE StubGLDeleteProgram(GLuint program) { | |
201 glDeleteProgram(program); | |
202 } | |
203 | |
204 GLvoid GR_GL_FUNCTION_TYPE | |
205 StubGLDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) { | |
206 glDeleteRenderbuffersEXT(n, renderbuffers); | |
207 } | |
208 | |
209 GLvoid GR_GL_FUNCTION_TYPE StubGLDeleteShader(GLuint shader) { | |
210 glDeleteShader(shader); | |
211 } | |
212 | |
213 GLvoid GR_GL_FUNCTION_TYPE StubGLDeleteTextures(GLsizei n, | |
214 const GLuint* textures) { | |
215 glDeleteTextures(n, textures); | |
216 } | |
217 | |
218 GLvoid GR_GL_FUNCTION_TYPE StubGLDeleteVertexArrays(GLsizei n, | |
219 const GLuint* arrays) { | |
220 glDeleteVertexArraysOES(n, arrays); | |
221 } | |
222 | |
223 GLvoid GR_GL_FUNCTION_TYPE StubGLDepthMask(GLboolean flag) { | |
224 glDepthMask(flag); | |
225 } | |
226 | |
227 GLvoid GR_GL_FUNCTION_TYPE StubGLDisable(GLenum cap) { | |
228 glDisable(cap); | |
229 } | |
230 | |
231 GLvoid GR_GL_FUNCTION_TYPE StubGLDisableVertexAttribArray(GLuint index) { | |
232 glDisableVertexAttribArray(index); | |
233 } | |
234 | |
235 GLvoid GR_GL_FUNCTION_TYPE StubGLDiscardFramebuffer(GLenum target, | |
236 GLsizei numAttachments, | |
237 const GLenum* attachments) { | |
238 glDiscardFramebufferEXT(target, numAttachments, attachments); | |
239 } | |
240 | |
241 GLvoid GR_GL_FUNCTION_TYPE StubGLDrawArrays(GLenum mode, | |
242 GLint first, | |
243 GLsizei count) { | |
244 glDrawArrays(mode, first, count); | |
245 } | |
246 | |
247 GLvoid GR_GL_FUNCTION_TYPE StubGLDrawBuffer(GLenum mode) { | |
248 glDrawBuffer(mode); | |
249 } | |
250 | |
251 GLvoid GR_GL_FUNCTION_TYPE StubGLDrawBuffers(GLsizei n, const GLenum* bufs) { | |
252 glDrawBuffersARB(n, bufs); | |
253 } | |
254 | |
255 GLvoid GR_GL_FUNCTION_TYPE StubGLDrawElements(GLenum mode, | |
256 GLsizei count, | |
257 GLenum type, | |
258 const void* indices) { | |
259 glDrawElements(mode, count, type, indices); | |
260 } | |
261 | |
262 GLvoid GR_GL_FUNCTION_TYPE StubGLEnable(GLenum cap) { | |
263 glEnable(cap); | |
264 } | |
265 | |
266 GLvoid GR_GL_FUNCTION_TYPE StubGLEnableVertexAttribArray(GLuint index) { | |
267 glEnableVertexAttribArray(index); | |
268 } | |
269 | |
270 GLvoid GR_GL_FUNCTION_TYPE StubGLEndQuery(GLenum target) { | |
271 glEndQuery(target); | |
272 } | |
273 | |
274 GLvoid GR_GL_FUNCTION_TYPE StubGLFinish() { | |
275 glFinish(); | |
276 } | |
277 | |
278 GLvoid GR_GL_FUNCTION_TYPE StubGLFlush() { | |
279 glFlush(); | |
280 } | |
281 | |
282 GLvoid GR_GL_FUNCTION_TYPE StubGLFlushMappedBufferRange(GLenum target, | |
283 GLintptr offset, | |
284 GLsizeiptr length) { | |
285 glFlushMappedBufferRange(target, offset, length); | |
286 } | |
287 | |
288 GLvoid GR_GL_FUNCTION_TYPE | |
289 StubGLFramebufferRenderbuffer(GLenum target, | |
290 GLenum attachment, | |
291 GLenum renderbuffertarget, | |
292 GLuint renderbuffer) { | |
293 glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, | |
294 renderbuffer); | |
295 } | |
296 | |
297 GLvoid GR_GL_FUNCTION_TYPE StubGLFramebufferTexture2D(GLenum target, | |
298 GLenum attachment, | |
299 GLenum textarget, | |
300 GLuint texture, | |
301 GLint level) { | |
302 glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); | |
303 } | |
304 | |
305 GLvoid GR_GL_FUNCTION_TYPE | |
306 StubGLFramebufferTexture2DMultisample(GLenum target, | |
307 GLenum attachment, | |
308 GLenum textarget, | |
309 GLuint texture, | |
310 GLint level, | |
311 GLsizei samples) { | |
312 glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, texture, | |
313 level, samples); | |
314 } | |
315 | |
316 GLvoid GR_GL_FUNCTION_TYPE StubGLFrontFace(GLenum mode) { | |
317 glFrontFace(mode); | |
318 } | |
319 | |
320 GLvoid GR_GL_FUNCTION_TYPE StubGLGenBuffers(GLsizei n, GLuint* buffers) { | |
321 glGenBuffersARB(n, buffers); | |
322 } | |
323 | |
324 GLvoid GR_GL_FUNCTION_TYPE StubGLGenFramebuffers(GLsizei n, | |
325 GLuint* framebuffers) { | |
326 glGenFramebuffersEXT(n, framebuffers); | |
327 } | |
328 | |
329 GLvoid GR_GL_FUNCTION_TYPE StubGLGenQueries(GLsizei n, GLuint* ids) { | |
330 glGenQueries(n, ids); | |
331 } | |
332 | |
333 GLvoid GR_GL_FUNCTION_TYPE StubGLGenRenderbuffers(GLsizei n, | |
334 GLuint* renderbuffers) { | |
335 glGenRenderbuffersEXT(n, renderbuffers); | |
336 } | |
337 | |
338 GLvoid GR_GL_FUNCTION_TYPE StubGLGenTextures(GLsizei n, GLuint* textures) { | |
339 glGenTextures(n, textures); | |
340 } | |
341 | |
342 GLvoid GR_GL_FUNCTION_TYPE StubGLGenVertexArrays(GLsizei n, GLuint* arrays) { | |
343 glGenVertexArraysOES(n, arrays); | |
344 } | |
345 | |
346 GLvoid GR_GL_FUNCTION_TYPE StubGLGenerateMipmap(GLenum target) { | |
347 glGenerateMipmapEXT(target); | |
348 } | |
349 | |
350 GLvoid GR_GL_FUNCTION_TYPE StubGLGetBufferParameteriv(GLenum target, | |
351 GLenum pname, | |
352 GLint* params) { | |
353 glGetBufferParameteriv(target, pname, params); | |
354 } | |
355 | |
356 GLvoid GR_GL_FUNCTION_TYPE | |
357 StubGLGetFramebufferAttachmentParameteriv(GLenum target, | |
358 GLenum attachment, | |
359 GLenum pname, | |
360 GLint* params) { | |
361 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); | |
362 } | |
363 | |
364 GLenum GR_GL_FUNCTION_TYPE StubGLGetError() { | |
365 return glGetError(); | |
366 } | |
367 | |
368 GLvoid GR_GL_FUNCTION_TYPE StubGLGetIntegerv(GLenum pname, GLint* params) { | |
369 glGetIntegerv(pname, params); | |
370 } | |
371 | |
372 GLvoid GR_GL_FUNCTION_TYPE StubGLGetProgramInfoLog(GLuint program, | |
373 GLsizei bufsize, | |
374 GLsizei* length, | |
375 char* infolog) { | |
376 glGetProgramInfoLog(program, bufsize, length, infolog); | |
377 } | |
378 | |
379 GLvoid GR_GL_FUNCTION_TYPE StubGLGetProgramiv(GLuint program, | |
380 GLenum pname, | |
381 GLint* params) { | |
382 glGetProgramiv(program, pname, params); | |
383 } | |
384 | |
385 GLvoid GR_GL_FUNCTION_TYPE StubGLGetRenderbufferParameteriv(GLenum target, | |
386 GLenum pname, | |
387 GLint* params) { | |
388 glGetRenderbufferParameterivEXT(target, pname, params); | |
389 } | |
390 | |
391 GLvoid GR_GL_FUNCTION_TYPE StubGLGetShaderInfoLog(GLuint shader, | |
392 GLsizei bufsize, | |
393 GLsizei* length, | |
394 char* infolog) { | |
395 glGetShaderInfoLog(shader, bufsize, length, infolog); | |
396 } | |
397 | |
398 GLvoid GR_GL_FUNCTION_TYPE StubGLGetShaderiv(GLuint shader, | |
399 GLenum pname, | |
400 GLint* params) { | |
401 glGetShaderiv(shader, pname, params); | |
402 } | |
403 | |
404 GLvoid GR_GL_FUNCTION_TYPE StubGLGetShaderPrecisionFormat(GLenum shadertype, | |
405 GLenum precisiontype, | |
406 GLint* range, | |
407 GLint* precision) { | |
408 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); | |
409 } | |
410 | |
411 const GLubyte* GR_GL_FUNCTION_TYPE StubGLGetString(GLenum name) { | |
412 return glGetString(name); | |
413 } | |
414 | |
415 const GLubyte* GR_GL_FUNCTION_TYPE StubGLGetStringi(GLenum name, GLuint index) { | |
416 return glGetStringi(name, index); | |
417 } | |
418 | |
419 GLvoid GR_GL_FUNCTION_TYPE StubGLGetQueryiv(GLenum target, | |
420 GLenum pname, | |
421 GLint* params) { | |
422 glGetQueryiv(target, pname, params); | |
423 } | |
424 | |
425 GLvoid GR_GL_FUNCTION_TYPE StubGLGetQueryObjecti64v(GLuint id, | |
426 GLenum pname, | |
427 GLint64* params) { | |
428 glGetQueryObjecti64v(id, pname, params); | |
429 } | |
430 | |
431 GLvoid GR_GL_FUNCTION_TYPE StubGLGetQueryObjectiv(GLuint id, | |
432 GLenum pname, | |
433 GLint* params) { | |
434 glGetQueryObjectiv(id, pname, params); | |
435 } | |
436 | |
437 GLvoid GR_GL_FUNCTION_TYPE StubGLGetQueryObjectui64v(GLuint id, | |
438 GLenum pname, | |
439 GLuint64* params) { | |
440 glGetQueryObjectui64v(id, pname, params); | |
441 } | |
442 | |
443 GLvoid GR_GL_FUNCTION_TYPE StubGLGetQueryObjectuiv(GLuint id, | |
444 GLenum pname, | |
445 GLuint* params) { | |
446 glGetQueryObjectuiv(id, pname, params); | |
447 } | |
448 | |
449 GLvoid GR_GL_FUNCTION_TYPE StubGLGetTexLevelParameteriv(GLenum target, | |
450 GLint level, | |
451 GLenum pname, | |
452 GLint* params) { | |
453 glGetTexLevelParameteriv(target, level, pname, params); | |
454 } | |
455 | |
456 GLint GR_GL_FUNCTION_TYPE StubGLGetUniformLocation(GLuint program, | |
457 const char* name) { | |
458 return glGetUniformLocation(program, name); | |
459 } | |
460 | |
461 GLvoid GR_GL_FUNCTION_TYPE StubGLInsertEventMarker(GLsizei length, | |
462 const char* marker) { | |
463 glInsertEventMarkerEXT(length, marker); | |
464 } | |
465 | |
466 GLvoid GR_GL_FUNCTION_TYPE | |
467 StubGLInvalidateFramebuffer(GLenum target, | |
468 GLsizei numAttachments, | |
469 const GLenum* attachments) { | |
470 glInvalidateFramebuffer(target, numAttachments, attachments); | |
471 } | |
472 | |
473 GLvoid GR_GL_FUNCTION_TYPE | |
474 StubGLInvalidateSubFramebuffer(GLenum target, | |
475 GLsizei numAttachments, | |
476 const GLenum* attachments, | |
477 GLint x, | |
478 GLint y, | |
479 GLsizei width, | |
480 GLsizei height) { | |
481 glInvalidateSubFramebuffer(target, numAttachments, attachments, | |
482 x, y, width, height); | |
483 } | |
484 | |
485 GLvoid GR_GL_FUNCTION_TYPE StubGLLineWidth(GLfloat width) { | |
486 glLineWidth(width); | |
487 } | |
488 | |
489 GLvoid GR_GL_FUNCTION_TYPE StubGLLinkProgram(GLuint program) { | |
490 glLinkProgram(program); | |
491 } | |
492 | |
493 void* GR_GL_FUNCTION_TYPE StubGLMapBuffer(GLenum target, GLenum access) { | |
494 return glMapBuffer(target, access); | |
495 } | |
496 | |
497 void* GR_GL_FUNCTION_TYPE StubGLMapBufferRange(GLenum target, | |
498 GLintptr offset, | |
499 GLsizeiptr length, | |
500 GLbitfield access) { | |
501 return glMapBufferRange(target, offset, length, access); | |
502 } | |
503 | |
504 GLvoid GR_GL_FUNCTION_TYPE StubGLPixelStorei(GLenum pname, GLint param) { | |
505 glPixelStorei(pname, param); | |
506 } | |
507 | |
508 GLvoid GR_GL_FUNCTION_TYPE StubGLPopGroupMarker() { | |
509 glPopGroupMarkerEXT(); | |
510 } | |
511 | |
512 GLvoid GR_GL_FUNCTION_TYPE StubGLPushGroupMarker(GLsizei length, | |
513 const char* marker) { | |
514 glPushGroupMarkerEXT(length, marker); | |
515 } | |
516 | |
517 GLvoid GR_GL_FUNCTION_TYPE StubGLQueryCounter(GLuint id, GLenum target) { | |
518 glQueryCounter(id, target); | |
519 } | |
520 | |
521 GLvoid GR_GL_FUNCTION_TYPE StubGLReadBuffer(GLenum src) { | |
522 glReadBuffer(src); | |
523 } | |
524 | |
525 GLvoid GR_GL_FUNCTION_TYPE StubGLReadPixels(GLint x, | |
526 GLint y, | |
527 GLsizei width, | |
528 GLsizei height, | |
529 GLenum format, | |
530 GLenum type, | |
531 void* pixels) { | |
532 glReadPixels(x, y, width, height, format, type, pixels); | |
533 } | |
534 | |
535 GLvoid GR_GL_FUNCTION_TYPE StubGLRenderbufferStorage(GLenum target, | |
536 GLenum internalformat, | |
537 GLsizei width, | |
538 GLsizei height) { | |
539 glRenderbufferStorageEXT(target, internalformat, width, height); | |
540 } | |
541 | |
542 GLvoid GR_GL_FUNCTION_TYPE | |
543 StubGLRenderbufferStorageMultisample(GLenum target, | |
544 GLsizei samples, | |
545 GLenum internalformat, | |
546 GLsizei width, | |
547 GLsizei height) { | |
548 glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, | |
549 height); | |
550 } | |
551 | |
552 GLvoid GR_GL_FUNCTION_TYPE StubGLScissor(GLint x, | |
553 GLint y, | |
554 GLsizei width, | |
555 GLsizei height) { | |
556 glScissor(x, y, width, height); | |
557 } | |
558 | |
559 GLvoid GR_GL_FUNCTION_TYPE StubGLShaderSource(GLuint shader, | |
560 GLsizei count, | |
561 const char* const* str, | |
562 const GLint* length) { | |
563 glShaderSource(shader, count, str, length); | |
564 } | |
565 | |
566 GLvoid GR_GL_FUNCTION_TYPE StubGLStencilFunc(GLenum func, | |
567 GLint ref, | |
568 GLuint mask) { | |
569 glStencilFunc(func, ref, mask); | |
570 } | |
571 | |
572 GLvoid GR_GL_FUNCTION_TYPE StubGLStencilFuncSeparate(GLenum face, | |
573 GLenum func, | |
574 GLint ref, | |
575 GLuint mask) { | |
576 glStencilFuncSeparate(face, func, ref, mask); | |
577 } | |
578 | |
579 GLvoid GR_GL_FUNCTION_TYPE StubGLStencilMask(GLuint mask) { | |
580 glStencilMask(mask); | |
581 } | |
582 | |
583 GLvoid GR_GL_FUNCTION_TYPE StubGLStencilMaskSeparate(GLenum face, GLuint mask) { | |
584 glStencilMaskSeparate(face, mask); | |
585 } | |
586 | |
587 GLvoid GR_GL_FUNCTION_TYPE StubGLStencilOp(GLenum fail, | |
588 GLenum zfail, | |
589 GLenum zpass) { | |
590 glStencilOp(fail, zfail, zpass); | |
591 } | |
592 | |
593 GLvoid GR_GL_FUNCTION_TYPE StubGLStencilOpSeparate(GLenum face, | |
594 GLenum fail, | |
595 GLenum zfail, | |
596 GLenum zpass) { | |
597 glStencilOpSeparate(face, fail, zfail, zpass); | |
598 } | |
599 | |
600 GLvoid GR_GL_FUNCTION_TYPE StubGLTexImage2D(GLenum target, | |
601 GLint level, | |
602 GLint internalformat, | |
603 GLsizei width, | |
604 GLsizei height, | |
605 GLint border, | |
606 GLenum format, | |
607 GLenum type, | |
608 const void* pixels) { | |
609 glTexImage2D(target, level, internalformat, width, height, border, format, | |
610 type, pixels); | |
611 } | |
612 | |
613 GLvoid GR_GL_FUNCTION_TYPE StubGLTexParameteri(GLenum target, | |
614 GLenum pname, | |
615 GLint param) { | |
616 glTexParameteri(target, pname, param); | |
617 } | |
618 | |
619 GLvoid GR_GL_FUNCTION_TYPE StubGLTexParameteriv(GLenum target, | |
620 GLenum pname, | |
621 const GLint* params) { | |
622 glTexParameteriv(target, pname, params); | |
623 } | |
624 | |
625 GLvoid GR_GL_FUNCTION_TYPE StubGLTexStorage2D(GLenum target, | |
626 GLsizei levels, | |
627 GLenum internalFormat, | |
628 GLsizei width, | |
629 GLsizei height) { | |
630 glTexStorage2DEXT(target, levels, internalFormat, width, height); | |
631 } | |
632 | |
633 GLvoid GR_GL_FUNCTION_TYPE StubGLTexSubImage2D(GLenum target, | |
634 GLint level, | |
635 GLint xoffset, | |
636 GLint yoffset, | |
637 GLsizei width, | |
638 GLsizei height, | |
639 GLenum format, | |
640 GLenum type, | |
641 const void* pixels) { | |
642 glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, | |
643 pixels); | |
644 } | |
645 | |
646 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform1f(GLint location, GLfloat v) { | |
647 glUniform1f(location, v); | |
648 } | |
649 | |
650 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform1i(GLint location, GLint v) { | |
651 glUniform1i(location, v); | |
652 } | |
653 | |
654 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform1fv(GLint location, | |
655 GLsizei count, | |
656 const GLfloat* v) { | |
657 glUniform1fv(location, count, v); | |
658 } | |
659 | |
660 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform1iv(GLint location, | |
661 GLsizei count, | |
662 const GLint* v) { | |
663 glUniform1iv(location, count, v); | |
664 } | |
665 | |
666 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform2f(GLint location, | |
667 GLfloat v0, | |
668 GLfloat v1) { | |
669 glUniform2f(location, v0, v1); | |
670 } | |
671 | |
672 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform2i(GLint location, GLint v0, GLint v1) { | |
673 glUniform2i(location, v0, v1); | |
674 } | |
675 | |
676 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform2fv(GLint location, | |
677 GLsizei count, | |
678 const GLfloat* v) { | |
679 glUniform2fv(location, count, v); | |
680 } | |
681 | |
682 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform2iv(GLint location, | |
683 GLsizei count, | |
684 const GLint* v) { | |
685 glUniform2iv(location, count, v); | |
686 } | |
687 | |
688 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform3f(GLint location, | |
689 GLfloat v0, | |
690 GLfloat v1, | |
691 GLfloat v2) { | |
692 glUniform3f(location, v0, v1, v2); | |
693 } | |
694 | |
695 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform3i(GLint location, | |
696 GLint v0, | |
697 GLint v1, | |
698 GLint v2) { | |
699 glUniform3i(location, v0, v1, v2); | |
700 } | |
701 | |
702 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform3fv(GLint location, | |
703 GLsizei count, | |
704 const GLfloat* v) { | |
705 glUniform3fv(location, count, v); | |
706 } | |
707 | |
708 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform3iv(GLint location, | |
709 GLsizei count, | |
710 const GLint* v) { | |
711 glUniform3iv(location, count, v); | |
712 } | |
713 | |
714 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform4f(GLint location, | |
715 GLfloat v0, | |
716 GLfloat v1, | |
717 GLfloat v2, | |
718 GLfloat v3) { | |
719 glUniform4f(location, v0, v1, v2, v3); | |
720 } | |
721 | |
722 GLvoid GR_GL_FUNCTION_TYPE | |
723 StubGLUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { | |
724 glUniform4i(location, v0, v1, v2, v3); | |
725 } | |
726 | |
727 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform4fv(GLint location, | |
728 GLsizei count, | |
729 const GLfloat* v) { | |
730 glUniform4fv(location, count, v); | |
731 } | |
732 | |
733 GLvoid GR_GL_FUNCTION_TYPE StubGLUniform4iv(GLint location, | |
734 GLsizei count, | |
735 const GLint* v) { | |
736 glUniform4iv(location, count, v); | |
737 } | |
738 | |
739 GLvoid GR_GL_FUNCTION_TYPE StubGLUniformMatrix2fv(GLint location, | |
740 GLsizei count, | |
741 GLboolean transpose, | |
742 const GLfloat* value) { | |
743 glUniformMatrix2fv(location, count, transpose, value); | |
744 } | |
745 | |
746 GLvoid GR_GL_FUNCTION_TYPE StubGLUniformMatrix3fv(GLint location, | |
747 GLsizei count, | |
748 GLboolean transpose, | |
749 const GLfloat* value) { | |
750 glUniformMatrix3fv(location, count, transpose, value); | |
751 } | |
752 | |
753 GLvoid GR_GL_FUNCTION_TYPE StubGLUniformMatrix4fv(GLint location, | |
754 GLsizei count, | |
755 GLboolean transpose, | |
756 const GLfloat* value) { | |
757 glUniformMatrix4fv(location, count, transpose, value); | |
758 } | |
759 | |
760 GLboolean GR_GL_FUNCTION_TYPE StubGLUnmapBuffer(GLenum target) { | |
761 return glUnmapBuffer(target); | |
762 } | |
763 | |
764 GLvoid GR_GL_FUNCTION_TYPE StubGLUseProgram(GLuint program) { | |
765 glUseProgram(program); | |
766 } | |
767 | |
768 GLvoid GR_GL_FUNCTION_TYPE StubGLVertexAttrib1f(GLuint indx, | |
769 const GLfloat value) { | |
770 glVertexAttrib1f(indx, value); | |
771 } | |
772 | |
773 GLvoid GR_GL_FUNCTION_TYPE StubGLVertexAttrib2fv(GLuint indx, | |
774 const GLfloat* values) { | |
775 glVertexAttrib2fv(indx, values); | |
776 } | |
777 | |
778 GLvoid GR_GL_FUNCTION_TYPE StubGLVertexAttrib3fv(GLuint indx, | |
779 const GLfloat* values) { | |
780 glVertexAttrib3fv(indx, values); | |
781 } | |
782 | |
783 GLvoid GR_GL_FUNCTION_TYPE StubGLVertexAttrib4fv(GLuint indx, | |
784 const GLfloat* values) { | |
785 glVertexAttrib4fv(indx, values); | |
786 } | |
787 | |
788 GLvoid GR_GL_FUNCTION_TYPE StubGLVertexAttribPointer(GLuint indx, | |
789 GLint size, | |
790 GLenum type, | |
791 GLboolean normalized, | |
792 GLsizei stride, | |
793 const void* ptr) { | |
794 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | |
795 } | |
796 | |
797 GLvoid GR_GL_FUNCTION_TYPE StubGLViewport(GLint x, | |
798 GLint y, | |
799 GLsizei width, | |
800 GLsizei height) { | |
801 glViewport(x, y, width, height); | |
802 } | |
803 | |
804 GLint GR_GL_FUNCTION_TYPE | |
805 StubGLGetProgramResourceLocation(GLuint program, | |
806 GLenum programInterface, | |
807 const char* name) { | |
808 return glGetProgramResourceLocation(program, programInterface, name); | |
809 } | |
810 | |
811 } // extern "C" | |
812 } // namespace | |
813 | |
814 namespace gfx { | |
815 | |
816 GrGLInterface* CreateInProcessSkiaGLBinding() { | |
817 GrGLStandard standard; | |
818 switch (gfx::GetGLImplementation()) { | |
819 case gfx::kGLImplementationNone: | |
820 NOTREACHED(); | |
821 return NULL; | |
822 case gfx::kGLImplementationDesktopGL: | |
823 case gfx::kGLImplementationAppleGL: | |
824 standard = kGL_GrGLStandard; | |
825 break; | |
826 case gfx::kGLImplementationOSMesaGL: | |
827 standard = kGL_GrGLStandard; | |
828 break; | |
829 case gfx::kGLImplementationEGLGLES2: | |
830 standard = kGLES_GrGLStandard; | |
831 break; | |
832 case gfx::kGLImplementationMockGL: | |
833 NOTREACHED(); | |
834 return NULL; | |
835 default: | |
836 NOTREACHED(); | |
837 return NULL; | |
838 } | |
839 | |
840 GrGLInterface* interface = new GrGLInterface; | |
841 interface->fStandard = standard; | |
842 interface->fExtensions.init(standard, | |
843 StubGLGetString, | |
844 StubGLGetStringi, | |
845 StubGLGetIntegerv); | |
846 | |
847 GrGLInterface::Functions* functions = &interface->fFunctions; | |
848 functions->fActiveTexture = StubGLActiveTexture; | |
849 functions->fAttachShader = StubGLAttachShader; | |
850 functions->fBeginQuery = StubGLBeginQuery; | |
851 functions->fBindAttribLocation = StubGLBindAttribLocation; | |
852 functions->fBindBuffer = StubGLBindBuffer; | |
853 functions->fBindFragDataLocation = StubGLBindFragDataLocation; | |
854 functions->fBindTexture = StubGLBindTexture; | |
855 functions->fBindVertexArray = StubGLBindVertexArray; | |
856 functions->fBlendBarrier = StubGLBlendBarrier; | |
857 functions->fBlendColor = StubGLBlendColor; | |
858 functions->fBlendEquation = StubGLBlendEquation; | |
859 functions->fBlendFunc = StubGLBlendFunc; | |
860 functions->fBufferData = StubGLBufferData; | |
861 functions->fBufferSubData = StubGLBufferSubData; | |
862 functions->fClear = StubGLClear; | |
863 functions->fClearColor = StubGLClearColor; | |
864 functions->fClearStencil = StubGLClearStencil; | |
865 functions->fColorMask = StubGLColorMask; | |
866 functions->fCompileShader = StubGLCompileShader; | |
867 functions->fCompressedTexImage2D = StubGLCompressedTexImage2D; | |
868 functions->fCopyTexSubImage2D = StubGLCopyTexSubImage2D; | |
869 functions->fCreateProgram = StubGLCreateProgram; | |
870 functions->fCreateShader = StubGLCreateShader; | |
871 functions->fCullFace = StubGLCullFace; | |
872 functions->fDeleteBuffers = StubGLDeleteBuffers; | |
873 functions->fDeleteProgram = StubGLDeleteProgram; | |
874 functions->fDeleteQueries = StubGLDeleteQueries; | |
875 functions->fDeleteShader = StubGLDeleteShader; | |
876 functions->fDeleteTextures = StubGLDeleteTextures; | |
877 functions->fDeleteVertexArrays = StubGLDeleteVertexArrays; | |
878 functions->fDepthMask = StubGLDepthMask; | |
879 functions->fDisable = StubGLDisable; | |
880 functions->fDisableVertexAttribArray = StubGLDisableVertexAttribArray; | |
881 functions->fDiscardFramebuffer = StubGLDiscardFramebuffer; | |
882 functions->fDrawArrays = StubGLDrawArrays; | |
883 functions->fDrawBuffer = StubGLDrawBuffer; | |
884 functions->fDrawBuffers = StubGLDrawBuffers; | |
885 functions->fDrawElements = StubGLDrawElements; | |
886 functions->fEnable = StubGLEnable; | |
887 functions->fEnableVertexAttribArray = StubGLEnableVertexAttribArray; | |
888 functions->fEndQuery = StubGLEndQuery; | |
889 functions->fFinish = StubGLFinish; | |
890 functions->fFlush = StubGLFlush; | |
891 functions->fFlushMappedBufferRange = StubGLFlushMappedBufferRange; | |
892 functions->fFrontFace = StubGLFrontFace; | |
893 functions->fGenBuffers = StubGLGenBuffers; | |
894 functions->fGenQueries = StubGLGenQueries; | |
895 functions->fGenTextures = StubGLGenTextures; | |
896 functions->fGenVertexArrays = StubGLGenVertexArrays; | |
897 functions->fGenerateMipmap = StubGLGenerateMipmap; | |
898 functions->fGetBufferParameteriv = StubGLGetBufferParameteriv; | |
899 functions->fGetError = StubGLGetError; | |
900 functions->fGetIntegerv = StubGLGetIntegerv; | |
901 functions->fGetQueryiv = StubGLGetQueryiv; | |
902 functions->fGetQueryObjecti64v = StubGLGetQueryObjecti64v; | |
903 functions->fGetQueryObjectiv = StubGLGetQueryObjectiv; | |
904 functions->fGetQueryObjectui64v = StubGLGetQueryObjectui64v; | |
905 functions->fGetQueryObjectuiv = StubGLGetQueryObjectuiv; | |
906 functions->fGetProgramInfoLog = StubGLGetProgramInfoLog; | |
907 functions->fGetProgramiv = StubGLGetProgramiv; | |
908 functions->fGetShaderInfoLog = StubGLGetShaderInfoLog; | |
909 functions->fGetShaderiv = StubGLGetShaderiv; | |
910 functions->fGetShaderPrecisionFormat = StubGLGetShaderPrecisionFormat; | |
911 functions->fGetString = StubGLGetString; | |
912 functions->fGetStringi = StubGLGetStringi; | |
913 functions->fGetTexLevelParameteriv = StubGLGetTexLevelParameteriv; | |
914 functions->fGetUniformLocation = StubGLGetUniformLocation; | |
915 functions->fInsertEventMarker = StubGLInsertEventMarker; | |
916 functions->fInvalidateFramebuffer = StubGLInvalidateFramebuffer; | |
917 functions->fInvalidateSubFramebuffer = StubGLInvalidateSubFramebuffer; | |
918 functions->fLineWidth = StubGLLineWidth; | |
919 functions->fLinkProgram = StubGLLinkProgram; | |
920 functions->fMapBufferRange = StubGLMapBufferRange; | |
921 functions->fPixelStorei = StubGLPixelStorei; | |
922 functions->fPopGroupMarker = StubGLPopGroupMarker; | |
923 functions->fPushGroupMarker = StubGLPushGroupMarker; | |
924 functions->fQueryCounter = StubGLQueryCounter; | |
925 functions->fReadBuffer = StubGLReadBuffer; | |
926 functions->fReadPixels = StubGLReadPixels; | |
927 functions->fScissor = StubGLScissor; | |
928 functions->fShaderSource = StubGLShaderSource; | |
929 functions->fStencilFunc = StubGLStencilFunc; | |
930 functions->fStencilFuncSeparate = StubGLStencilFuncSeparate; | |
931 functions->fStencilMask = StubGLStencilMask; | |
932 functions->fStencilMaskSeparate = StubGLStencilMaskSeparate; | |
933 functions->fStencilOp = StubGLStencilOp; | |
934 functions->fStencilOpSeparate = StubGLStencilOpSeparate; | |
935 functions->fTexImage2D = StubGLTexImage2D; | |
936 functions->fTexParameteri = StubGLTexParameteri; | |
937 functions->fTexParameteriv = StubGLTexParameteriv; | |
938 functions->fTexSubImage2D = StubGLTexSubImage2D; | |
939 functions->fTexStorage2D = StubGLTexStorage2D; | |
940 functions->fUniform1f = StubGLUniform1f; | |
941 functions->fUniform1i = StubGLUniform1i; | |
942 functions->fUniform1fv = StubGLUniform1fv; | |
943 functions->fUniform1iv = StubGLUniform1iv; | |
944 functions->fUniform2f = StubGLUniform2f; | |
945 functions->fUniform2i = StubGLUniform2i; | |
946 functions->fUniform2fv = StubGLUniform2fv; | |
947 functions->fUniform2iv = StubGLUniform2iv; | |
948 functions->fUniform3f = StubGLUniform3f; | |
949 functions->fUniform3i = StubGLUniform3i; | |
950 functions->fUniform3fv = StubGLUniform3fv; | |
951 functions->fUniform3iv = StubGLUniform3iv; | |
952 functions->fUniform4f = StubGLUniform4f; | |
953 functions->fUniform4i = StubGLUniform4i; | |
954 functions->fUniform4fv = StubGLUniform4fv; | |
955 functions->fUniform4iv = StubGLUniform4iv; | |
956 functions->fUniformMatrix2fv = StubGLUniformMatrix2fv; | |
957 functions->fUniformMatrix3fv = StubGLUniformMatrix3fv; | |
958 functions->fUniformMatrix4fv = StubGLUniformMatrix4fv; | |
959 functions->fUseProgram = StubGLUseProgram; | |
960 functions->fVertexAttrib1f = StubGLVertexAttrib1f; | |
961 functions->fVertexAttrib2fv = StubGLVertexAttrib2fv; | |
962 functions->fVertexAttrib3fv = StubGLVertexAttrib3fv; | |
963 functions->fVertexAttrib4fv = StubGLVertexAttrib4fv; | |
964 functions->fVertexAttribPointer = StubGLVertexAttribPointer; | |
965 functions->fViewport = StubGLViewport; | |
966 functions->fBindFramebuffer = StubGLBindFramebuffer; | |
967 functions->fBindRenderbuffer = StubGLBindRenderbuffer; | |
968 functions->fCheckFramebufferStatus = StubGLCheckFramebufferStatus; | |
969 functions->fDeleteFramebuffers = StubGLDeleteFramebuffers; | |
970 functions->fDeleteRenderbuffers = StubGLDeleteRenderbuffers; | |
971 functions->fFramebufferRenderbuffer = StubGLFramebufferRenderbuffer; | |
972 functions->fFramebufferTexture2D = StubGLFramebufferTexture2D; | |
973 functions->fFramebufferTexture2DMultisample = | |
974 StubGLFramebufferTexture2DMultisample; | |
975 functions->fGenFramebuffers = StubGLGenFramebuffers; | |
976 functions->fGenRenderbuffers = StubGLGenRenderbuffers; | |
977 functions->fGetFramebufferAttachmentParameteriv = | |
978 StubGLGetFramebufferAttachmentParameteriv; | |
979 functions->fGetRenderbufferParameteriv = StubGLGetRenderbufferParameteriv; | |
980 functions->fRenderbufferStorage = StubGLRenderbufferStorage; | |
981 functions->fRenderbufferStorageMultisample = | |
982 StubGLRenderbufferStorageMultisample; | |
983 functions->fRenderbufferStorageMultisampleES2EXT = | |
984 StubGLRenderbufferStorageMultisample; | |
985 functions->fBlitFramebuffer = StubGLBlitFramebuffer; | |
986 functions->fMapBuffer = StubGLMapBuffer; | |
987 functions->fUnmapBuffer = StubGLUnmapBuffer; | |
988 functions->fBindFragDataLocationIndexed = | |
989 StubGLBindFragDataLocationIndexed; | |
990 functions->fGetProgramResourceLocation = StubGLGetProgramResourceLocation; | |
991 | |
992 return interface; | |
993 } | |
994 | |
995 } // namespace gfx | |
OLD | NEW |