WebKit/chromium/src/GraphicsContext3D.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2009 Google Inc. All rights reserved.
       
     3  *
       
     4  * Redistribution and use in source and binary forms, with or without
       
     5  * modification, are permitted provided that the following conditions are
       
     6  * met:
       
     7  *
       
     8  *     * Redistributions of source code must retain the above copyright
       
     9  * notice, this list of conditions and the following disclaimer.
       
    10  *     * Redistributions in binary form must reproduce the above
       
    11  * copyright notice, this list of conditions and the following disclaimer
       
    12  * in the documentation and/or other materials provided with the
       
    13  * distribution.
       
    14  *     * Neither the name of Google Inc. nor the names of its
       
    15  * contributors may be used to endorse or promote products derived from
       
    16  * this software without specific prior written permission.
       
    17  *
       
    18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
       
    19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
       
    20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
       
    21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
       
    22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
       
    23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
       
    24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
       
    25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
       
    26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    29  */
       
    30 
       
    31 #include "config.h"
       
    32 
       
    33 #if ENABLE(3D_CANVAS)
       
    34 
       
    35 #include "GraphicsContext3D.h"
       
    36 
       
    37 #include "CachedImage.h"
       
    38 #include "Chrome.h"
       
    39 #include "ChromeClientImpl.h"
       
    40 #include "HTMLCanvasElement.h"
       
    41 #include "HTMLImageElement.h"
       
    42 #include "ImageBuffer.h"
       
    43 #include "ImageData.h"
       
    44 #include "WebGLBuffer.h"
       
    45 #include "Int8Array.h"
       
    46 #include "Float32Array.h"
       
    47 #include "WebGLFramebuffer.h"
       
    48 #include "Int32Array.h"
       
    49 #include "WebGLProgram.h"
       
    50 #include "WebGLRenderbuffer.h"
       
    51 #include "WebGLRenderingContext.h"
       
    52 #include "WebGLShader.h"
       
    53 #include "WebGLTexture.h"
       
    54 #include "Uint8Array.h"
       
    55 #include "WebGLLayerChromium.h"
       
    56 #include "WebGraphicsContext3D.h"
       
    57 #include "WebGraphicsContext3DDefaultImpl.h"
       
    58 #include "WebKit.h"
       
    59 #include "WebKitClient.h"
       
    60 #include "WebViewImpl.h"
       
    61 
       
    62 #include <stdio.h>
       
    63 #include <wtf/FastMalloc.h>
       
    64 #include <wtf/text/CString.h>
       
    65 
       
    66 #if PLATFORM(CG)
       
    67 #include "GraphicsContext.h"
       
    68 #include <CoreGraphics/CGContext.h>
       
    69 #include <CoreGraphics/CGImage.h>
       
    70 #endif
       
    71 
       
    72 // using namespace std;
       
    73 
       
    74 // There are two levels of delegation in this file:
       
    75 //
       
    76 //   1. GraphicsContext3D delegates to GraphicsContext3DInternal. This is done
       
    77 //      so that we have some place to store data members common among
       
    78 //      implementations; GraphicsContext3D only provides us the m_internal
       
    79 //      pointer. We always delegate to the GraphicsContext3DInternal. While we
       
    80 //      could sidestep it and go directly to the WebGraphicsContext3D in some
       
    81 //      cases, it is better for consistency to always delegate through it.
       
    82 //
       
    83 //   2. GraphicsContext3DInternal delegates to an implementation of
       
    84 //      WebGraphicsContext3D. This is done so we have a place to inject an
       
    85 //      implementation which remotes the OpenGL calls across processes.
       
    86 //
       
    87 // The legacy, in-process, implementation uses WebGraphicsContext3DDefaultImpl.
       
    88 
       
    89 namespace WebCore {
       
    90 
       
    91 //----------------------------------------------------------------------
       
    92 // GraphicsContext3DInternal
       
    93 
       
    94 // Uncomment this to render to a separate window for debugging
       
    95 // #define RENDER_TO_DEBUGGING_WINDOW
       
    96 
       
    97 #define EXTRACT(val) (!val ? 0 : val->object())
       
    98 
       
    99 class GraphicsContext3DInternal {
       
   100 public:
       
   101     GraphicsContext3DInternal();
       
   102     ~GraphicsContext3DInternal();
       
   103 
       
   104     bool initialize(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow);
       
   105 
       
   106     PlatformGraphicsContext3D platformGraphicsContext3D() const;
       
   107     Platform3DObject platformTexture() const;
       
   108 
       
   109     bool makeContextCurrent();
       
   110 
       
   111     int sizeInBytes(int type);
       
   112 
       
   113     void reshape(int width, int height);
       
   114 
       
   115     void paintRenderingResultsToCanvas(WebGLRenderingContext* context);
       
   116     void beginPaint(WebGLRenderingContext* context);
       
   117     void endPaint();
       
   118 
       
   119     void prepareTexture();
       
   120 
       
   121 #if USE(ACCELERATED_COMPOSITING)
       
   122     WebGLLayerChromium* platformLayer() const;
       
   123 #endif
       
   124     bool isGLES2Compliant() const;
       
   125 
       
   126     //----------------------------------------------------------------------
       
   127     // Entry points for WebGL.
       
   128     //
       
   129     void activeTexture(unsigned long texture);
       
   130     void attachShader(WebGLProgram* program, WebGLShader* shader);
       
   131     void bindAttribLocation(WebGLProgram*, unsigned long index, const String& name);
       
   132     void bindBuffer(unsigned long target, WebGLBuffer*);
       
   133     void bindFramebuffer(unsigned long target, WebGLFramebuffer*);
       
   134     void bindRenderbuffer(unsigned long target, WebGLRenderbuffer*);
       
   135     void bindTexture(unsigned long target, WebGLTexture* texture);
       
   136     void blendColor(double red, double green, double blue, double alpha);
       
   137     void blendEquation(unsigned long mode);
       
   138     void blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha);
       
   139     void blendFunc(unsigned long sfactor, unsigned long dfactor);
       
   140     void blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha);
       
   141 
       
   142     void bufferData(unsigned long target, int size, unsigned long usage);
       
   143     void bufferData(unsigned long target, ArrayBuffer* data, unsigned long usage);
       
   144     void bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage);
       
   145     void bufferSubData(unsigned long target, long offset, ArrayBuffer* data);
       
   146     void bufferSubData(unsigned long target, long offset, ArrayBufferView* data);
       
   147 
       
   148     unsigned long checkFramebufferStatus(unsigned long target);
       
   149     void clear(unsigned long mask);
       
   150     void clearColor(double red, double green, double blue, double alpha);
       
   151     void clearDepth(double depth);
       
   152     void clearStencil(long s);
       
   153     void colorMask(bool red, bool green, bool blue, bool alpha);
       
   154     void compileShader(WebGLShader*);
       
   155 
       
   156     void copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border);
       
   157     void copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height);
       
   158     void cullFace(unsigned long mode);
       
   159     void depthFunc(unsigned long func);
       
   160     void depthMask(bool flag);
       
   161     void depthRange(double zNear, double zFar);
       
   162     void detachShader(WebGLProgram*, WebGLShader*);
       
   163     void disable(unsigned long cap);
       
   164     void disableVertexAttribArray(unsigned long index);
       
   165     void drawArrays(unsigned long mode, long first, long count);
       
   166     void drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset);
       
   167 
       
   168     void enable(unsigned long cap);
       
   169     void enableVertexAttribArray(unsigned long index);
       
   170     void finish();
       
   171     void flush();
       
   172     void framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, WebGLRenderbuffer*);
       
   173     void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, WebGLTexture*, long level);
       
   174     void frontFace(unsigned long mode);
       
   175     void generateMipmap(unsigned long target);
       
   176 
       
   177     bool getActiveAttrib(WebGLProgram* program, unsigned long index, ActiveInfo&);
       
   178     bool getActiveUniform(WebGLProgram* program, unsigned long index, ActiveInfo&);
       
   179 
       
   180     void getAttachedShaders(WebGLProgram* program, int maxCount, int* count, unsigned int* shaders);
       
   181 
       
   182     int  getAttribLocation(WebGLProgram*, const String& name);
       
   183 
       
   184     void getBooleanv(unsigned long pname, unsigned char* value);
       
   185 
       
   186     void getBufferParameteriv(unsigned long target, unsigned long pname, int* value);
       
   187 
       
   188     GraphicsContext3D::Attributes getContextAttributes();
       
   189 
       
   190     unsigned long getError();
       
   191 
       
   192     void getFloatv(unsigned long pname, float* value);
       
   193 
       
   194     void getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname, int* value);
       
   195 
       
   196     void getIntegerv(unsigned long pname, int* value);
       
   197 
       
   198     void getProgramiv(WebGLProgram* program, unsigned long pname, int* value);
       
   199 
       
   200     String getProgramInfoLog(WebGLProgram*);
       
   201 
       
   202     void getRenderbufferParameteriv(unsigned long target, unsigned long pname, int* value);
       
   203 
       
   204     void getShaderiv(WebGLShader*, unsigned long pname, int* value);
       
   205 
       
   206     String getShaderInfoLog(WebGLShader*);
       
   207 
       
   208     String getShaderSource(WebGLShader*);
       
   209     String getString(unsigned long name);
       
   210 
       
   211     void getTexParameterfv(unsigned long target, unsigned long pname, float* value);
       
   212     void getTexParameteriv(unsigned long target, unsigned long pname, int* value);
       
   213 
       
   214     void getUniformfv(WebGLProgram* program, long location, float* value);
       
   215     void getUniformiv(WebGLProgram* program, long location, int* value);
       
   216 
       
   217     long getUniformLocation(WebGLProgram*, const String& name);
       
   218 
       
   219     void getVertexAttribfv(unsigned long index, unsigned long pname, float* value);
       
   220     void getVertexAttribiv(unsigned long index, unsigned long pname, int* value);
       
   221 
       
   222     long getVertexAttribOffset(unsigned long index, unsigned long pname);
       
   223 
       
   224     void hint(unsigned long target, unsigned long mode);
       
   225     bool isBuffer(WebGLBuffer*);
       
   226     bool isEnabled(unsigned long cap);
       
   227     bool isFramebuffer(WebGLFramebuffer*);
       
   228     bool isProgram(WebGLProgram*);
       
   229     bool isRenderbuffer(WebGLRenderbuffer*);
       
   230     bool isShader(WebGLShader*);
       
   231     bool isTexture(WebGLTexture*);
       
   232     void lineWidth(double);
       
   233     void linkProgram(WebGLProgram*);
       
   234     void pixelStorei(unsigned long pname, long param);
       
   235     void polygonOffset(double factor, double units);
       
   236 
       
   237     void readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type, void* data);
       
   238 
       
   239     void releaseShaderCompiler();
       
   240     void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height);
       
   241     void sampleCoverage(double value, bool invert);
       
   242     void scissor(long x, long y, unsigned long width, unsigned long height);
       
   243     void shaderSource(WebGLShader*, const String& string);
       
   244     void stencilFunc(unsigned long func, long ref, unsigned long mask);
       
   245     void stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask);
       
   246     void stencilMask(unsigned long mask);
       
   247     void stencilMaskSeparate(unsigned long face, unsigned long mask);
       
   248     void stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass);
       
   249     void stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass);
       
   250 
       
   251     // These next several functions return an error code (0 if no errors) rather than using an ExceptionCode.
       
   252     // Currently they return -1 on any error.
       
   253     int texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, void* pixels);
       
   254 
       
   255     void texParameterf(unsigned target, unsigned pname, float param);
       
   256     void texParameteri(unsigned target, unsigned pname, int param);
       
   257 
       
   258     int texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, unsigned width, unsigned height, unsigned format, unsigned type, void* pixels);
       
   259 
       
   260     void uniform1f(long location, float x);
       
   261     void uniform1fv(long location, float* v, int size);
       
   262     void uniform1i(long location, int x);
       
   263     void uniform1iv(long location, int* v, int size);
       
   264     void uniform2f(long location, float x, float y);
       
   265     void uniform2fv(long location, float* v, int size);
       
   266     void uniform2i(long location, int x, int y);
       
   267     void uniform2iv(long location, int* v, int size);
       
   268     void uniform3f(long location, float x, float y, float z);
       
   269     void uniform3fv(long location, float* v, int size);
       
   270     void uniform3i(long location, int x, int y, int z);
       
   271     void uniform3iv(long location, int* v, int size);
       
   272     void uniform4f(long location, float x, float y, float z, float w);
       
   273     void uniform4fv(long location, float* v, int size);
       
   274     void uniform4i(long location, int x, int y, int z, int w);
       
   275     void uniform4iv(long location, int* v, int size);
       
   276     void uniformMatrix2fv(long location, bool transpose, float* value, int size);
       
   277     void uniformMatrix3fv(long location, bool transpose, float* value, int size);
       
   278     void uniformMatrix4fv(long location, bool transpose, float* value, int size);
       
   279 
       
   280     void useProgram(WebGLProgram*);
       
   281     void validateProgram(WebGLProgram*);
       
   282 
       
   283     void vertexAttrib1f(unsigned long indx, float x);
       
   284     void vertexAttrib1fv(unsigned long indx, float* values);
       
   285     void vertexAttrib2f(unsigned long indx, float x, float y);
       
   286     void vertexAttrib2fv(unsigned long indx, float* values);
       
   287     void vertexAttrib3f(unsigned long indx, float x, float y, float z);
       
   288     void vertexAttrib3fv(unsigned long indx, float* values);
       
   289     void vertexAttrib4f(unsigned long indx, float x, float y, float z, float w);
       
   290     void vertexAttrib4fv(unsigned long indx, float* values);
       
   291     void vertexAttribPointer(unsigned long indx, int size, int type, bool normalized,
       
   292                              unsigned long stride, unsigned long offset);
       
   293 
       
   294     void viewport(long x, long y, unsigned long width, unsigned long height);
       
   295 
       
   296     unsigned createBuffer();
       
   297     unsigned createFramebuffer();
       
   298     unsigned createProgram();
       
   299     unsigned createRenderbuffer();
       
   300     unsigned createShader(unsigned long);
       
   301     unsigned createTexture();
       
   302 
       
   303     void deleteBuffer(unsigned);
       
   304     void deleteFramebuffer(unsigned);
       
   305     void deleteProgram(unsigned);
       
   306     void deleteRenderbuffer(unsigned);
       
   307     void deleteShader(unsigned);
       
   308     void deleteTexture(unsigned);
       
   309 
       
   310     void synthesizeGLError(unsigned long error);
       
   311 
       
   312 private:
       
   313     OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
       
   314 #if USE(ACCELERATED_COMPOSITING)
       
   315     RefPtr<WebGLLayerChromium> m_compositingLayer;
       
   316 #endif
       
   317 #if PLATFORM(SKIA)
       
   318     // If the width and height of the Canvas's backing store don't
       
   319     // match those that we were given in the most recent call to
       
   320     // reshape(), then we need an intermediate bitmap to read back the
       
   321     // frame buffer into. This seems to happen when CSS styles are
       
   322     // used to resize the Canvas.
       
   323     SkBitmap m_resizingBitmap;
       
   324 #endif
       
   325 
       
   326 #if PLATFORM(CG)
       
   327     unsigned char* m_renderOutput;
       
   328 #endif
       
   329 };
       
   330 
       
   331 GraphicsContext3DInternal::GraphicsContext3DInternal()
       
   332 #if PLATFORM(SKIA)
       
   333 #elif PLATFORM(CG)
       
   334     : m_renderOutput(0)
       
   335 #else
       
   336 #error Must port to your platform
       
   337 #endif
       
   338 {
       
   339 }
       
   340 
       
   341 GraphicsContext3DInternal::~GraphicsContext3DInternal()
       
   342 {
       
   343 #if PLATFORM(CG)
       
   344     if (m_renderOutput)
       
   345         delete[] m_renderOutput;
       
   346 #endif
       
   347 }
       
   348 
       
   349 bool GraphicsContext3DInternal::initialize(GraphicsContext3D::Attributes attrs,
       
   350                                            HostWindow* hostWindow)
       
   351 {
       
   352     WebKit::WebGraphicsContext3D::Attributes webAttributes;
       
   353     webAttributes.alpha = attrs.alpha;
       
   354     webAttributes.depth = attrs.depth;
       
   355     webAttributes.stencil = attrs.stencil;
       
   356     webAttributes.antialias = attrs.antialias;
       
   357     webAttributes.premultipliedAlpha = attrs.premultipliedAlpha;
       
   358     WebKit::WebGraphicsContext3D* webContext = WebKit::webKitClient()->createGraphicsContext3D();
       
   359     if (!webContext)
       
   360         return false;
       
   361 
       
   362     Chrome* chrome = static_cast<Chrome*>(hostWindow);
       
   363     WebKit::ChromeClientImpl* chromeClientImpl = static_cast<WebKit::ChromeClientImpl*>(chrome->client());
       
   364 
       
   365     WebKit::WebViewImpl* webView = chromeClientImpl->webView();
       
   366 
       
   367     if (!webView)
       
   368         return false;
       
   369     if (!webContext->initialize(webAttributes, webView)) {
       
   370         delete webContext;
       
   371         return false;
       
   372     }
       
   373     m_impl.set(webContext);
       
   374 
       
   375 #if USE(ACCELERATED_COMPOSITING)
       
   376     m_compositingLayer = WebGLLayerChromium::create(0);
       
   377 #endif
       
   378     return true;
       
   379 }
       
   380 
       
   381 PlatformGraphicsContext3D GraphicsContext3DInternal::platformGraphicsContext3D() const
       
   382 {
       
   383     return m_impl.get();
       
   384 }
       
   385 
       
   386 Platform3DObject GraphicsContext3DInternal::platformTexture() const
       
   387 {
       
   388     return m_impl->getPlatformTextureId();
       
   389 }
       
   390 
       
   391 void GraphicsContext3DInternal::prepareTexture()
       
   392 {
       
   393     m_impl->prepareTexture();
       
   394 }
       
   395 
       
   396 #if USE(ACCELERATED_COMPOSITING)
       
   397 WebGLLayerChromium* GraphicsContext3DInternal::platformLayer() const
       
   398 {
       
   399     return m_compositingLayer.get();
       
   400 }
       
   401 #endif
       
   402 
       
   403 void GraphicsContext3DInternal::paintRenderingResultsToCanvas(WebGLRenderingContext* context)
       
   404 {
       
   405     HTMLCanvasElement* canvas = context->canvas();
       
   406     ImageBuffer* imageBuffer = canvas->buffer();
       
   407     unsigned char* pixels = 0;
       
   408 #if PLATFORM(SKIA)
       
   409     const SkBitmap* canvasBitmap = imageBuffer->context()->platformContext()->bitmap();
       
   410     const SkBitmap* readbackBitmap = 0;
       
   411     ASSERT(canvasBitmap->config() == SkBitmap::kARGB_8888_Config);
       
   412     if (canvasBitmap->width() == m_impl->width() && canvasBitmap->height() == m_impl->height()) {
       
   413         // This is the fastest and most common case. We read back
       
   414         // directly into the canvas's backing store.
       
   415         readbackBitmap = canvasBitmap;
       
   416         m_resizingBitmap.reset();
       
   417     } else {
       
   418         // We need to allocate a temporary bitmap for reading back the
       
   419         // pixel data. We will then use Skia to rescale this bitmap to
       
   420         // the size of the canvas's backing store.
       
   421         if (m_resizingBitmap.width() != m_impl->width() || m_resizingBitmap.height() != m_impl->height()) {
       
   422             m_resizingBitmap.setConfig(SkBitmap::kARGB_8888_Config,
       
   423                                        m_impl->width(),
       
   424                                        m_impl->height());
       
   425             if (!m_resizingBitmap.allocPixels()) {
       
   426                 return;
       
   427             }
       
   428         }
       
   429         readbackBitmap = &m_resizingBitmap;
       
   430     }
       
   431 
       
   432     // Read back the frame buffer.
       
   433     SkAutoLockPixels bitmapLock(*readbackBitmap);
       
   434     pixels = static_cast<unsigned char*>(readbackBitmap->getPixels());
       
   435 #elif PLATFORM(CG)
       
   436     if (m_renderOutput)
       
   437         pixels = m_renderOutput;
       
   438 #else
       
   439 #error Must port to your platform
       
   440 #endif
       
   441 
       
   442     m_impl->readBackFramebuffer(pixels, 4 * m_impl->width() * m_impl->height());
       
   443 
       
   444 #if PLATFORM(SKIA)
       
   445     if (m_resizingBitmap.readyToDraw()) {
       
   446         // We need to draw the resizing bitmap into the canvas's backing store.
       
   447         SkCanvas canvas(*canvasBitmap);
       
   448         SkRect dst;
       
   449         dst.set(SkIntToScalar(0), SkIntToScalar(0), canvasBitmap->width(), canvasBitmap->height());
       
   450         canvas.drawBitmapRect(m_resizingBitmap, 0, dst);
       
   451     }
       
   452 #elif PLATFORM(CG)
       
   453     if (m_renderOutput)
       
   454         context->graphicsContext3D()->paintToCanvas(m_renderOutput, m_impl->width(), m_impl->height(),
       
   455                                                     canvas->width(), canvas->height(),
       
   456                                                     imageBuffer->context()->platformContext());
       
   457 #else
       
   458 #error Must port to your platform
       
   459 #endif
       
   460 }
       
   461 
       
   462 void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context)
       
   463 {
       
   464     paintRenderingResultsToCanvas(context);
       
   465 }
       
   466 
       
   467 void GraphicsContext3DInternal::endPaint()
       
   468 {
       
   469 }
       
   470 
       
   471 void GraphicsContext3DInternal::reshape(int width, int height)
       
   472 {
       
   473     if (width == m_impl->width() && height == m_impl->height())
       
   474         return;
       
   475 
       
   476     m_impl->reshape(width, height);
       
   477 
       
   478 #if PLATFORM(CG)
       
   479     // Need to reallocate the client-side backing store.
       
   480     // FIXME: make this more efficient.
       
   481     if (m_renderOutput) {
       
   482         delete[] m_renderOutput;
       
   483         m_renderOutput = 0;
       
   484     }
       
   485     int rowBytes = width * 4;
       
   486     m_renderOutput = new unsigned char[height * rowBytes];
       
   487 #endif // PLATFORM(CG)
       
   488 }
       
   489 
       
   490 // Macros to assist in delegating from GraphicsContext3DInternal to
       
   491 // WebGraphicsContext3D.
       
   492 
       
   493 #define DELEGATE_TO_IMPL(name) \
       
   494 void GraphicsContext3DInternal::name() \
       
   495 { \
       
   496     m_impl->name(); \
       
   497 }
       
   498 
       
   499 #define DELEGATE_TO_IMPL_R(name, rt)           \
       
   500 rt GraphicsContext3DInternal::name() \
       
   501 { \
       
   502     return m_impl->name(); \
       
   503 }
       
   504 
       
   505 #define DELEGATE_TO_IMPL_1(name, t1) \
       
   506 void GraphicsContext3DInternal::name(t1 a1) \
       
   507 { \
       
   508     m_impl->name(a1); \
       
   509 }
       
   510 
       
   511 #define DELEGATE_TO_IMPL_1_X(name, t1) \
       
   512 void GraphicsContext3DInternal::name(t1 a1) \
       
   513 { \
       
   514     m_impl->name(EXTRACT(a1));                  \
       
   515 }
       
   516 
       
   517 #define DELEGATE_TO_IMPL_1R(name, t1, rt)    \
       
   518 rt GraphicsContext3DInternal::name(t1 a1) \
       
   519 { \
       
   520     return m_impl->name(a1); \
       
   521 }
       
   522 
       
   523 #define DELEGATE_TO_IMPL_1R_X(name, t1, rt)    \
       
   524 rt GraphicsContext3DInternal::name(t1 a1) \
       
   525 { \
       
   526     return m_impl->name(EXTRACT(a1));           \
       
   527 }
       
   528 
       
   529 #define DELEGATE_TO_IMPL_2(name, t1, t2) \
       
   530 void GraphicsContext3DInternal::name(t1 a1, t2 a2) \
       
   531 { \
       
   532     m_impl->name(a1, a2); \
       
   533 }
       
   534 
       
   535 #define DELEGATE_TO_IMPL_2_X12(name, t1, t2) \
       
   536 void GraphicsContext3DInternal::name(t1 a1, t2 a2) \
       
   537 { \
       
   538     m_impl->name(EXTRACT(a1), EXTRACT(a2));     \
       
   539 }
       
   540 
       
   541 #define DELEGATE_TO_IMPL_2_X2(name, t1, t2) \
       
   542 void GraphicsContext3DInternal::name(t1 a1, t2 a2) \
       
   543 { \
       
   544     m_impl->name(a1, EXTRACT(a2));     \
       
   545 }
       
   546 
       
   547 #define DELEGATE_TO_IMPL_2R(name, t1, t2, rt)  \
       
   548 rt GraphicsContext3DInternal::name(t1 a1, t2 a2) \
       
   549 { \
       
   550     return m_impl->name(a1, a2); \
       
   551 }
       
   552 
       
   553 #define DELEGATE_TO_IMPL_3(name, t1, t2, t3)   \
       
   554 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3)    \
       
   555 { \
       
   556     m_impl->name(a1, a2, a3);                  \
       
   557 }
       
   558 
       
   559 #define DELEGATE_TO_IMPL_3_X1(name, t1, t2, t3)   \
       
   560 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3)    \
       
   561 { \
       
   562     m_impl->name(EXTRACT(a1), a2, a3);          \
       
   563 }
       
   564 
       
   565 #define DELEGATE_TO_IMPL_3R(name, t1, t2, t3, rt)   \
       
   566 rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3)    \
       
   567 { \
       
   568     return m_impl->name(a1, a2, a3);                  \
       
   569 }
       
   570 
       
   571 #define DELEGATE_TO_IMPL_4(name, t1, t2, t3, t4)    \
       
   572 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4)  \
       
   573 { \
       
   574     m_impl->name(a1, a2, a3, a4);              \
       
   575 }
       
   576 
       
   577 #define DELEGATE_TO_IMPL_4_X1(name, t1, t2, t3, t4)    \
       
   578 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4)  \
       
   579 { \
       
   580     m_impl->name(EXTRACT(a1), a2, a3, a4);     \
       
   581 }
       
   582 
       
   583 #define DELEGATE_TO_IMPL_4_X4(name, t1, t2, t3, t4)    \
       
   584 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4)  \
       
   585 { \
       
   586     m_impl->name(a1, a2, a3, EXTRACT(a4));      \
       
   587 }
       
   588 
       
   589 #define DELEGATE_TO_IMPL_5(name, t1, t2, t3, t4, t5)      \
       
   590 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5)        \
       
   591 { \
       
   592     m_impl->name(a1, a2, a3, a4, a5);   \
       
   593 }
       
   594 
       
   595 #define DELEGATE_TO_IMPL_5_X4(name, t1, t2, t3, t4, t5)                \
       
   596 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5)        \
       
   597 { \
       
   598     m_impl->name(a1, a2, a3, EXTRACT(a4), a5);  \
       
   599 }
       
   600 
       
   601 #define DELEGATE_TO_IMPL_5R(name, t1, t2, t3, t4, t5, rt)      \
       
   602 rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5)        \
       
   603 { \
       
   604     return m_impl->name(a1, a2, a3, a4, a5);   \
       
   605 }
       
   606 
       
   607 #define DELEGATE_TO_IMPL_6(name, t1, t2, t3, t4, t5, t6)  \
       
   608 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
       
   609 { \
       
   610     m_impl->name(a1, a2, a3, a4, a5, a6);       \
       
   611 }
       
   612 
       
   613 #define DELEGATE_TO_IMPL_6R(name, t1, t2, t3, t4, t5, t6, rt)  \
       
   614 rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
       
   615 { \
       
   616     return m_impl->name(a1, a2, a3, a4, a5, a6);       \
       
   617 }
       
   618 
       
   619 #define DELEGATE_TO_IMPL_7(name, t1, t2, t3, t4, t5, t6, t7) \
       
   620 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
       
   621 { \
       
   622     m_impl->name(a1, a2, a3, a4, a5, a6, a7);   \
       
   623 }
       
   624 
       
   625 #define DELEGATE_TO_IMPL_7R(name, t1, t2, t3, t4, t5, t6, t7, rt) \
       
   626 rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
       
   627 { \
       
   628     return m_impl->name(a1, a2, a3, a4, a5, a6, a7);   \
       
   629 }
       
   630 
       
   631 #define DELEGATE_TO_IMPL_8(name, t1, t2, t3, t4, t5, t6, t7, t8)       \
       
   632 void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \
       
   633 { \
       
   634     m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8);      \
       
   635 }
       
   636 
       
   637 #define DELEGATE_TO_IMPL_9R(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, rt) \
       
   638 rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \
       
   639 { \
       
   640     return m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9);   \
       
   641 }
       
   642 
       
   643 DELEGATE_TO_IMPL_R(makeContextCurrent, bool)
       
   644 DELEGATE_TO_IMPL_1R(sizeInBytes, int, int)
       
   645 
       
   646 bool GraphicsContext3DInternal::isGLES2Compliant() const
       
   647 {
       
   648     return m_impl->isGLES2Compliant();
       
   649 }
       
   650 
       
   651 DELEGATE_TO_IMPL_1(activeTexture, unsigned long)
       
   652 DELEGATE_TO_IMPL_2_X12(attachShader, WebGLProgram*, WebGLShader*)
       
   653 
       
   654 void GraphicsContext3DInternal::bindAttribLocation(WebGLProgram* program, unsigned long index, const String& name)
       
   655 {
       
   656     m_impl->bindAttribLocation(EXTRACT(program), index, name.utf8().data());
       
   657 }
       
   658 
       
   659 DELEGATE_TO_IMPL_2_X2(bindBuffer, unsigned long, WebGLBuffer*)
       
   660 DELEGATE_TO_IMPL_2_X2(bindFramebuffer, unsigned long, WebGLFramebuffer*)
       
   661 DELEGATE_TO_IMPL_2_X2(bindRenderbuffer, unsigned long, WebGLRenderbuffer*)
       
   662 
       
   663 static const int kTextureWrapR = 0x8072;
       
   664 
       
   665 // If we didn't have to hack GL_TEXTURE_WRAP_R for cube maps,
       
   666 // we could just use:
       
   667 // DELEGATE_TO_IMPL_2_X2(bindTexture, unsigned long, WebGLTexture*)
       
   668 void GraphicsContext3DInternal::bindTexture(unsigned long target,
       
   669                                             WebGLTexture* texture)
       
   670 {
       
   671     unsigned int textureObject = EXTRACT(texture);
       
   672 
       
   673     m_impl->bindTexture(target, textureObject);
       
   674 
       
   675     // FIXME: GL_TEXTURE_WRAP_R isn't exposed in the OpenGL ES 2.0
       
   676     // API. On desktop OpenGL implementations it seems necessary to
       
   677     // set this wrap mode to GL_CLAMP_TO_EDGE to get correct behavior
       
   678     // of cube maps.
       
   679     if (texture)
       
   680         if (target == GraphicsContext3D::TEXTURE_CUBE_MAP) {
       
   681             if (!texture->isCubeMapRWrapModeInitialized()) {
       
   682                 m_impl->texParameteri(GraphicsContext3D::TEXTURE_CUBE_MAP, kTextureWrapR, GraphicsContext3D::CLAMP_TO_EDGE);
       
   683                 texture->setCubeMapRWrapModeInitialized(true);
       
   684             }
       
   685         } else
       
   686             texture->setCubeMapRWrapModeInitialized(false);
       
   687 }
       
   688 
       
   689 DELEGATE_TO_IMPL_4(blendColor, double, double, double, double)
       
   690 DELEGATE_TO_IMPL_1(blendEquation, unsigned long)
       
   691 DELEGATE_TO_IMPL_2(blendEquationSeparate, unsigned long, unsigned long)
       
   692 DELEGATE_TO_IMPL_2(blendFunc, unsigned long, unsigned long)
       
   693 DELEGATE_TO_IMPL_4(blendFuncSeparate, unsigned long, unsigned long, unsigned long, unsigned long)
       
   694 
       
   695 void GraphicsContext3DInternal::bufferData(unsigned long target, int size, unsigned long usage)
       
   696 {
       
   697     m_impl->bufferData(target, size, 0, usage);
       
   698 }
       
   699 
       
   700 void GraphicsContext3DInternal::bufferData(unsigned long target, ArrayBuffer* array, unsigned long usage)
       
   701 {
       
   702     m_impl->bufferData(target, array->byteLength(), array->data(), usage);
       
   703 }
       
   704 
       
   705 void GraphicsContext3DInternal::bufferData(unsigned long target, ArrayBufferView* array, unsigned long usage)
       
   706 {
       
   707     m_impl->bufferData(target, array->byteLength(), array->baseAddress(), usage);
       
   708 }
       
   709 
       
   710 void GraphicsContext3DInternal::bufferSubData(unsigned long target, long offset, ArrayBuffer* array)
       
   711 {
       
   712     m_impl->bufferSubData(target, offset, array->byteLength(), array->data());
       
   713 }
       
   714 
       
   715 void GraphicsContext3DInternal::bufferSubData(unsigned long target, long offset, ArrayBufferView* array)
       
   716 {
       
   717     m_impl->bufferSubData(target, offset, array->byteLength(), array->baseAddress());
       
   718 }
       
   719 
       
   720 DELEGATE_TO_IMPL_1R(checkFramebufferStatus, unsigned long, unsigned long)
       
   721 DELEGATE_TO_IMPL_1(clear, unsigned long)
       
   722 DELEGATE_TO_IMPL_4(clearColor, double, double, double, double)
       
   723 DELEGATE_TO_IMPL_1(clearDepth, double)
       
   724 DELEGATE_TO_IMPL_1(clearStencil, long)
       
   725 DELEGATE_TO_IMPL_4(colorMask, bool, bool, bool, bool)
       
   726 DELEGATE_TO_IMPL_1_X(compileShader, WebGLShader*)
       
   727 
       
   728 DELEGATE_TO_IMPL_8(copyTexImage2D, unsigned long, long, unsigned long, long, long, unsigned long, unsigned long, long)
       
   729 DELEGATE_TO_IMPL_8(copyTexSubImage2D, unsigned long, long, long, long, long, long, unsigned long, unsigned long)
       
   730 DELEGATE_TO_IMPL_1(cullFace, unsigned long)
       
   731 DELEGATE_TO_IMPL_1(depthFunc, unsigned long)
       
   732 DELEGATE_TO_IMPL_1(depthMask, bool)
       
   733 DELEGATE_TO_IMPL_2(depthRange, double, double)
       
   734 DELEGATE_TO_IMPL_2_X12(detachShader, WebGLProgram*, WebGLShader*)
       
   735 DELEGATE_TO_IMPL_1(disable, unsigned long)
       
   736 DELEGATE_TO_IMPL_1(disableVertexAttribArray, unsigned long)
       
   737 DELEGATE_TO_IMPL_3(drawArrays, unsigned long, long, long)
       
   738 DELEGATE_TO_IMPL_4(drawElements, unsigned long, unsigned long, unsigned long, long)
       
   739 
       
   740 DELEGATE_TO_IMPL_1(enable, unsigned long)
       
   741 DELEGATE_TO_IMPL_1(enableVertexAttribArray, unsigned long)
       
   742 DELEGATE_TO_IMPL(finish)
       
   743 DELEGATE_TO_IMPL(flush)
       
   744 DELEGATE_TO_IMPL_4_X4(framebufferRenderbuffer, unsigned long, unsigned long, unsigned long, WebGLRenderbuffer*)
       
   745 DELEGATE_TO_IMPL_5_X4(framebufferTexture2D, unsigned long, unsigned long, unsigned long, WebGLTexture*, long)
       
   746 DELEGATE_TO_IMPL_1(frontFace, unsigned long)
       
   747 DELEGATE_TO_IMPL_1(generateMipmap, unsigned long)
       
   748 
       
   749 bool GraphicsContext3DInternal::getActiveAttrib(WebGLProgram* program, unsigned long index, ActiveInfo& info)
       
   750 {
       
   751     WebKit::WebGraphicsContext3D::ActiveInfo webInfo;
       
   752     if (!m_impl->getActiveAttrib(EXTRACT(program), index, webInfo))
       
   753         return false;
       
   754     info.name = webInfo.name;
       
   755     info.type = webInfo.type;
       
   756     info.size = webInfo.size;
       
   757     return true;
       
   758 }
       
   759 
       
   760 bool GraphicsContext3DInternal::getActiveUniform(WebGLProgram* program, unsigned long index, ActiveInfo& info)
       
   761 {
       
   762     WebKit::WebGraphicsContext3D::ActiveInfo webInfo;
       
   763     if (!m_impl->getActiveUniform(EXTRACT(program), index, webInfo))
       
   764         return false;
       
   765     info.name = webInfo.name;
       
   766     info.type = webInfo.type;
       
   767     info.size = webInfo.size;
       
   768     return true;
       
   769 }
       
   770 
       
   771 DELEGATE_TO_IMPL_4_X1(getAttachedShaders, WebGLProgram*, int, int*, unsigned int*)
       
   772 
       
   773 int GraphicsContext3DInternal::getAttribLocation(WebGLProgram* program, const String& name)
       
   774 {
       
   775     return m_impl->getAttribLocation(EXTRACT(program), name.utf8().data());
       
   776 }
       
   777 
       
   778 DELEGATE_TO_IMPL_2(getBooleanv, unsigned long, unsigned char*)
       
   779 
       
   780 DELEGATE_TO_IMPL_3(getBufferParameteriv, unsigned long, unsigned long, int*)
       
   781 
       
   782 GraphicsContext3D::Attributes GraphicsContext3DInternal::getContextAttributes()
       
   783 {
       
   784     WebKit::WebGraphicsContext3D::Attributes webAttributes = m_impl->getContextAttributes();
       
   785     GraphicsContext3D::Attributes attributes;
       
   786     attributes.alpha = webAttributes.alpha;
       
   787     attributes.depth = webAttributes.depth;
       
   788     attributes.stencil = webAttributes.stencil;
       
   789     attributes.antialias = webAttributes.antialias;
       
   790     attributes.premultipliedAlpha = webAttributes.premultipliedAlpha;
       
   791     return attributes;
       
   792 }
       
   793 
       
   794 DELEGATE_TO_IMPL_R(getError, unsigned long)
       
   795 
       
   796 DELEGATE_TO_IMPL_2(getFloatv, unsigned long, float*)
       
   797 
       
   798 DELEGATE_TO_IMPL_4(getFramebufferAttachmentParameteriv, unsigned long, unsigned long, unsigned long, int*)
       
   799 
       
   800 DELEGATE_TO_IMPL_2(getIntegerv, unsigned long, int*)
       
   801 
       
   802 DELEGATE_TO_IMPL_3_X1(getProgramiv, WebGLProgram*, unsigned long, int*)
       
   803 
       
   804 String GraphicsContext3DInternal::getProgramInfoLog(WebGLProgram* program)
       
   805 {
       
   806     return m_impl->getProgramInfoLog(EXTRACT(program));
       
   807 }
       
   808 
       
   809 DELEGATE_TO_IMPL_3(getRenderbufferParameteriv, unsigned long, unsigned long, int*)
       
   810 
       
   811 DELEGATE_TO_IMPL_3_X1(getShaderiv, WebGLShader*, unsigned long, int*)
       
   812 
       
   813 String GraphicsContext3DInternal::getShaderInfoLog(WebGLShader* shader)
       
   814 {
       
   815     return m_impl->getShaderInfoLog(EXTRACT(shader));
       
   816 }
       
   817 
       
   818 String GraphicsContext3DInternal::getShaderSource(WebGLShader* shader)
       
   819 {
       
   820     return m_impl->getShaderSource(EXTRACT(shader));
       
   821 }
       
   822 
       
   823 String GraphicsContext3DInternal::getString(unsigned long name)
       
   824 {
       
   825     return m_impl->getString(name);
       
   826 }
       
   827 
       
   828 DELEGATE_TO_IMPL_3(getTexParameterfv, unsigned long, unsigned long, float*)
       
   829 DELEGATE_TO_IMPL_3(getTexParameteriv, unsigned long, unsigned long, int*)
       
   830 
       
   831 DELEGATE_TO_IMPL_3_X1(getUniformfv, WebGLProgram*, long, float*)
       
   832 DELEGATE_TO_IMPL_3_X1(getUniformiv, WebGLProgram*, long, int*)
       
   833 
       
   834 long GraphicsContext3DInternal::getUniformLocation(WebGLProgram* program, const String& name)
       
   835 {
       
   836     return m_impl->getUniformLocation(EXTRACT(program), name.utf8().data());
       
   837 }
       
   838 
       
   839 DELEGATE_TO_IMPL_3(getVertexAttribfv, unsigned long, unsigned long, float*)
       
   840 DELEGATE_TO_IMPL_3(getVertexAttribiv, unsigned long, unsigned long, int*)
       
   841 
       
   842 DELEGATE_TO_IMPL_2R(getVertexAttribOffset, unsigned long, unsigned long, long)
       
   843 
       
   844 DELEGATE_TO_IMPL_2(hint, unsigned long, unsigned long)
       
   845 DELEGATE_TO_IMPL_1R_X(isBuffer, WebGLBuffer*, bool)
       
   846 DELEGATE_TO_IMPL_1R(isEnabled, unsigned long, bool)
       
   847 DELEGATE_TO_IMPL_1R_X(isFramebuffer, WebGLFramebuffer*, bool)
       
   848 DELEGATE_TO_IMPL_1R_X(isProgram, WebGLProgram*, bool)
       
   849 DELEGATE_TO_IMPL_1R_X(isRenderbuffer, WebGLRenderbuffer*, bool)
       
   850 DELEGATE_TO_IMPL_1R_X(isShader, WebGLShader*, bool)
       
   851 DELEGATE_TO_IMPL_1R_X(isTexture, WebGLTexture*, bool)
       
   852 DELEGATE_TO_IMPL_1(lineWidth, double)
       
   853 DELEGATE_TO_IMPL_1_X(linkProgram, WebGLProgram*)
       
   854 DELEGATE_TO_IMPL_2(pixelStorei, unsigned long, long)
       
   855 DELEGATE_TO_IMPL_2(polygonOffset, double, double)
       
   856 DELEGATE_TO_IMPL_7(readPixels, long, long, unsigned long, unsigned long, unsigned long, unsigned long, void*)
       
   857 DELEGATE_TO_IMPL(releaseShaderCompiler)
       
   858 DELEGATE_TO_IMPL_4(renderbufferStorage, unsigned long, unsigned long, unsigned long, unsigned long)
       
   859 DELEGATE_TO_IMPL_2(sampleCoverage, double, bool)
       
   860 DELEGATE_TO_IMPL_4(scissor, long, long, unsigned long, unsigned long)
       
   861 
       
   862 void GraphicsContext3DInternal::shaderSource(WebGLShader* shader, const String& string)
       
   863 {
       
   864     m_impl->shaderSource(EXTRACT(shader), string.utf8().data());
       
   865 }
       
   866 
       
   867 DELEGATE_TO_IMPL_3(stencilFunc, unsigned long, long, unsigned long)
       
   868 DELEGATE_TO_IMPL_4(stencilFuncSeparate, unsigned long, unsigned long, long, unsigned long)
       
   869 DELEGATE_TO_IMPL_1(stencilMask, unsigned long)
       
   870 DELEGATE_TO_IMPL_2(stencilMaskSeparate, unsigned long, unsigned long)
       
   871 DELEGATE_TO_IMPL_3(stencilOp, unsigned long, unsigned long, unsigned long)
       
   872 DELEGATE_TO_IMPL_4(stencilOpSeparate, unsigned long, unsigned long, unsigned long, unsigned long)
       
   873 
       
   874 int GraphicsContext3DInternal::texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, void* pixels)
       
   875 {
       
   876     m_impl->texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
       
   877     return 0;
       
   878 }
       
   879 
       
   880 DELEGATE_TO_IMPL_3(texParameterf, unsigned, unsigned, float)
       
   881 DELEGATE_TO_IMPL_3(texParameteri, unsigned, unsigned, int)
       
   882 
       
   883 int GraphicsContext3DInternal::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, unsigned width, unsigned height, unsigned format, unsigned type, void* pixels)
       
   884 {
       
   885     m_impl->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
       
   886     return 0;
       
   887 }
       
   888 
       
   889 DELEGATE_TO_IMPL_2(uniform1f, long, float)
       
   890 
       
   891 void GraphicsContext3DInternal::uniform1fv(long location, float* v, int size)
       
   892 {
       
   893     m_impl->uniform1fv(location, size, v);
       
   894 }
       
   895 
       
   896 DELEGATE_TO_IMPL_2(uniform1i, long, int)
       
   897 
       
   898 void GraphicsContext3DInternal::uniform1iv(long location, int* v, int size)
       
   899 {
       
   900     m_impl->uniform1iv(location, size, v);
       
   901 }
       
   902 
       
   903 DELEGATE_TO_IMPL_3(uniform2f, long, float, float)
       
   904 
       
   905 void GraphicsContext3DInternal::uniform2fv(long location, float* v, int size)
       
   906 {
       
   907     m_impl->uniform2fv(location, size, v);
       
   908 }
       
   909 
       
   910 DELEGATE_TO_IMPL_3(uniform2i, long, int, int)
       
   911 
       
   912 void GraphicsContext3DInternal::uniform2iv(long location, int* v, int size)
       
   913 {
       
   914     m_impl->uniform2iv(location, size, v);
       
   915 }
       
   916 
       
   917 DELEGATE_TO_IMPL_4(uniform3f, long, float, float, float)
       
   918 
       
   919 void GraphicsContext3DInternal::uniform3fv(long location, float* v, int size)
       
   920 {
       
   921     m_impl->uniform3fv(location, size, v);
       
   922 }
       
   923 
       
   924 DELEGATE_TO_IMPL_4(uniform3i, long, int, int, int)
       
   925 
       
   926 void GraphicsContext3DInternal::uniform3iv(long location, int* v, int size)
       
   927 {
       
   928     m_impl->uniform3iv(location, size, v);
       
   929 }
       
   930 
       
   931 DELEGATE_TO_IMPL_5(uniform4f, long, float, float, float, float)
       
   932 
       
   933 void GraphicsContext3DInternal::uniform4fv(long location, float* v, int size)
       
   934 {
       
   935     m_impl->uniform4fv(location, size, v);
       
   936 }
       
   937 
       
   938 DELEGATE_TO_IMPL_5(uniform4i, long, int, int, int, int)
       
   939 
       
   940 void GraphicsContext3DInternal::uniform4iv(long location, int* v, int size)
       
   941 {
       
   942     m_impl->uniform4iv(location, size, v);
       
   943 }
       
   944 
       
   945 void GraphicsContext3DInternal::uniformMatrix2fv(long location, bool transpose, float* value, int size)
       
   946 {
       
   947     m_impl->uniformMatrix2fv(location, size, transpose, value);
       
   948 }
       
   949 
       
   950 void GraphicsContext3DInternal::uniformMatrix3fv(long location, bool transpose, float* value, int size)
       
   951 {
       
   952     m_impl->uniformMatrix3fv(location, size, transpose, value);
       
   953 }
       
   954 
       
   955 void GraphicsContext3DInternal::uniformMatrix4fv(long location, bool transpose, float* value, int size)
       
   956 {
       
   957     m_impl->uniformMatrix4fv(location, size, transpose, value);
       
   958 }
       
   959 
       
   960 DELEGATE_TO_IMPL_1_X(useProgram, WebGLProgram*)
       
   961 DELEGATE_TO_IMPL_1_X(validateProgram, WebGLProgram*)
       
   962 
       
   963 DELEGATE_TO_IMPL_2(vertexAttrib1f, unsigned long, float)
       
   964 DELEGATE_TO_IMPL_2(vertexAttrib1fv, unsigned long, float*)
       
   965 DELEGATE_TO_IMPL_3(vertexAttrib2f, unsigned long, float, float)
       
   966 DELEGATE_TO_IMPL_2(vertexAttrib2fv, unsigned long, float*)
       
   967 DELEGATE_TO_IMPL_4(vertexAttrib3f, unsigned long, float, float, float)
       
   968 DELEGATE_TO_IMPL_2(vertexAttrib3fv, unsigned long, float*)
       
   969 DELEGATE_TO_IMPL_5(vertexAttrib4f, unsigned long, float, float, float, float)
       
   970 DELEGATE_TO_IMPL_2(vertexAttrib4fv, unsigned long, float*)
       
   971 DELEGATE_TO_IMPL_6(vertexAttribPointer, unsigned long, int, int, bool, unsigned long, unsigned long)
       
   972 
       
   973 DELEGATE_TO_IMPL_4(viewport, long, long, unsigned long, unsigned long)
       
   974 
       
   975 DELEGATE_TO_IMPL_R(createBuffer, unsigned)
       
   976 DELEGATE_TO_IMPL_R(createFramebuffer, unsigned)
       
   977 DELEGATE_TO_IMPL_R(createProgram, unsigned)
       
   978 DELEGATE_TO_IMPL_R(createRenderbuffer, unsigned)
       
   979 DELEGATE_TO_IMPL_1R(createShader, unsigned long, unsigned)
       
   980 DELEGATE_TO_IMPL_R(createTexture, unsigned)
       
   981 
       
   982 DELEGATE_TO_IMPL_1(deleteBuffer, unsigned)
       
   983 DELEGATE_TO_IMPL_1(deleteFramebuffer, unsigned)
       
   984 DELEGATE_TO_IMPL_1(deleteProgram, unsigned)
       
   985 DELEGATE_TO_IMPL_1(deleteRenderbuffer, unsigned)
       
   986 DELEGATE_TO_IMPL_1(deleteShader, unsigned)
       
   987 DELEGATE_TO_IMPL_1(deleteTexture, unsigned)
       
   988 
       
   989 DELEGATE_TO_IMPL_1(synthesizeGLError, unsigned long)
       
   990 
       
   991 //----------------------------------------------------------------------
       
   992 // GraphicsContext3D
       
   993 //
       
   994 
       
   995 // Macros to assist in delegating from GraphicsContext3D to
       
   996 // GraphicsContext3DInternal.
       
   997 
       
   998 #define DELEGATE_TO_INTERNAL(name) \
       
   999 void GraphicsContext3D::name() \
       
  1000 { \
       
  1001     m_internal->name(); \
       
  1002 }
       
  1003 
       
  1004 #define DELEGATE_TO_INTERNAL_R(name, rt)           \
       
  1005 rt GraphicsContext3D::name() \
       
  1006 { \
       
  1007     return m_internal->name(); \
       
  1008 }
       
  1009 
       
  1010 #define DELEGATE_TO_INTERNAL_1(name, t1) \
       
  1011 void GraphicsContext3D::name(t1 a1) \
       
  1012 { \
       
  1013     m_internal->name(a1); \
       
  1014 }
       
  1015 
       
  1016 #define DELEGATE_TO_INTERNAL_1R(name, t1, rt)    \
       
  1017 rt GraphicsContext3D::name(t1 a1) \
       
  1018 { \
       
  1019     return m_internal->name(a1); \
       
  1020 }
       
  1021 
       
  1022 #define DELEGATE_TO_INTERNAL_2(name, t1, t2) \
       
  1023 void GraphicsContext3D::name(t1 a1, t2 a2) \
       
  1024 { \
       
  1025     m_internal->name(a1, a2); \
       
  1026 }
       
  1027 
       
  1028 #define DELEGATE_TO_INTERNAL_2R(name, t1, t2, rt)  \
       
  1029 rt GraphicsContext3D::name(t1 a1, t2 a2) \
       
  1030 { \
       
  1031     return m_internal->name(a1, a2); \
       
  1032 }
       
  1033 
       
  1034 #define DELEGATE_TO_INTERNAL_3(name, t1, t2, t3)   \
       
  1035 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3)    \
       
  1036 { \
       
  1037     m_internal->name(a1, a2, a3);                  \
       
  1038 }
       
  1039 
       
  1040 #define DELEGATE_TO_INTERNAL_3R(name, t1, t2, t3, rt)   \
       
  1041 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3)    \
       
  1042 { \
       
  1043     return m_internal->name(a1, a2, a3);                  \
       
  1044 }
       
  1045 
       
  1046 #define DELEGATE_TO_INTERNAL_4(name, t1, t2, t3, t4)    \
       
  1047 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4)  \
       
  1048 { \
       
  1049     m_internal->name(a1, a2, a3, a4);              \
       
  1050 }
       
  1051 
       
  1052 #define DELEGATE_TO_INTERNAL_5(name, t1, t2, t3, t4, t5)      \
       
  1053 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5)        \
       
  1054 { \
       
  1055     m_internal->name(a1, a2, a3, a4, a5);   \
       
  1056 }
       
  1057 
       
  1058 #define DELEGATE_TO_INTERNAL_6(name, t1, t2, t3, t4, t5, t6)  \
       
  1059 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
       
  1060 { \
       
  1061     m_internal->name(a1, a2, a3, a4, a5, a6);   \
       
  1062 }
       
  1063 
       
  1064 #define DELEGATE_TO_INTERNAL_6R(name, t1, t2, t3, t4, t5, t6, rt)  \
       
  1065 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) \
       
  1066 { \
       
  1067     return m_internal->name(a1, a2, a3, a4, a5, a6);       \
       
  1068 }
       
  1069 
       
  1070 #define DELEGATE_TO_INTERNAL_7(name, t1, t2, t3, t4, t5, t6, t7) \
       
  1071 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
       
  1072 { \
       
  1073     m_internal->name(a1, a2, a3, a4, a5, a6, a7);   \
       
  1074 }
       
  1075 
       
  1076 #define DELEGATE_TO_INTERNAL_7R(name, t1, t2, t3, t4, t5, t6, t7, rt) \
       
  1077 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) \
       
  1078 { \
       
  1079     return m_internal->name(a1, a2, a3, a4, a5, a6, a7);   \
       
  1080 }
       
  1081 
       
  1082 #define DELEGATE_TO_INTERNAL_8(name, t1, t2, t3, t4, t5, t6, t7, t8)       \
       
  1083 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) \
       
  1084 { \
       
  1085     m_internal->name(a1, a2, a3, a4, a5, a6, a7, a8);      \
       
  1086 }
       
  1087 
       
  1088 #define DELEGATE_TO_INTERNAL_9R(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, rt) \
       
  1089 rt GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) \
       
  1090 { \
       
  1091     return m_internal->name(a1, a2, a3, a4, a5, a6, a7, a8, a9);   \
       
  1092 }
       
  1093 
       
  1094 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*)
       
  1095 {
       
  1096 }
       
  1097 
       
  1098 GraphicsContext3D::~GraphicsContext3D()
       
  1099 {
       
  1100 }
       
  1101 
       
  1102 PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
       
  1103 {
       
  1104     GraphicsContext3DInternal* internal = new GraphicsContext3DInternal();
       
  1105     if (!internal->initialize(attrs, hostWindow)) {
       
  1106         delete internal;
       
  1107         return 0;
       
  1108     }
       
  1109     PassOwnPtr<GraphicsContext3D> result = new GraphicsContext3D(attrs, hostWindow);
       
  1110     result->m_internal.set(internal);
       
  1111     return result;
       
  1112 }
       
  1113 
       
  1114 PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const
       
  1115 {
       
  1116     return m_internal->platformGraphicsContext3D();
       
  1117 }
       
  1118 
       
  1119 Platform3DObject GraphicsContext3D::platformTexture() const
       
  1120 {
       
  1121     return m_internal->platformTexture();
       
  1122 }
       
  1123 
       
  1124 void GraphicsContext3D::prepareTexture()
       
  1125 {
       
  1126     return m_internal->prepareTexture();
       
  1127 }
       
  1128 
       
  1129 #if USE(ACCELERATED_COMPOSITING)
       
  1130 PlatformLayer* GraphicsContext3D::platformLayer() const
       
  1131 {
       
  1132     WebGLLayerChromium* webGLLayer = m_internal->platformLayer();
       
  1133     webGLLayer->setContext(this);
       
  1134     return webGLLayer;
       
  1135 }
       
  1136 #endif
       
  1137 
       
  1138 DELEGATE_TO_INTERNAL(makeContextCurrent)
       
  1139 DELEGATE_TO_INTERNAL_1R(sizeInBytes, int, int)
       
  1140 DELEGATE_TO_INTERNAL_2(reshape, int, int)
       
  1141 
       
  1142 DELEGATE_TO_INTERNAL_1(activeTexture, unsigned long)
       
  1143 DELEGATE_TO_INTERNAL_2(attachShader, WebGLProgram*, WebGLShader*)
       
  1144 DELEGATE_TO_INTERNAL_3(bindAttribLocation, WebGLProgram*, unsigned long, const String&)
       
  1145 
       
  1146 DELEGATE_TO_INTERNAL_2(bindBuffer, unsigned long, WebGLBuffer*)
       
  1147 DELEGATE_TO_INTERNAL_2(bindFramebuffer, unsigned long, WebGLFramebuffer*)
       
  1148 DELEGATE_TO_INTERNAL_2(bindRenderbuffer, unsigned long, WebGLRenderbuffer*)
       
  1149 DELEGATE_TO_INTERNAL_2(bindTexture, unsigned long, WebGLTexture*)
       
  1150 DELEGATE_TO_INTERNAL_4(blendColor, double, double, double, double)
       
  1151 DELEGATE_TO_INTERNAL_1(blendEquation, unsigned long)
       
  1152 DELEGATE_TO_INTERNAL_2(blendEquationSeparate, unsigned long, unsigned long)
       
  1153 DELEGATE_TO_INTERNAL_2(blendFunc, unsigned long, unsigned long)
       
  1154 DELEGATE_TO_INTERNAL_4(blendFuncSeparate, unsigned long, unsigned long, unsigned long, unsigned long)
       
  1155 
       
  1156 DELEGATE_TO_INTERNAL_3(bufferData, unsigned long, int, unsigned long)
       
  1157 DELEGATE_TO_INTERNAL_3(bufferData, unsigned long, ArrayBuffer*, unsigned long)
       
  1158 DELEGATE_TO_INTERNAL_3(bufferData, unsigned long, ArrayBufferView*, unsigned long)
       
  1159 DELEGATE_TO_INTERNAL_3(bufferSubData, unsigned long, long, ArrayBuffer*)
       
  1160 DELEGATE_TO_INTERNAL_3(bufferSubData, unsigned long, long, ArrayBufferView*)
       
  1161 
       
  1162 DELEGATE_TO_INTERNAL_1R(checkFramebufferStatus, unsigned long, unsigned long)
       
  1163 DELEGATE_TO_INTERNAL_1(clear, unsigned long)
       
  1164 DELEGATE_TO_INTERNAL_4(clearColor, double, double, double, double)
       
  1165 DELEGATE_TO_INTERNAL_1(clearDepth, double)
       
  1166 DELEGATE_TO_INTERNAL_1(clearStencil, long)
       
  1167 DELEGATE_TO_INTERNAL_4(colorMask, bool, bool, bool, bool)
       
  1168 DELEGATE_TO_INTERNAL_1(compileShader, WebGLShader*)
       
  1169 
       
  1170 DELEGATE_TO_INTERNAL_8(copyTexImage2D, unsigned long, long, unsigned long, long, long, unsigned long, unsigned long, long)
       
  1171 DELEGATE_TO_INTERNAL_8(copyTexSubImage2D, unsigned long, long, long, long, long, long, unsigned long, unsigned long)
       
  1172 DELEGATE_TO_INTERNAL_1(cullFace, unsigned long)
       
  1173 DELEGATE_TO_INTERNAL_1(depthFunc, unsigned long)
       
  1174 DELEGATE_TO_INTERNAL_1(depthMask, bool)
       
  1175 DELEGATE_TO_INTERNAL_2(depthRange, double, double)
       
  1176 DELEGATE_TO_INTERNAL_2(detachShader, WebGLProgram*, WebGLShader*)
       
  1177 DELEGATE_TO_INTERNAL_1(disable, unsigned long)
       
  1178 DELEGATE_TO_INTERNAL_1(disableVertexAttribArray, unsigned long)
       
  1179 DELEGATE_TO_INTERNAL_3(drawArrays, unsigned long, long, long)
       
  1180 DELEGATE_TO_INTERNAL_4(drawElements, unsigned long, unsigned long, unsigned long, long)
       
  1181 
       
  1182 DELEGATE_TO_INTERNAL_1(enable, unsigned long)
       
  1183 DELEGATE_TO_INTERNAL_1(enableVertexAttribArray, unsigned long)
       
  1184 DELEGATE_TO_INTERNAL(finish)
       
  1185 DELEGATE_TO_INTERNAL(flush)
       
  1186 DELEGATE_TO_INTERNAL_4(framebufferRenderbuffer, unsigned long, unsigned long, unsigned long, WebGLRenderbuffer*)
       
  1187 DELEGATE_TO_INTERNAL_5(framebufferTexture2D, unsigned long, unsigned long, unsigned long, WebGLTexture*, long)
       
  1188 DELEGATE_TO_INTERNAL_1(frontFace, unsigned long)
       
  1189 DELEGATE_TO_INTERNAL_1(generateMipmap, unsigned long)
       
  1190 
       
  1191 DELEGATE_TO_INTERNAL_3R(getActiveAttrib, WebGLProgram*, unsigned long, ActiveInfo&, bool)
       
  1192 DELEGATE_TO_INTERNAL_3R(getActiveUniform, WebGLProgram*, unsigned long, ActiveInfo&, bool)
       
  1193 
       
  1194 DELEGATE_TO_INTERNAL_4(getAttachedShaders, WebGLProgram*, int, int*, unsigned int*)
       
  1195 
       
  1196 DELEGATE_TO_INTERNAL_2R(getAttribLocation, WebGLProgram*, const String&, int)
       
  1197 
       
  1198 DELEGATE_TO_INTERNAL_2(getBooleanv, unsigned long, unsigned char*)
       
  1199 
       
  1200 DELEGATE_TO_INTERNAL_3(getBufferParameteriv, unsigned long, unsigned long, int*)
       
  1201 
       
  1202 DELEGATE_TO_INTERNAL_R(getContextAttributes, GraphicsContext3D::Attributes)
       
  1203 
       
  1204 DELEGATE_TO_INTERNAL_R(getError, unsigned long)
       
  1205 
       
  1206 DELEGATE_TO_INTERNAL_2(getFloatv, unsigned long, float*)
       
  1207 
       
  1208 DELEGATE_TO_INTERNAL_4(getFramebufferAttachmentParameteriv, unsigned long, unsigned long, unsigned long, int*)
       
  1209 
       
  1210 DELEGATE_TO_INTERNAL_2(getIntegerv, unsigned long, int*)
       
  1211 
       
  1212 DELEGATE_TO_INTERNAL_3(getProgramiv, WebGLProgram*, unsigned long, int*)
       
  1213 
       
  1214 DELEGATE_TO_INTERNAL_1R(getProgramInfoLog, WebGLProgram*, String)
       
  1215 
       
  1216 DELEGATE_TO_INTERNAL_3(getRenderbufferParameteriv, unsigned long, unsigned long, int*)
       
  1217 
       
  1218 DELEGATE_TO_INTERNAL_3(getShaderiv, WebGLShader*, unsigned long, int*)
       
  1219 
       
  1220 DELEGATE_TO_INTERNAL_1R(getShaderInfoLog, WebGLShader*, String)
       
  1221 
       
  1222 DELEGATE_TO_INTERNAL_1R(getShaderSource, WebGLShader*, String)
       
  1223 DELEGATE_TO_INTERNAL_1R(getString, unsigned long, String)
       
  1224 
       
  1225 DELEGATE_TO_INTERNAL_3(getTexParameterfv, unsigned long, unsigned long, float*)
       
  1226 DELEGATE_TO_INTERNAL_3(getTexParameteriv, unsigned long, unsigned long, int*)
       
  1227 
       
  1228 DELEGATE_TO_INTERNAL_3(getUniformfv, WebGLProgram*, long, float*)
       
  1229 DELEGATE_TO_INTERNAL_3(getUniformiv, WebGLProgram*, long, int*)
       
  1230 
       
  1231 DELEGATE_TO_INTERNAL_2R(getUniformLocation, WebGLProgram*, const String&, long)
       
  1232 
       
  1233 DELEGATE_TO_INTERNAL_3(getVertexAttribfv, unsigned long, unsigned long, float*)
       
  1234 DELEGATE_TO_INTERNAL_3(getVertexAttribiv, unsigned long, unsigned long, int*)
       
  1235 
       
  1236 DELEGATE_TO_INTERNAL_2R(getVertexAttribOffset, unsigned long, unsigned long, long)
       
  1237 
       
  1238 DELEGATE_TO_INTERNAL_2(hint, unsigned long, unsigned long)
       
  1239 DELEGATE_TO_INTERNAL_1R(isBuffer, WebGLBuffer*, bool)
       
  1240 DELEGATE_TO_INTERNAL_1R(isEnabled, unsigned long, bool)
       
  1241 DELEGATE_TO_INTERNAL_1R(isFramebuffer, WebGLFramebuffer*, bool)
       
  1242 DELEGATE_TO_INTERNAL_1R(isProgram, WebGLProgram*, bool)
       
  1243 DELEGATE_TO_INTERNAL_1R(isRenderbuffer, WebGLRenderbuffer*, bool)
       
  1244 DELEGATE_TO_INTERNAL_1R(isShader, WebGLShader*, bool)
       
  1245 DELEGATE_TO_INTERNAL_1R(isTexture, WebGLTexture*, bool)
       
  1246 DELEGATE_TO_INTERNAL_1(lineWidth, double)
       
  1247 DELEGATE_TO_INTERNAL_1(linkProgram, WebGLProgram*)
       
  1248 DELEGATE_TO_INTERNAL_2(pixelStorei, unsigned long, long)
       
  1249 DELEGATE_TO_INTERNAL_2(polygonOffset, double, double)
       
  1250 
       
  1251 DELEGATE_TO_INTERNAL_7(readPixels, long, long, unsigned long, unsigned long, unsigned long, unsigned long, void*)
       
  1252 
       
  1253 DELEGATE_TO_INTERNAL(releaseShaderCompiler)
       
  1254 DELEGATE_TO_INTERNAL_4(renderbufferStorage, unsigned long, unsigned long, unsigned long, unsigned long)
       
  1255 DELEGATE_TO_INTERNAL_2(sampleCoverage, double, bool)
       
  1256 DELEGATE_TO_INTERNAL_4(scissor, long, long, unsigned long, unsigned long)
       
  1257 DELEGATE_TO_INTERNAL_2(shaderSource, WebGLShader*, const String&)
       
  1258 DELEGATE_TO_INTERNAL_3(stencilFunc, unsigned long, long, unsigned long)
       
  1259 DELEGATE_TO_INTERNAL_4(stencilFuncSeparate, unsigned long, unsigned long, long, unsigned long)
       
  1260 DELEGATE_TO_INTERNAL_1(stencilMask, unsigned long)
       
  1261 DELEGATE_TO_INTERNAL_2(stencilMaskSeparate, unsigned long, unsigned long)
       
  1262 DELEGATE_TO_INTERNAL_3(stencilOp, unsigned long, unsigned long, unsigned long)
       
  1263 DELEGATE_TO_INTERNAL_4(stencilOpSeparate, unsigned long, unsigned long, unsigned long, unsigned long)
       
  1264 
       
  1265 DELEGATE_TO_INTERNAL_9R(texImage2D, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, void*, int)
       
  1266 DELEGATE_TO_INTERNAL_3(texParameterf, unsigned, unsigned, float)
       
  1267 DELEGATE_TO_INTERNAL_3(texParameteri, unsigned, unsigned, int)
       
  1268 DELEGATE_TO_INTERNAL_9R(texSubImage2D, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, void*, int)
       
  1269 
       
  1270 DELEGATE_TO_INTERNAL_2(uniform1f, long, float)
       
  1271 DELEGATE_TO_INTERNAL_3(uniform1fv, long, float*, int)
       
  1272 DELEGATE_TO_INTERNAL_2(uniform1i, long, int)
       
  1273 DELEGATE_TO_INTERNAL_3(uniform1iv, long, int*, int)
       
  1274 DELEGATE_TO_INTERNAL_3(uniform2f, long, float, float)
       
  1275 DELEGATE_TO_INTERNAL_3(uniform2fv, long, float*, int)
       
  1276 DELEGATE_TO_INTERNAL_3(uniform2i, long, int, int)
       
  1277 DELEGATE_TO_INTERNAL_3(uniform2iv, long, int*, int)
       
  1278 DELEGATE_TO_INTERNAL_4(uniform3f, long, float, float, float)
       
  1279 DELEGATE_TO_INTERNAL_3(uniform3fv, long, float*, int)
       
  1280 DELEGATE_TO_INTERNAL_4(uniform3i, long, int, int, int)
       
  1281 DELEGATE_TO_INTERNAL_3(uniform3iv, long, int*, int)
       
  1282 DELEGATE_TO_INTERNAL_5(uniform4f, long, float, float, float, float)
       
  1283 DELEGATE_TO_INTERNAL_3(uniform4fv, long, float*, int)
       
  1284 DELEGATE_TO_INTERNAL_5(uniform4i, long, int, int, int, int)
       
  1285 DELEGATE_TO_INTERNAL_3(uniform4iv, long, int*, int)
       
  1286 DELEGATE_TO_INTERNAL_4(uniformMatrix2fv, long, bool, float*, int)
       
  1287 DELEGATE_TO_INTERNAL_4(uniformMatrix3fv, long, bool, float*, int)
       
  1288 DELEGATE_TO_INTERNAL_4(uniformMatrix4fv, long, bool, float*, int)
       
  1289 
       
  1290 DELEGATE_TO_INTERNAL_1(useProgram, WebGLProgram*)
       
  1291 DELEGATE_TO_INTERNAL_1(validateProgram, WebGLProgram*)
       
  1292 
       
  1293 DELEGATE_TO_INTERNAL_2(vertexAttrib1f, unsigned long, float)
       
  1294 DELEGATE_TO_INTERNAL_2(vertexAttrib1fv, unsigned long, float*)
       
  1295 DELEGATE_TO_INTERNAL_3(vertexAttrib2f, unsigned long, float, float)
       
  1296 DELEGATE_TO_INTERNAL_2(vertexAttrib2fv, unsigned long, float*)
       
  1297 DELEGATE_TO_INTERNAL_4(vertexAttrib3f, unsigned long, float, float, float)
       
  1298 DELEGATE_TO_INTERNAL_2(vertexAttrib3fv, unsigned long, float*)
       
  1299 DELEGATE_TO_INTERNAL_5(vertexAttrib4f, unsigned long, float, float, float, float)
       
  1300 DELEGATE_TO_INTERNAL_2(vertexAttrib4fv, unsigned long, float*)
       
  1301 DELEGATE_TO_INTERNAL_6(vertexAttribPointer, unsigned long, int, int, bool, unsigned long, unsigned long)
       
  1302 
       
  1303 DELEGATE_TO_INTERNAL_4(viewport, long, long, unsigned long, unsigned long)
       
  1304 
       
  1305 DELEGATE_TO_INTERNAL_1(paintRenderingResultsToCanvas, WebGLRenderingContext*)
       
  1306 DELEGATE_TO_INTERNAL_1(beginPaint, WebGLRenderingContext*)
       
  1307 DELEGATE_TO_INTERNAL(endPaint)
       
  1308 
       
  1309 DELEGATE_TO_INTERNAL_R(createBuffer, unsigned)
       
  1310 DELEGATE_TO_INTERNAL_R(createFramebuffer, unsigned)
       
  1311 DELEGATE_TO_INTERNAL_R(createProgram, unsigned)
       
  1312 DELEGATE_TO_INTERNAL_R(createRenderbuffer, unsigned)
       
  1313 DELEGATE_TO_INTERNAL_1R(createShader, unsigned long, unsigned)
       
  1314 DELEGATE_TO_INTERNAL_R(createTexture, unsigned)
       
  1315 
       
  1316 DELEGATE_TO_INTERNAL_1(deleteBuffer, unsigned)
       
  1317 DELEGATE_TO_INTERNAL_1(deleteFramebuffer, unsigned)
       
  1318 DELEGATE_TO_INTERNAL_1(deleteProgram, unsigned)
       
  1319 DELEGATE_TO_INTERNAL_1(deleteRenderbuffer, unsigned)
       
  1320 DELEGATE_TO_INTERNAL_1(deleteShader, unsigned)
       
  1321 DELEGATE_TO_INTERNAL_1(deleteTexture, unsigned)
       
  1322 
       
  1323 DELEGATE_TO_INTERNAL_1(synthesizeGLError, unsigned long)
       
  1324 
       
  1325 bool GraphicsContext3D::isGLES2Compliant() const
       
  1326 {
       
  1327     return m_internal->isGLES2Compliant();
       
  1328 }
       
  1329 
       
  1330 } // namespace WebCore
       
  1331 
       
  1332 #endif // ENABLE(3D_CANVAS)