Home | History | Annotate | Download | only in shared_impl
      1 // Copyright 2014 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 // This file is auto-generated from
      6 // gpu/command_buffer/build_gles2_cmd_buffer.py
      7 // It's formatted by clang-format using chromium coding style:
      8 //    clang-format -i -style=chromium filename
      9 // DO NOT EDIT!
     10 
     11 #include "ppapi/shared_impl/ppb_opengles2_shared.h"
     12 
     13 #include "base/logging.h"
     14 #include "gpu/command_buffer/client/gles2_implementation.h"
     15 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
     16 #include "ppapi/thunk/enter.h"
     17 
     18 namespace ppapi {
     19 
     20 namespace {
     21 
     22 typedef thunk::EnterResource<thunk::PPB_Graphics3D_API> Enter3D;
     23 
     24 gpu::gles2::GLES2Implementation* ToGles2Impl(Enter3D* enter) {
     25   DCHECK(enter);
     26   DCHECK(enter->succeeded());
     27   return static_cast<PPB_Graphics3D_Shared*>(enter->object())->gles2_impl();
     28 }
     29 
     30 void ActiveTexture(PP_Resource context_id, GLenum texture) {
     31   Enter3D enter(context_id, true);
     32   if (enter.succeeded()) {
     33     ToGles2Impl(&enter)->ActiveTexture(texture);
     34   }
     35 }
     36 
     37 void AttachShader(PP_Resource context_id, GLuint program, GLuint shader) {
     38   Enter3D enter(context_id, true);
     39   if (enter.succeeded()) {
     40     ToGles2Impl(&enter)->AttachShader(program, shader);
     41   }
     42 }
     43 
     44 void BindAttribLocation(PP_Resource context_id,
     45                         GLuint program,
     46                         GLuint index,
     47                         const char* name) {
     48   Enter3D enter(context_id, true);
     49   if (enter.succeeded()) {
     50     ToGles2Impl(&enter)->BindAttribLocation(program, index, name);
     51   }
     52 }
     53 
     54 void BindBuffer(PP_Resource context_id, GLenum target, GLuint buffer) {
     55   Enter3D enter(context_id, true);
     56   if (enter.succeeded()) {
     57     ToGles2Impl(&enter)->BindBuffer(target, buffer);
     58   }
     59 }
     60 
     61 void BindFramebuffer(PP_Resource context_id,
     62                      GLenum target,
     63                      GLuint framebuffer) {
     64   Enter3D enter(context_id, true);
     65   if (enter.succeeded()) {
     66     ToGles2Impl(&enter)->BindFramebuffer(target, framebuffer);
     67   }
     68 }
     69 
     70 void BindRenderbuffer(PP_Resource context_id,
     71                       GLenum target,
     72                       GLuint renderbuffer) {
     73   Enter3D enter(context_id, true);
     74   if (enter.succeeded()) {
     75     ToGles2Impl(&enter)->BindRenderbuffer(target, renderbuffer);
     76   }
     77 }
     78 
     79 void BindTexture(PP_Resource context_id, GLenum target, GLuint texture) {
     80   Enter3D enter(context_id, true);
     81   if (enter.succeeded()) {
     82     ToGles2Impl(&enter)->BindTexture(target, texture);
     83   }
     84 }
     85 
     86 void BlendColor(PP_Resource context_id,
     87                 GLclampf red,
     88                 GLclampf green,
     89                 GLclampf blue,
     90                 GLclampf alpha) {
     91   Enter3D enter(context_id, true);
     92   if (enter.succeeded()) {
     93     ToGles2Impl(&enter)->BlendColor(red, green, blue, alpha);
     94   }
     95 }
     96 
     97 void BlendEquation(PP_Resource context_id, GLenum mode) {
     98   Enter3D enter(context_id, true);
     99   if (enter.succeeded()) {
    100     ToGles2Impl(&enter)->BlendEquation(mode);
    101   }
    102 }
    103 
    104 void BlendEquationSeparate(PP_Resource context_id,
    105                            GLenum modeRGB,
    106                            GLenum modeAlpha) {
    107   Enter3D enter(context_id, true);
    108   if (enter.succeeded()) {
    109     ToGles2Impl(&enter)->BlendEquationSeparate(modeRGB, modeAlpha);
    110   }
    111 }
    112 
    113 void BlendFunc(PP_Resource context_id, GLenum sfactor, GLenum dfactor) {
    114   Enter3D enter(context_id, true);
    115   if (enter.succeeded()) {
    116     ToGles2Impl(&enter)->BlendFunc(sfactor, dfactor);
    117   }
    118 }
    119 
    120 void BlendFuncSeparate(PP_Resource context_id,
    121                        GLenum srcRGB,
    122                        GLenum dstRGB,
    123                        GLenum srcAlpha,
    124                        GLenum dstAlpha) {
    125   Enter3D enter(context_id, true);
    126   if (enter.succeeded()) {
    127     ToGles2Impl(&enter)->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
    128   }
    129 }
    130 
    131 void BufferData(PP_Resource context_id,
    132                 GLenum target,
    133                 GLsizeiptr size,
    134                 const void* data,
    135                 GLenum usage) {
    136   Enter3D enter(context_id, true);
    137   if (enter.succeeded()) {
    138     ToGles2Impl(&enter)->BufferData(target, size, data, usage);
    139   }
    140 }
    141 
    142 void BufferSubData(PP_Resource context_id,
    143                    GLenum target,
    144                    GLintptr offset,
    145                    GLsizeiptr size,
    146                    const void* data) {
    147   Enter3D enter(context_id, true);
    148   if (enter.succeeded()) {
    149     ToGles2Impl(&enter)->BufferSubData(target, offset, size, data);
    150   }
    151 }
    152 
    153 GLenum CheckFramebufferStatus(PP_Resource context_id, GLenum target) {
    154   Enter3D enter(context_id, true);
    155   if (enter.succeeded()) {
    156     return ToGles2Impl(&enter)->CheckFramebufferStatus(target);
    157   } else {
    158     return 0;
    159   }
    160 }
    161 
    162 void Clear(PP_Resource context_id, GLbitfield mask) {
    163   Enter3D enter(context_id, true);
    164   if (enter.succeeded()) {
    165     ToGles2Impl(&enter)->Clear(mask);
    166   }
    167 }
    168 
    169 void ClearColor(PP_Resource context_id,
    170                 GLclampf red,
    171                 GLclampf green,
    172                 GLclampf blue,
    173                 GLclampf alpha) {
    174   Enter3D enter(context_id, true);
    175   if (enter.succeeded()) {
    176     ToGles2Impl(&enter)->ClearColor(red, green, blue, alpha);
    177   }
    178 }
    179 
    180 void ClearDepthf(PP_Resource context_id, GLclampf depth) {
    181   Enter3D enter(context_id, true);
    182   if (enter.succeeded()) {
    183     ToGles2Impl(&enter)->ClearDepthf(depth);
    184   }
    185 }
    186 
    187 void ClearStencil(PP_Resource context_id, GLint s) {
    188   Enter3D enter(context_id, true);
    189   if (enter.succeeded()) {
    190     ToGles2Impl(&enter)->ClearStencil(s);
    191   }
    192 }
    193 
    194 void ColorMask(PP_Resource context_id,
    195                GLboolean red,
    196                GLboolean green,
    197                GLboolean blue,
    198                GLboolean alpha) {
    199   Enter3D enter(context_id, true);
    200   if (enter.succeeded()) {
    201     ToGles2Impl(&enter)->ColorMask(red, green, blue, alpha);
    202   }
    203 }
    204 
    205 void CompileShader(PP_Resource context_id, GLuint shader) {
    206   Enter3D enter(context_id, true);
    207   if (enter.succeeded()) {
    208     ToGles2Impl(&enter)->CompileShader(shader);
    209   }
    210 }
    211 
    212 void CompressedTexImage2D(PP_Resource context_id,
    213                           GLenum target,
    214                           GLint level,
    215                           GLenum internalformat,
    216                           GLsizei width,
    217                           GLsizei height,
    218                           GLint border,
    219                           GLsizei imageSize,
    220                           const void* data) {
    221   Enter3D enter(context_id, true);
    222   if (enter.succeeded()) {
    223     ToGles2Impl(&enter)->CompressedTexImage2D(
    224         target, level, internalformat, width, height, border, imageSize, data);
    225   }
    226 }
    227 
    228 void CompressedTexSubImage2D(PP_Resource context_id,
    229                              GLenum target,
    230                              GLint level,
    231                              GLint xoffset,
    232                              GLint yoffset,
    233                              GLsizei width,
    234                              GLsizei height,
    235                              GLenum format,
    236                              GLsizei imageSize,
    237                              const void* data) {
    238   Enter3D enter(context_id, true);
    239   if (enter.succeeded()) {
    240     ToGles2Impl(&enter)->CompressedTexSubImage2D(target,
    241                                                  level,
    242                                                  xoffset,
    243                                                  yoffset,
    244                                                  width,
    245                                                  height,
    246                                                  format,
    247                                                  imageSize,
    248                                                  data);
    249   }
    250 }
    251 
    252 void CopyTexImage2D(PP_Resource context_id,
    253                     GLenum target,
    254                     GLint level,
    255                     GLenum internalformat,
    256                     GLint x,
    257                     GLint y,
    258                     GLsizei width,
    259                     GLsizei height,
    260                     GLint border) {
    261   Enter3D enter(context_id, true);
    262   if (enter.succeeded()) {
    263     ToGles2Impl(&enter)->CopyTexImage2D(
    264         target, level, internalformat, x, y, width, height, border);
    265   }
    266 }
    267 
    268 void CopyTexSubImage2D(PP_Resource context_id,
    269                        GLenum target,
    270                        GLint level,
    271                        GLint xoffset,
    272                        GLint yoffset,
    273                        GLint x,
    274                        GLint y,
    275                        GLsizei width,
    276                        GLsizei height) {
    277   Enter3D enter(context_id, true);
    278   if (enter.succeeded()) {
    279     ToGles2Impl(&enter)->CopyTexSubImage2D(
    280         target, level, xoffset, yoffset, x, y, width, height);
    281   }
    282 }
    283 
    284 GLuint CreateProgram(PP_Resource context_id) {
    285   Enter3D enter(context_id, true);
    286   if (enter.succeeded()) {
    287     return ToGles2Impl(&enter)->CreateProgram();
    288   } else {
    289     return 0;
    290   }
    291 }
    292 
    293 GLuint CreateShader(PP_Resource context_id, GLenum type) {
    294   Enter3D enter(context_id, true);
    295   if (enter.succeeded()) {
    296     return ToGles2Impl(&enter)->CreateShader(type);
    297   } else {
    298     return 0;
    299   }
    300 }
    301 
    302 void CullFace(PP_Resource context_id, GLenum mode) {
    303   Enter3D enter(context_id, true);
    304   if (enter.succeeded()) {
    305     ToGles2Impl(&enter)->CullFace(mode);
    306   }
    307 }
    308 
    309 void DeleteBuffers(PP_Resource context_id, GLsizei n, const GLuint* buffers) {
    310   Enter3D enter(context_id, true);
    311   if (enter.succeeded()) {
    312     ToGles2Impl(&enter)->DeleteBuffers(n, buffers);
    313   }
    314 }
    315 
    316 void DeleteFramebuffers(PP_Resource context_id,
    317                         GLsizei n,
    318                         const GLuint* framebuffers) {
    319   Enter3D enter(context_id, true);
    320   if (enter.succeeded()) {
    321     ToGles2Impl(&enter)->DeleteFramebuffers(n, framebuffers);
    322   }
    323 }
    324 
    325 void DeleteProgram(PP_Resource context_id, GLuint program) {
    326   Enter3D enter(context_id, true);
    327   if (enter.succeeded()) {
    328     ToGles2Impl(&enter)->DeleteProgram(program);
    329   }
    330 }
    331 
    332 void DeleteRenderbuffers(PP_Resource context_id,
    333                          GLsizei n,
    334                          const GLuint* renderbuffers) {
    335   Enter3D enter(context_id, true);
    336   if (enter.succeeded()) {
    337     ToGles2Impl(&enter)->DeleteRenderbuffers(n, renderbuffers);
    338   }
    339 }
    340 
    341 void DeleteShader(PP_Resource context_id, GLuint shader) {
    342   Enter3D enter(context_id, true);
    343   if (enter.succeeded()) {
    344     ToGles2Impl(&enter)->DeleteShader(shader);
    345   }
    346 }
    347 
    348 void DeleteTextures(PP_Resource context_id, GLsizei n, const GLuint* textures) {
    349   Enter3D enter(context_id, true);
    350   if (enter.succeeded()) {
    351     ToGles2Impl(&enter)->DeleteTextures(n, textures);
    352   }
    353 }
    354 
    355 void DepthFunc(PP_Resource context_id, GLenum func) {
    356   Enter3D enter(context_id, true);
    357   if (enter.succeeded()) {
    358     ToGles2Impl(&enter)->DepthFunc(func);
    359   }
    360 }
    361 
    362 void DepthMask(PP_Resource context_id, GLboolean flag) {
    363   Enter3D enter(context_id, true);
    364   if (enter.succeeded()) {
    365     ToGles2Impl(&enter)->DepthMask(flag);
    366   }
    367 }
    368 
    369 void DepthRangef(PP_Resource context_id, GLclampf zNear, GLclampf zFar) {
    370   Enter3D enter(context_id, true);
    371   if (enter.succeeded()) {
    372     ToGles2Impl(&enter)->DepthRangef(zNear, zFar);
    373   }
    374 }
    375 
    376 void DetachShader(PP_Resource context_id, GLuint program, GLuint shader) {
    377   Enter3D enter(context_id, true);
    378   if (enter.succeeded()) {
    379     ToGles2Impl(&enter)->DetachShader(program, shader);
    380   }
    381 }
    382 
    383 void Disable(PP_Resource context_id, GLenum cap) {
    384   Enter3D enter(context_id, true);
    385   if (enter.succeeded()) {
    386     ToGles2Impl(&enter)->Disable(cap);
    387   }
    388 }
    389 
    390 void DisableVertexAttribArray(PP_Resource context_id, GLuint index) {
    391   Enter3D enter(context_id, true);
    392   if (enter.succeeded()) {
    393     ToGles2Impl(&enter)->DisableVertexAttribArray(index);
    394   }
    395 }
    396 
    397 void DrawArrays(PP_Resource context_id,
    398                 GLenum mode,
    399                 GLint first,
    400                 GLsizei count) {
    401   Enter3D enter(context_id, true);
    402   if (enter.succeeded()) {
    403     ToGles2Impl(&enter)->DrawArrays(mode, first, count);
    404   }
    405 }
    406 
    407 void DrawElements(PP_Resource context_id,
    408                   GLenum mode,
    409                   GLsizei count,
    410                   GLenum type,
    411                   const void* indices) {
    412   Enter3D enter(context_id, true);
    413   if (enter.succeeded()) {
    414     ToGles2Impl(&enter)->DrawElements(mode, count, type, indices);
    415   }
    416 }
    417 
    418 void Enable(PP_Resource context_id, GLenum cap) {
    419   Enter3D enter(context_id, true);
    420   if (enter.succeeded()) {
    421     ToGles2Impl(&enter)->Enable(cap);
    422   }
    423 }
    424 
    425 void EnableVertexAttribArray(PP_Resource context_id, GLuint index) {
    426   Enter3D enter(context_id, true);
    427   if (enter.succeeded()) {
    428     ToGles2Impl(&enter)->EnableVertexAttribArray(index);
    429   }
    430 }
    431 
    432 void Finish(PP_Resource context_id) {
    433   Enter3D enter(context_id, true);
    434   if (enter.succeeded()) {
    435     ToGles2Impl(&enter)->Finish();
    436   }
    437 }
    438 
    439 void Flush(PP_Resource context_id) {
    440   Enter3D enter(context_id, true);
    441   if (enter.succeeded()) {
    442     ToGles2Impl(&enter)->Flush();
    443   }
    444 }
    445 
    446 void FramebufferRenderbuffer(PP_Resource context_id,
    447                              GLenum target,
    448                              GLenum attachment,
    449                              GLenum renderbuffertarget,
    450                              GLuint renderbuffer) {
    451   Enter3D enter(context_id, true);
    452   if (enter.succeeded()) {
    453     ToGles2Impl(&enter)->FramebufferRenderbuffer(
    454         target, attachment, renderbuffertarget, renderbuffer);
    455   }
    456 }
    457 
    458 void FramebufferTexture2D(PP_Resource context_id,
    459                           GLenum target,
    460                           GLenum attachment,
    461                           GLenum textarget,
    462                           GLuint texture,
    463                           GLint level) {
    464   Enter3D enter(context_id, true);
    465   if (enter.succeeded()) {
    466     ToGles2Impl(&enter)
    467         ->FramebufferTexture2D(target, attachment, textarget, texture, level);
    468   }
    469 }
    470 
    471 void FrontFace(PP_Resource context_id, GLenum mode) {
    472   Enter3D enter(context_id, true);
    473   if (enter.succeeded()) {
    474     ToGles2Impl(&enter)->FrontFace(mode);
    475   }
    476 }
    477 
    478 void GenBuffers(PP_Resource context_id, GLsizei n, GLuint* buffers) {
    479   Enter3D enter(context_id, true);
    480   if (enter.succeeded()) {
    481     ToGles2Impl(&enter)->GenBuffers(n, buffers);
    482   }
    483 }
    484 
    485 void GenerateMipmap(PP_Resource context_id, GLenum target) {
    486   Enter3D enter(context_id, true);
    487   if (enter.succeeded()) {
    488     ToGles2Impl(&enter)->GenerateMipmap(target);
    489   }
    490 }
    491 
    492 void GenFramebuffers(PP_Resource context_id, GLsizei n, GLuint* framebuffers) {
    493   Enter3D enter(context_id, true);
    494   if (enter.succeeded()) {
    495     ToGles2Impl(&enter)->GenFramebuffers(n, framebuffers);
    496   }
    497 }
    498 
    499 void GenRenderbuffers(PP_Resource context_id,
    500                       GLsizei n,
    501                       GLuint* renderbuffers) {
    502   Enter3D enter(context_id, true);
    503   if (enter.succeeded()) {
    504     ToGles2Impl(&enter)->GenRenderbuffers(n, renderbuffers);
    505   }
    506 }
    507 
    508 void GenTextures(PP_Resource context_id, GLsizei n, GLuint* textures) {
    509   Enter3D enter(context_id, true);
    510   if (enter.succeeded()) {
    511     ToGles2Impl(&enter)->GenTextures(n, textures);
    512   }
    513 }
    514 
    515 void GetActiveAttrib(PP_Resource context_id,
    516                      GLuint program,
    517                      GLuint index,
    518                      GLsizei bufsize,
    519                      GLsizei* length,
    520                      GLint* size,
    521                      GLenum* type,
    522                      char* name) {
    523   Enter3D enter(context_id, true);
    524   if (enter.succeeded()) {
    525     ToGles2Impl(&enter)
    526         ->GetActiveAttrib(program, index, bufsize, length, size, type, name);
    527   }
    528 }
    529 
    530 void GetActiveUniform(PP_Resource context_id,
    531                       GLuint program,
    532                       GLuint index,
    533                       GLsizei bufsize,
    534                       GLsizei* length,
    535                       GLint* size,
    536                       GLenum* type,
    537                       char* name) {
    538   Enter3D enter(context_id, true);
    539   if (enter.succeeded()) {
    540     ToGles2Impl(&enter)
    541         ->GetActiveUniform(program, index, bufsize, length, size, type, name);
    542   }
    543 }
    544 
    545 void GetAttachedShaders(PP_Resource context_id,
    546                         GLuint program,
    547                         GLsizei maxcount,
    548                         GLsizei* count,
    549                         GLuint* shaders) {
    550   Enter3D enter(context_id, true);
    551   if (enter.succeeded()) {
    552     ToGles2Impl(&enter)->GetAttachedShaders(program, maxcount, count, shaders);
    553   }
    554 }
    555 
    556 GLint GetAttribLocation(PP_Resource context_id,
    557                         GLuint program,
    558                         const char* name) {
    559   Enter3D enter(context_id, true);
    560   if (enter.succeeded()) {
    561     return ToGles2Impl(&enter)->GetAttribLocation(program, name);
    562   } else {
    563     return -1;
    564   }
    565 }
    566 
    567 void GetBooleanv(PP_Resource context_id, GLenum pname, GLboolean* params) {
    568   Enter3D enter(context_id, true);
    569   if (enter.succeeded()) {
    570     ToGles2Impl(&enter)->GetBooleanv(pname, params);
    571   }
    572 }
    573 
    574 void GetBufferParameteriv(PP_Resource context_id,
    575                           GLenum target,
    576                           GLenum pname,
    577                           GLint* params) {
    578   Enter3D enter(context_id, true);
    579   if (enter.succeeded()) {
    580     ToGles2Impl(&enter)->GetBufferParameteriv(target, pname, params);
    581   }
    582 }
    583 
    584 GLenum GetError(PP_Resource context_id) {
    585   Enter3D enter(context_id, true);
    586   if (enter.succeeded()) {
    587     return ToGles2Impl(&enter)->GetError();
    588   } else {
    589     return 0;
    590   }
    591 }
    592 
    593 void GetFloatv(PP_Resource context_id, GLenum pname, GLfloat* params) {
    594   Enter3D enter(context_id, true);
    595   if (enter.succeeded()) {
    596     ToGles2Impl(&enter)->GetFloatv(pname, params);
    597   }
    598 }
    599 
    600 void GetFramebufferAttachmentParameteriv(PP_Resource context_id,
    601                                          GLenum target,
    602                                          GLenum attachment,
    603                                          GLenum pname,
    604                                          GLint* params) {
    605   Enter3D enter(context_id, true);
    606   if (enter.succeeded()) {
    607     ToGles2Impl(&enter)->GetFramebufferAttachmentParameteriv(
    608         target, attachment, pname, params);
    609   }
    610 }
    611 
    612 void GetIntegerv(PP_Resource context_id, GLenum pname, GLint* params) {
    613   Enter3D enter(context_id, true);
    614   if (enter.succeeded()) {
    615     ToGles2Impl(&enter)->GetIntegerv(pname, params);
    616   }
    617 }
    618 
    619 void GetProgramiv(PP_Resource context_id,
    620                   GLuint program,
    621                   GLenum pname,
    622                   GLint* params) {
    623   Enter3D enter(context_id, true);
    624   if (enter.succeeded()) {
    625     ToGles2Impl(&enter)->GetProgramiv(program, pname, params);
    626   }
    627 }
    628 
    629 void GetProgramInfoLog(PP_Resource context_id,
    630                        GLuint program,
    631                        GLsizei bufsize,
    632                        GLsizei* length,
    633                        char* infolog) {
    634   Enter3D enter(context_id, true);
    635   if (enter.succeeded()) {
    636     ToGles2Impl(&enter)->GetProgramInfoLog(program, bufsize, length, infolog);
    637   }
    638 }
    639 
    640 void GetRenderbufferParameteriv(PP_Resource context_id,
    641                                 GLenum target,
    642                                 GLenum pname,
    643                                 GLint* params) {
    644   Enter3D enter(context_id, true);
    645   if (enter.succeeded()) {
    646     ToGles2Impl(&enter)->GetRenderbufferParameteriv(target, pname, params);
    647   }
    648 }
    649 
    650 void GetShaderiv(PP_Resource context_id,
    651                  GLuint shader,
    652                  GLenum pname,
    653                  GLint* params) {
    654   Enter3D enter(context_id, true);
    655   if (enter.succeeded()) {
    656     ToGles2Impl(&enter)->GetShaderiv(shader, pname, params);
    657   }
    658 }
    659 
    660 void GetShaderInfoLog(PP_Resource context_id,
    661                       GLuint shader,
    662                       GLsizei bufsize,
    663                       GLsizei* length,
    664                       char* infolog) {
    665   Enter3D enter(context_id, true);
    666   if (enter.succeeded()) {
    667     ToGles2Impl(&enter)->GetShaderInfoLog(shader, bufsize, length, infolog);
    668   }
    669 }
    670 
    671 void GetShaderPrecisionFormat(PP_Resource context_id,
    672                               GLenum shadertype,
    673                               GLenum precisiontype,
    674                               GLint* range,
    675                               GLint* precision) {
    676   Enter3D enter(context_id, true);
    677   if (enter.succeeded()) {
    678     ToGles2Impl(&enter)
    679         ->GetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
    680   }
    681 }
    682 
    683 void GetShaderSource(PP_Resource context_id,
    684                      GLuint shader,
    685                      GLsizei bufsize,
    686                      GLsizei* length,
    687                      char* source) {
    688   Enter3D enter(context_id, true);
    689   if (enter.succeeded()) {
    690     ToGles2Impl(&enter)->GetShaderSource(shader, bufsize, length, source);
    691   }
    692 }
    693 
    694 const GLubyte* GetString(PP_Resource context_id, GLenum name) {
    695   Enter3D enter(context_id, true);
    696   if (enter.succeeded()) {
    697     return ToGles2Impl(&enter)->GetString(name);
    698   } else {
    699     return NULL;
    700   }
    701 }
    702 
    703 void GetTexParameterfv(PP_Resource context_id,
    704                        GLenum target,
    705                        GLenum pname,
    706                        GLfloat* params) {
    707   Enter3D enter(context_id, true);
    708   if (enter.succeeded()) {
    709     ToGles2Impl(&enter)->GetTexParameterfv(target, pname, params);
    710   }
    711 }
    712 
    713 void GetTexParameteriv(PP_Resource context_id,
    714                        GLenum target,
    715                        GLenum pname,
    716                        GLint* params) {
    717   Enter3D enter(context_id, true);
    718   if (enter.succeeded()) {
    719     ToGles2Impl(&enter)->GetTexParameteriv(target, pname, params);
    720   }
    721 }
    722 
    723 void GetUniformfv(PP_Resource context_id,
    724                   GLuint program,
    725                   GLint location,
    726                   GLfloat* params) {
    727   Enter3D enter(context_id, true);
    728   if (enter.succeeded()) {
    729     ToGles2Impl(&enter)->GetUniformfv(program, location, params);
    730   }
    731 }
    732 
    733 void GetUniformiv(PP_Resource context_id,
    734                   GLuint program,
    735                   GLint location,
    736                   GLint* params) {
    737   Enter3D enter(context_id, true);
    738   if (enter.succeeded()) {
    739     ToGles2Impl(&enter)->GetUniformiv(program, location, params);
    740   }
    741 }
    742 
    743 GLint GetUniformLocation(PP_Resource context_id,
    744                          GLuint program,
    745                          const char* name) {
    746   Enter3D enter(context_id, true);
    747   if (enter.succeeded()) {
    748     return ToGles2Impl(&enter)->GetUniformLocation(program, name);
    749   } else {
    750     return -1;
    751   }
    752 }
    753 
    754 void GetVertexAttribfv(PP_Resource context_id,
    755                        GLuint index,
    756                        GLenum pname,
    757                        GLfloat* params) {
    758   Enter3D enter(context_id, true);
    759   if (enter.succeeded()) {
    760     ToGles2Impl(&enter)->GetVertexAttribfv(index, pname, params);
    761   }
    762 }
    763 
    764 void GetVertexAttribiv(PP_Resource context_id,
    765                        GLuint index,
    766                        GLenum pname,
    767                        GLint* params) {
    768   Enter3D enter(context_id, true);
    769   if (enter.succeeded()) {
    770     ToGles2Impl(&enter)->GetVertexAttribiv(index, pname, params);
    771   }
    772 }
    773 
    774 void GetVertexAttribPointerv(PP_Resource context_id,
    775                              GLuint index,
    776                              GLenum pname,
    777                              void** pointer) {
    778   Enter3D enter(context_id, true);
    779   if (enter.succeeded()) {
    780     ToGles2Impl(&enter)->GetVertexAttribPointerv(index, pname, pointer);
    781   }
    782 }
    783 
    784 void Hint(PP_Resource context_id, GLenum target, GLenum mode) {
    785   Enter3D enter(context_id, true);
    786   if (enter.succeeded()) {
    787     ToGles2Impl(&enter)->Hint(target, mode);
    788   }
    789 }
    790 
    791 GLboolean IsBuffer(PP_Resource context_id, GLuint buffer) {
    792   Enter3D enter(context_id, true);
    793   if (enter.succeeded()) {
    794     return ToGles2Impl(&enter)->IsBuffer(buffer);
    795   } else {
    796     return GL_FALSE;
    797   }
    798 }
    799 
    800 GLboolean IsEnabled(PP_Resource context_id, GLenum cap) {
    801   Enter3D enter(context_id, true);
    802   if (enter.succeeded()) {
    803     return ToGles2Impl(&enter)->IsEnabled(cap);
    804   } else {
    805     return GL_FALSE;
    806   }
    807 }
    808 
    809 GLboolean IsFramebuffer(PP_Resource context_id, GLuint framebuffer) {
    810   Enter3D enter(context_id, true);
    811   if (enter.succeeded()) {
    812     return ToGles2Impl(&enter)->IsFramebuffer(framebuffer);
    813   } else {
    814     return GL_FALSE;
    815   }
    816 }
    817 
    818 GLboolean IsProgram(PP_Resource context_id, GLuint program) {
    819   Enter3D enter(context_id, true);
    820   if (enter.succeeded()) {
    821     return ToGles2Impl(&enter)->IsProgram(program);
    822   } else {
    823     return GL_FALSE;
    824   }
    825 }
    826 
    827 GLboolean IsRenderbuffer(PP_Resource context_id, GLuint renderbuffer) {
    828   Enter3D enter(context_id, true);
    829   if (enter.succeeded()) {
    830     return ToGles2Impl(&enter)->IsRenderbuffer(renderbuffer);
    831   } else {
    832     return GL_FALSE;
    833   }
    834 }
    835 
    836 GLboolean IsShader(PP_Resource context_id, GLuint shader) {
    837   Enter3D enter(context_id, true);
    838   if (enter.succeeded()) {
    839     return ToGles2Impl(&enter)->IsShader(shader);
    840   } else {
    841     return GL_FALSE;
    842   }
    843 }
    844 
    845 GLboolean IsTexture(PP_Resource context_id, GLuint texture) {
    846   Enter3D enter(context_id, true);
    847   if (enter.succeeded()) {
    848     return ToGles2Impl(&enter)->IsTexture(texture);
    849   } else {
    850     return GL_FALSE;
    851   }
    852 }
    853 
    854 void LineWidth(PP_Resource context_id, GLfloat width) {
    855   Enter3D enter(context_id, true);
    856   if (enter.succeeded()) {
    857     ToGles2Impl(&enter)->LineWidth(width);
    858   }
    859 }
    860 
    861 void LinkProgram(PP_Resource context_id, GLuint program) {
    862   Enter3D enter(context_id, true);
    863   if (enter.succeeded()) {
    864     ToGles2Impl(&enter)->LinkProgram(program);
    865   }
    866 }
    867 
    868 void PixelStorei(PP_Resource context_id, GLenum pname, GLint param) {
    869   Enter3D enter(context_id, true);
    870   if (enter.succeeded()) {
    871     ToGles2Impl(&enter)->PixelStorei(pname, param);
    872   }
    873 }
    874 
    875 void PolygonOffset(PP_Resource context_id, GLfloat factor, GLfloat units) {
    876   Enter3D enter(context_id, true);
    877   if (enter.succeeded()) {
    878     ToGles2Impl(&enter)->PolygonOffset(factor, units);
    879   }
    880 }
    881 
    882 void ReadPixels(PP_Resource context_id,
    883                 GLint x,
    884                 GLint y,
    885                 GLsizei width,
    886                 GLsizei height,
    887                 GLenum format,
    888                 GLenum type,
    889                 void* pixels) {
    890   Enter3D enter(context_id, true);
    891   if (enter.succeeded()) {
    892     ToGles2Impl(&enter)->ReadPixels(x, y, width, height, format, type, pixels);
    893   }
    894 }
    895 
    896 void ReleaseShaderCompiler(PP_Resource context_id) {
    897   Enter3D enter(context_id, true);
    898   if (enter.succeeded()) {
    899     ToGles2Impl(&enter)->ReleaseShaderCompiler();
    900   }
    901 }
    902 
    903 void RenderbufferStorage(PP_Resource context_id,
    904                          GLenum target,
    905                          GLenum internalformat,
    906                          GLsizei width,
    907                          GLsizei height) {
    908   Enter3D enter(context_id, true);
    909   if (enter.succeeded()) {
    910     ToGles2Impl(&enter)
    911         ->RenderbufferStorage(target, internalformat, width, height);
    912   }
    913 }
    914 
    915 void SampleCoverage(PP_Resource context_id, GLclampf value, GLboolean invert) {
    916   Enter3D enter(context_id, true);
    917   if (enter.succeeded()) {
    918     ToGles2Impl(&enter)->SampleCoverage(value, invert);
    919   }
    920 }
    921 
    922 void Scissor(PP_Resource context_id,
    923              GLint x,
    924              GLint y,
    925              GLsizei width,
    926              GLsizei height) {
    927   Enter3D enter(context_id, true);
    928   if (enter.succeeded()) {
    929     ToGles2Impl(&enter)->Scissor(x, y, width, height);
    930   }
    931 }
    932 
    933 void ShaderBinary(PP_Resource context_id,
    934                   GLsizei n,
    935                   const GLuint* shaders,
    936                   GLenum binaryformat,
    937                   const void* binary,
    938                   GLsizei length) {
    939   Enter3D enter(context_id, true);
    940   if (enter.succeeded()) {
    941     ToGles2Impl(&enter)->ShaderBinary(n, shaders, binaryformat, binary, length);
    942   }
    943 }
    944 
    945 void ShaderSource(PP_Resource context_id,
    946                   GLuint shader,
    947                   GLsizei count,
    948                   const char** str,
    949                   const GLint* length) {
    950   Enter3D enter(context_id, true);
    951   if (enter.succeeded()) {
    952     ToGles2Impl(&enter)->ShaderSource(shader, count, str, length);
    953   }
    954 }
    955 
    956 void StencilFunc(PP_Resource context_id, GLenum func, GLint ref, GLuint mask) {
    957   Enter3D enter(context_id, true);
    958   if (enter.succeeded()) {
    959     ToGles2Impl(&enter)->StencilFunc(func, ref, mask);
    960   }
    961 }
    962 
    963 void StencilFuncSeparate(PP_Resource context_id,
    964                          GLenum face,
    965                          GLenum func,
    966                          GLint ref,
    967                          GLuint mask) {
    968   Enter3D enter(context_id, true);
    969   if (enter.succeeded()) {
    970     ToGles2Impl(&enter)->StencilFuncSeparate(face, func, ref, mask);
    971   }
    972 }
    973 
    974 void StencilMask(PP_Resource context_id, GLuint mask) {
    975   Enter3D enter(context_id, true);
    976   if (enter.succeeded()) {
    977     ToGles2Impl(&enter)->StencilMask(mask);
    978   }
    979 }
    980 
    981 void StencilMaskSeparate(PP_Resource context_id, GLenum face, GLuint mask) {
    982   Enter3D enter(context_id, true);
    983   if (enter.succeeded()) {
    984     ToGles2Impl(&enter)->StencilMaskSeparate(face, mask);
    985   }
    986 }
    987 
    988 void StencilOp(PP_Resource context_id,
    989                GLenum fail,
    990                GLenum zfail,
    991                GLenum zpass) {
    992   Enter3D enter(context_id, true);
    993   if (enter.succeeded()) {
    994     ToGles2Impl(&enter)->StencilOp(fail, zfail, zpass);
    995   }
    996 }
    997 
    998 void StencilOpSeparate(PP_Resource context_id,
    999                        GLenum face,
   1000                        GLenum fail,
   1001                        GLenum zfail,
   1002                        GLenum zpass) {
   1003   Enter3D enter(context_id, true);
   1004   if (enter.succeeded()) {
   1005     ToGles2Impl(&enter)->StencilOpSeparate(face, fail, zfail, zpass);
   1006   }
   1007 }
   1008 
   1009 void TexImage2D(PP_Resource context_id,
   1010                 GLenum target,
   1011                 GLint level,
   1012                 GLint internalformat,
   1013                 GLsizei width,
   1014                 GLsizei height,
   1015                 GLint border,
   1016                 GLenum format,
   1017                 GLenum type,
   1018                 const void* pixels) {
   1019   Enter3D enter(context_id, true);
   1020   if (enter.succeeded()) {
   1021     ToGles2Impl(&enter)->TexImage2D(target,
   1022                                     level,
   1023                                     internalformat,
   1024                                     width,
   1025                                     height,
   1026                                     border,
   1027                                     format,
   1028                                     type,
   1029                                     pixels);
   1030   }
   1031 }
   1032 
   1033 void TexParameterf(PP_Resource context_id,
   1034                    GLenum target,
   1035                    GLenum pname,
   1036                    GLfloat param) {
   1037   Enter3D enter(context_id, true);
   1038   if (enter.succeeded()) {
   1039     ToGles2Impl(&enter)->TexParameterf(target, pname, param);
   1040   }
   1041 }
   1042 
   1043 void TexParameterfv(PP_Resource context_id,
   1044                     GLenum target,
   1045                     GLenum pname,
   1046                     const GLfloat* params) {
   1047   Enter3D enter(context_id, true);
   1048   if (enter.succeeded()) {
   1049     ToGles2Impl(&enter)->TexParameterfv(target, pname, params);
   1050   }
   1051 }
   1052 
   1053 void TexParameteri(PP_Resource context_id,
   1054                    GLenum target,
   1055                    GLenum pname,
   1056                    GLint param) {
   1057   Enter3D enter(context_id, true);
   1058   if (enter.succeeded()) {
   1059     ToGles2Impl(&enter)->TexParameteri(target, pname, param);
   1060   }
   1061 }
   1062 
   1063 void TexParameteriv(PP_Resource context_id,
   1064                     GLenum target,
   1065                     GLenum pname,
   1066                     const GLint* params) {
   1067   Enter3D enter(context_id, true);
   1068   if (enter.succeeded()) {
   1069     ToGles2Impl(&enter)->TexParameteriv(target, pname, params);
   1070   }
   1071 }
   1072 
   1073 void TexSubImage2D(PP_Resource context_id,
   1074                    GLenum target,
   1075                    GLint level,
   1076                    GLint xoffset,
   1077                    GLint yoffset,
   1078                    GLsizei width,
   1079                    GLsizei height,
   1080                    GLenum format,
   1081                    GLenum type,
   1082                    const void* pixels) {
   1083   Enter3D enter(context_id, true);
   1084   if (enter.succeeded()) {
   1085     ToGles2Impl(&enter)->TexSubImage2D(
   1086         target, level, xoffset, yoffset, width, height, format, type, pixels);
   1087   }
   1088 }
   1089 
   1090 void Uniform1f(PP_Resource context_id, GLint location, GLfloat x) {
   1091   Enter3D enter(context_id, true);
   1092   if (enter.succeeded()) {
   1093     ToGles2Impl(&enter)->Uniform1f(location, x);
   1094   }
   1095 }
   1096 
   1097 void Uniform1fv(PP_Resource context_id,
   1098                 GLint location,
   1099                 GLsizei count,
   1100                 const GLfloat* v) {
   1101   Enter3D enter(context_id, true);
   1102   if (enter.succeeded()) {
   1103     ToGles2Impl(&enter)->Uniform1fv(location, count, v);
   1104   }
   1105 }
   1106 
   1107 void Uniform1i(PP_Resource context_id, GLint location, GLint x) {
   1108   Enter3D enter(context_id, true);
   1109   if (enter.succeeded()) {
   1110     ToGles2Impl(&enter)->Uniform1i(location, x);
   1111   }
   1112 }
   1113 
   1114 void Uniform1iv(PP_Resource context_id,
   1115                 GLint location,
   1116                 GLsizei count,
   1117                 const GLint* v) {
   1118   Enter3D enter(context_id, true);
   1119   if (enter.succeeded()) {
   1120     ToGles2Impl(&enter)->Uniform1iv(location, count, v);
   1121   }
   1122 }
   1123 
   1124 void Uniform2f(PP_Resource context_id, GLint location, GLfloat x, GLfloat y) {
   1125   Enter3D enter(context_id, true);
   1126   if (enter.succeeded()) {
   1127     ToGles2Impl(&enter)->Uniform2f(location, x, y);
   1128   }
   1129 }
   1130 
   1131 void Uniform2fv(PP_Resource context_id,
   1132                 GLint location,
   1133                 GLsizei count,
   1134                 const GLfloat* v) {
   1135   Enter3D enter(context_id, true);
   1136   if (enter.succeeded()) {
   1137     ToGles2Impl(&enter)->Uniform2fv(location, count, v);
   1138   }
   1139 }
   1140 
   1141 void Uniform2i(PP_Resource context_id, GLint location, GLint x, GLint y) {
   1142   Enter3D enter(context_id, true);
   1143   if (enter.succeeded()) {
   1144     ToGles2Impl(&enter)->Uniform2i(location, x, y);
   1145   }
   1146 }
   1147 
   1148 void Uniform2iv(PP_Resource context_id,
   1149                 GLint location,
   1150                 GLsizei count,
   1151                 const GLint* v) {
   1152   Enter3D enter(context_id, true);
   1153   if (enter.succeeded()) {
   1154     ToGles2Impl(&enter)->Uniform2iv(location, count, v);
   1155   }
   1156 }
   1157 
   1158 void Uniform3f(PP_Resource context_id,
   1159                GLint location,
   1160                GLfloat x,
   1161                GLfloat y,
   1162                GLfloat z) {
   1163   Enter3D enter(context_id, true);
   1164   if (enter.succeeded()) {
   1165     ToGles2Impl(&enter)->Uniform3f(location, x, y, z);
   1166   }
   1167 }
   1168 
   1169 void Uniform3fv(PP_Resource context_id,
   1170                 GLint location,
   1171                 GLsizei count,
   1172                 const GLfloat* v) {
   1173   Enter3D enter(context_id, true);
   1174   if (enter.succeeded()) {
   1175     ToGles2Impl(&enter)->Uniform3fv(location, count, v);
   1176   }
   1177 }
   1178 
   1179 void Uniform3i(PP_Resource context_id,
   1180                GLint location,
   1181                GLint x,
   1182                GLint y,
   1183                GLint z) {
   1184   Enter3D enter(context_id, true);
   1185   if (enter.succeeded()) {
   1186     ToGles2Impl(&enter)->Uniform3i(location, x, y, z);
   1187   }
   1188 }
   1189 
   1190 void Uniform3iv(PP_Resource context_id,
   1191                 GLint location,
   1192                 GLsizei count,
   1193                 const GLint* v) {
   1194   Enter3D enter(context_id, true);
   1195   if (enter.succeeded()) {
   1196     ToGles2Impl(&enter)->Uniform3iv(location, count, v);
   1197   }
   1198 }
   1199 
   1200 void Uniform4f(PP_Resource context_id,
   1201                GLint location,
   1202                GLfloat x,
   1203                GLfloat y,
   1204                GLfloat z,
   1205                GLfloat w) {
   1206   Enter3D enter(context_id, true);
   1207   if (enter.succeeded()) {
   1208     ToGles2Impl(&enter)->Uniform4f(location, x, y, z, w);
   1209   }
   1210 }
   1211 
   1212 void Uniform4fv(PP_Resource context_id,
   1213                 GLint location,
   1214                 GLsizei count,
   1215                 const GLfloat* v) {
   1216   Enter3D enter(context_id, true);
   1217   if (enter.succeeded()) {
   1218     ToGles2Impl(&enter)->Uniform4fv(location, count, v);
   1219   }
   1220 }
   1221 
   1222 void Uniform4i(PP_Resource context_id,
   1223                GLint location,
   1224                GLint x,
   1225                GLint y,
   1226                GLint z,
   1227                GLint w) {
   1228   Enter3D enter(context_id, true);
   1229   if (enter.succeeded()) {
   1230     ToGles2Impl(&enter)->Uniform4i(location, x, y, z, w);
   1231   }
   1232 }
   1233 
   1234 void Uniform4iv(PP_Resource context_id,
   1235                 GLint location,
   1236                 GLsizei count,
   1237                 const GLint* v) {
   1238   Enter3D enter(context_id, true);
   1239   if (enter.succeeded()) {
   1240     ToGles2Impl(&enter)->Uniform4iv(location, count, v);
   1241   }
   1242 }
   1243 
   1244 void UniformMatrix2fv(PP_Resource context_id,
   1245                       GLint location,
   1246                       GLsizei count,
   1247                       GLboolean transpose,
   1248                       const GLfloat* value) {
   1249   Enter3D enter(context_id, true);
   1250   if (enter.succeeded()) {
   1251     ToGles2Impl(&enter)->UniformMatrix2fv(location, count, transpose, value);
   1252   }
   1253 }
   1254 
   1255 void UniformMatrix3fv(PP_Resource context_id,
   1256                       GLint location,
   1257                       GLsizei count,
   1258                       GLboolean transpose,
   1259                       const GLfloat* value) {
   1260   Enter3D enter(context_id, true);
   1261   if (enter.succeeded()) {
   1262     ToGles2Impl(&enter)->UniformMatrix3fv(location, count, transpose, value);
   1263   }
   1264 }
   1265 
   1266 void UniformMatrix4fv(PP_Resource context_id,
   1267                       GLint location,
   1268                       GLsizei count,
   1269                       GLboolean transpose,
   1270                       const GLfloat* value) {
   1271   Enter3D enter(context_id, true);
   1272   if (enter.succeeded()) {
   1273     ToGles2Impl(&enter)->UniformMatrix4fv(location, count, transpose, value);
   1274   }
   1275 }
   1276 
   1277 void UseProgram(PP_Resource context_id, GLuint program) {
   1278   Enter3D enter(context_id, true);
   1279   if (enter.succeeded()) {
   1280     ToGles2Impl(&enter)->UseProgram(program);
   1281   }
   1282 }
   1283 
   1284 void ValidateProgram(PP_Resource context_id, GLuint program) {
   1285   Enter3D enter(context_id, true);
   1286   if (enter.succeeded()) {
   1287     ToGles2Impl(&enter)->ValidateProgram(program);
   1288   }
   1289 }
   1290 
   1291 void VertexAttrib1f(PP_Resource context_id, GLuint indx, GLfloat x) {
   1292   Enter3D enter(context_id, true);
   1293   if (enter.succeeded()) {
   1294     ToGles2Impl(&enter)->VertexAttrib1f(indx, x);
   1295   }
   1296 }
   1297 
   1298 void VertexAttrib1fv(PP_Resource context_id,
   1299                      GLuint indx,
   1300                      const GLfloat* values) {
   1301   Enter3D enter(context_id, true);
   1302   if (enter.succeeded()) {
   1303     ToGles2Impl(&enter)->VertexAttrib1fv(indx, values);
   1304   }
   1305 }
   1306 
   1307 void VertexAttrib2f(PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y) {
   1308   Enter3D enter(context_id, true);
   1309   if (enter.succeeded()) {
   1310     ToGles2Impl(&enter)->VertexAttrib2f(indx, x, y);
   1311   }
   1312 }
   1313 
   1314 void VertexAttrib2fv(PP_Resource context_id,
   1315                      GLuint indx,
   1316                      const GLfloat* values) {
   1317   Enter3D enter(context_id, true);
   1318   if (enter.succeeded()) {
   1319     ToGles2Impl(&enter)->VertexAttrib2fv(indx, values);
   1320   }
   1321 }
   1322 
   1323 void VertexAttrib3f(PP_Resource context_id,
   1324                     GLuint indx,
   1325                     GLfloat x,
   1326                     GLfloat y,
   1327                     GLfloat z) {
   1328   Enter3D enter(context_id, true);
   1329   if (enter.succeeded()) {
   1330     ToGles2Impl(&enter)->VertexAttrib3f(indx, x, y, z);
   1331   }
   1332 }
   1333 
   1334 void VertexAttrib3fv(PP_Resource context_id,
   1335                      GLuint indx,
   1336                      const GLfloat* values) {
   1337   Enter3D enter(context_id, true);
   1338   if (enter.succeeded()) {
   1339     ToGles2Impl(&enter)->VertexAttrib3fv(indx, values);
   1340   }
   1341 }
   1342 
   1343 void VertexAttrib4f(PP_Resource context_id,
   1344                     GLuint indx,
   1345                     GLfloat x,
   1346                     GLfloat y,
   1347                     GLfloat z,
   1348                     GLfloat w) {
   1349   Enter3D enter(context_id, true);
   1350   if (enter.succeeded()) {
   1351     ToGles2Impl(&enter)->VertexAttrib4f(indx, x, y, z, w);
   1352   }
   1353 }
   1354 
   1355 void VertexAttrib4fv(PP_Resource context_id,
   1356                      GLuint indx,
   1357                      const GLfloat* values) {
   1358   Enter3D enter(context_id, true);
   1359   if (enter.succeeded()) {
   1360     ToGles2Impl(&enter)->VertexAttrib4fv(indx, values);
   1361   }
   1362 }
   1363 
   1364 void VertexAttribPointer(PP_Resource context_id,
   1365                          GLuint indx,
   1366                          GLint size,
   1367                          GLenum type,
   1368                          GLboolean normalized,
   1369                          GLsizei stride,
   1370                          const void* ptr) {
   1371   Enter3D enter(context_id, true);
   1372   if (enter.succeeded()) {
   1373     ToGles2Impl(&enter)
   1374         ->VertexAttribPointer(indx, size, type, normalized, stride, ptr);
   1375   }
   1376 }
   1377 
   1378 void Viewport(PP_Resource context_id,
   1379               GLint x,
   1380               GLint y,
   1381               GLsizei width,
   1382               GLsizei height) {
   1383   Enter3D enter(context_id, true);
   1384   if (enter.succeeded()) {
   1385     ToGles2Impl(&enter)->Viewport(x, y, width, height);
   1386   }
   1387 }
   1388 
   1389 void BlitFramebufferEXT(PP_Resource context_id,
   1390                         GLint srcX0,
   1391                         GLint srcY0,
   1392                         GLint srcX1,
   1393                         GLint srcY1,
   1394                         GLint dstX0,
   1395                         GLint dstY0,
   1396                         GLint dstX1,
   1397                         GLint dstY1,
   1398                         GLbitfield mask,
   1399                         GLenum filter) {
   1400   Enter3D enter(context_id, true);
   1401   if (enter.succeeded()) {
   1402     ToGles2Impl(&enter)->BlitFramebufferCHROMIUM(
   1403         srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
   1404   }
   1405 }
   1406 
   1407 void RenderbufferStorageMultisampleEXT(PP_Resource context_id,
   1408                                        GLenum target,
   1409                                        GLsizei samples,
   1410                                        GLenum internalformat,
   1411                                        GLsizei width,
   1412                                        GLsizei height) {
   1413   Enter3D enter(context_id, true);
   1414   if (enter.succeeded()) {
   1415     ToGles2Impl(&enter)->RenderbufferStorageMultisampleCHROMIUM(
   1416         target, samples, internalformat, width, height);
   1417   }
   1418 }
   1419 
   1420 void GenQueriesEXT(PP_Resource context_id, GLsizei n, GLuint* queries) {
   1421   Enter3D enter(context_id, true);
   1422   if (enter.succeeded()) {
   1423     ToGles2Impl(&enter)->GenQueriesEXT(n, queries);
   1424   }
   1425 }
   1426 
   1427 void DeleteQueriesEXT(PP_Resource context_id,
   1428                       GLsizei n,
   1429                       const GLuint* queries) {
   1430   Enter3D enter(context_id, true);
   1431   if (enter.succeeded()) {
   1432     ToGles2Impl(&enter)->DeleteQueriesEXT(n, queries);
   1433   }
   1434 }
   1435 
   1436 GLboolean IsQueryEXT(PP_Resource context_id, GLuint id) {
   1437   Enter3D enter(context_id, true);
   1438   if (enter.succeeded()) {
   1439     return ToGles2Impl(&enter)->IsQueryEXT(id);
   1440   } else {
   1441     return GL_FALSE;
   1442   }
   1443 }
   1444 
   1445 void BeginQueryEXT(PP_Resource context_id, GLenum target, GLuint id) {
   1446   Enter3D enter(context_id, true);
   1447   if (enter.succeeded()) {
   1448     ToGles2Impl(&enter)->BeginQueryEXT(target, id);
   1449   }
   1450 }
   1451 
   1452 void EndQueryEXT(PP_Resource context_id, GLenum target) {
   1453   Enter3D enter(context_id, true);
   1454   if (enter.succeeded()) {
   1455     ToGles2Impl(&enter)->EndQueryEXT(target);
   1456   }
   1457 }
   1458 
   1459 void GetQueryivEXT(PP_Resource context_id,
   1460                    GLenum target,
   1461                    GLenum pname,
   1462                    GLint* params) {
   1463   Enter3D enter(context_id, true);
   1464   if (enter.succeeded()) {
   1465     ToGles2Impl(&enter)->GetQueryivEXT(target, pname, params);
   1466   }
   1467 }
   1468 
   1469 void GetQueryObjectuivEXT(PP_Resource context_id,
   1470                           GLuint id,
   1471                           GLenum pname,
   1472                           GLuint* params) {
   1473   Enter3D enter(context_id, true);
   1474   if (enter.succeeded()) {
   1475     ToGles2Impl(&enter)->GetQueryObjectuivEXT(id, pname, params);
   1476   }
   1477 }
   1478 
   1479 GLboolean EnableFeatureCHROMIUM(PP_Resource context_id, const char* feature) {
   1480   Enter3D enter(context_id, true);
   1481   if (enter.succeeded()) {
   1482     return ToGles2Impl(&enter)->EnableFeatureCHROMIUM(feature);
   1483   } else {
   1484     return GL_FALSE;
   1485   }
   1486 }
   1487 
   1488 void* MapBufferSubDataCHROMIUM(PP_Resource context_id,
   1489                                GLuint target,
   1490                                GLintptr offset,
   1491                                GLsizeiptr size,
   1492                                GLenum access) {
   1493   Enter3D enter(context_id, true);
   1494   if (enter.succeeded()) {
   1495     return ToGles2Impl(&enter)
   1496         ->MapBufferSubDataCHROMIUM(target, offset, size, access);
   1497   } else {
   1498     return NULL;
   1499   }
   1500 }
   1501 
   1502 void UnmapBufferSubDataCHROMIUM(PP_Resource context_id, const void* mem) {
   1503   Enter3D enter(context_id, true);
   1504   if (enter.succeeded()) {
   1505     ToGles2Impl(&enter)->UnmapBufferSubDataCHROMIUM(mem);
   1506   }
   1507 }
   1508 
   1509 void* MapTexSubImage2DCHROMIUM(PP_Resource context_id,
   1510                                GLenum target,
   1511                                GLint level,
   1512                                GLint xoffset,
   1513                                GLint yoffset,
   1514                                GLsizei width,
   1515                                GLsizei height,
   1516                                GLenum format,
   1517                                GLenum type,
   1518                                GLenum access) {
   1519   Enter3D enter(context_id, true);
   1520   if (enter.succeeded()) {
   1521     return ToGles2Impl(&enter)->MapTexSubImage2DCHROMIUM(
   1522         target, level, xoffset, yoffset, width, height, format, type, access);
   1523   } else {
   1524     return NULL;
   1525   }
   1526 }
   1527 
   1528 void UnmapTexSubImage2DCHROMIUM(PP_Resource context_id, const void* mem) {
   1529   Enter3D enter(context_id, true);
   1530   if (enter.succeeded()) {
   1531     ToGles2Impl(&enter)->UnmapTexSubImage2DCHROMIUM(mem);
   1532   }
   1533 }
   1534 
   1535 void DrawArraysInstancedANGLE(PP_Resource context_id,
   1536                               GLenum mode,
   1537                               GLint first,
   1538                               GLsizei count,
   1539                               GLsizei primcount) {
   1540   Enter3D enter(context_id, true);
   1541   if (enter.succeeded()) {
   1542     ToGles2Impl(&enter)
   1543         ->DrawArraysInstancedANGLE(mode, first, count, primcount);
   1544   }
   1545 }
   1546 
   1547 void DrawElementsInstancedANGLE(PP_Resource context_id,
   1548                                 GLenum mode,
   1549                                 GLsizei count,
   1550                                 GLenum type,
   1551                                 const void* indices,
   1552                                 GLsizei primcount) {
   1553   Enter3D enter(context_id, true);
   1554   if (enter.succeeded()) {
   1555     ToGles2Impl(&enter)
   1556         ->DrawElementsInstancedANGLE(mode, count, type, indices, primcount);
   1557   }
   1558 }
   1559 
   1560 void VertexAttribDivisorANGLE(PP_Resource context_id,
   1561                               GLuint index,
   1562                               GLuint divisor) {
   1563   Enter3D enter(context_id, true);
   1564   if (enter.succeeded()) {
   1565     ToGles2Impl(&enter)->VertexAttribDivisorANGLE(index, divisor);
   1566   }
   1567 }
   1568 
   1569 void DrawBuffersEXT(PP_Resource context_id, GLsizei count, const GLenum* bufs) {
   1570   Enter3D enter(context_id, true);
   1571   if (enter.succeeded()) {
   1572     ToGles2Impl(&enter)->DrawBuffersEXT(count, bufs);
   1573   }
   1574 }
   1575 
   1576 }  // namespace
   1577 const PPB_OpenGLES2* PPB_OpenGLES2_Shared::GetInterface() {
   1578   static const struct PPB_OpenGLES2 ppb_opengles2 = {
   1579       &ActiveTexture,                       &AttachShader,
   1580       &BindAttribLocation,                  &BindBuffer,
   1581       &BindFramebuffer,                     &BindRenderbuffer,
   1582       &BindTexture,                         &BlendColor,
   1583       &BlendEquation,                       &BlendEquationSeparate,
   1584       &BlendFunc,                           &BlendFuncSeparate,
   1585       &BufferData,                          &BufferSubData,
   1586       &CheckFramebufferStatus,              &Clear,
   1587       &ClearColor,                          &ClearDepthf,
   1588       &ClearStencil,                        &ColorMask,
   1589       &CompileShader,                       &CompressedTexImage2D,
   1590       &CompressedTexSubImage2D,             &CopyTexImage2D,
   1591       &CopyTexSubImage2D,                   &CreateProgram,
   1592       &CreateShader,                        &CullFace,
   1593       &DeleteBuffers,                       &DeleteFramebuffers,
   1594       &DeleteProgram,                       &DeleteRenderbuffers,
   1595       &DeleteShader,                        &DeleteTextures,
   1596       &DepthFunc,                           &DepthMask,
   1597       &DepthRangef,                         &DetachShader,
   1598       &Disable,                             &DisableVertexAttribArray,
   1599       &DrawArrays,                          &DrawElements,
   1600       &Enable,                              &EnableVertexAttribArray,
   1601       &Finish,                              &Flush,
   1602       &FramebufferRenderbuffer,             &FramebufferTexture2D,
   1603       &FrontFace,                           &GenBuffers,
   1604       &GenerateMipmap,                      &GenFramebuffers,
   1605       &GenRenderbuffers,                    &GenTextures,
   1606       &GetActiveAttrib,                     &GetActiveUniform,
   1607       &GetAttachedShaders,                  &GetAttribLocation,
   1608       &GetBooleanv,                         &GetBufferParameteriv,
   1609       &GetError,                            &GetFloatv,
   1610       &GetFramebufferAttachmentParameteriv, &GetIntegerv,
   1611       &GetProgramiv,                        &GetProgramInfoLog,
   1612       &GetRenderbufferParameteriv,          &GetShaderiv,
   1613       &GetShaderInfoLog,                    &GetShaderPrecisionFormat,
   1614       &GetShaderSource,                     &GetString,
   1615       &GetTexParameterfv,                   &GetTexParameteriv,
   1616       &GetUniformfv,                        &GetUniformiv,
   1617       &GetUniformLocation,                  &GetVertexAttribfv,
   1618       &GetVertexAttribiv,                   &GetVertexAttribPointerv,
   1619       &Hint,                                &IsBuffer,
   1620       &IsEnabled,                           &IsFramebuffer,
   1621       &IsProgram,                           &IsRenderbuffer,
   1622       &IsShader,                            &IsTexture,
   1623       &LineWidth,                           &LinkProgram,
   1624       &PixelStorei,                         &PolygonOffset,
   1625       &ReadPixels,                          &ReleaseShaderCompiler,
   1626       &RenderbufferStorage,                 &SampleCoverage,
   1627       &Scissor,                             &ShaderBinary,
   1628       &ShaderSource,                        &StencilFunc,
   1629       &StencilFuncSeparate,                 &StencilMask,
   1630       &StencilMaskSeparate,                 &StencilOp,
   1631       &StencilOpSeparate,                   &TexImage2D,
   1632       &TexParameterf,                       &TexParameterfv,
   1633       &TexParameteri,                       &TexParameteriv,
   1634       &TexSubImage2D,                       &Uniform1f,
   1635       &Uniform1fv,                          &Uniform1i,
   1636       &Uniform1iv,                          &Uniform2f,
   1637       &Uniform2fv,                          &Uniform2i,
   1638       &Uniform2iv,                          &Uniform3f,
   1639       &Uniform3fv,                          &Uniform3i,
   1640       &Uniform3iv,                          &Uniform4f,
   1641       &Uniform4fv,                          &Uniform4i,
   1642       &Uniform4iv,                          &UniformMatrix2fv,
   1643       &UniformMatrix3fv,                    &UniformMatrix4fv,
   1644       &UseProgram,                          &ValidateProgram,
   1645       &VertexAttrib1f,                      &VertexAttrib1fv,
   1646       &VertexAttrib2f,                      &VertexAttrib2fv,
   1647       &VertexAttrib3f,                      &VertexAttrib3fv,
   1648       &VertexAttrib4f,                      &VertexAttrib4fv,
   1649       &VertexAttribPointer,                 &Viewport};
   1650   return &ppb_opengles2;
   1651 }
   1652 const PPB_OpenGLES2InstancedArrays*
   1653 PPB_OpenGLES2_Shared::GetInstancedArraysInterface() {
   1654   static const struct PPB_OpenGLES2InstancedArrays ppb_opengles2 = {
   1655       &DrawArraysInstancedANGLE, &DrawElementsInstancedANGLE,
   1656       &VertexAttribDivisorANGLE};
   1657   return &ppb_opengles2;
   1658 }
   1659 const PPB_OpenGLES2FramebufferBlit*
   1660 PPB_OpenGLES2_Shared::GetFramebufferBlitInterface() {
   1661   static const struct PPB_OpenGLES2FramebufferBlit ppb_opengles2 = {
   1662       &BlitFramebufferEXT};
   1663   return &ppb_opengles2;
   1664 }
   1665 const PPB_OpenGLES2FramebufferMultisample*
   1666 PPB_OpenGLES2_Shared::GetFramebufferMultisampleInterface() {
   1667   static const struct PPB_OpenGLES2FramebufferMultisample ppb_opengles2 = {
   1668       &RenderbufferStorageMultisampleEXT};
   1669   return &ppb_opengles2;
   1670 }
   1671 const PPB_OpenGLES2ChromiumEnableFeature*
   1672 PPB_OpenGLES2_Shared::GetChromiumEnableFeatureInterface() {
   1673   static const struct PPB_OpenGLES2ChromiumEnableFeature ppb_opengles2 = {
   1674       &EnableFeatureCHROMIUM};
   1675   return &ppb_opengles2;
   1676 }
   1677 const PPB_OpenGLES2ChromiumMapSub*
   1678 PPB_OpenGLES2_Shared::GetChromiumMapSubInterface() {
   1679   static const struct PPB_OpenGLES2ChromiumMapSub ppb_opengles2 = {
   1680       &MapBufferSubDataCHROMIUM, &UnmapBufferSubDataCHROMIUM,
   1681       &MapTexSubImage2DCHROMIUM, &UnmapTexSubImage2DCHROMIUM};
   1682   return &ppb_opengles2;
   1683 }
   1684 const PPB_OpenGLES2Query* PPB_OpenGLES2_Shared::GetQueryInterface() {
   1685   static const struct PPB_OpenGLES2Query ppb_opengles2 = {
   1686       &GenQueriesEXT, &DeleteQueriesEXT, &IsQueryEXT,          &BeginQueryEXT,
   1687       &EndQueryEXT,   &GetQueryivEXT,    &GetQueryObjectuivEXT};
   1688   return &ppb_opengles2;
   1689 }
   1690 const PPB_OpenGLES2DrawBuffers_Dev*
   1691 PPB_OpenGLES2_Shared::GetDrawBuffersInterface() {
   1692   static const struct PPB_OpenGLES2DrawBuffers_Dev ppb_opengles2 = {
   1693       &DrawBuffersEXT};
   1694   return &ppb_opengles2;
   1695 }
   1696 }  // namespace ppapi
   1697