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"
22 using blink::WGC3Dbitfield
;
23 using blink::WGC3Dboolean
;
24 using blink::WGC3Dbyte
;
25 using blink::WGC3Dchar
;
26 using blink::WGC3Dclampf
;
27 using blink::WGC3Denum
;
28 using blink::WGC3Dfloat
;
29 using blink::WGC3Dint
;
30 using blink::WGC3Dintptr
;
31 using blink::WGC3Dsizei
;
32 using blink::WGC3Dsizeiptr
;
33 using blink::WGC3Dint64
;
34 using blink::WGC3Duint64
;
35 using blink::WGC3Duint
;
37 using blink::WGC3Dsync
;
43 uint32_t GenFlushID() {
44 static base::subtle::Atomic32 flush_id
= 0;
46 base::subtle::Atomic32 my_id
= base::subtle::Barrier_AtomicIncrement(
48 return static_cast<uint32_t>(my_id
);
51 } // namespace anonymous
53 class WebGraphicsContext3DErrorMessageCallback
54 : public ::gpu::gles2::GLES2ImplementationErrorMessageCallback
{
56 WebGraphicsContext3DErrorMessageCallback(
57 WebGraphicsContext3DImpl
* context
)
58 : graphics_context_(context
) {
61 void OnErrorMessage(const char* msg
, int id
) override
;
64 WebGraphicsContext3DImpl
* graphics_context_
;
66 DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback
);
69 void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage(
70 const char* msg
, int id
) {
71 graphics_context_
->OnErrorMessage(msg
, id
);
74 // Helper macros to reduce the amount of code.
76 #define DELEGATE_TO_GL(name, glname) \
77 void WebGraphicsContext3DImpl::name() { \
81 #define DELEGATE_TO_GL_R(name, glname, rt) \
82 rt WebGraphicsContext3DImpl::name() { \
83 return gl_->glname(); \
86 #define DELEGATE_TO_GL_1(name, glname, t1) \
87 void WebGraphicsContext3DImpl::name(t1 a1) { \
91 #define DELEGATE_TO_GL_1R(name, glname, t1, rt) \
92 rt WebGraphicsContext3DImpl::name(t1 a1) { \
93 return gl_->glname(a1); \
96 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \
97 rt WebGraphicsContext3DImpl::name(t1 a1) { \
98 return gl_->glname(a1) ? true : false; \
101 #define DELEGATE_TO_GL_2(name, glname, t1, t2) \
102 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2) { \
103 gl_->glname(a1, a2); \
106 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \
107 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2) { \
108 return gl_->glname(a1, a2); \
111 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \
112 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3) { \
113 gl_->glname(a1, a2, a3); \
116 #define DELEGATE_TO_GL_3R(name, glname, t1, t2, t3, rt) \
117 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3) { \
118 return gl_->glname(a1, a2, a3); \
121 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \
122 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
123 gl_->glname(a1, a2, a3, a4); \
126 #define DELEGATE_TO_GL_4R(name, glname, t1, t2, t3, t4, rt) \
127 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
128 return gl_->glname(a1, a2, a3, a4); \
131 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \
132 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) {\
134 gl_->glname(a1, a2, a3, a4, a5); \
137 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \
138 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
140 gl_->glname(a1, a2, a3, a4, a5, a6); \
143 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \
144 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
146 gl_->glname(a1, a2, a3, a4, a5, a6, a7); \
149 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \
150 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
151 t6 a6, t7 a7, t8 a8) { \
152 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \
155 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
156 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
157 t6 a6, t7 a7, t8 a8, t9 a9) { \
158 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
161 #define DELEGATE_TO_GL_9R(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, \
163 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
164 t6 a6, t7 a7, t8 a8, t9 a9) { \
165 return gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
168 #define DELEGATE_TO_GL_10(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, \
170 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
171 t6 a6, t7 a7, t8 a8, t9 a9, \
173 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); \
176 #define DELEGATE_TO_GL_11(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, \
178 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
179 t6 a6, t7 a7, t8 a8, t9 a9, t10 a10,\
181 gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); \
184 WebGraphicsContext3DImpl::WebGraphicsContext3DImpl()
185 : initialized_(false),
186 initialize_failed_(false),
187 context_lost_callback_(0),
188 error_message_callback_(0),
193 WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() {
197 void WebGraphicsContext3DImpl::synthesizeGLError(WGC3Denum error
) {
198 if (std::find(synthetic_errors_
.begin(), synthetic_errors_
.end(), error
) ==
199 synthetic_errors_
.end()) {
200 synthetic_errors_
.push_back(error
);
204 uint32_t WebGraphicsContext3DImpl::lastFlushID() {
208 DELEGATE_TO_GL_R(insertSyncPoint
, InsertSyncPointCHROMIUM
, unsigned int)
210 DELEGATE_TO_GL_3(reshapeWithScaleFactor
, ResizeCHROMIUM
, int, int, float)
212 DELEGATE_TO_GL_4R(mapBufferSubDataCHROMIUM
, MapBufferSubDataCHROMIUM
, WGC3Denum
,
213 WGC3Dintptr
, WGC3Dsizeiptr
, WGC3Denum
, void*)
215 DELEGATE_TO_GL_1(unmapBufferSubDataCHROMIUM
, UnmapBufferSubDataCHROMIUM
,
218 DELEGATE_TO_GL_9R(mapTexSubImage2DCHROMIUM
, MapTexSubImage2DCHROMIUM
, WGC3Denum
,
219 WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
,
220 WGC3Denum
, WGC3Denum
, WGC3Denum
, void*)
222 DELEGATE_TO_GL_1(unmapTexSubImage2DCHROMIUM
, UnmapTexSubImage2DCHROMIUM
,
225 DELEGATE_TO_GL_3(discardFramebufferEXT
, DiscardFramebufferEXT
, WGC3Denum
,
226 WGC3Dsizei
, const WGC3Denum
*)
228 blink::WebString
WebGraphicsContext3DImpl::
229 getRequestableExtensionsCHROMIUM() {
230 return blink::WebString::fromUTF8(
231 gl_
->GetRequestableExtensionsCHROMIUM());
234 DELEGATE_TO_GL_1(requestExtensionCHROMIUM
, RequestExtensionCHROMIUM
,
237 void WebGraphicsContext3DImpl::blitFramebufferCHROMIUM(
238 WGC3Dint srcX0
, WGC3Dint srcY0
, WGC3Dint srcX1
, WGC3Dint srcY1
,
239 WGC3Dint dstX0
, WGC3Dint dstY0
, WGC3Dint dstX1
, WGC3Dint dstY1
,
240 WGC3Dbitfield mask
, WGC3Denum filter
) {
241 gl_
->BlitFramebufferCHROMIUM(
242 srcX0
, srcY0
, srcX1
, srcY1
,
243 dstX0
, dstY0
, dstX1
, dstY1
,
247 DELEGATE_TO_GL_5(renderbufferStorageMultisampleCHROMIUM
,
248 RenderbufferStorageMultisampleCHROMIUM
, WGC3Denum
, WGC3Dsizei
,
249 WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
)
251 DELEGATE_TO_GL_1(activeTexture
, ActiveTexture
, WGC3Denum
)
253 DELEGATE_TO_GL_2(attachShader
, AttachShader
, WebGLId
, WebGLId
)
255 DELEGATE_TO_GL_3(bindAttribLocation
, BindAttribLocation
, WebGLId
,
256 WGC3Duint
, const WGC3Dchar
*)
258 DELEGATE_TO_GL_2(bindBuffer
, BindBuffer
, WGC3Denum
, WebGLId
)
260 DELEGATE_TO_GL_2(bindFramebuffer
, BindFramebuffer
, WGC3Denum
, WebGLId
)
262 DELEGATE_TO_GL_2(bindRenderbuffer
, BindRenderbuffer
, WGC3Denum
, WebGLId
)
264 DELEGATE_TO_GL_2(bindTexture
, BindTexture
, WGC3Denum
, WebGLId
)
266 DELEGATE_TO_GL_4(blendColor
, BlendColor
,
267 WGC3Dclampf
, WGC3Dclampf
, WGC3Dclampf
, WGC3Dclampf
)
269 DELEGATE_TO_GL_1(blendEquation
, BlendEquation
, WGC3Denum
)
271 DELEGATE_TO_GL_2(blendEquationSeparate
, BlendEquationSeparate
,
272 WGC3Denum
, WGC3Denum
)
274 DELEGATE_TO_GL_2(blendFunc
, BlendFunc
, WGC3Denum
, WGC3Denum
)
276 DELEGATE_TO_GL_4(blendFuncSeparate
, BlendFuncSeparate
,
277 WGC3Denum
, WGC3Denum
, WGC3Denum
, WGC3Denum
)
279 DELEGATE_TO_GL_4(bufferData
, BufferData
,
280 WGC3Denum
, WGC3Dsizeiptr
, const void*, WGC3Denum
)
282 DELEGATE_TO_GL_4(bufferSubData
, BufferSubData
,
283 WGC3Denum
, WGC3Dintptr
, WGC3Dsizeiptr
, const void*)
285 DELEGATE_TO_GL_1R(checkFramebufferStatus
, CheckFramebufferStatus
,
286 WGC3Denum
, WGC3Denum
)
288 DELEGATE_TO_GL_1(clear
, Clear
, WGC3Dbitfield
)
290 DELEGATE_TO_GL_4(clearColor
, ClearColor
,
291 WGC3Dclampf
, WGC3Dclampf
, WGC3Dclampf
, WGC3Dclampf
)
293 DELEGATE_TO_GL_1(clearDepth
, ClearDepthf
, WGC3Dclampf
)
295 DELEGATE_TO_GL_1(clearStencil
, ClearStencil
, WGC3Dint
)
297 DELEGATE_TO_GL_4(colorMask
, ColorMask
,
298 WGC3Dboolean
, WGC3Dboolean
, WGC3Dboolean
, WGC3Dboolean
)
300 DELEGATE_TO_GL_1(compileShader
, CompileShader
, WebGLId
)
302 DELEGATE_TO_GL_8(compressedTexImage2D
, CompressedTexImage2D
,
303 WGC3Denum
, WGC3Dint
, WGC3Denum
, WGC3Dint
, WGC3Dint
,
304 WGC3Dsizei
, WGC3Dsizei
, const void*)
306 DELEGATE_TO_GL_9(compressedTexSubImage2D
, CompressedTexSubImage2D
,
307 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
,
308 WGC3Denum
, WGC3Dsizei
, const void*)
310 DELEGATE_TO_GL_8(copyTexImage2D
, CopyTexImage2D
,
311 WGC3Denum
, WGC3Dint
, WGC3Denum
, WGC3Dint
, WGC3Dint
,
312 WGC3Dsizei
, WGC3Dsizei
, WGC3Dint
)
314 DELEGATE_TO_GL_8(copyTexSubImage2D
, CopyTexSubImage2D
,
315 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
,
316 WGC3Dsizei
, WGC3Dsizei
)
318 DELEGATE_TO_GL_1(cullFace
, CullFace
, WGC3Denum
)
320 DELEGATE_TO_GL_1(depthFunc
, DepthFunc
, WGC3Denum
)
322 DELEGATE_TO_GL_1(depthMask
, DepthMask
, WGC3Dboolean
)
324 DELEGATE_TO_GL_2(depthRange
, DepthRangef
, WGC3Dclampf
, WGC3Dclampf
)
326 DELEGATE_TO_GL_2(detachShader
, DetachShader
, WebGLId
, WebGLId
)
328 DELEGATE_TO_GL_1(disable
, Disable
, WGC3Denum
)
330 DELEGATE_TO_GL_1(disableVertexAttribArray
, DisableVertexAttribArray
,
333 DELEGATE_TO_GL_3(drawArrays
, DrawArrays
, WGC3Denum
, WGC3Dint
, WGC3Dsizei
)
335 void WebGraphicsContext3DImpl::drawElements(WGC3Denum mode
,
338 WGC3Dintptr offset
) {
341 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)));
344 DELEGATE_TO_GL_1(enable
, Enable
, WGC3Denum
)
346 DELEGATE_TO_GL_1(enableVertexAttribArray
, EnableVertexAttribArray
,
349 void WebGraphicsContext3DImpl::finish() {
350 flush_id_
= GenFlushID();
354 void WebGraphicsContext3DImpl::flush() {
355 flush_id_
= GenFlushID();
359 DELEGATE_TO_GL_4(framebufferRenderbuffer
, FramebufferRenderbuffer
,
360 WGC3Denum
, WGC3Denum
, WGC3Denum
, WebGLId
)
362 DELEGATE_TO_GL_5(framebufferTexture2D
, FramebufferTexture2D
,
363 WGC3Denum
, WGC3Denum
, WGC3Denum
, WebGLId
, WGC3Dint
)
365 DELEGATE_TO_GL_1(frontFace
, FrontFace
, WGC3Denum
)
367 DELEGATE_TO_GL_1(generateMipmap
, GenerateMipmap
, WGC3Denum
)
369 bool WebGraphicsContext3DImpl::getActiveAttrib(
370 WebGLId program
, WGC3Duint index
, ActiveInfo
& info
) {
372 synthesizeGLError(GL_INVALID_VALUE
);
375 GLint max_name_length
= -1;
377 program
, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
, &max_name_length
);
378 if (max_name_length
< 0)
380 if (max_name_length
== 0) {
381 // No active attributes exist.
382 synthesizeGLError(GL_INVALID_VALUE
);
385 scoped_ptr
<GLchar
[]> name(new GLchar
[max_name_length
]);
389 gl_
->GetActiveAttrib(
390 program
, index
, max_name_length
, &length
, &size
, &type
, name
.get());
394 info
.name
= blink::WebString::fromUTF8(name
.get(), length
);
400 bool WebGraphicsContext3DImpl::getActiveUniform(
401 WebGLId program
, WGC3Duint index
, ActiveInfo
& info
) {
402 GLint max_name_length
= -1;
404 program
, GL_ACTIVE_UNIFORM_MAX_LENGTH
, &max_name_length
);
405 if (max_name_length
< 0)
407 if (max_name_length
== 0) {
408 // No active uniforms exist.
409 synthesizeGLError(GL_INVALID_VALUE
);
412 scoped_ptr
<GLchar
[]> name(new GLchar
[max_name_length
]);
416 gl_
->GetActiveUniform(
417 program
, index
, max_name_length
, &length
, &size
, &type
, name
.get());
421 info
.name
= blink::WebString::fromUTF8(name
.get(), length
);
427 DELEGATE_TO_GL_4(getAttachedShaders
, GetAttachedShaders
,
428 WebGLId
, WGC3Dsizei
, WGC3Dsizei
*, WebGLId
*)
430 DELEGATE_TO_GL_2R(getAttribLocation
, GetAttribLocation
,
431 WebGLId
, const WGC3Dchar
*, WGC3Dint
)
433 DELEGATE_TO_GL_2(getBooleanv
, GetBooleanv
, WGC3Denum
, WGC3Dboolean
*)
435 DELEGATE_TO_GL_3(getBufferParameteriv
, GetBufferParameteriv
,
436 WGC3Denum
, WGC3Denum
, WGC3Dint
*)
438 WGC3Denum
WebGraphicsContext3DImpl::getError() {
439 if (!synthetic_errors_
.empty()) {
440 std::vector
<WGC3Denum
>::iterator iter
= synthetic_errors_
.begin();
441 WGC3Denum err
= *iter
;
442 synthetic_errors_
.erase(iter
);
446 return gl_
->GetError();
449 DELEGATE_TO_GL_2(getFloatv
, GetFloatv
, WGC3Denum
, WGC3Dfloat
*)
451 DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv
,
452 GetFramebufferAttachmentParameteriv
,
453 WGC3Denum
, WGC3Denum
, WGC3Denum
, WGC3Dint
*)
455 DELEGATE_TO_GL_2(getIntegerv
, GetIntegerv
, WGC3Denum
, WGC3Dint
*)
457 DELEGATE_TO_GL_2(getInteger64v
, GetInteger64v
, WGC3Denum
, WGC3Dint64
*)
459 DELEGATE_TO_GL_3(getProgramiv
, GetProgramiv
, WebGLId
, WGC3Denum
, WGC3Dint
*)
461 blink::WebString
WebGraphicsContext3DImpl::getProgramInfoLog(
464 gl_
->GetProgramiv(program
, GL_INFO_LOG_LENGTH
, &logLength
);
466 return blink::WebString();
467 scoped_ptr
<GLchar
[]> log(new GLchar
[logLength
]);
469 return blink::WebString();
470 GLsizei returnedLogLength
= 0;
471 gl_
->GetProgramInfoLog(
472 program
, logLength
, &returnedLogLength
, log
.get());
473 DCHECK_EQ(logLength
, returnedLogLength
+ 1);
474 blink::WebString res
=
475 blink::WebString::fromUTF8(log
.get(), returnedLogLength
);
479 DELEGATE_TO_GL_3(getRenderbufferParameteriv
, GetRenderbufferParameteriv
,
480 WGC3Denum
, WGC3Denum
, WGC3Dint
*)
482 DELEGATE_TO_GL_3(getShaderiv
, GetShaderiv
, WebGLId
, WGC3Denum
, WGC3Dint
*)
484 blink::WebString
WebGraphicsContext3DImpl::getShaderInfoLog(
487 gl_
->GetShaderiv(shader
, GL_INFO_LOG_LENGTH
, &logLength
);
489 return blink::WebString();
490 scoped_ptr
<GLchar
[]> log(new GLchar
[logLength
]);
492 return blink::WebString();
493 GLsizei returnedLogLength
= 0;
494 gl_
->GetShaderInfoLog(
495 shader
, logLength
, &returnedLogLength
, log
.get());
496 DCHECK_EQ(logLength
, returnedLogLength
+ 1);
497 blink::WebString res
=
498 blink::WebString::fromUTF8(log
.get(), returnedLogLength
);
502 DELEGATE_TO_GL_4(getShaderPrecisionFormat
, GetShaderPrecisionFormat
,
503 WGC3Denum
, WGC3Denum
, WGC3Dint
*, WGC3Dint
*)
505 blink::WebString
WebGraphicsContext3DImpl::getShaderSource(
508 gl_
->GetShaderiv(shader
, GL_SHADER_SOURCE_LENGTH
, &logLength
);
510 return blink::WebString();
511 scoped_ptr
<GLchar
[]> log(new GLchar
[logLength
]);
513 return blink::WebString();
514 GLsizei returnedLogLength
= 0;
515 gl_
->GetShaderSource(
516 shader
, logLength
, &returnedLogLength
, log
.get());
517 if (!returnedLogLength
)
518 return blink::WebString();
519 DCHECK_EQ(logLength
, returnedLogLength
+ 1);
520 blink::WebString res
=
521 blink::WebString::fromUTF8(log
.get(), returnedLogLength
);
525 blink::WebString
WebGraphicsContext3DImpl::
526 getTranslatedShaderSourceANGLE(WebGLId shader
) {
529 shader
, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE
, &logLength
);
531 return blink::WebString();
532 scoped_ptr
<GLchar
[]> log(new GLchar
[logLength
]);
534 return blink::WebString();
535 GLsizei returnedLogLength
= 0;
536 gl_
->GetTranslatedShaderSourceANGLE(
537 shader
, logLength
, &returnedLogLength
, log
.get());
538 if (!returnedLogLength
)
539 return blink::WebString();
540 DCHECK_EQ(logLength
, returnedLogLength
+ 1);
541 blink::WebString res
=
542 blink::WebString::fromUTF8(log
.get(), returnedLogLength
);
546 blink::WebString
WebGraphicsContext3DImpl::getString(
548 return blink::WebString::fromUTF8(
549 reinterpret_cast<const char*>(gl_
->GetString(name
)));
552 DELEGATE_TO_GL_3(getTexParameterfv
, GetTexParameterfv
,
553 WGC3Denum
, WGC3Denum
, WGC3Dfloat
*)
555 DELEGATE_TO_GL_3(getTexParameteriv
, GetTexParameteriv
,
556 WGC3Denum
, WGC3Denum
, WGC3Dint
*)
558 DELEGATE_TO_GL_3(getUniformfv
, GetUniformfv
, WebGLId
, WGC3Dint
, WGC3Dfloat
*)
560 DELEGATE_TO_GL_3(getUniformiv
, GetUniformiv
, WebGLId
, WGC3Dint
, WGC3Dint
*)
562 DELEGATE_TO_GL_2R(getUniformLocation
, GetUniformLocation
,
563 WebGLId
, const WGC3Dchar
*, WGC3Dint
)
565 DELEGATE_TO_GL_3(getVertexAttribfv
, GetVertexAttribfv
,
566 WGC3Duint
, WGC3Denum
, WGC3Dfloat
*)
568 DELEGATE_TO_GL_3(getVertexAttribiv
, GetVertexAttribiv
,
569 WGC3Duint
, WGC3Denum
, WGC3Dint
*)
571 WGC3Dsizeiptr
WebGraphicsContext3DImpl::getVertexAttribOffset(
572 WGC3Duint index
, WGC3Denum pname
) {
573 GLvoid
* value
= NULL
;
574 // NOTE: If pname is ever a value that returns more then 1 element
575 // this will corrupt memory.
576 gl_
->GetVertexAttribPointerv(index
, pname
, &value
);
577 return static_cast<WGC3Dsizeiptr
>(reinterpret_cast<intptr_t>(value
));
580 DELEGATE_TO_GL_2(hint
, Hint
, WGC3Denum
, WGC3Denum
)
582 DELEGATE_TO_GL_1RB(isBuffer
, IsBuffer
, WebGLId
, WGC3Dboolean
)
584 DELEGATE_TO_GL_1RB(isEnabled
, IsEnabled
, WGC3Denum
, WGC3Dboolean
)
586 DELEGATE_TO_GL_1RB(isFramebuffer
, IsFramebuffer
, WebGLId
, WGC3Dboolean
)
588 DELEGATE_TO_GL_1RB(isProgram
, IsProgram
, WebGLId
, WGC3Dboolean
)
590 DELEGATE_TO_GL_1RB(isRenderbuffer
, IsRenderbuffer
, WebGLId
, WGC3Dboolean
)
592 DELEGATE_TO_GL_1RB(isShader
, IsShader
, WebGLId
, WGC3Dboolean
)
594 DELEGATE_TO_GL_1RB(isTexture
, IsTexture
, WebGLId
, WGC3Dboolean
)
596 DELEGATE_TO_GL_1(lineWidth
, LineWidth
, WGC3Dfloat
)
598 DELEGATE_TO_GL_1(linkProgram
, LinkProgram
, WebGLId
)
600 DELEGATE_TO_GL_2(pixelStorei
, PixelStorei
, WGC3Denum
, WGC3Dint
)
602 DELEGATE_TO_GL_2(polygonOffset
, PolygonOffset
, WGC3Dfloat
, WGC3Dfloat
)
604 DELEGATE_TO_GL_7(readPixels
, ReadPixels
,
605 WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
, WGC3Denum
,
608 DELEGATE_TO_GL_4(renderbufferStorage
, RenderbufferStorage
,
609 WGC3Denum
, WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
)
611 DELEGATE_TO_GL_2(sampleCoverage
, SampleCoverage
, WGC3Dfloat
, WGC3Dboolean
)
613 DELEGATE_TO_GL_4(scissor
, Scissor
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
)
615 void WebGraphicsContext3DImpl::shaderSource(
616 WebGLId shader
, const WGC3Dchar
* string
) {
617 GLint length
= strlen(string
);
618 gl_
->ShaderSource(shader
, 1, &string
, &length
);
621 DELEGATE_TO_GL_3(stencilFunc
, StencilFunc
, WGC3Denum
, WGC3Dint
, WGC3Duint
)
623 DELEGATE_TO_GL_4(stencilFuncSeparate
, StencilFuncSeparate
,
624 WGC3Denum
, WGC3Denum
, WGC3Dint
, WGC3Duint
)
626 DELEGATE_TO_GL_1(stencilMask
, StencilMask
, WGC3Duint
)
628 DELEGATE_TO_GL_2(stencilMaskSeparate
, StencilMaskSeparate
,
629 WGC3Denum
, WGC3Duint
)
631 DELEGATE_TO_GL_3(stencilOp
, StencilOp
,
632 WGC3Denum
, WGC3Denum
, WGC3Denum
)
634 DELEGATE_TO_GL_4(stencilOpSeparate
, StencilOpSeparate
,
635 WGC3Denum
, WGC3Denum
, WGC3Denum
, WGC3Denum
)
637 DELEGATE_TO_GL_9(texImage2D
, TexImage2D
,
638 WGC3Denum
, WGC3Dint
, WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
,
639 WGC3Dint
, WGC3Denum
, WGC3Denum
, const void*)
641 DELEGATE_TO_GL_3(texParameterf
, TexParameterf
,
642 WGC3Denum
, WGC3Denum
, WGC3Dfloat
);
644 DELEGATE_TO_GL_3(texParameteri
, TexParameteri
,
645 WGC3Denum
, WGC3Denum
, WGC3Dint
);
647 DELEGATE_TO_GL_9(texSubImage2D
, TexSubImage2D
,
648 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
649 WGC3Dsizei
, WGC3Denum
, WGC3Denum
, const void*)
651 DELEGATE_TO_GL_2(uniform1f
, Uniform1f
, WGC3Dint
, WGC3Dfloat
)
653 DELEGATE_TO_GL_3(uniform1fv
, Uniform1fv
, WGC3Dint
, WGC3Dsizei
,
656 DELEGATE_TO_GL_2(uniform1i
, Uniform1i
, WGC3Dint
, WGC3Dint
)
658 DELEGATE_TO_GL_3(uniform1iv
, Uniform1iv
, WGC3Dint
, WGC3Dsizei
, const WGC3Dint
*)
660 DELEGATE_TO_GL_3(uniform2f
, Uniform2f
, WGC3Dint
, WGC3Dfloat
, WGC3Dfloat
)
662 DELEGATE_TO_GL_3(uniform2fv
, Uniform2fv
, WGC3Dint
, WGC3Dsizei
,
665 DELEGATE_TO_GL_3(uniform2i
, Uniform2i
, WGC3Dint
, WGC3Dint
, WGC3Dint
)
667 DELEGATE_TO_GL_3(uniform2iv
, Uniform2iv
, WGC3Dint
, WGC3Dsizei
, const WGC3Dint
*)
669 DELEGATE_TO_GL_4(uniform3f
, Uniform3f
, WGC3Dint
,
670 WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
)
672 DELEGATE_TO_GL_3(uniform3fv
, Uniform3fv
, WGC3Dint
, WGC3Dsizei
,
675 DELEGATE_TO_GL_4(uniform3i
, Uniform3i
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
)
677 DELEGATE_TO_GL_3(uniform3iv
, Uniform3iv
, WGC3Dint
, WGC3Dsizei
, const WGC3Dint
*)
679 DELEGATE_TO_GL_5(uniform4f
, Uniform4f
, WGC3Dint
,
680 WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
)
682 DELEGATE_TO_GL_3(uniform4fv
, Uniform4fv
, WGC3Dint
, WGC3Dsizei
,
685 DELEGATE_TO_GL_5(uniform4i
, Uniform4i
, WGC3Dint
,
686 WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
)
688 DELEGATE_TO_GL_3(uniform4iv
, Uniform4iv
, WGC3Dint
, WGC3Dsizei
, const WGC3Dint
*)
690 DELEGATE_TO_GL_4(uniformMatrix2fv
, UniformMatrix2fv
,
691 WGC3Dint
, WGC3Dsizei
, WGC3Dboolean
, const WGC3Dfloat
*)
693 DELEGATE_TO_GL_4(uniformMatrix3fv
, UniformMatrix3fv
,
694 WGC3Dint
, WGC3Dsizei
, WGC3Dboolean
, const WGC3Dfloat
*)
696 DELEGATE_TO_GL_4(uniformMatrix4fv
, UniformMatrix4fv
,
697 WGC3Dint
, WGC3Dsizei
, WGC3Dboolean
, const WGC3Dfloat
*)
699 DELEGATE_TO_GL_1(useProgram
, UseProgram
, WebGLId
)
701 DELEGATE_TO_GL_1(validateProgram
, ValidateProgram
, WebGLId
)
703 DELEGATE_TO_GL_2(vertexAttrib1f
, VertexAttrib1f
, WGC3Duint
, WGC3Dfloat
)
705 DELEGATE_TO_GL_2(vertexAttrib1fv
, VertexAttrib1fv
, WGC3Duint
,
708 DELEGATE_TO_GL_3(vertexAttrib2f
, VertexAttrib2f
, WGC3Duint
,
709 WGC3Dfloat
, WGC3Dfloat
)
711 DELEGATE_TO_GL_2(vertexAttrib2fv
, VertexAttrib2fv
, WGC3Duint
,
714 DELEGATE_TO_GL_4(vertexAttrib3f
, VertexAttrib3f
, WGC3Duint
,
715 WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
)
717 DELEGATE_TO_GL_2(vertexAttrib3fv
, VertexAttrib3fv
, WGC3Duint
,
720 DELEGATE_TO_GL_5(vertexAttrib4f
, VertexAttrib4f
, WGC3Duint
,
721 WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
, WGC3Dfloat
)
723 DELEGATE_TO_GL_2(vertexAttrib4fv
, VertexAttrib4fv
, WGC3Duint
,
726 void WebGraphicsContext3DImpl::vertexAttribPointer(
727 WGC3Duint index
, WGC3Dint size
, WGC3Denum type
, WGC3Dboolean normalized
,
728 WGC3Dsizei stride
, WGC3Dintptr offset
) {
729 gl_
->VertexAttribPointer(
730 index
, size
, type
, normalized
, stride
,
731 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)));
734 DELEGATE_TO_GL_4(viewport
, Viewport
,
735 WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
)
737 WebGLId
WebGraphicsContext3DImpl::createBuffer() {
739 gl_
->GenBuffers(1, &o
);
743 WebGLId
WebGraphicsContext3DImpl::createFramebuffer() {
745 gl_
->GenFramebuffers(1, &o
);
749 WebGLId
WebGraphicsContext3DImpl::createRenderbuffer() {
751 gl_
->GenRenderbuffers(1, &o
);
755 WebGLId
WebGraphicsContext3DImpl::createTexture() {
757 gl_
->GenTextures(1, &o
);
761 void WebGraphicsContext3DImpl::deleteBuffer(WebGLId buffer
) {
762 gl_
->DeleteBuffers(1, &buffer
);
765 void WebGraphicsContext3DImpl::deleteFramebuffer(
766 WebGLId framebuffer
) {
767 gl_
->DeleteFramebuffers(1, &framebuffer
);
770 void WebGraphicsContext3DImpl::deleteRenderbuffer(
771 WebGLId renderbuffer
) {
772 gl_
->DeleteRenderbuffers(1, &renderbuffer
);
775 void WebGraphicsContext3DImpl::deleteTexture(WebGLId texture
) {
776 gl_
->DeleteTextures(1, &texture
);
779 DELEGATE_TO_GL_R(createProgram
, CreateProgram
, WebGLId
)
781 DELEGATE_TO_GL_1R(createShader
, CreateShader
, WGC3Denum
, WebGLId
)
783 DELEGATE_TO_GL_1(deleteProgram
, DeleteProgram
, WebGLId
)
785 DELEGATE_TO_GL_1(deleteShader
, DeleteShader
, WebGLId
)
787 void WebGraphicsContext3DImpl::setErrorMessageCallback(
788 WebGraphicsContext3D::WebGraphicsErrorMessageCallback
* cb
) {
789 error_message_callback_
= cb
;
792 void WebGraphicsContext3DImpl::setContextLostCallback(
793 WebGraphicsContext3D::WebGraphicsContextLostCallback
* cb
) {
794 context_lost_callback_
= cb
;
797 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM
, TexImageIOSurface2DCHROMIUM
,
798 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Duint
, WGC3Duint
)
800 DELEGATE_TO_GL_5(texStorage2DEXT
, TexStorage2DEXT
,
801 WGC3Denum
, WGC3Dint
, WGC3Duint
, WGC3Dint
, WGC3Dint
)
803 WebGLId
WebGraphicsContext3DImpl::createQueryEXT() {
805 gl_
->GenQueriesEXT(1, &o
);
809 void WebGraphicsContext3DImpl::deleteQueryEXT(
811 gl_
->DeleteQueriesEXT(1, &query
);
814 DELEGATE_TO_GL_1R(isQueryEXT
, IsQueryEXT
, WebGLId
, WGC3Dboolean
)
815 DELEGATE_TO_GL_2(beginQueryEXT
, BeginQueryEXT
, WGC3Denum
, WebGLId
)
816 DELEGATE_TO_GL_1(endQueryEXT
, EndQueryEXT
, WGC3Denum
)
817 DELEGATE_TO_GL_3(getQueryivEXT
, GetQueryivEXT
, WGC3Denum
, WGC3Denum
, WGC3Dint
*)
818 DELEGATE_TO_GL_3(getQueryObjectuivEXT
, GetQueryObjectuivEXT
,
819 WebGLId
, WGC3Denum
, WGC3Duint
*)
821 DELEGATE_TO_GL_5(copyTextureCHROMIUM
,
829 DELEGATE_TO_GL_9(copySubTextureCHROMIUM
,
830 CopySubTextureCHROMIUM
,
841 DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM
, BindUniformLocationCHROMIUM
,
842 WebGLId
, WGC3Dint
, const WGC3Dchar
*)
844 void WebGraphicsContext3DImpl::shallowFlushCHROMIUM() {
845 flush_id_
= GenFlushID();
846 gl_
->ShallowFlushCHROMIUM();
849 void WebGraphicsContext3DImpl::shallowFinishCHROMIUM() {
850 flush_id_
= GenFlushID();
851 gl_
->ShallowFinishCHROMIUM();
854 DELEGATE_TO_GL_1(waitSyncPoint
, WaitSyncPointCHROMIUM
, GLuint
)
856 void WebGraphicsContext3DImpl::loseContextCHROMIUM(
857 WGC3Denum current
, WGC3Denum other
) {
858 gl_
->LoseContextCHROMIUM(current
, other
);
862 DELEGATE_TO_GL_1(genMailboxCHROMIUM
, GenMailboxCHROMIUM
, WGC3Dbyte
*)
863 DELEGATE_TO_GL_2(produceTextureCHROMIUM
, ProduceTextureCHROMIUM
,
864 WGC3Denum
, const WGC3Dbyte
*)
865 DELEGATE_TO_GL_3(produceTextureDirectCHROMIUM
, ProduceTextureDirectCHROMIUM
,
866 WebGLId
, WGC3Denum
, const WGC3Dbyte
*)
867 DELEGATE_TO_GL_2(consumeTextureCHROMIUM
, ConsumeTextureCHROMIUM
,
868 WGC3Denum
, const WGC3Dbyte
*)
869 DELEGATE_TO_GL_2R(createAndConsumeTextureCHROMIUM
,
870 CreateAndConsumeTextureCHROMIUM
,
871 WGC3Denum
, const WGC3Dbyte
*, WebGLId
)
873 DELEGATE_TO_GL_2(genValuebuffersCHROMIUM
,
874 GenValuebuffersCHROMIUM
,
878 WebGLId
WebGraphicsContext3DImpl::createValuebufferCHROMIUM() {
880 gl_
->GenValuebuffersCHROMIUM(1, &o
);
884 DELEGATE_TO_GL_2(deleteValuebuffersCHROMIUM
,
885 DeleteValuebuffersCHROMIUM
,
889 void WebGraphicsContext3DImpl::deleteValuebufferCHROMIUM(WebGLId valuebuffer
) {
890 gl_
->DeleteValuebuffersCHROMIUM(1, &valuebuffer
);
893 DELEGATE_TO_GL_1RB(isValuebufferCHROMIUM
,
894 IsValuebufferCHROMIUM
,
897 DELEGATE_TO_GL_2(bindValuebufferCHROMIUM
,
898 BindValuebufferCHROMIUM
,
901 DELEGATE_TO_GL_2(subscribeValueCHROMIUM
,
902 SubscribeValueCHROMIUM
,
905 DELEGATE_TO_GL_1(populateSubscribedValuesCHROMIUM
,
906 PopulateSubscribedValuesCHROMIUM
,
908 DELEGATE_TO_GL_3(uniformValuebufferCHROMIUM
,
909 UniformValuebufferCHROMIUM
,
913 DELEGATE_TO_GL_2(traceBeginCHROMIUM
,
917 DELEGATE_TO_GL(traceEndCHROMIUM
, TraceEndCHROMIUM
);
919 void WebGraphicsContext3DImpl::insertEventMarkerEXT(
920 const WGC3Dchar
* marker
) {
921 gl_
->InsertEventMarkerEXT(0, marker
);
924 void WebGraphicsContext3DImpl::pushGroupMarkerEXT(
925 const WGC3Dchar
* marker
) {
926 gl_
->PushGroupMarkerEXT(0, marker
);
929 DELEGATE_TO_GL(popGroupMarkerEXT
, PopGroupMarkerEXT
);
931 WebGLId
WebGraphicsContext3DImpl::createVertexArrayOES() {
933 gl_
->GenVertexArraysOES(1, &array
);
937 void WebGraphicsContext3DImpl::deleteVertexArrayOES(
939 gl_
->DeleteVertexArraysOES(1, &array
);
942 DELEGATE_TO_GL_1R(isVertexArrayOES
, IsVertexArrayOES
, WebGLId
, WGC3Dboolean
)
943 DELEGATE_TO_GL_1(bindVertexArrayOES
, BindVertexArrayOES
, WebGLId
)
945 DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM
, BindTexImage2DCHROMIUM
,
947 DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM
, ReleaseTexImage2DCHROMIUM
,
950 DELEGATE_TO_GL_2R(mapBufferCHROMIUM
, MapBufferCHROMIUM
, WGC3Denum
, WGC3Denum
,
952 DELEGATE_TO_GL_1R(unmapBufferCHROMIUM
, UnmapBufferCHROMIUM
, WGC3Denum
,
955 DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM
, AsyncTexImage2DCHROMIUM
, WGC3Denum
,
956 WGC3Dint
, WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
, WGC3Dint
,
957 WGC3Denum
, WGC3Denum
, const void*)
958 DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM
, AsyncTexSubImage2DCHROMIUM
,
959 WGC3Denum
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
960 WGC3Dsizei
, WGC3Denum
, WGC3Denum
, const void*)
962 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM
, WaitAsyncTexImage2DCHROMIUM
,
965 DELEGATE_TO_GL_2(drawBuffersEXT
, DrawBuffersEXT
, WGC3Dsizei
, const WGC3Denum
*)
967 DELEGATE_TO_GL_4(drawArraysInstancedANGLE
, DrawArraysInstancedANGLE
, WGC3Denum
,
968 WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
)
970 void WebGraphicsContext3DImpl::drawElementsInstancedANGLE(
975 WGC3Dsizei primcount
) {
976 gl_
->DrawElementsInstancedANGLE(
978 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)), primcount
);
981 DELEGATE_TO_GL_2(vertexAttribDivisorANGLE
, VertexAttribDivisorANGLE
, WGC3Duint
,
984 DELEGATE_TO_GL_4R(createGpuMemoryBufferImageCHROMIUM
,
985 CreateGpuMemoryBufferImageCHROMIUM
,
992 DELEGATE_TO_GL_1(destroyImageCHROMIUM
, DestroyImageCHROMIUM
, WGC3Duint
);
994 DELEGATE_TO_GL_6(framebufferTexture2DMultisampleEXT
,
995 FramebufferTexture2DMultisampleEXT
,
996 WGC3Denum
, WGC3Denum
, WGC3Denum
, WebGLId
, WGC3Dint
, WGC3Dsizei
)
998 DELEGATE_TO_GL_5(renderbufferStorageMultisampleEXT
,
999 RenderbufferStorageMultisampleEXT
, WGC3Denum
, WGC3Dsizei
,
1000 WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
)
1002 DELEGATE_TO_GL_1(beginTransformFeedback
, BeginTransformFeedback
, WGC3Denum
)
1003 DELEGATE_TO_GL_3(bindBufferBase
, BindBufferBase
, WGC3Denum
, WGC3Duint
,
1005 DELEGATE_TO_GL_5(bindBufferRange
, BindBufferRange
, WGC3Denum
, WGC3Duint
,
1006 WGC3Duint
, WGC3Dintptr
, WGC3Dsizeiptr
)
1007 DELEGATE_TO_GL_2(bindSampler
, BindSampler
, WGC3Duint
, WebGLId
)
1008 DELEGATE_TO_GL_2(bindTransformFeedback
, BindTransformFeedback
, WGC3Denum
,
1010 DELEGATE_TO_GL_4(clearBufferfi
, ClearBufferfi
, WGC3Denum
, WGC3Dint
, WGC3Dfloat
,
1012 DELEGATE_TO_GL_3(clearBufferfv
, ClearBufferfv
, WGC3Denum
, WGC3Dint
,
1014 DELEGATE_TO_GL_3(clearBufferiv
, ClearBufferiv
, WGC3Denum
, WGC3Dint
,
1016 DELEGATE_TO_GL_3(clearBufferuiv
, ClearBufferuiv
, WGC3Denum
, WGC3Dint
,
1018 WGC3Denum
WebGraphicsContext3DImpl::clientWaitSync(WGC3Dsync sync
,
1019 WGC3Dbitfield flags
,
1020 WGC3Duint64 timeout
) {
1021 return gl_
->ClientWaitSync(reinterpret_cast<GLsync
>(sync
), flags
, timeout
);
1023 DELEGATE_TO_GL_9(compressedTexImage3D
, CompressedTexImage3D
, WGC3Denum
,
1024 WGC3Dint
, WGC3Denum
, WGC3Dsizei
, WGC3Dsizei
, WGC3Dsizei
,
1025 WGC3Dint
, WGC3Dsizei
, const void *)
1026 DELEGATE_TO_GL_11(compressedTexSubImage3D
, CompressedTexSubImage3D
, WGC3Denum
,
1027 WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
1028 WGC3Dsizei
, WGC3Dsizei
, WGC3Denum
, WGC3Dsizei
, const void *)
1029 DELEGATE_TO_GL_5(copyBufferSubData
, CopyBufferSubData
, WGC3Denum
, WGC3Denum
,
1030 WGC3Dintptr
, WGC3Dintptr
, WGC3Dsizeiptr
)
1031 DELEGATE_TO_GL_9(copyTexSubImage3D
, CopyTexSubImage3D
, WGC3Denum
, WGC3Dint
,
1032 WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
1034 WebGLId
WebGraphicsContext3DImpl::createSampler() {
1036 gl_
->GenSamplers(1, &sampler
);
1039 WebGLId
WebGraphicsContext3DImpl::createTransformFeedback() {
1041 gl_
->GenTransformFeedbacks(1, &tf
);
1044 void WebGraphicsContext3DImpl::deleteSampler(WebGLId sampler
) {
1045 gl_
->DeleteSamplers(1, &sampler
);
1047 void WebGraphicsContext3DImpl::deleteSync(WGC3Dsync sync
) {
1048 gl_
->DeleteSync(reinterpret_cast<GLsync
>(sync
));
1050 void WebGraphicsContext3DImpl::deleteTransformFeedback(WebGLId tf
) {
1051 gl_
->DeleteTransformFeedbacks(1, &tf
);
1053 void WebGraphicsContext3DImpl::drawRangeElements(
1054 WGC3Denum mode
, WGC3Duint start
, WGC3Duint end
, WGC3Dsizei count
,
1055 WGC3Denum type
, WGC3Dintptr offset
) {
1056 gl_
->DrawRangeElements(mode
, start
, end
, count
, type
,
1057 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)));
1059 DELEGATE_TO_GL(endTransformFeedback
, EndTransformFeedback
)
1060 WGC3Dsync
WebGraphicsContext3DImpl::fenceSync(WGC3Denum condition
,
1061 WGC3Dbitfield flags
) {
1062 return reinterpret_cast<WGC3Dsync
>(gl_
->FenceSync(condition
, flags
));
1064 DELEGATE_TO_GL_5(framebufferTextureLayer
, FramebufferTextureLayer
, WGC3Denum
,
1065 WGC3Denum
, WGC3Duint
, WGC3Dint
, WGC3Dint
)
1066 DELEGATE_TO_GL_5(getActiveUniformBlockName
, GetActiveUniformBlockName
,
1067 WGC3Duint
, WGC3Duint
, WGC3Dsizei
, WGC3Dsizei
*, WGC3Dchar
*)
1068 DELEGATE_TO_GL_4(getActiveUniformBlockiv
, GetActiveUniformBlockiv
, WGC3Duint
,
1069 WGC3Duint
, WGC3Denum
, WGC3Dint
*)
1070 DELEGATE_TO_GL_5(getActiveUniformsiv
, GetActiveUniformsiv
, WGC3Duint
,
1071 WGC3Dsizei
, const WGC3Duint
*, WGC3Denum
, WGC3Dint
*)
1072 DELEGATE_TO_GL_2R(getFragDataLocation
, GetFragDataLocation
, WGC3Duint
,
1073 const WGC3Dchar
*, WGC3Dint
)
1074 DELEGATE_TO_GL_5(getInternalformativ
, GetInternalformativ
, WGC3Denum
, WGC3Denum
,
1075 WGC3Denum
, WGC3Dsizei
, WGC3Dint
*)
1076 DELEGATE_TO_GL_3(getSamplerParameterfv
, GetSamplerParameterfv
, WGC3Duint
,
1077 WGC3Denum
, WGC3Dfloat
*)
1078 DELEGATE_TO_GL_3(getSamplerParameteriv
, GetSamplerParameteriv
, WGC3Duint
,
1079 WGC3Denum
, WGC3Dint
*)
1080 DELEGATE_TO_GL_7(getTransformFeedbackVarying
, GetTransformFeedbackVarying
,
1081 WGC3Duint
, WGC3Duint
, WGC3Dsizei
, WGC3Dsizei
*, WGC3Dsizei
*,
1082 WGC3Denum
*, WGC3Dchar
*)
1083 DELEGATE_TO_GL_2R(getUniformBlockIndex
, GetUniformBlockIndex
, WGC3Duint
,
1084 const WGC3Dchar
*, WGC3Duint
)
1085 DELEGATE_TO_GL_4(getUniformIndices
, GetUniformIndices
, WGC3Duint
, WGC3Dsizei
,
1086 const WGC3Dchar
*const*, WGC3Duint
*)
1087 //DELEGATE_TO_GL_3(getUniformuiv, GetUniformuiv, WGC3Duint, WGC3Dint,
1089 //DELEGATE_TO_GL_3(getVertexAttribIiv, GetVertexAttribIiv, WGC3Duint,
1090 // WGC3Denum, WGC3Dint *)
1091 //DELEGATE_TO_GL_3(getVertexAttribIuiv, GetVertexAttribIuiv, WGC3Duint,
1092 // WGC3Denum, WGC3Duint *)
1093 DELEGATE_TO_GL_3(invalidateFramebuffer
, InvalidateFramebuffer
, WGC3Denum
,
1094 WGC3Dsizei
, const WGC3Denum
*)
1095 DELEGATE_TO_GL_7(invalidateSubFramebuffer
, InvalidateSubFramebuffer
, WGC3Denum
,
1096 WGC3Dsizei
, const WGC3Denum
*, WGC3Dint
, WGC3Dint
, WGC3Dsizei
,
1098 DELEGATE_TO_GL_1R(isSampler
, IsSampler
, WebGLId
, WGC3Dboolean
)
1099 WGC3Dboolean
WebGraphicsContext3DImpl::isSync(WGC3Dsync sync
) {
1100 return gl_
->IsSync(reinterpret_cast<GLsync
>(sync
));
1102 DELEGATE_TO_GL_1R(isTransformFeedback
, IsTransformFeedback
, WGC3Duint
,
1104 DELEGATE_TO_GL(pauseTransformFeedback
, PauseTransformFeedback
)
1105 //DELEGATE_TO_GL_3(programParameteri, ProgramParameteri, WGC3Duint, WGC3Denum,
1107 DELEGATE_TO_GL_1(readBuffer
, ReadBuffer
, WGC3Denum
)
1108 DELEGATE_TO_GL(resumeTransformFeedback
, ResumeTransformFeedback
)
1109 DELEGATE_TO_GL_3(samplerParameterf
, SamplerParameterf
, WGC3Duint
, WGC3Denum
,
1111 DELEGATE_TO_GL_3(samplerParameterfv
, SamplerParameterfv
, WGC3Duint
, WGC3Denum
,
1113 DELEGATE_TO_GL_3(samplerParameteri
, SamplerParameteri
, WGC3Duint
, WGC3Denum
,
1115 DELEGATE_TO_GL_3(samplerParameteriv
, SamplerParameteriv
, WGC3Duint
, WGC3Denum
,
1117 DELEGATE_TO_GL_10(texImage3D
, TexImage3D
, WGC3Denum
, WGC3Dint
, WGC3Dint
,
1118 WGC3Dsizei
, WGC3Dsizei
, WGC3Dsizei
, WGC3Dint
, WGC3Denum
,
1119 WGC3Denum
, const void *)
1120 DELEGATE_TO_GL_6(texStorage3D
, TexStorage3D
, WGC3Denum
, WGC3Dsizei
, WGC3Denum
,
1121 WGC3Dsizei
, WGC3Dsizei
, WGC3Dsizei
)
1122 DELEGATE_TO_GL_11(texSubImage3D
, TexSubImage3D
, WGC3Denum
, WGC3Dint
, WGC3Dint
,
1123 WGC3Dint
, WGC3Dint
, WGC3Dsizei
, WGC3Dsizei
, WGC3Dsizei
,
1124 WGC3Denum
, WGC3Denum
, const void *)
1125 DELEGATE_TO_GL_4(transformFeedbackVaryings
, TransformFeedbackVaryings
,
1126 WGC3Duint
, WGC3Dsizei
, const WGC3Dchar
*const*, WGC3Denum
)
1127 DELEGATE_TO_GL_2(uniform1ui
, Uniform1ui
, WGC3Dint
, WGC3Duint
)
1128 DELEGATE_TO_GL_3(uniform1uiv
, Uniform1uiv
, WGC3Dint
, WGC3Dsizei
,
1130 DELEGATE_TO_GL_3(uniform2ui
, Uniform2ui
, WGC3Dint
, WGC3Duint
, WGC3Duint
)
1131 DELEGATE_TO_GL_3(uniform2uiv
, Uniform2uiv
, WGC3Dint
, WGC3Dsizei
,
1133 DELEGATE_TO_GL_4(uniform3ui
, Uniform3ui
, WGC3Dint
, WGC3Duint
, WGC3Duint
,
1135 DELEGATE_TO_GL_3(uniform3uiv
, Uniform3uiv
, WGC3Dint
, WGC3Dsizei
,
1137 DELEGATE_TO_GL_5(uniform4ui
, Uniform4ui
, WGC3Dint
, WGC3Duint
, WGC3Duint
,
1138 WGC3Duint
, WGC3Duint
)
1139 DELEGATE_TO_GL_3(uniform4uiv
, Uniform4uiv
, WGC3Dint
, WGC3Dsizei
,
1141 DELEGATE_TO_GL_3(uniformBlockBinding
, UniformBlockBinding
, WGC3Duint
, WGC3Duint
,
1143 DELEGATE_TO_GL_4(uniformMatrix2x3fv
, UniformMatrix2x3fv
, WGC3Dint
, WGC3Dsizei
,
1144 WGC3Dboolean
, const WGC3Dfloat
*)
1145 DELEGATE_TO_GL_4(uniformMatrix2x4fv
, UniformMatrix2x4fv
, WGC3Dint
, WGC3Dsizei
,
1146 WGC3Dboolean
, const WGC3Dfloat
*)
1147 DELEGATE_TO_GL_4(uniformMatrix3x2fv
, UniformMatrix3x2fv
, WGC3Dint
, WGC3Dsizei
,
1148 WGC3Dboolean
, const WGC3Dfloat
*)
1149 DELEGATE_TO_GL_4(uniformMatrix3x4fv
, UniformMatrix3x4fv
, WGC3Dint
, WGC3Dsizei
,
1150 WGC3Dboolean
, const WGC3Dfloat
*)
1151 DELEGATE_TO_GL_4(uniformMatrix4x2fv
, UniformMatrix4x2fv
, WGC3Dint
, WGC3Dsizei
,
1152 WGC3Dboolean
, const WGC3Dfloat
*)
1153 DELEGATE_TO_GL_4(uniformMatrix4x3fv
, UniformMatrix4x3fv
, WGC3Dint
, WGC3Dsizei
,
1154 WGC3Dboolean
, const WGC3Dfloat
*)
1155 DELEGATE_TO_GL_5(vertexAttribI4i
, VertexAttribI4i
, WGC3Duint
, WGC3Dint
,
1156 WGC3Dint
, WGC3Dint
, WGC3Dint
)
1157 DELEGATE_TO_GL_2(vertexAttribI4iv
, VertexAttribI4iv
, WGC3Duint
,
1159 DELEGATE_TO_GL_5(vertexAttribI4ui
, VertexAttribI4ui
, WGC3Duint
, WGC3Duint
,
1160 WGC3Duint
, WGC3Duint
, WGC3Duint
)
1161 DELEGATE_TO_GL_2(vertexAttribI4uiv
, VertexAttribI4uiv
, WGC3Duint
,
1163 void WebGraphicsContext3DImpl::vertexAttribIPointer(
1164 WGC3Duint index
, WGC3Dint size
, WGC3Denum type
, WGC3Dsizei stride
,
1165 WGC3Dintptr offset
) {
1166 gl_
->VertexAttribIPointer(
1167 index
, size
, type
, stride
,
1168 reinterpret_cast<void*>(static_cast<intptr_t>(offset
)));
1170 void WebGraphicsContext3DImpl::waitSync(WGC3Dsync sync
,
1171 WGC3Dbitfield flags
,
1172 WGC3Duint64 timeout
) {
1173 gl_
->WaitSync(reinterpret_cast<GLsync
>(sync
), flags
, timeout
);
1176 bool WebGraphicsContext3DImpl::isContextLost() {
1177 return getGraphicsResetStatusARB() != GL_NO_ERROR
;
1180 blink::WGC3Denum
WebGraphicsContext3DImpl::getGraphicsResetStatusARB() {
1181 return gl_
->GetGraphicsResetStatusKHR();
1184 GrGLInterface
* WebGraphicsContext3DImpl::createGrGLInterface() {
1185 return skia_bindings::CreateCommandBufferSkiaGLBinding();
1188 ::gpu::gles2::GLES2ImplementationErrorMessageCallback
*
1189 WebGraphicsContext3DImpl::getErrorMessageCallback() {
1190 if (!client_error_message_callback_
) {
1191 client_error_message_callback_
.reset(
1192 new WebGraphicsContext3DErrorMessageCallback(this));
1194 return client_error_message_callback_
.get();
1197 void WebGraphicsContext3DImpl::OnErrorMessage(
1198 const std::string
& message
, int id
) {
1199 if (error_message_callback_
) {
1200 blink::WebString str
= blink::WebString::fromUTF8(message
.c_str());
1201 error_message_callback_
->onErrorMessage(str
, id
);
1205 // TODO(bajones): Look into removing these functions from the blink interface
1206 void WebGraphicsContext3DImpl::prepareTexture() {
1210 void WebGraphicsContext3DImpl::postSubBufferCHROMIUM(
1211 int x
, int y
, int width
, int height
) {
1215 void WebGraphicsContext3DImpl::setVisibilityCHROMIUM(
1220 void WebGraphicsContext3DImpl::copyTextureToParentTextureCHROMIUM(
1221 WebGLId texture
, WebGLId parentTexture
) {
1225 void WebGraphicsContext3DImpl::releaseShaderCompiler() {
1229 void WebGraphicsContext3DImpl::ConvertAttributes(
1230 const blink::WebGraphicsContext3D::Attributes
& attributes
,
1231 ::gpu::gles2::ContextCreationAttribHelper
* output_attribs
) {
1232 output_attribs
->alpha_size
= attributes
.alpha
? 8 : 0;
1233 output_attribs
->depth_size
= attributes
.depth
? 24 : 0;
1234 output_attribs
->stencil_size
= attributes
.stencil
? 8 : 0;
1235 output_attribs
->samples
= attributes
.antialias
? 4 : 0;
1236 output_attribs
->sample_buffers
= attributes
.antialias
? 1 : 0;
1237 output_attribs
->fail_if_major_perf_caveat
=
1238 attributes
.failIfMajorPerformanceCaveat
;
1239 output_attribs
->bind_generates_resource
= false;
1240 output_attribs
->webgl_version
= attributes
.webGLVersion
;
1243 } // namespace gpu_blink