Home | History | Annotate | Download | only in gpu
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "webkit/common/gpu/webgraphicscontext3d_impl.h"
      6 
      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/skia_bindings/gl_bindings_skia_cmd_buffer.h"
     14 
     15 #include "third_party/khronos/GLES2/gl2.h"
     16 #ifndef GL_GLEXT_PROTOTYPES
     17 #define GL_GLEXT_PROTOTYPES 1
     18 #endif
     19 #include "third_party/khronos/GLES2/gl2ext.h"
     20 
     21 namespace webkit {
     22 namespace gpu {
     23 
     24 namespace {
     25 
     26 uint32_t GenFlushID() {
     27   static base::subtle::Atomic32 flush_id = 0;
     28 
     29   base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement(
     30       &flush_id, 1);
     31   return static_cast<uint32_t>(my_id);
     32 }
     33 
     34 } // namespace anonymous
     35 
     36 class WebGraphicsContext3DErrorMessageCallback
     37     : public ::gpu::gles2::GLES2ImplementationErrorMessageCallback {
     38  public:
     39   WebGraphicsContext3DErrorMessageCallback(
     40       WebGraphicsContext3DImpl* context)
     41       : graphics_context_(context) {
     42   }
     43 
     44   virtual void OnErrorMessage(const char* msg, int id) OVERRIDE;
     45 
     46  private:
     47   WebGraphicsContext3DImpl* graphics_context_;
     48 
     49   DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback);
     50 };
     51 
     52 void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage(
     53     const char* msg, int id) {
     54   graphics_context_->OnErrorMessage(msg, id);
     55 }
     56 
     57 // Helper macros to reduce the amount of code.
     58 
     59 #define DELEGATE_TO_GL(name, glname)                                    \
     60 void WebGraphicsContext3DImpl::name() {                                 \
     61   gl_->glname();                                                        \
     62 }
     63 
     64 #define DELEGATE_TO_GL_R(name, glname, rt)                              \
     65 rt WebGraphicsContext3DImpl::name() {                                   \
     66   return gl_->glname();                                                 \
     67 }
     68 
     69 #define DELEGATE_TO_GL_1(name, glname, t1)                              \
     70 void WebGraphicsContext3DImpl::name(t1 a1) {                            \
     71   gl_->glname(a1);                                                      \
     72 }
     73 
     74 #define DELEGATE_TO_GL_1R(name, glname, t1, rt)                         \
     75 rt WebGraphicsContext3DImpl::name(t1 a1) {                              \
     76   return gl_->glname(a1);                                               \
     77 }
     78 
     79 #define DELEGATE_TO_GL_1RB(name, glname, t1, rt)                        \
     80 rt WebGraphicsContext3DImpl::name(t1 a1) {                              \
     81   return gl_->glname(a1) ? true : false;                                \
     82 }
     83 
     84 #define DELEGATE_TO_GL_2(name, glname, t1, t2)                          \
     85 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2) {                     \
     86   gl_->glname(a1, a2);                                                  \
     87 }
     88 
     89 #define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt)                     \
     90 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2) {                       \
     91   return gl_->glname(a1, a2);                                           \
     92 }
     93 
     94 #define DELEGATE_TO_GL_3(name, glname, t1, t2, t3)                      \
     95 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3) {              \
     96   gl_->glname(a1, a2, a3);                                              \
     97 }
     98 
     99 #define DELEGATE_TO_GL_3R(name, glname, t1, t2, t3, rt)                 \
    100 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3) {                \
    101   return gl_->glname(a1, a2, a3);                                       \
    102 }
    103 
    104 #define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4)                  \
    105 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) {       \
    106   gl_->glname(a1, a2, a3, a4);                                          \
    107 }
    108 
    109 #define DELEGATE_TO_GL_4R(name, glname, t1, t2, t3, t4, rt)             \
    110 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) {         \
    111   return gl_->glname(a1, a2, a3, a4);                                   \
    112 }
    113 
    114 #define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5)              \
    115 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) {\
    116                                                                         \
    117   gl_->glname(a1, a2, a3, a4, a5);                                      \
    118 }
    119 
    120 #define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6)          \
    121 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5,  \
    122                                     t6 a6) {                            \
    123   gl_->glname(a1, a2, a3, a4, a5, a6);                                  \
    124 }
    125 
    126 #define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7)      \
    127 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5,  \
    128                                     t6 a6, t7 a7) {                     \
    129   gl_->glname(a1, a2, a3, a4, a5, a6, a7);                              \
    130 }
    131 
    132 #define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8)  \
    133 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5,  \
    134                                     t6 a6, t7 a7, t8 a8) {              \
    135   gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8);                          \
    136 }
    137 
    138 #define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
    139 void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5,  \
    140                                     t6 a6, t7 a7, t8 a8, t9 a9) {       \
    141   gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9);                      \
    142 }
    143 
    144 #define DELEGATE_TO_GL_9R(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, \
    145                           t9, rt)                                       \
    146 rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5,    \
    147                                     t6 a6, t7 a7, t8 a8, t9 a9) {       \
    148   return gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9);               \
    149 }
    150 
    151 WebGraphicsContext3DImpl::WebGraphicsContext3DImpl()
    152     : initialized_(false),
    153       initialize_failed_(false),
    154       context_lost_callback_(0),
    155       context_lost_reason_(GL_NO_ERROR),
    156       error_message_callback_(0),
    157       gl_(NULL),
    158       flush_id_(0) {
    159 }
    160 
    161 WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() {
    162 
    163 }
    164 
    165 void WebGraphicsContext3DImpl::synthesizeGLError(WGC3Denum error) {
    166   if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) ==
    167       synthetic_errors_.end()) {
    168     synthetic_errors_.push_back(error);
    169   }
    170 }
    171 
    172 uint32_t WebGraphicsContext3DImpl::lastFlushID() {
    173   return flush_id_;
    174 }
    175 
    176 DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned int)
    177 
    178 DELEGATE_TO_GL_3(reshapeWithScaleFactor, ResizeCHROMIUM, int, int, float)
    179 
    180 DELEGATE_TO_GL_4R(mapBufferSubDataCHROMIUM, MapBufferSubDataCHROMIUM, WGC3Denum,
    181                   WGC3Dintptr, WGC3Dsizeiptr, WGC3Denum, void*)
    182 
    183 DELEGATE_TO_GL_1(unmapBufferSubDataCHROMIUM, UnmapBufferSubDataCHROMIUM,
    184                  const void*)
    185 
    186 DELEGATE_TO_GL_9R(mapTexSubImage2DCHROMIUM, MapTexSubImage2DCHROMIUM, WGC3Denum,
    187                   WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei,
    188                   WGC3Denum, WGC3Denum, WGC3Denum, void*)
    189 
    190 DELEGATE_TO_GL_1(unmapTexSubImage2DCHROMIUM, UnmapTexSubImage2DCHROMIUM,
    191                  const void*)
    192 
    193 DELEGATE_TO_GL_3(discardFramebufferEXT, DiscardFramebufferEXT, WGC3Denum,
    194                  WGC3Dsizei, const WGC3Denum*)
    195 
    196 blink::WebString WebGraphicsContext3DImpl::
    197     getRequestableExtensionsCHROMIUM() {
    198   return blink::WebString::fromUTF8(
    199       gl_->GetRequestableExtensionsCHROMIUM());
    200 }
    201 
    202 DELEGATE_TO_GL_1(requestExtensionCHROMIUM, RequestExtensionCHROMIUM,
    203                  const char*)
    204 
    205 void WebGraphicsContext3DImpl::blitFramebufferCHROMIUM(
    206     WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
    207     WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
    208     WGC3Dbitfield mask, WGC3Denum filter) {
    209   gl_->BlitFramebufferCHROMIUM(
    210       srcX0, srcY0, srcX1, srcY1,
    211       dstX0, dstY0, dstX1, dstY1,
    212       mask, filter);
    213 }
    214 
    215 DELEGATE_TO_GL_5(renderbufferStorageMultisampleCHROMIUM,
    216                  RenderbufferStorageMultisampleCHROMIUM, WGC3Denum, WGC3Dsizei,
    217                  WGC3Denum, WGC3Dsizei, WGC3Dsizei)
    218 
    219 DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum)
    220 
    221 DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId)
    222 
    223 DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId,
    224                  WGC3Duint, const WGC3Dchar*)
    225 
    226 DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId)
    227 
    228 DELEGATE_TO_GL_2(bindFramebuffer, BindFramebuffer, WGC3Denum, WebGLId)
    229 
    230 DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId)
    231 
    232 DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId)
    233 
    234 DELEGATE_TO_GL_4(blendColor, BlendColor,
    235                  WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
    236 
    237 DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum)
    238 
    239 DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate,
    240                  WGC3Denum, WGC3Denum)
    241 
    242 DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum)
    243 
    244 DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate,
    245                  WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
    246 
    247 DELEGATE_TO_GL_4(bufferData, BufferData,
    248                  WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum)
    249 
    250 DELEGATE_TO_GL_4(bufferSubData, BufferSubData,
    251                  WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*)
    252 
    253 DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatus,
    254                   WGC3Denum, WGC3Denum)
    255 
    256 DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield)
    257 
    258 DELEGATE_TO_GL_4(clearColor, ClearColor,
    259                  WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
    260 
    261 DELEGATE_TO_GL_1(clearDepth, ClearDepthf, WGC3Dclampf)
    262 
    263 DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint)
    264 
    265 DELEGATE_TO_GL_4(colorMask, ColorMask,
    266                  WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean)
    267 
    268 DELEGATE_TO_GL_1(compileShader, CompileShader, WebGLId)
    269 
    270 DELEGATE_TO_GL_8(compressedTexImage2D, CompressedTexImage2D,
    271                  WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
    272                  WGC3Dsizei, WGC3Dsizei, const void*)
    273 
    274 DELEGATE_TO_GL_9(compressedTexSubImage2D, CompressedTexSubImage2D,
    275                  WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
    276                  WGC3Denum, WGC3Dsizei, const void*)
    277 
    278 DELEGATE_TO_GL_8(copyTexImage2D, CopyTexImage2D,
    279                  WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
    280                  WGC3Dsizei, WGC3Dsizei, WGC3Dint)
    281 
    282 DELEGATE_TO_GL_8(copyTexSubImage2D, CopyTexSubImage2D,
    283                  WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
    284                  WGC3Dsizei, WGC3Dsizei)
    285 
    286 DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum)
    287 
    288 DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum)
    289 
    290 DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean)
    291 
    292 DELEGATE_TO_GL_2(depthRange, DepthRangef, WGC3Dclampf, WGC3Dclampf)
    293 
    294 DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId)
    295 
    296 DELEGATE_TO_GL_1(disable, Disable, WGC3Denum)
    297 
    298 DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray,
    299                  WGC3Duint)
    300 
    301 DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei)
    302 
    303 void WebGraphicsContext3DImpl::drawElements(WGC3Denum mode,
    304                                                          WGC3Dsizei count,
    305                                                          WGC3Denum type,
    306                                                          WGC3Dintptr offset) {
    307   gl_->DrawElements(
    308       mode, count, type,
    309       reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
    310 }
    311 
    312 DELEGATE_TO_GL_1(enable, Enable, WGC3Denum)
    313 
    314 DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray,
    315                  WGC3Duint)
    316 
    317 void WebGraphicsContext3DImpl::finish() {
    318   flush_id_ = GenFlushID();
    319   gl_->Finish();
    320 }
    321 
    322 void WebGraphicsContext3DImpl::flush() {
    323   flush_id_ = GenFlushID();
    324   gl_->Flush();
    325 }
    326 
    327 DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer,
    328                  WGC3Denum, WGC3Denum, WGC3Denum, WebGLId)
    329 
    330 DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D,
    331                  WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint)
    332 
    333 DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum)
    334 
    335 DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum)
    336 
    337 bool WebGraphicsContext3DImpl::getActiveAttrib(
    338     WebGLId program, WGC3Duint index, ActiveInfo& info) {
    339   if (!program) {
    340     synthesizeGLError(GL_INVALID_VALUE);
    341     return false;
    342   }
    343   GLint max_name_length = -1;
    344   gl_->GetProgramiv(
    345       program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
    346   if (max_name_length < 0)
    347     return false;
    348   scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
    349   if (!name) {
    350     synthesizeGLError(GL_OUT_OF_MEMORY);
    351     return false;
    352   }
    353   GLsizei length = 0;
    354   GLint size = -1;
    355   GLenum type = 0;
    356   gl_->GetActiveAttrib(
    357       program, index, max_name_length, &length, &size, &type, name.get());
    358   if (size < 0) {
    359     return false;
    360   }
    361   info.name = blink::WebString::fromUTF8(name.get(), length);
    362   info.type = type;
    363   info.size = size;
    364   return true;
    365 }
    366 
    367 bool WebGraphicsContext3DImpl::getActiveUniform(
    368     WebGLId program, WGC3Duint index, ActiveInfo& info) {
    369   GLint max_name_length = -1;
    370   gl_->GetProgramiv(
    371       program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
    372   if (max_name_length < 0)
    373     return false;
    374   scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
    375   if (!name) {
    376     synthesizeGLError(GL_OUT_OF_MEMORY);
    377     return false;
    378   }
    379   GLsizei length = 0;
    380   GLint size = -1;
    381   GLenum type = 0;
    382   gl_->GetActiveUniform(
    383       program, index, max_name_length, &length, &size, &type, name.get());
    384   if (size < 0) {
    385     return false;
    386   }
    387   info.name = blink::WebString::fromUTF8(name.get(), length);
    388   info.type = type;
    389   info.size = size;
    390   return true;
    391 }
    392 
    393 DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders,
    394                  WebGLId, WGC3Dsizei, WGC3Dsizei*, WebGLId*)
    395 
    396 DELEGATE_TO_GL_2R(getAttribLocation, GetAttribLocation,
    397                   WebGLId, const WGC3Dchar*, WGC3Dint)
    398 
    399 DELEGATE_TO_GL_2(getBooleanv, GetBooleanv, WGC3Denum, WGC3Dboolean*)
    400 
    401 DELEGATE_TO_GL_3(getBufferParameteriv, GetBufferParameteriv,
    402                  WGC3Denum, WGC3Denum, WGC3Dint*)
    403 
    404 WGC3Denum WebGraphicsContext3DImpl::getError() {
    405   if (!synthetic_errors_.empty()) {
    406     std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin();
    407     WGC3Denum err = *iter;
    408     synthetic_errors_.erase(iter);
    409     return err;
    410   }
    411 
    412   return gl_->GetError();
    413 }
    414 
    415 DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*)
    416 
    417 DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv,
    418                  GetFramebufferAttachmentParameteriv,
    419                  WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*)
    420 
    421 DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*)
    422 
    423 DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*)
    424 
    425 blink::WebString WebGraphicsContext3DImpl::getProgramInfoLog(
    426     WebGLId program) {
    427   GLint logLength = 0;
    428   gl_->GetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
    429   if (!logLength)
    430     return blink::WebString();
    431   scoped_ptr<GLchar[]> log(new GLchar[logLength]);
    432   if (!log)
    433     return blink::WebString();
    434   GLsizei returnedLogLength = 0;
    435   gl_->GetProgramInfoLog(
    436       program, logLength, &returnedLogLength, log.get());
    437   DCHECK_EQ(logLength, returnedLogLength + 1);
    438   blink::WebString res =
    439       blink::WebString::fromUTF8(log.get(), returnedLogLength);
    440   return res;
    441 }
    442 
    443 DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv,
    444                  WGC3Denum, WGC3Denum, WGC3Dint*)
    445 
    446 DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*)
    447 
    448 blink::WebString WebGraphicsContext3DImpl::getShaderInfoLog(
    449     WebGLId shader) {
    450   GLint logLength = 0;
    451   gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
    452   if (!logLength)
    453     return blink::WebString();
    454   scoped_ptr<GLchar[]> log(new GLchar[logLength]);
    455   if (!log)
    456     return blink::WebString();
    457   GLsizei returnedLogLength = 0;
    458   gl_->GetShaderInfoLog(
    459       shader, logLength, &returnedLogLength, log.get());
    460   DCHECK_EQ(logLength, returnedLogLength + 1);
    461   blink::WebString res =
    462       blink::WebString::fromUTF8(log.get(), returnedLogLength);
    463   return res;
    464 }
    465 
    466 DELEGATE_TO_GL_4(getShaderPrecisionFormat, GetShaderPrecisionFormat,
    467                  WGC3Denum, WGC3Denum, WGC3Dint*, WGC3Dint*)
    468 
    469 blink::WebString WebGraphicsContext3DImpl::getShaderSource(
    470     WebGLId shader) {
    471   GLint logLength = 0;
    472   gl_->GetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength);
    473   if (!logLength)
    474     return blink::WebString();
    475   scoped_ptr<GLchar[]> log(new GLchar[logLength]);
    476   if (!log)
    477     return blink::WebString();
    478   GLsizei returnedLogLength = 0;
    479   gl_->GetShaderSource(
    480       shader, logLength, &returnedLogLength, log.get());
    481   if (!returnedLogLength)
    482     return blink::WebString();
    483   DCHECK_EQ(logLength, returnedLogLength + 1);
    484   blink::WebString res =
    485       blink::WebString::fromUTF8(log.get(), returnedLogLength);
    486   return res;
    487 }
    488 
    489 blink::WebString WebGraphicsContext3DImpl::
    490     getTranslatedShaderSourceANGLE(WebGLId shader) {
    491   GLint logLength = 0;
    492   gl_->GetShaderiv(
    493       shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &logLength);
    494   if (!logLength)
    495     return blink::WebString();
    496   scoped_ptr<GLchar[]> log(new GLchar[logLength]);
    497   if (!log)
    498     return blink::WebString();
    499   GLsizei returnedLogLength = 0;
    500   gl_->GetTranslatedShaderSourceANGLE(
    501       shader, logLength, &returnedLogLength, log.get());
    502   if (!returnedLogLength)
    503     return blink::WebString();
    504   DCHECK_EQ(logLength, returnedLogLength + 1);
    505   blink::WebString res =
    506       blink::WebString::fromUTF8(log.get(), returnedLogLength);
    507   return res;
    508 }
    509 
    510 blink::WebString WebGraphicsContext3DImpl::getString(
    511     WGC3Denum name) {
    512   return blink::WebString::fromUTF8(
    513       reinterpret_cast<const char*>(gl_->GetString(name)));
    514 }
    515 
    516 DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv,
    517                  WGC3Denum, WGC3Denum, WGC3Dfloat*)
    518 
    519 DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv,
    520                  WGC3Denum, WGC3Denum, WGC3Dint*)
    521 
    522 DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*)
    523 
    524 DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*)
    525 
    526 DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation,
    527                   WebGLId, const WGC3Dchar*, WGC3Dint)
    528 
    529 DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv,
    530                  WGC3Duint, WGC3Denum, WGC3Dfloat*)
    531 
    532 DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv,
    533                  WGC3Duint, WGC3Denum, WGC3Dint*)
    534 
    535 WGC3Dsizeiptr WebGraphicsContext3DImpl::getVertexAttribOffset(
    536     WGC3Duint index, WGC3Denum pname) {
    537   GLvoid* value = NULL;
    538   // NOTE: If pname is ever a value that returns more then 1 element
    539   // this will corrupt memory.
    540   gl_->GetVertexAttribPointerv(index, pname, &value);
    541   return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value));
    542 }
    543 
    544 DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum)
    545 
    546 DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean)
    547 
    548 DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean)
    549 
    550 DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean)
    551 
    552 DELEGATE_TO_GL_1RB(isProgram, IsProgram, WebGLId, WGC3Dboolean)
    553 
    554 DELEGATE_TO_GL_1RB(isRenderbuffer, IsRenderbuffer, WebGLId, WGC3Dboolean)
    555 
    556 DELEGATE_TO_GL_1RB(isShader, IsShader, WebGLId, WGC3Dboolean)
    557 
    558 DELEGATE_TO_GL_1RB(isTexture, IsTexture, WebGLId, WGC3Dboolean)
    559 
    560 DELEGATE_TO_GL_1(lineWidth, LineWidth, WGC3Dfloat)
    561 
    562 DELEGATE_TO_GL_1(linkProgram, LinkProgram, WebGLId)
    563 
    564 DELEGATE_TO_GL_2(pixelStorei, PixelStorei, WGC3Denum, WGC3Dint)
    565 
    566 DELEGATE_TO_GL_2(polygonOffset, PolygonOffset, WGC3Dfloat, WGC3Dfloat)
    567 
    568 DELEGATE_TO_GL_7(readPixels, ReadPixels,
    569                  WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, WGC3Denum,
    570                  WGC3Denum, void*)
    571 
    572 DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage,
    573                  WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei)
    574 
    575 DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean)
    576 
    577 DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
    578 
    579 void WebGraphicsContext3DImpl::shaderSource(
    580     WebGLId shader, const WGC3Dchar* string) {
    581   GLint length = strlen(string);
    582   gl_->ShaderSource(shader, 1, &string, &length);
    583 }
    584 
    585 DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint)
    586 
    587 DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate,
    588                  WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint)
    589 
    590 DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint)
    591 
    592 DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate,
    593                  WGC3Denum, WGC3Duint)
    594 
    595 DELEGATE_TO_GL_3(stencilOp, StencilOp,
    596                  WGC3Denum, WGC3Denum, WGC3Denum)
    597 
    598 DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate,
    599                  WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
    600 
    601 DELEGATE_TO_GL_9(texImage2D, TexImage2D,
    602                  WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei,
    603                  WGC3Dint, WGC3Denum, WGC3Denum, const void*)
    604 
    605 DELEGATE_TO_GL_3(texParameterf, TexParameterf,
    606                  WGC3Denum, WGC3Denum, WGC3Dfloat);
    607 
    608 static const unsigned int kTextureWrapR = 0x8072;
    609 
    610 void WebGraphicsContext3DImpl::texParameteri(
    611     WGC3Denum target, WGC3Denum pname, WGC3Dint param) {
    612   // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in
    613   // GraphicsContext3D.cpp is strictly necessary to avoid seams at the
    614   // edge of cube maps, and, if it is, push it into the GLES2 service
    615   // side code.
    616   if (pname == kTextureWrapR) {
    617     return;
    618   }
    619   gl_->TexParameteri(target, pname, param);
    620 }
    621 
    622 DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D,
    623                  WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
    624                  WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
    625 
    626 DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat)
    627 
    628 DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei,
    629                  const WGC3Dfloat*)
    630 
    631 DELEGATE_TO_GL_2(uniform1i, Uniform1i, WGC3Dint, WGC3Dint)
    632 
    633 DELEGATE_TO_GL_3(uniform1iv, Uniform1iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
    634 
    635 DELEGATE_TO_GL_3(uniform2f, Uniform2f, WGC3Dint, WGC3Dfloat, WGC3Dfloat)
    636 
    637 DELEGATE_TO_GL_3(uniform2fv, Uniform2fv, WGC3Dint, WGC3Dsizei,
    638                  const WGC3Dfloat*)
    639 
    640 DELEGATE_TO_GL_3(uniform2i, Uniform2i, WGC3Dint, WGC3Dint, WGC3Dint)
    641 
    642 DELEGATE_TO_GL_3(uniform2iv, Uniform2iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
    643 
    644 DELEGATE_TO_GL_4(uniform3f, Uniform3f, WGC3Dint,
    645                  WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
    646 
    647 DELEGATE_TO_GL_3(uniform3fv, Uniform3fv, WGC3Dint, WGC3Dsizei,
    648                  const WGC3Dfloat*)
    649 
    650 DELEGATE_TO_GL_4(uniform3i, Uniform3i, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
    651 
    652 DELEGATE_TO_GL_3(uniform3iv, Uniform3iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
    653 
    654 DELEGATE_TO_GL_5(uniform4f, Uniform4f, WGC3Dint,
    655                  WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
    656 
    657 DELEGATE_TO_GL_3(uniform4fv, Uniform4fv, WGC3Dint, WGC3Dsizei,
    658                  const WGC3Dfloat*)
    659 
    660 DELEGATE_TO_GL_5(uniform4i, Uniform4i, WGC3Dint,
    661                  WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
    662 
    663 DELEGATE_TO_GL_3(uniform4iv, Uniform4iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
    664 
    665 DELEGATE_TO_GL_4(uniformMatrix2fv, UniformMatrix2fv,
    666                  WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
    667 
    668 DELEGATE_TO_GL_4(uniformMatrix3fv, UniformMatrix3fv,
    669                  WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
    670 
    671 DELEGATE_TO_GL_4(uniformMatrix4fv, UniformMatrix4fv,
    672                  WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
    673 
    674 DELEGATE_TO_GL_1(useProgram, UseProgram, WebGLId)
    675 
    676 DELEGATE_TO_GL_1(validateProgram, ValidateProgram, WebGLId)
    677 
    678 DELEGATE_TO_GL_2(vertexAttrib1f, VertexAttrib1f, WGC3Duint, WGC3Dfloat)
    679 
    680 DELEGATE_TO_GL_2(vertexAttrib1fv, VertexAttrib1fv, WGC3Duint,
    681                  const WGC3Dfloat*)
    682 
    683 DELEGATE_TO_GL_3(vertexAttrib2f, VertexAttrib2f, WGC3Duint,
    684                  WGC3Dfloat, WGC3Dfloat)
    685 
    686 DELEGATE_TO_GL_2(vertexAttrib2fv, VertexAttrib2fv, WGC3Duint,
    687                  const WGC3Dfloat*)
    688 
    689 DELEGATE_TO_GL_4(vertexAttrib3f, VertexAttrib3f, WGC3Duint,
    690                  WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
    691 
    692 DELEGATE_TO_GL_2(vertexAttrib3fv, VertexAttrib3fv, WGC3Duint,
    693                  const WGC3Dfloat*)
    694 
    695 DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint,
    696                  WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
    697 
    698 DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint,
    699                  const WGC3Dfloat*)
    700 
    701 void WebGraphicsContext3DImpl::vertexAttribPointer(
    702     WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized,
    703     WGC3Dsizei stride, WGC3Dintptr offset) {
    704   gl_->VertexAttribPointer(
    705       index, size, type, normalized, stride,
    706       reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
    707 }
    708 
    709 DELEGATE_TO_GL_4(viewport, Viewport,
    710                  WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
    711 
    712 DELEGATE_TO_GL_2(genBuffers, GenBuffers, WGC3Dsizei, WebGLId*);
    713 
    714 DELEGATE_TO_GL_2(genFramebuffers, GenFramebuffers, WGC3Dsizei, WebGLId*);
    715 
    716 DELEGATE_TO_GL_2(genRenderbuffers, GenRenderbuffers, WGC3Dsizei, WebGLId*);
    717 
    718 DELEGATE_TO_GL_2(genTextures, GenTextures, WGC3Dsizei, WebGLId*);
    719 
    720 DELEGATE_TO_GL_2(deleteBuffers, DeleteBuffers, WGC3Dsizei, WebGLId*);
    721 
    722 DELEGATE_TO_GL_2(deleteFramebuffers, DeleteFramebuffers, WGC3Dsizei, WebGLId*);
    723 
    724 DELEGATE_TO_GL_2(deleteRenderbuffers, DeleteRenderbuffers, WGC3Dsizei,
    725                  WebGLId*);
    726 
    727 DELEGATE_TO_GL_2(deleteTextures, DeleteTextures, WGC3Dsizei, WebGLId*);
    728 
    729 WebGLId WebGraphicsContext3DImpl::createBuffer() {
    730   GLuint o;
    731   gl_->GenBuffers(1, &o);
    732   return o;
    733 }
    734 
    735 WebGLId WebGraphicsContext3DImpl::createFramebuffer() {
    736   GLuint o = 0;
    737   gl_->GenFramebuffers(1, &o);
    738   return o;
    739 }
    740 
    741 WebGLId WebGraphicsContext3DImpl::createRenderbuffer() {
    742   GLuint o;
    743   gl_->GenRenderbuffers(1, &o);
    744   return o;
    745 }
    746 
    747 WebGLId WebGraphicsContext3DImpl::createTexture() {
    748   GLuint o;
    749   gl_->GenTextures(1, &o);
    750   return o;
    751 }
    752 
    753 void WebGraphicsContext3DImpl::deleteBuffer(WebGLId buffer) {
    754   gl_->DeleteBuffers(1, &buffer);
    755 }
    756 
    757 void WebGraphicsContext3DImpl::deleteFramebuffer(
    758     WebGLId framebuffer) {
    759   gl_->DeleteFramebuffers(1, &framebuffer);
    760 }
    761 
    762 void WebGraphicsContext3DImpl::deleteRenderbuffer(
    763     WebGLId renderbuffer) {
    764   gl_->DeleteRenderbuffers(1, &renderbuffer);
    765 }
    766 
    767 void WebGraphicsContext3DImpl::deleteTexture(WebGLId texture) {
    768   gl_->DeleteTextures(1, &texture);
    769 }
    770 
    771 DELEGATE_TO_GL_R(createProgram, CreateProgram, WebGLId)
    772 
    773 DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId)
    774 
    775 DELEGATE_TO_GL_1(deleteProgram, DeleteProgram, WebGLId)
    776 
    777 DELEGATE_TO_GL_1(deleteShader, DeleteShader, WebGLId)
    778 
    779 void WebGraphicsContext3DImpl::setErrorMessageCallback(
    780     WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) {
    781   error_message_callback_ = cb;
    782 }
    783 
    784 void WebGraphicsContext3DImpl::setContextLostCallback(
    785     WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) {
    786   context_lost_callback_ = cb;
    787 }
    788 
    789 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM,
    790                  WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint)
    791 
    792 DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT,
    793                  WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint)
    794 
    795 WebGLId WebGraphicsContext3DImpl::createQueryEXT() {
    796   GLuint o;
    797   gl_->GenQueriesEXT(1, &o);
    798   return o;
    799 }
    800 
    801 void WebGraphicsContext3DImpl::deleteQueryEXT(
    802     WebGLId query) {
    803   gl_->DeleteQueriesEXT(1, &query);
    804 }
    805 
    806 DELEGATE_TO_GL_1R(isQueryEXT, IsQueryEXT, WebGLId, WGC3Dboolean)
    807 DELEGATE_TO_GL_2(beginQueryEXT, BeginQueryEXT, WGC3Denum, WebGLId)
    808 DELEGATE_TO_GL_1(endQueryEXT, EndQueryEXT, WGC3Denum)
    809 DELEGATE_TO_GL_3(getQueryivEXT, GetQueryivEXT, WGC3Denum, WGC3Denum, WGC3Dint*)
    810 DELEGATE_TO_GL_3(getQueryObjectuivEXT, GetQueryObjectuivEXT,
    811                  WebGLId, WGC3Denum, WGC3Duint*)
    812 
    813 DELEGATE_TO_GL_6(copyTextureCHROMIUM, CopyTextureCHROMIUM,  WGC3Denum,
    814                  WebGLId, WebGLId, WGC3Dint, WGC3Denum, WGC3Denum);
    815 
    816 DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM,
    817                  WebGLId, WGC3Dint, const WGC3Dchar*)
    818 
    819 void WebGraphicsContext3DImpl::shallowFlushCHROMIUM() {
    820   flush_id_ = GenFlushID();
    821   gl_->ShallowFlushCHROMIUM();
    822 }
    823 
    824 void WebGraphicsContext3DImpl::shallowFinishCHROMIUM() {
    825   flush_id_ = GenFlushID();
    826   gl_->ShallowFinishCHROMIUM();
    827 }
    828 
    829 DELEGATE_TO_GL_1(waitSyncPoint, WaitSyncPointCHROMIUM, GLuint)
    830 
    831 void WebGraphicsContext3DImpl::loseContextCHROMIUM(
    832     WGC3Denum current, WGC3Denum other) {
    833   gl_->LoseContextCHROMIUM(current, other);
    834   gl_->Flush();
    835 }
    836 
    837 DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*)
    838 DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM,
    839                  WGC3Denum, const WGC3Dbyte*)
    840 DELEGATE_TO_GL_3(produceTextureDirectCHROMIUM, ProduceTextureDirectCHROMIUM,
    841                  WebGLId, WGC3Denum, const WGC3Dbyte*)
    842 DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM,
    843                  WGC3Denum, const WGC3Dbyte*)
    844 DELEGATE_TO_GL_2R(createAndConsumeTextureCHROMIUM,
    845                   CreateAndConsumeTextureCHROMIUM,
    846                   WGC3Denum, const WGC3Dbyte*, WebGLId)
    847 
    848 void WebGraphicsContext3DImpl::insertEventMarkerEXT(
    849     const WGC3Dchar* marker) {
    850   gl_->InsertEventMarkerEXT(0, marker);
    851 }
    852 
    853 void WebGraphicsContext3DImpl::pushGroupMarkerEXT(
    854     const WGC3Dchar* marker) {
    855   gl_->PushGroupMarkerEXT(0, marker);
    856 }
    857 
    858 DELEGATE_TO_GL(popGroupMarkerEXT, PopGroupMarkerEXT);
    859 
    860 WebGLId WebGraphicsContext3DImpl::createVertexArrayOES() {
    861   GLuint array;
    862   gl_->GenVertexArraysOES(1, &array);
    863   return array;
    864 }
    865 
    866 void WebGraphicsContext3DImpl::deleteVertexArrayOES(
    867     WebGLId array) {
    868   gl_->DeleteVertexArraysOES(1, &array);
    869 }
    870 
    871 DELEGATE_TO_GL_1R(isVertexArrayOES, IsVertexArrayOES, WebGLId, WGC3Dboolean)
    872 DELEGATE_TO_GL_1(bindVertexArrayOES, BindVertexArrayOES, WebGLId)
    873 
    874 DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM, BindTexImage2DCHROMIUM,
    875                  WGC3Denum, WGC3Dint)
    876 DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM, ReleaseTexImage2DCHROMIUM,
    877                  WGC3Denum, WGC3Dint)
    878 
    879 DELEGATE_TO_GL_2R(mapBufferCHROMIUM, MapBufferCHROMIUM, WGC3Denum, WGC3Denum,
    880                   void*)
    881 DELEGATE_TO_GL_1R(unmapBufferCHROMIUM, UnmapBufferCHROMIUM, WGC3Denum,
    882                   WGC3Dboolean)
    883 
    884 DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM, AsyncTexImage2DCHROMIUM, WGC3Denum,
    885                  WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dint,
    886                  WGC3Denum, WGC3Denum, const void*)
    887 DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM,
    888                  WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
    889                  WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
    890 
    891 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM,
    892                  WGC3Denum)
    893 
    894 DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT, WGC3Dsizei, const WGC3Denum*)
    895 
    896 DELEGATE_TO_GL_4(drawArraysInstancedANGLE, DrawArraysInstancedANGLE, WGC3Denum,
    897                  WGC3Dint, WGC3Dsizei, WGC3Dsizei)
    898 
    899 void WebGraphicsContext3DImpl::drawElementsInstancedANGLE(
    900     WGC3Denum mode,
    901     WGC3Dsizei count,
    902     WGC3Denum type,
    903     WGC3Dintptr offset,
    904     WGC3Dsizei primcount) {
    905   gl_->DrawElementsInstancedANGLE(
    906       mode, count, type,
    907       reinterpret_cast<void*>(static_cast<intptr_t>(offset)), primcount);
    908 }
    909 
    910 DELEGATE_TO_GL_2(vertexAttribDivisorANGLE, VertexAttribDivisorANGLE, WGC3Duint,
    911                  WGC3Duint)
    912 
    913 DELEGATE_TO_GL_4R(createImageCHROMIUM,
    914                   CreateImageCHROMIUM,
    915                   WGC3Dsizei,
    916                   WGC3Dsizei,
    917                   WGC3Denum,
    918                   WGC3Denum,
    919                   WGC3Duint);
    920 
    921 DELEGATE_TO_GL_1(destroyImageCHROMIUM, DestroyImageCHROMIUM, WGC3Duint);
    922 
    923 DELEGATE_TO_GL_3(getImageParameterivCHROMIUM, GetImageParameterivCHROMIUM,
    924                  WGC3Duint, WGC3Denum, GLint*);
    925 
    926 DELEGATE_TO_GL_1R(mapImageCHROMIUM, MapImageCHROMIUM, WGC3Duint, void*);
    927 
    928 DELEGATE_TO_GL_1(unmapImageCHROMIUM, UnmapImageCHROMIUM, WGC3Duint);
    929 
    930 DELEGATE_TO_GL_6(framebufferTexture2DMultisampleEXT,
    931                  FramebufferTexture2DMultisampleEXT,
    932                  WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint, WGC3Dsizei)
    933 
    934 DELEGATE_TO_GL_5(renderbufferStorageMultisampleEXT,
    935                  RenderbufferStorageMultisampleEXT, WGC3Denum, WGC3Dsizei,
    936                  WGC3Denum, WGC3Dsizei, WGC3Dsizei)
    937 
    938 GrGLInterface* WebGraphicsContext3DImpl::createGrGLInterface() {
    939   makeContextCurrent();
    940   return skia_bindings::CreateCommandBufferSkiaGLBinding();
    941 }
    942 
    943 ::gpu::gles2::GLES2ImplementationErrorMessageCallback*
    944     WebGraphicsContext3DImpl::getErrorMessageCallback() {
    945   if (!client_error_message_callback_) {
    946     client_error_message_callback_.reset(
    947         new WebGraphicsContext3DErrorMessageCallback(this));
    948   }
    949   return client_error_message_callback_.get();
    950 }
    951 
    952 void WebGraphicsContext3DImpl::OnErrorMessage(
    953     const std::string& message, int id) {
    954   if (error_message_callback_) {
    955     blink::WebString str = blink::WebString::fromUTF8(message.c_str());
    956     error_message_callback_->onErrorMessage(str, id);
    957   }
    958 }
    959 
    960 // TODO(bajones): Look into removing these functions from the blink interface
    961 void WebGraphicsContext3DImpl::prepareTexture() {
    962   NOTREACHED();
    963 }
    964 
    965 void WebGraphicsContext3DImpl::postSubBufferCHROMIUM(
    966     int x, int y, int width, int height) {
    967   NOTREACHED();
    968 }
    969 
    970 void WebGraphicsContext3DImpl::setVisibilityCHROMIUM(
    971     bool visible) {
    972   NOTREACHED();
    973 }
    974 
    975 void WebGraphicsContext3DImpl::copyTextureToParentTextureCHROMIUM(
    976     WebGLId texture, WebGLId parentTexture) {
    977   NOTIMPLEMENTED();
    978 }
    979 
    980 void WebGraphicsContext3DImpl::releaseShaderCompiler() {
    981 }
    982 
    983 }  // namespace gpu
    984 }  // namespace webkit
    985