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.
5 #include "gpu/blink/webgraphicscontext3d_impl.h"
7 #include "base/atomicops.h"
8 #include "base/lazy_instance.h"
9 #include "base/logging.h"
10 #include "gpu/GLES2/gl2extchromium.h"
11 #include "gpu/command_buffer/client/gles2_implementation.h"
12 #include "gpu/command_buffer/client/gles2_lib.h"
13 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
14 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
16 #include "third_party/khronos/GLES2/gl2.h"
17 #ifndef GL_GLEXT_PROTOTYPES
18 #define GL_GLEXT_PROTOTYPES 1
20 #include "third_party/khronos/GLES2/gl2ext.h"
26 uint32_t GenFlushID() {
27 static base::subtle::Atomic32 flush_id
= 0;
29 base::subtle::Atomic32 my_id
= base::subtle::Barrier_AtomicIncrement(
31 return static_cast<uint32_t>(my_id
);
34 } // namespace anonymous
36 class WebGraphicsContext3DErrorMessageCallback
37 : public ::gpu::gles2::GLES2ImplementationErrorMessageCallback
{
39 WebGraphicsContext3DErrorMessageCallback(
40 WebGraphicsContext3DImpl
* context
)
41 : graphics_context_(context
) {
44 void OnErrorMessage(const char* msg
, int id
) override
;
47 WebGraphicsContext3DImpl
* graphics_context_
;
49 DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback
);
52 void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage(
53 const char* msg
, int id
) {
54 graphics_context_
->OnErrorMessage(msg
, id
);
57 // Helper macros to reduce the amount of code.
59 #define DELEGATE_TO_GL(name, glname) \
60 void WebGraphicsContext3DImpl::name() { \
64 #define DELEGATE_TO_GL_R(name, glname, rt) \
65 rt WebGraphicsContext3DImpl::name() { \
66 return gl_->glname(); \
69 #define DELEGATE_TO_GL_1(name, glname, t1) \
70 void WebGraphicsContext3DImpl::name(t1 a1) { \
74 #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \
75 rt WebGraphicsContext3DImpl::name(t1 a1) { \
76 return gl_->glname(a1); \
79 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \
80 rt WebGraphicsContext3DImpl::name(t1 a1) { \
81 return gl_->glname(a1) ? true : false; \
84 #define DELEGATE_TO_GL_2(name, glname, t1, t2) \
85 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2) { \
86 gl_->glname(a1, a2); \
89 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \
90 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2) { \
91 return gl_->glname(a1, a2); \
94 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \
95 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3) { \
96 gl_->glname(a1, a2, a3); \
99 #define DELEGATE_TO_GL_3R(name, glname, t1, t2, t3, rt) \
100 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3) { \
101 return gl_->glname(a1, a2, a3); \
104 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \
105 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
106 gl_->glname(a1, a2, a3, a4); \
109 #define DELEGATE_TO_GL_4R(name, glname, t1, t2, t3, t4, rt) \
110 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
111 return gl_->glname(a1, a2, a3, a4); \
114 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \
115 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) {\
117 gl_->glname(a1, a2, a3, a4, a5); \
120 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \
121 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
123 gl_->glname(a1, a2, a3, a4, a5, a6); \
126 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \
127 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
129 gl_->glname(a1, a2, a3, a4, a5, a6, a7); \
132 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \
133 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
134 t6 a6, t7 a7, t8 a8) { \
135 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \
138 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
139 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
140 t6 a6, t7 a7, t8 a8, t9 a9) { \
141 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
144 #define DELEGATE_TO_GL_9R(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, \
146 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
147 t6 a6, t7 a7, t8 a8, t9 a9) { \
148 return gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
151 #define DELEGATE_TO_GL_10(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, \
153 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
154 t6 a6, t7 a7, t8 a8, t9 a9, \
156 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); \
159 #define DELEGATE_TO_GL_11(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, \
161 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
162 t6 a6, t7 a7, t8 a8, t9 a9, t10 a10,\
164 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); \
167 WebGraphicsContext3DImpl::WebGraphicsContext3DImpl()
168 : initialized_(false),
169 initialize_failed_(false),
170 context_lost_callback_(0),
171 context_lost_reason_(GL_NO_ERROR
),
172 error_message_callback_(0),
177 WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() {
181 void WebGraphicsContext3DImpl::synthesizeGLError(WGC3Denum error
) {
182 if (std::find(synthetic_errors_
.begin(), synthetic_errors_
.end(), error
) ==
183 synthetic_errors_
.end()) {
184 synthetic_errors_
.push_back(error
);
188 uint32_t WebGraphicsContext3DImpl::lastFlushID() {
192 DELEGATE_TO_GL_R(insertSyncPoint
, InsertSyncPointCHROMIUM
, unsigned int)
194 DELEGATE_TO_GL_3(reshapeWithScaleFactor
, ResizeCHROMIUM
, int, int, float)
196 DELEGATE_TO_GL_4R(mapBufferSubDataCHROMIUM
, MapBufferSubDataCHROMIUM
, WGC3Denum
,
197 WGC3Dintptr
, WGC3Dsizeiptr
, WGC3Denum
, void*)
199 DELEGATE_TO_GL_1(unmapBufferSubDataCHROMIUM
, UnmapBufferSubDataCHROMIUM
,
202 DELEGATE_TO_GL_9R(mapTexSubImage2DCHROMIUM
, MapTexSubImage2DCHROMIUM
, WGC3Denum
,
203 WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
,
204 WGC3Denum
, WGC3Denum
, WGC3Denum
, void*)
206 DELEGATE_TO_GL_1(unmapTexSubImage2DCHROMIUM
, UnmapTexSubImage2DCHROMIUM
,
209 DELEGATE_TO_GL_3(discardFramebufferEXT
, DiscardFramebufferEXT
, WGC3Denum
,
210 WGC3Dsizei
, const WGC3Denum
*)
212 blink::WebString
WebGraphicsContext3DImpl::
213 getRequestableExtensionsCHROMIUM() {
214 return blink::WebString::fromUTF8(
215 gl_
->GetRequestableExtensionsCHROMIUM());
218 DELEGATE_TO_GL_1(requestExtensionCHROMIUM
, RequestExtensionCHROMIUM
,
221 void WebGraphicsContext3DImpl::blitFramebufferCHROMIUM(
222 WGC3Dint srcX0
, WGC3Dint srcY0
, WGC3Dint srcX1
, WGC3Dint srcY1
,
223 WGC3Dint dstX0
, WGC3Dint dstY0
, WGC3Dint dstX1
, WGC3Dint dstY1
,
224 WGC3Dbitfield mask
, WGC3Denum filter
) {
225 gl_
->BlitFramebufferCHROMIUM(
226 srcX0
, srcY0
, srcX1
, srcY1
,
227 dstX0
, dstY0
, dstX1
, dstY1
,
231 DELEGATE_TO_GL_5(renderbufferStorageMultisampleCHROMIUM
,
232 RenderbufferStorageMultisampleCHROMIUM
, WGC3Denum
, WGC3Dsizei
,
233 WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
)
235 DELEGATE_TO_GL_1(activeTexture
, ActiveTexture
, WGC3Denum
)
237 DELEGATE_TO_GL_2(attachShader
, AttachShader
, WebGLId
, WebGLId
)
239 DELEGATE_TO_GL_3(bindAttribLocation
, BindAttribLocation
, WebGLId
,
240 WGC3Duint
, const WGC3Dchar
*)
242 DELEGATE_TO_GL_2(bindBuffer
, BindBuffer
, WGC3Denum
, WebGLId
)
244 DELEGATE_TO_GL_2(bindFramebuffer
, BindFramebuffer
, WGC3Denum
, WebGLId
)
246 DELEGATE_TO_GL_2(bindRenderbuffer
, BindRenderbuffer
, WGC3Denum
, WebGLId
)
248 DELEGATE_TO_GL_2(bindTexture
, BindTexture
, WGC3Denum
, WebGLId
)
250 DELEGATE_TO_GL_4(blendColor
, BlendColor
,
251 WGC3Dclampf
, WGC3Dclampf
, WGC3Dclampf
, WGC3Dclampf
)
253 DELEGATE_TO_GL_1(blendEquation
, BlendEquation
, WGC3Denum
)
255 DELEGATE_TO_GL_2(blendEquationSeparate
, BlendEquationSeparate
,
256 WGC3Denum
, WGC3Denum
)
258 DELEGATE_TO_GL_2(blendFunc
, BlendFunc
, WGC3Denum
, WGC3Denum
)
260 DELEGATE_TO_GL_4(blendFuncSeparate
, BlendFuncSeparate
,
261 WGC3Denum
, WGC3Denum
, WGC3Denum
, WGC3Denum
)
263 DELEGATE_TO_GL_4(bufferData
, BufferData
,
264 WGC3Denum
, WGC3Dsizeiptr
, const void*, WGC3Denum
)
266 DELEGATE_TO_GL_4(bufferSubData
, BufferSubData
,
267 WGC3Denum
, WGC3Dintptr
, WGC3Dsizeiptr
, const void*)
269 DELEGATE_TO_GL_1R(checkFramebufferStatus
, CheckFramebufferStatus
,
270 WGC3Denum
, WGC3Denum
)
272 DELEGATE_TO_GL_1(clear
, Clear
, WGC3Dbitfield
)
274 DELEGATE_TO_GL_4(clearColor
, ClearColor
,
275 WGC3Dclampf
, WGC3Dclampf
, WGC3Dclampf
, WGC3Dclampf
)
277 DELEGATE_TO_GL_1(clearDepth
, ClearDepthf
, WGC3Dclampf
)
279 DELEGATE_TO_GL_1(clearStencil
, ClearStencil
, WGC3Dint
)
281 DELEGATE_TO_GL_4(colorMask
, ColorMask
,
282 WGC3Dboolean
, WGC3Dboolean
, WGC3Dboolean
, WGC3Dboolean
)
284 DELEGATE_TO_GL_1(compileShader
, CompileShader
, WebGLId
)
286 DELEGATE_TO_GL_8(compressedTexImage2D
, CompressedTexImage2D
,
287 WGC3Denum
, WGC3Dint
, WGC3Denum
, WGC3Dint
, WGC3Dint
,
288 WGC3Dsizei
, WGC3Dsizei
, const void*)
290 DELEGATE_TO_GL_9(compressedTexSubImage2D
, CompressedTexSubImage2D
,
291 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
,
292 WGC3Denum
, WGC3Dsizei
, const void*)
294 DELEGATE_TO_GL_8(copyTexImage2D
, CopyTexImage2D
,
295 WGC3Denum
, WGC3Dint
, WGC3Denum
, WGC3Dint
, WGC3Dint
,
296 WGC3Dsizei
, WGC3Dsizei
, WGC3Dint
)
298 DELEGATE_TO_GL_8(copyTexSubImage2D
, CopyTexSubImage2D
,
299 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
,
300 WGC3Dsizei
, WGC3Dsizei
)
302 DELEGATE_TO_GL_1(cullFace
, CullFace
, WGC3Denum
)
304 DELEGATE_TO_GL_1(depthFunc
, DepthFunc
, WGC3Denum
)
306 DELEGATE_TO_GL_1(depthMask
, DepthMask
, WGC3Dboolean
)
308 DELEGATE_TO_GL_2(depthRange
, DepthRangef
, WGC3Dclampf
, WGC3Dclampf
)
310 DELEGATE_TO_GL_2(detachShader
, DetachShader
, WebGLId
, WebGLId
)
312 DELEGATE_TO_GL_1(disable
, Disable
, WGC3Denum
)
314 DELEGATE_TO_GL_1(disableVertexAttribArray
, DisableVertexAttribArray
,
317 DELEGATE_TO_GL_3(drawArrays
, DrawArrays
, WGC3Denum
, WGC3Dint
, WGC3Dsizei
)
319 void WebGraphicsContext3DImpl::drawElements(WGC3Denum mode
,
322 WGC3Dintptr offset
) {
325 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)));
328 DELEGATE_TO_GL_1(enable
, Enable
, WGC3Denum
)
330 DELEGATE_TO_GL_1(enableVertexAttribArray
, EnableVertexAttribArray
,
333 void WebGraphicsContext3DImpl::finish() {
334 flush_id_
= GenFlushID();
338 void WebGraphicsContext3DImpl::flush() {
339 flush_id_
= GenFlushID();
343 DELEGATE_TO_GL_4(framebufferRenderbuffer
, FramebufferRenderbuffer
,
344 WGC3Denum
, WGC3Denum
, WGC3Denum
, WebGLId
)
346 DELEGATE_TO_GL_5(framebufferTexture2D
, FramebufferTexture2D
,
347 WGC3Denum
, WGC3Denum
, WGC3Denum
, WebGLId
, WGC3Dint
)
349 DELEGATE_TO_GL_1(frontFace
, FrontFace
, WGC3Denum
)
351 DELEGATE_TO_GL_1(generateMipmap
, GenerateMipmap
, WGC3Denum
)
353 bool WebGraphicsContext3DImpl::getActiveAttrib(
354 WebGLId program
, WGC3Duint index
, ActiveInfo
& info
) {
356 synthesizeGLError(GL_INVALID_VALUE
);
359 GLint max_name_length
= -1;
361 program
, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
, &max_name_length
);
362 if (max_name_length
< 0)
364 scoped_ptr
<GLchar
[]> name(new GLchar
[max_name_length
]);
366 synthesizeGLError(GL_OUT_OF_MEMORY
);
372 gl_
->GetActiveAttrib(
373 program
, index
, max_name_length
, &length
, &size
, &type
, name
.get());
377 info
.name
= blink::WebString::fromUTF8(name
.get(), length
);
383 bool WebGraphicsContext3DImpl::getActiveUniform(
384 WebGLId program
, WGC3Duint index
, ActiveInfo
& info
) {
385 GLint max_name_length
= -1;
387 program
, GL_ACTIVE_UNIFORM_MAX_LENGTH
, &max_name_length
);
388 if (max_name_length
< 0)
390 scoped_ptr
<GLchar
[]> name(new GLchar
[max_name_length
]);
392 synthesizeGLError(GL_OUT_OF_MEMORY
);
398 gl_
->GetActiveUniform(
399 program
, index
, max_name_length
, &length
, &size
, &type
, name
.get());
403 info
.name
= blink::WebString::fromUTF8(name
.get(), length
);
409 DELEGATE_TO_GL_4(getAttachedShaders
, GetAttachedShaders
,
410 WebGLId
, WGC3Dsizei
, WGC3Dsizei
*, WebGLId
*)
412 DELEGATE_TO_GL_2R(getAttribLocation
, GetAttribLocation
,
413 WebGLId
, const WGC3Dchar
*, WGC3Dint
)
415 DELEGATE_TO_GL_2(getBooleanv
, GetBooleanv
, WGC3Denum
, WGC3Dboolean
*)
417 DELEGATE_TO_GL_3(getBufferParameteriv
, GetBufferParameteriv
,
418 WGC3Denum
, WGC3Denum
, WGC3Dint
*)
420 WGC3Denum
WebGraphicsContext3DImpl::getError() {
421 if (!synthetic_errors_
.empty()) {
422 std::vector
<WGC3Denum
>::iterator iter
= synthetic_errors_
.begin();
423 WGC3Denum err
= *iter
;
424 synthetic_errors_
.erase(iter
);
428 return gl_
->GetError();
431 DELEGATE_TO_GL_2(getFloatv
, GetFloatv
, WGC3Denum
, WGC3Dfloat
*)
433 DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv
,
434 GetFramebufferAttachmentParameteriv
,
435 WGC3Denum
, WGC3Denum
, WGC3Denum
, WGC3Dint
*)
437 DELEGATE_TO_GL_2(getIntegerv
, GetIntegerv
, WGC3Denum
, WGC3Dint
*)
439 DELEGATE_TO_GL_3(getProgramiv
, GetProgramiv
, WebGLId
, WGC3Denum
, WGC3Dint
*)
441 blink::WebString
WebGraphicsContext3DImpl::getProgramInfoLog(
444 gl_
->GetProgramiv(program
, GL_INFO_LOG_LENGTH
, &logLength
);
446 return blink::WebString();
447 scoped_ptr
<GLchar
[]> log(new GLchar
[logLength
]);
449 return blink::WebString();
450 GLsizei returnedLogLength
= 0;
451 gl_
->GetProgramInfoLog(
452 program
, logLength
, &returnedLogLength
, log
.get());
453 DCHECK_EQ(logLength
, returnedLogLength
+ 1);
454 blink::WebString res
=
455 blink::WebString::fromUTF8(log
.get(), returnedLogLength
);
459 DELEGATE_TO_GL_3(getRenderbufferParameteriv
, GetRenderbufferParameteriv
,
460 WGC3Denum
, WGC3Denum
, WGC3Dint
*)
462 DELEGATE_TO_GL_3(getShaderiv
, GetShaderiv
, WebGLId
, WGC3Denum
, WGC3Dint
*)
464 blink::WebString
WebGraphicsContext3DImpl::getShaderInfoLog(
467 gl_
->GetShaderiv(shader
, GL_INFO_LOG_LENGTH
, &logLength
);
469 return blink::WebString();
470 scoped_ptr
<GLchar
[]> log(new GLchar
[logLength
]);
472 return blink::WebString();
473 GLsizei returnedLogLength
= 0;
474 gl_
->GetShaderInfoLog(
475 shader
, logLength
, &returnedLogLength
, log
.get());
476 DCHECK_EQ(logLength
, returnedLogLength
+ 1);
477 blink::WebString res
=
478 blink::WebString::fromUTF8(log
.get(), returnedLogLength
);
482 DELEGATE_TO_GL_4(getShaderPrecisionFormat
, GetShaderPrecisionFormat
,
483 WGC3Denum
, WGC3Denum
, WGC3Dint
*, WGC3Dint
*)
485 blink::WebString
WebGraphicsContext3DImpl::getShaderSource(
488 gl_
->GetShaderiv(shader
, GL_SHADER_SOURCE_LENGTH
, &logLength
);
490 return blink::WebString();
491 scoped_ptr
<GLchar
[]> log(new GLchar
[logLength
]);
493 return blink::WebString();
494 GLsizei returnedLogLength
= 0;
495 gl_
->GetShaderSource(
496 shader
, logLength
, &returnedLogLength
, log
.get());
497 if (!returnedLogLength
)
498 return blink::WebString();
499 DCHECK_EQ(logLength
, returnedLogLength
+ 1);
500 blink::WebString res
=
501 blink::WebString::fromUTF8(log
.get(), returnedLogLength
);
505 blink::WebString
WebGraphicsContext3DImpl::
506 getTranslatedShaderSourceANGLE(WebGLId shader
) {
509 shader
, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE
, &logLength
);
511 return blink::WebString();
512 scoped_ptr
<GLchar
[]> log(new GLchar
[logLength
]);
514 return blink::WebString();
515 GLsizei returnedLogLength
= 0;
516 gl_
->GetTranslatedShaderSourceANGLE(
517 shader
, logLength
, &returnedLogLength
, log
.get());
518 if (!returnedLogLength
)
519 return blink::WebString();
520 DCHECK_EQ(logLength
, returnedLogLength
+ 1);
521 blink::WebString res
=
522 blink::WebString::fromUTF8(log
.get(), returnedLogLength
);
526 blink::WebString
WebGraphicsContext3DImpl::getString(
528 return blink::WebString::fromUTF8(
529 reinterpret_cast<const char*>(gl_
->GetString(name
)));
532 DELEGATE_TO_GL_3(getTexParameterfv
, GetTexParameterfv
,
533 WGC3Denum
, WGC3Denum
, WGC3Dfloat
*)
535 DELEGATE_TO_GL_3(getTexParameteriv
, GetTexParameteriv
,
536 WGC3Denum
, WGC3Denum
, WGC3Dint
*)
538 DELEGATE_TO_GL_3(getUniformfv
, GetUniformfv
, WebGLId
, WGC3Dint
, WGC3Dfloat
*)
540 DELEGATE_TO_GL_3(getUniformiv
, GetUniformiv
, WebGLId
, WGC3Dint
, WGC3Dint
*)
542 DELEGATE_TO_GL_2R(getUniformLocation
, GetUniformLocation
,
543 WebGLId
, const WGC3Dchar
*, WGC3Dint
)
545 DELEGATE_TO_GL_3(getVertexAttribfv
, GetVertexAttribfv
,
546 WGC3Duint
, WGC3Denum
, WGC3Dfloat
*)
548 DELEGATE_TO_GL_3(getVertexAttribiv
, GetVertexAttribiv
,
549 WGC3Duint
, WGC3Denum
, WGC3Dint
*)
551 WGC3Dsizeiptr
WebGraphicsContext3DImpl::getVertexAttribOffset(
552 WGC3Duint index
, WGC3Denum pname
) {
553 GLvoid
* value
= NULL
;
554 // NOTE: If pname is ever a value that returns more then 1 element
555 // this will corrupt memory.
556 gl_
->GetVertexAttribPointerv(index
, pname
, &value
);
557 return static_cast<WGC3Dsizeiptr
>(reinterpret_cast<intptr_t>(value
));
560 DELEGATE_TO_GL_2(hint
, Hint
, WGC3Denum
, WGC3Denum
)
562 DELEGATE_TO_GL_1RB(isBuffer
, IsBuffer
, WebGLId
, WGC3Dboolean
)
564 DELEGATE_TO_GL_1RB(isEnabled
, IsEnabled
, WGC3Denum
, WGC3Dboolean
)
566 DELEGATE_TO_GL_1RB(isFramebuffer
, IsFramebuffer
, WebGLId
, WGC3Dboolean
)
568 DELEGATE_TO_GL_1RB(isProgram
, IsProgram
, WebGLId
, WGC3Dboolean
)
570 DELEGATE_TO_GL_1RB(isRenderbuffer
, IsRenderbuffer
, WebGLId
, WGC3Dboolean
)
572 DELEGATE_TO_GL_1RB(isShader
, IsShader
, WebGLId
, WGC3Dboolean
)
574 DELEGATE_TO_GL_1RB(isTexture
, IsTexture
, WebGLId
, WGC3Dboolean
)
576 DELEGATE_TO_GL_1(lineWidth
, LineWidth
, WGC3Dfloat
)
578 DELEGATE_TO_GL_1(linkProgram
, LinkProgram
, WebGLId
)
580 DELEGATE_TO_GL_2(pixelStorei
, PixelStorei
, WGC3Denum
, WGC3Dint
)
582 DELEGATE_TO_GL_2(polygonOffset
, PolygonOffset
, WGC3Dfloat
, WGC3Dfloat
)
584 DELEGATE_TO_GL_7(readPixels
, ReadPixels
,
585 WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
, WGC3Denum
,
588 DELEGATE_TO_GL_4(renderbufferStorage
, RenderbufferStorage
,
589 WGC3Denum
, WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
)
591 DELEGATE_TO_GL_2(sampleCoverage
, SampleCoverage
, WGC3Dfloat
, WGC3Dboolean
)
593 DELEGATE_TO_GL_4(scissor
, Scissor
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
)
595 void WebGraphicsContext3DImpl::shaderSource(
596 WebGLId shader
, const WGC3Dchar
* string
) {
597 GLint length
= strlen(string
);
598 gl_
->ShaderSource(shader
, 1, &string
, &length
);
601 DELEGATE_TO_GL_3(stencilFunc
, StencilFunc
, WGC3Denum
, WGC3Dint
, WGC3Duint
)
603 DELEGATE_TO_GL_4(stencilFuncSeparate
, StencilFuncSeparate
,
604 WGC3Denum
, WGC3Denum
, WGC3Dint
, WGC3Duint
)
606 DELEGATE_TO_GL_1(stencilMask
, StencilMask
, WGC3Duint
)
608 DELEGATE_TO_GL_2(stencilMaskSeparate
, StencilMaskSeparate
,
609 WGC3Denum
, WGC3Duint
)
611 DELEGATE_TO_GL_3(stencilOp
, StencilOp
,
612 WGC3Denum
, WGC3Denum
, WGC3Denum
)
614 DELEGATE_TO_GL_4(stencilOpSeparate
, StencilOpSeparate
,
615 WGC3Denum
, WGC3Denum
, WGC3Denum
, WGC3Denum
)
617 DELEGATE_TO_GL_9(texImage2D
, TexImage2D
,
618 WGC3Denum
, WGC3Dint
, WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
,
619 WGC3Dint
, WGC3Denum
, WGC3Denum
, const void*)
621 DELEGATE_TO_GL_3(texParameterf
, TexParameterf
,
622 WGC3Denum
, WGC3Denum
, WGC3Dfloat
);
624 static const unsigned int kTextureWrapR
= 0x8072;
626 void WebGraphicsContext3DImpl::texParameteri(
627 WGC3Denum target
, WGC3Denum pname
, WGC3Dint param
) {
628 // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in
629 // GraphicsContext3D.cpp is strictly necessary to avoid seams at the
630 // edge of cube maps, and, if it is, push it into the GLES2 service
632 if (pname
== kTextureWrapR
) {
635 gl_
->TexParameteri(target
, pname
, param
);
638 DELEGATE_TO_GL_9(texSubImage2D
, TexSubImage2D
,
639 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
640 WGC3Dsizei
, WGC3Denum
, WGC3Denum
, const void*)
642 DELEGATE_TO_GL_2(uniform1f
, Uniform1f
, WGC3Dint
, WGC3Dfloat
)
644 DELEGATE_TO_GL_3(uniform1fv
, Uniform1fv
, WGC3Dint
, WGC3Dsizei
,
647 DELEGATE_TO_GL_2(uniform1i
, Uniform1i
, WGC3Dint
, WGC3Dint
)
649 DELEGATE_TO_GL_3(uniform1iv
, Uniform1iv
, WGC3Dint
, WGC3Dsizei
, const WGC3Dint
*)
651 DELEGATE_TO_GL_3(uniform2f
, Uniform2f
, WGC3Dint
, WGC3Dfloat
, WGC3Dfloat
)
653 DELEGATE_TO_GL_3(uniform2fv
, Uniform2fv
, WGC3Dint
, WGC3Dsizei
,
656 DELEGATE_TO_GL_3(uniform2i
, Uniform2i
, WGC3Dint
, WGC3Dint
, WGC3Dint
)
658 DELEGATE_TO_GL_3(uniform2iv
, Uniform2iv
, WGC3Dint
, WGC3Dsizei
, const WGC3Dint
*)
660 DELEGATE_TO_GL_4(uniform3f
, Uniform3f
, WGC3Dint
,
661 WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
)
663 DELEGATE_TO_GL_3(uniform3fv
, Uniform3fv
, WGC3Dint
, WGC3Dsizei
,
666 DELEGATE_TO_GL_4(uniform3i
, Uniform3i
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
)
668 DELEGATE_TO_GL_3(uniform3iv
, Uniform3iv
, WGC3Dint
, WGC3Dsizei
, const WGC3Dint
*)
670 DELEGATE_TO_GL_5(uniform4f
, Uniform4f
, WGC3Dint
,
671 WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
)
673 DELEGATE_TO_GL_3(uniform4fv
, Uniform4fv
, WGC3Dint
, WGC3Dsizei
,
676 DELEGATE_TO_GL_5(uniform4i
, Uniform4i
, WGC3Dint
,
677 WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
)
679 DELEGATE_TO_GL_3(uniform4iv
, Uniform4iv
, WGC3Dint
, WGC3Dsizei
, const WGC3Dint
*)
681 DELEGATE_TO_GL_4(uniformMatrix2fv
, UniformMatrix2fv
,
682 WGC3Dint
, WGC3Dsizei
, WGC3Dboolean
, const WGC3Dfloat
*)
684 DELEGATE_TO_GL_4(uniformMatrix3fv
, UniformMatrix3fv
,
685 WGC3Dint
, WGC3Dsizei
, WGC3Dboolean
, const WGC3Dfloat
*)
687 DELEGATE_TO_GL_4(uniformMatrix4fv
, UniformMatrix4fv
,
688 WGC3Dint
, WGC3Dsizei
, WGC3Dboolean
, const WGC3Dfloat
*)
690 DELEGATE_TO_GL_1(useProgram
, UseProgram
, WebGLId
)
692 DELEGATE_TO_GL_1(validateProgram
, ValidateProgram
, WebGLId
)
694 DELEGATE_TO_GL_2(vertexAttrib1f
, VertexAttrib1f
, WGC3Duint
, WGC3Dfloat
)
696 DELEGATE_TO_GL_2(vertexAttrib1fv
, VertexAttrib1fv
, WGC3Duint
,
699 DELEGATE_TO_GL_3(vertexAttrib2f
, VertexAttrib2f
, WGC3Duint
,
700 WGC3Dfloat
, WGC3Dfloat
)
702 DELEGATE_TO_GL_2(vertexAttrib2fv
, VertexAttrib2fv
, WGC3Duint
,
705 DELEGATE_TO_GL_4(vertexAttrib3f
, VertexAttrib3f
, WGC3Duint
,
706 WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
)
708 DELEGATE_TO_GL_2(vertexAttrib3fv
, VertexAttrib3fv
, WGC3Duint
,
711 DELEGATE_TO_GL_5(vertexAttrib4f
, VertexAttrib4f
, WGC3Duint
,
712 WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
)
714 DELEGATE_TO_GL_2(vertexAttrib4fv
, VertexAttrib4fv
, WGC3Duint
,
717 void WebGraphicsContext3DImpl::vertexAttribPointer(
718 WGC3Duint index
, WGC3Dint size
, WGC3Denum type
, WGC3Dboolean normalized
,
719 WGC3Dsizei stride
, WGC3Dintptr offset
) {
720 gl_
->VertexAttribPointer(
721 index
, size
, type
, normalized
, stride
,
722 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)));
725 DELEGATE_TO_GL_4(viewport
, Viewport
,
726 WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
)
728 WebGLId
WebGraphicsContext3DImpl::createBuffer() {
730 gl_
->GenBuffers(1, &o
);
734 WebGLId
WebGraphicsContext3DImpl::createFramebuffer() {
736 gl_
->GenFramebuffers(1, &o
);
740 WebGLId
WebGraphicsContext3DImpl::createRenderbuffer() {
742 gl_
->GenRenderbuffers(1, &o
);
746 WebGLId
WebGraphicsContext3DImpl::createTexture() {
748 gl_
->GenTextures(1, &o
);
752 void WebGraphicsContext3DImpl::deleteBuffer(WebGLId buffer
) {
753 gl_
->DeleteBuffers(1, &buffer
);
756 void WebGraphicsContext3DImpl::deleteFramebuffer(
757 WebGLId framebuffer
) {
758 gl_
->DeleteFramebuffers(1, &framebuffer
);
761 void WebGraphicsContext3DImpl::deleteRenderbuffer(
762 WebGLId renderbuffer
) {
763 gl_
->DeleteRenderbuffers(1, &renderbuffer
);
766 void WebGraphicsContext3DImpl::deleteTexture(WebGLId texture
) {
767 gl_
->DeleteTextures(1, &texture
);
770 DELEGATE_TO_GL_R(createProgram
, CreateProgram
, WebGLId
)
772 DELEGATE_TO_GL_1R(createShader
, CreateShader
, WGC3Denum
, WebGLId
)
774 DELEGATE_TO_GL_1(deleteProgram
, DeleteProgram
, WebGLId
)
776 DELEGATE_TO_GL_1(deleteShader
, DeleteShader
, WebGLId
)
778 void WebGraphicsContext3DImpl::setErrorMessageCallback(
779 WebGraphicsContext3D::WebGraphicsErrorMessageCallback
* cb
) {
780 error_message_callback_
= cb
;
783 void WebGraphicsContext3DImpl::setContextLostCallback(
784 WebGraphicsContext3D::WebGraphicsContextLostCallback
* cb
) {
785 context_lost_callback_
= cb
;
788 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM
, TexImageIOSurface2DCHROMIUM
,
789 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Duint
, WGC3Duint
)
791 DELEGATE_TO_GL_5(texStorage2DEXT
, TexStorage2DEXT
,
792 WGC3Denum
, WGC3Dint
, WGC3Duint
, WGC3Dint
, WGC3Dint
)
794 WebGLId
WebGraphicsContext3DImpl::createQueryEXT() {
796 gl_
->GenQueriesEXT(1, &o
);
800 void WebGraphicsContext3DImpl::deleteQueryEXT(
802 gl_
->DeleteQueriesEXT(1, &query
);
805 DELEGATE_TO_GL_1R(isQueryEXT
, IsQueryEXT
, WebGLId
, WGC3Dboolean
)
806 DELEGATE_TO_GL_2(beginQueryEXT
, BeginQueryEXT
, WGC3Denum
, WebGLId
)
807 DELEGATE_TO_GL_1(endQueryEXT
, EndQueryEXT
, WGC3Denum
)
808 DELEGATE_TO_GL_3(getQueryivEXT
, GetQueryivEXT
, WGC3Denum
, WGC3Denum
, WGC3Dint
*)
809 DELEGATE_TO_GL_3(getQueryObjectuivEXT
, GetQueryObjectuivEXT
,
810 WebGLId
, WGC3Denum
, WGC3Duint
*)
812 DELEGATE_TO_GL_6(copyTextureCHROMIUM
, CopyTextureCHROMIUM
, WGC3Denum
,
813 WebGLId
, WebGLId
, WGC3Dint
, WGC3Denum
, WGC3Denum
);
815 DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM
, BindUniformLocationCHROMIUM
,
816 WebGLId
, WGC3Dint
, const WGC3Dchar
*)
818 void WebGraphicsContext3DImpl::shallowFlushCHROMIUM() {
819 flush_id_
= GenFlushID();
820 gl_
->ShallowFlushCHROMIUM();
823 void WebGraphicsContext3DImpl::shallowFinishCHROMIUM() {
824 flush_id_
= GenFlushID();
825 gl_
->ShallowFinishCHROMIUM();
828 DELEGATE_TO_GL_1(waitSyncPoint
, WaitSyncPointCHROMIUM
, GLuint
)
830 void WebGraphicsContext3DImpl::loseContextCHROMIUM(
831 WGC3Denum current
, WGC3Denum other
) {
832 gl_
->LoseContextCHROMIUM(current
, other
);
836 DELEGATE_TO_GL_1(genMailboxCHROMIUM
, GenMailboxCHROMIUM
, WGC3Dbyte
*)
837 DELEGATE_TO_GL_2(produceTextureCHROMIUM
, ProduceTextureCHROMIUM
,
838 WGC3Denum
, const WGC3Dbyte
*)
839 DELEGATE_TO_GL_3(produceTextureDirectCHROMIUM
, ProduceTextureDirectCHROMIUM
,
840 WebGLId
, WGC3Denum
, const WGC3Dbyte
*)
841 DELEGATE_TO_GL_2(consumeTextureCHROMIUM
, ConsumeTextureCHROMIUM
,
842 WGC3Denum
, const WGC3Dbyte
*)
843 DELEGATE_TO_GL_2R(createAndConsumeTextureCHROMIUM
,
844 CreateAndConsumeTextureCHROMIUM
,
845 WGC3Denum
, const WGC3Dbyte
*, WebGLId
)
847 DELEGATE_TO_GL_2(genValuebuffersCHROMIUM
,
848 GenValuebuffersCHROMIUM
,
852 WebGLId
WebGraphicsContext3DImpl::createValuebufferCHROMIUM() {
854 gl_
->GenValuebuffersCHROMIUM(1, &o
);
858 DELEGATE_TO_GL_2(deleteValuebuffersCHROMIUM
,
859 DeleteValuebuffersCHROMIUM
,
863 void WebGraphicsContext3DImpl::deleteValuebufferCHROMIUM(WebGLId valuebuffer
) {
864 gl_
->DeleteValuebuffersCHROMIUM(1, &valuebuffer
);
867 DELEGATE_TO_GL_1RB(isValuebufferCHROMIUM
,
868 IsValuebufferCHROMIUM
,
871 DELEGATE_TO_GL_2(bindValuebufferCHROMIUM
,
872 BindValuebufferCHROMIUM
,
875 DELEGATE_TO_GL_2(subscribeValueCHROMIUM
,
876 SubscribeValueCHROMIUM
,
879 DELEGATE_TO_GL_1(populateSubscribedValuesCHROMIUM
,
880 PopulateSubscribedValuesCHROMIUM
,
882 DELEGATE_TO_GL_3(uniformValuebufferCHROMIUM
,
883 UniformValuebufferCHROMIUM
,
887 DELEGATE_TO_GL_2(traceBeginCHROMIUM
,
891 DELEGATE_TO_GL(traceEndCHROMIUM
, TraceEndCHROMIUM
);
893 void WebGraphicsContext3DImpl::insertEventMarkerEXT(
894 const WGC3Dchar
* marker
) {
895 gl_
->InsertEventMarkerEXT(0, marker
);
898 void WebGraphicsContext3DImpl::pushGroupMarkerEXT(
899 const WGC3Dchar
* marker
) {
900 gl_
->PushGroupMarkerEXT(0, marker
);
903 DELEGATE_TO_GL(popGroupMarkerEXT
, PopGroupMarkerEXT
);
905 WebGLId
WebGraphicsContext3DImpl::createVertexArrayOES() {
907 gl_
->GenVertexArraysOES(1, &array
);
911 void WebGraphicsContext3DImpl::deleteVertexArrayOES(
913 gl_
->DeleteVertexArraysOES(1, &array
);
916 DELEGATE_TO_GL_1R(isVertexArrayOES
, IsVertexArrayOES
, WebGLId
, WGC3Dboolean
)
917 DELEGATE_TO_GL_1(bindVertexArrayOES
, BindVertexArrayOES
, WebGLId
)
919 DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM
, BindTexImage2DCHROMIUM
,
921 DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM
, ReleaseTexImage2DCHROMIUM
,
924 DELEGATE_TO_GL_2R(mapBufferCHROMIUM
, MapBufferCHROMIUM
, WGC3Denum
, WGC3Denum
,
926 DELEGATE_TO_GL_1R(unmapBufferCHROMIUM
, UnmapBufferCHROMIUM
, WGC3Denum
,
929 DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM
, AsyncTexImage2DCHROMIUM
, WGC3Denum
,
930 WGC3Dint
, WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
, WGC3Dint
,
931 WGC3Denum
, WGC3Denum
, const void*)
932 DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM
, AsyncTexSubImage2DCHROMIUM
,
933 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
934 WGC3Dsizei
, WGC3Denum
, WGC3Denum
, const void*)
936 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM
, WaitAsyncTexImage2DCHROMIUM
,
939 DELEGATE_TO_GL_2(drawBuffersEXT
, DrawBuffersEXT
, WGC3Dsizei
, const WGC3Denum
*)
941 DELEGATE_TO_GL_4(drawArraysInstancedANGLE
, DrawArraysInstancedANGLE
, WGC3Denum
,
942 WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
)
944 void WebGraphicsContext3DImpl::drawElementsInstancedANGLE(
949 WGC3Dsizei primcount
) {
950 gl_
->DrawElementsInstancedANGLE(
952 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)), primcount
);
955 DELEGATE_TO_GL_2(vertexAttribDivisorANGLE
, VertexAttribDivisorANGLE
, WGC3Duint
,
958 DELEGATE_TO_GL_4R(createGpuMemoryBufferImageCHROMIUM
,
959 CreateGpuMemoryBufferImageCHROMIUM
,
966 DELEGATE_TO_GL_1(destroyImageCHROMIUM
, DestroyImageCHROMIUM
, WGC3Duint
);
968 DELEGATE_TO_GL_6(framebufferTexture2DMultisampleEXT
,
969 FramebufferTexture2DMultisampleEXT
,
970 WGC3Denum
, WGC3Denum
, WGC3Denum
, WebGLId
, WGC3Dint
, WGC3Dsizei
)
972 DELEGATE_TO_GL_5(renderbufferStorageMultisampleEXT
,
973 RenderbufferStorageMultisampleEXT
, WGC3Denum
, WGC3Dsizei
,
974 WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
)
976 DELEGATE_TO_GL_1(beginTransformFeedback
, BeginTransformFeedback
, WGC3Denum
)
977 DELEGATE_TO_GL_3(bindBufferBase
, BindBufferBase
, WGC3Denum
, WGC3Duint
,
979 DELEGATE_TO_GL_5(bindBufferRange
, BindBufferRange
, WGC3Denum
, WGC3Duint
,
980 WGC3Duint
, WGC3Dintptr
, WGC3Dsizeiptr
)
981 DELEGATE_TO_GL_2(bindSampler
, BindSampler
, WGC3Duint
, WebGLId
)
982 DELEGATE_TO_GL_2(bindTransformFeedback
, BindTransformFeedback
, WGC3Denum
,
984 DELEGATE_TO_GL_4(clearBufferfi
, ClearBufferfi
, WGC3Denum
, WGC3Dint
, WGC3Dfloat
,
986 DELEGATE_TO_GL_3(clearBufferfv
, ClearBufferfv
, WGC3Denum
, WGC3Dint
,
988 DELEGATE_TO_GL_3(clearBufferiv
, ClearBufferiv
, WGC3Denum
, WGC3Dint
,
990 DELEGATE_TO_GL_3(clearBufferuiv
, ClearBufferuiv
, WGC3Denum
, WGC3Dint
,
992 //DELEGATE_TO_GL_3R(clientWaitSync, ClientWaitSync, WebGLId, WGC3Dbitfield,
993 // WGC3Duint64, WGC3Denum)
994 //DELEGATE_TO_GL_9(compressedTexImage3D, CompressedTexImage3D, WGC3Denum,
995 // WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dsizei,
996 // WGC3Dint, WGC3Dsizei, const void *)
997 //DELEGATE_TO_GL_11(compressedTexSubImage3D, CompressedTexSubImage3D, WGC3Denum,
998 // WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
999 // WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Dsizei, const void *)
1000 DELEGATE_TO_GL_5(copyBufferSubData
, CopyBufferSubData
, WGC3Denum
, WGC3Denum
,
1001 WGC3Dintptr
, WGC3Dintptr
, WGC3Dsizeiptr
)
1002 DELEGATE_TO_GL_9(copyTexSubImage3D
, CopyTexSubImage3D
, WGC3Denum
, WGC3Dint
,
1003 WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
1005 WebGLId
WebGraphicsContext3DImpl::createSampler() {
1007 gl_
->GenSamplers(1, &sampler
);
1010 WebGLId
WebGraphicsContext3DImpl::createTransformFeedback() {
1012 gl_
->GenTransformFeedbacks(1, &tf
);
1015 void WebGraphicsContext3DImpl::deleteSampler(WebGLId sampler
) {
1016 gl_
->DeleteSamplers(1, &sampler
);
1018 //DELEGATE_TO_GL_1(deleteSync, DeleteSync, WebGLId)
1019 void WebGraphicsContext3DImpl::deleteTransformFeedback(WebGLId tf
) {
1020 gl_
->DeleteTransformFeedbacks(1, &tf
);
1022 DELEGATE_TO_GL(endTransformFeedback
, EndTransformFeedback
)
1023 //DELEGATE_TO_GL_2R(fenceSync, FenceSync, WGC3Denum, WGC3Dbitfield, WebGLId)
1024 DELEGATE_TO_GL_5(framebufferTextureLayer
, FramebufferTextureLayer
, WGC3Denum
,
1025 WGC3Denum
, WGC3Duint
, WGC3Dint
, WGC3Dint
)
1026 DELEGATE_TO_GL_5(getActiveUniformBlockName
, GetActiveUniformBlockName
,
1027 WGC3Duint
, WGC3Duint
, WGC3Dsizei
, WGC3Dsizei
*, WGC3Dchar
*)
1028 DELEGATE_TO_GL_4(getActiveUniformBlockiv
, GetActiveUniformBlockiv
, WGC3Duint
,
1029 WGC3Duint
, WGC3Denum
, WGC3Dint
*)
1030 //DELEGATE_TO_GL_5(getActiveUniformsiv, GetActiveUniformsiv, WGC3Duint,
1031 // WGC3Dsizei, const WGC3Duint *, WGC3Denum, WGC3Dint *)
1032 DELEGATE_TO_GL_2R(getFragDataLocation
, GetFragDataLocation
, WGC3Duint
,
1033 const WGC3Dchar
*, WGC3Dint
)
1034 DELEGATE_TO_GL_5(getInternalformativ
, GetInternalformativ
, WGC3Denum
, WGC3Denum
,
1035 WGC3Denum
, WGC3Dsizei
, WGC3Dint
*)
1036 DELEGATE_TO_GL_3(getSamplerParameterfv
, GetSamplerParameterfv
, WGC3Duint
,
1037 WGC3Denum
, WGC3Dfloat
*)
1038 DELEGATE_TO_GL_3(getSamplerParameteriv
, GetSamplerParameteriv
, WGC3Duint
,
1039 WGC3Denum
, WGC3Dint
*)
1040 //DELEGATE_TO_GL_7(getTransformFeedbackVarying, GetTransformFeedbackVarying,
1041 // WGC3Duint, WGC3Duint, WGC3Dsizei, WGC3Dsizei *, WGC3Dsizei *,
1042 // WGC3Denum *, WGC3Dchar *)
1043 DELEGATE_TO_GL_2R(getUniformBlockIndex
, GetUniformBlockIndex
, WGC3Duint
,
1044 const WGC3Dchar
*, WGC3Duint
)
1045 //DELEGATE_TO_GL_4(getUniformIndices, GetUniformIndices, WGC3Duint, WGC3Dsizei,
1046 // const WGC3Dchar *const*, WGC3Duint *)
1047 //DELEGATE_TO_GL_3(getUniformuiv, GetUniformuiv, WGC3Duint, WGC3Dint,
1049 //DELEGATE_TO_GL_3(getVertexAttribIiv, GetVertexAttribIiv, WGC3Duint,
1050 // WGC3Denum, WGC3Dint *)
1051 //DELEGATE_TO_GL_3(getVertexAttribIuiv, GetVertexAttribIuiv, WGC3Duint,
1052 // WGC3Denum, WGC3Duint *)
1053 DELEGATE_TO_GL_3(invalidateFramebuffer
, InvalidateFramebuffer
, WGC3Denum
,
1054 WGC3Dsizei
, const WGC3Denum
*)
1055 DELEGATE_TO_GL_7(invalidateSubFramebuffer
, InvalidateSubFramebuffer
, WGC3Denum
,
1056 WGC3Dsizei
, const WGC3Denum
*, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
1058 DELEGATE_TO_GL_1R(isSampler
, IsSampler
, WebGLId
, WGC3Dboolean
)
1059 //DELEGATE_TO_GL_1R(isSync, IsSync, WebGLId, WGC3Dboolean)
1060 DELEGATE_TO_GL_1R(isTransformFeedback
, IsTransformFeedback
, WGC3Duint
,
1062 DELEGATE_TO_GL(pauseTransformFeedback
, PauseTransformFeedback
)
1063 //DELEGATE_TO_GL_3(programParameteri, ProgramParameteri, WGC3Duint, WGC3Denum,
1065 DELEGATE_TO_GL_1(readBuffer
, ReadBuffer
, WGC3Denum
)
1066 DELEGATE_TO_GL(resumeTransformFeedback
, ResumeTransformFeedback
)
1067 DELEGATE_TO_GL_3(samplerParameterf
, SamplerParameterf
, WGC3Duint
, WGC3Denum
,
1069 DELEGATE_TO_GL_3(samplerParameterfv
, SamplerParameterfv
, WGC3Duint
, WGC3Denum
,
1071 DELEGATE_TO_GL_3(samplerParameteri
, SamplerParameteri
, WGC3Duint
, WGC3Denum
,
1073 DELEGATE_TO_GL_3(samplerParameteriv
, SamplerParameteriv
, WGC3Duint
, WGC3Denum
,
1075 DELEGATE_TO_GL_10(texImage3D
, TexImage3D
, WGC3Denum
, WGC3Dint
, WGC3Dint
,
1076 WGC3Dsizei
, WGC3Dsizei
, WGC3Dsizei
, WGC3Dint
, WGC3Denum
,
1077 WGC3Denum
, const void *)
1078 DELEGATE_TO_GL_6(texStorage3D
, TexStorage3D
, WGC3Denum
, WGC3Dsizei
, WGC3Denum
,
1079 WGC3Dsizei
, WGC3Dsizei
, WGC3Dsizei
)
1080 DELEGATE_TO_GL_11(texSubImage3D
, TexSubImage3D
, WGC3Denum
, WGC3Dint
, WGC3Dint
,
1081 WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
, WGC3Dsizei
,
1082 WGC3Denum
, WGC3Denum
, const void *)
1083 DELEGATE_TO_GL_4(transformFeedbackVaryings
, TransformFeedbackVaryings
,
1084 WGC3Duint
, WGC3Dsizei
, const WGC3Dchar
*const*, WGC3Denum
)
1085 DELEGATE_TO_GL_2(uniform1ui
, Uniform1ui
, WGC3Dint
, WGC3Duint
)
1086 DELEGATE_TO_GL_3(uniform1uiv
, Uniform1uiv
, WGC3Dint
, WGC3Dsizei
,
1088 DELEGATE_TO_GL_3(uniform2ui
, Uniform2ui
, WGC3Dint
, WGC3Duint
, WGC3Duint
)
1089 DELEGATE_TO_GL_3(uniform2uiv
, Uniform2uiv
, WGC3Dint
, WGC3Dsizei
,
1091 DELEGATE_TO_GL_4(uniform3ui
, Uniform3ui
, WGC3Dint
, WGC3Duint
, WGC3Duint
,
1093 DELEGATE_TO_GL_3(uniform3uiv
, Uniform3uiv
, WGC3Dint
, WGC3Dsizei
,
1095 DELEGATE_TO_GL_5(uniform4ui
, Uniform4ui
, WGC3Dint
, WGC3Duint
, WGC3Duint
,
1096 WGC3Duint
, WGC3Duint
)
1097 DELEGATE_TO_GL_3(uniform4uiv
, Uniform4uiv
, WGC3Dint
, WGC3Dsizei
,
1099 DELEGATE_TO_GL_3(uniformBlockBinding
, UniformBlockBinding
, WGC3Duint
, WGC3Duint
,
1101 DELEGATE_TO_GL_4(uniformMatrix2x3fv
, UniformMatrix2x3fv
, WGC3Dint
, WGC3Dsizei
,
1102 WGC3Dboolean
, const WGC3Dfloat
*)
1103 DELEGATE_TO_GL_4(uniformMatrix2x4fv
, UniformMatrix2x4fv
, WGC3Dint
, WGC3Dsizei
,
1104 WGC3Dboolean
, const WGC3Dfloat
*)
1105 DELEGATE_TO_GL_4(uniformMatrix3x2fv
, UniformMatrix3x2fv
, WGC3Dint
, WGC3Dsizei
,
1106 WGC3Dboolean
, const WGC3Dfloat
*)
1107 DELEGATE_TO_GL_4(uniformMatrix3x4fv
, UniformMatrix3x4fv
, WGC3Dint
, WGC3Dsizei
,
1108 WGC3Dboolean
, const WGC3Dfloat
*)
1109 DELEGATE_TO_GL_4(uniformMatrix4x2fv
, UniformMatrix4x2fv
, WGC3Dint
, WGC3Dsizei
,
1110 WGC3Dboolean
, const WGC3Dfloat
*)
1111 DELEGATE_TO_GL_4(uniformMatrix4x3fv
, UniformMatrix4x3fv
, WGC3Dint
, WGC3Dsizei
,
1112 WGC3Dboolean
, const WGC3Dfloat
*)
1113 DELEGATE_TO_GL_5(vertexAttribI4i
, VertexAttribI4i
, WGC3Duint
, WGC3Dint
,
1114 WGC3Dint
, WGC3Dint
, WGC3Dint
)
1115 DELEGATE_TO_GL_2(vertexAttribI4iv
, VertexAttribI4iv
, WGC3Duint
,
1117 DELEGATE_TO_GL_5(vertexAttribI4ui
, VertexAttribI4ui
, WGC3Duint
, WGC3Duint
,
1118 WGC3Duint
, WGC3Duint
, WGC3Duint
)
1119 DELEGATE_TO_GL_2(vertexAttribI4uiv
, VertexAttribI4uiv
, WGC3Duint
,
1121 void WebGraphicsContext3DImpl::vertexAttribIPointer(
1122 WGC3Duint index
, WGC3Dint size
, WGC3Denum type
, WGC3Dsizei stride
,
1123 WGC3Dintptr offset
) {
1124 gl_
->VertexAttribIPointer(
1125 index
, size
, type
, stride
,
1126 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)));
1128 //DELEGATE_TO_GL_3(waitSync, WaitSync, WebGLId, WGC3Dbitfield, WGC3Duint64)
1130 GrGLInterface
* WebGraphicsContext3DImpl::createGrGLInterface() {
1131 return skia_bindings::CreateCommandBufferSkiaGLBinding();
1134 ::gpu::gles2::GLES2ImplementationErrorMessageCallback
*
1135 WebGraphicsContext3DImpl::getErrorMessageCallback() {
1136 if (!client_error_message_callback_
) {
1137 client_error_message_callback_
.reset(
1138 new WebGraphicsContext3DErrorMessageCallback(this));
1140 return client_error_message_callback_
.get();
1143 void WebGraphicsContext3DImpl::OnErrorMessage(
1144 const std::string
& message
, int id
) {
1145 if (error_message_callback_
) {
1146 blink::WebString str
= blink::WebString::fromUTF8(message
.c_str());
1147 error_message_callback_
->onErrorMessage(str
, id
);
1151 // TODO(bajones): Look into removing these functions from the blink interface
1152 void WebGraphicsContext3DImpl::prepareTexture() {
1156 void WebGraphicsContext3DImpl::postSubBufferCHROMIUM(
1157 int x
, int y
, int width
, int height
) {
1161 void WebGraphicsContext3DImpl::setVisibilityCHROMIUM(
1166 void WebGraphicsContext3DImpl::copyTextureToParentTextureCHROMIUM(
1167 WebGLId texture
, WebGLId parentTexture
) {
1171 void WebGraphicsContext3DImpl::releaseShaderCompiler() {
1175 void WebGraphicsContext3DImpl::ConvertAttributes(
1176 const blink::WebGraphicsContext3D::Attributes
& attributes
,
1177 ::gpu::gles2::ContextCreationAttribHelper
* output_attribs
) {
1178 output_attribs
->alpha_size
= attributes
.alpha
? 8 : 0;
1179 output_attribs
->depth_size
= attributes
.depth
? 24 : 0;
1180 output_attribs
->stencil_size
= attributes
.stencil
? 8 : 0;
1181 output_attribs
->samples
= attributes
.antialias
? 4 : 0;
1182 output_attribs
->sample_buffers
= attributes
.antialias
? 1 : 0;
1183 output_attribs
->fail_if_major_perf_caveat
=
1184 attributes
.failIfMajorPerformanceCaveat
;
1185 output_attribs
->bind_generates_resource
= false;
1188 } // namespace gpu_blink