Changeset 66783 in webkit


Ignore:
Timestamp:
Sep 3, 2010 6:15:52 PM (14 years ago)
Author:
jamesr@google.com
Message:

2010-09-03 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r66781.
http://trac.webkit.org/changeset/66781
https://bugs.webkit.org/show_bug.cgi?id=45220

Breaks the build. Adds a mac-specific file to
platform/graphics without #if PLATFORM() guards and changes
the GraphicsContext3D interface without updating all
implementations (Requested by jamesr on #webkit).

  • WebCore.gypi:
  • WebCore.xcodeproj/project.pbxproj:
  • html/canvas/WebGLObject.cpp: (WebCore::WebGLObject::deleteObject):
  • platform/graphics/ANGLEWebKitBridge.h:
  • platform/graphics/GraphicsContext3D.h:
  • platform/graphics/GraphicsContext3DOpenGL.cpp: Removed.
  • platform/graphics/mac/GraphicsContext3DMac.mm: (WebCore::GraphicsContext3D::validateAttributes): (WebCore::GraphicsContext3D::makeContextCurrent): (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas): (WebCore::GraphicsContext3D::reshape): (WebCore::ensureContext): (WebCore::GraphicsContext3D::prepareTexture): (WebCore::GraphicsContext3D::activeTexture): (WebCore::GraphicsContext3D::attachShader): (WebCore::GraphicsContext3D::bindAttribLocation): (WebCore::GraphicsContext3D::bindBuffer): (WebCore::GraphicsContext3D::bindFramebuffer): (WebCore::GraphicsContext3D::bindRenderbuffer): (WebCore::GraphicsContext3D::bindTexture): (WebCore::GraphicsContext3D::blendColor): (WebCore::GraphicsContext3D::blendEquation): (WebCore::GraphicsContext3D::blendEquationSeparate): (WebCore::GraphicsContext3D::blendFunc): (WebCore::GraphicsContext3D::blendFuncSeparate): (WebCore::GraphicsContext3D::bufferData): (WebCore::GraphicsContext3D::bufferSubData): (WebCore::GraphicsContext3D::checkFramebufferStatus): (WebCore::GraphicsContext3D::clearColor): (WebCore::GraphicsContext3D::clear): (WebCore::GraphicsContext3D::clearDepth): (WebCore::GraphicsContext3D::clearStencil): (WebCore::GraphicsContext3D::colorMask): (WebCore::GraphicsContext3D::compileShader): (WebCore::GraphicsContext3D::copyTexImage2D): (WebCore::GraphicsContext3D::copyTexSubImage2D): (WebCore::GraphicsContext3D::cullFace): (WebCore::GraphicsContext3D::depthFunc): (WebCore::GraphicsContext3D::depthMask): (WebCore::GraphicsContext3D::depthRange): (WebCore::GraphicsContext3D::detachShader): (WebCore::GraphicsContext3D::disable): (WebCore::GraphicsContext3D::disableVertexAttribArray): (WebCore::GraphicsContext3D::drawArrays): (WebCore::GraphicsContext3D::drawElements): (WebCore::GraphicsContext3D::enable): (WebCore::GraphicsContext3D::enableVertexAttribArray): (WebCore::GraphicsContext3D::finish): (WebCore::GraphicsContext3D::flush): (WebCore::GraphicsContext3D::framebufferRenderbuffer): (WebCore::GraphicsContext3D::framebufferTexture2D): (WebCore::GraphicsContext3D::frontFace): (WebCore::GraphicsContext3D::generateMipmap): (WebCore::GraphicsContext3D::getActiveAttrib): (WebCore::GraphicsContext3D::getActiveUniform): (WebCore::GraphicsContext3D::getAttachedShaders): (WebCore::GraphicsContext3D::getAttribLocation): (WebCore::GraphicsContext3D::getContextAttributes): (WebCore::GraphicsContext3D::getError): (WebCore::GraphicsContext3D::getString): (WebCore::GraphicsContext3D::hint): (WebCore::GraphicsContext3D::isBuffer): (WebCore::GraphicsContext3D::isEnabled): (WebCore::GraphicsContext3D::isFramebuffer): (WebCore::GraphicsContext3D::isProgram): (WebCore::GraphicsContext3D::isRenderbuffer): (WebCore::GraphicsContext3D::isShader): (WebCore::GraphicsContext3D::isTexture): (WebCore::GraphicsContext3D::lineWidth): (WebCore::GraphicsContext3D::linkProgram): (WebCore::GraphicsContext3D::pixelStorei): (WebCore::GraphicsContext3D::polygonOffset): (WebCore::GraphicsContext3D::readPixels): (WebCore::GraphicsContext3D::releaseShaderCompiler): (WebCore::GraphicsContext3D::renderbufferStorage): (WebCore::GraphicsContext3D::sampleCoverage): (WebCore::GraphicsContext3D::scissor): (WebCore::GraphicsContext3D::shaderSource): (WebCore::GraphicsContext3D::stencilFunc): (WebCore::GraphicsContext3D::stencilFuncSeparate): (WebCore::GraphicsContext3D::stencilMask): (WebCore::GraphicsContext3D::stencilMaskSeparate): (WebCore::GraphicsContext3D::stencilOp): (WebCore::GraphicsContext3D::stencilOpSeparate): (WebCore::GraphicsContext3D::texParameterf): (WebCore::GraphicsContext3D::texParameteri): (WebCore::GraphicsContext3D::uniform1f): (WebCore::GraphicsContext3D::uniform1fv): (WebCore::GraphicsContext3D::uniform2f): (WebCore::GraphicsContext3D::uniform2fv): (WebCore::GraphicsContext3D::uniform3f): (WebCore::GraphicsContext3D::uniform3fv): (WebCore::GraphicsContext3D::uniform4f): (WebCore::GraphicsContext3D::uniform4fv): (WebCore::GraphicsContext3D::uniform1i): (WebCore::GraphicsContext3D::uniform1iv): (WebCore::GraphicsContext3D::uniform2i): (WebCore::GraphicsContext3D::uniform2iv): (WebCore::GraphicsContext3D::uniform3i): (WebCore::GraphicsContext3D::uniform3iv): (WebCore::GraphicsContext3D::uniform4i): (WebCore::GraphicsContext3D::uniform4iv): (WebCore::GraphicsContext3D::uniformMatrix2fv): (WebCore::GraphicsContext3D::uniformMatrix3fv): (WebCore::GraphicsContext3D::uniformMatrix4fv): (WebCore::GraphicsContext3D::useProgram): (WebCore::GraphicsContext3D::validateProgram): (WebCore::GraphicsContext3D::vertexAttrib1f): (WebCore::GraphicsContext3D::vertexAttrib1fv): (WebCore::GraphicsContext3D::vertexAttrib2f): (WebCore::GraphicsContext3D::vertexAttrib2fv): (WebCore::GraphicsContext3D::vertexAttrib3f): (WebCore::GraphicsContext3D::vertexAttrib3fv): (WebCore::GraphicsContext3D::vertexAttrib4f): (WebCore::GraphicsContext3D::vertexAttrib4fv): (WebCore::GraphicsContext3D::vertexAttribPointer): (WebCore::GraphicsContext3D::viewport): (WebCore::GraphicsContext3D::getBooleanv): (WebCore::GraphicsContext3D::getBufferParameteriv): (WebCore::GraphicsContext3D::getFloatv): (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv): (WebCore::GraphicsContext3D::getIntegerv): (WebCore::GraphicsContext3D::getProgramiv): (WebCore::GraphicsContext3D::getProgramInfoLog): (WebCore::GraphicsContext3D::getRenderbufferParameteriv): (WebCore::GraphicsContext3D::getShaderiv): (WebCore::GraphicsContext3D::getShaderInfoLog): (WebCore::GraphicsContext3D::getShaderSource): (WebCore::GraphicsContext3D::getTexParameterfv): (WebCore::GraphicsContext3D::getTexParameteriv): (WebCore::GraphicsContext3D::getUniformfv): (WebCore::GraphicsContext3D::getUniformiv): (WebCore::GraphicsContext3D::getUniformLocation): (WebCore::GraphicsContext3D::getVertexAttribfv): (WebCore::GraphicsContext3D::getVertexAttribiv): (WebCore::GraphicsContext3D::getVertexAttribOffset): (WebCore::GraphicsContext3D::texImage2D): (WebCore::GraphicsContext3D::texSubImage2D): (WebCore::GraphicsContext3D::createBuffer): (WebCore::GraphicsContext3D::createFramebuffer): (WebCore::GraphicsContext3D::createProgram): (WebCore::GraphicsContext3D::createRenderbuffer): (WebCore::GraphicsContext3D::createShader): (WebCore::GraphicsContext3D::createTexture): (WebCore::GraphicsContext3D::deleteBuffer): (WebCore::GraphicsContext3D::deleteFramebuffer): (WebCore::GraphicsContext3D::deleteProgram): (WebCore::GraphicsContext3D::deleteRenderbuffer): (WebCore::GraphicsContext3D::deleteShader): (WebCore::GraphicsContext3D::deleteTexture): (WebCore::GraphicsContext3D::sizeInBytes): (WebCore::GraphicsContext3D::synthesizeGLError):
Location:
trunk/WebCore
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66782 r66783  
     12010-09-03  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r66781.
     4        http://trac.webkit.org/changeset/66781
     5        https://bugs.webkit.org/show_bug.cgi?id=45220
     6
     7        Breaks the build. Adds a mac-specific file to
     8        platform/graphics without #if PLATFORM() guards and changes
     9        the GraphicsContext3D interface without updating all
     10        implementations (Requested by jamesr on #webkit).
     11
     12        * WebCore.gypi:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        * html/canvas/WebGLObject.cpp:
     15        (WebCore::WebGLObject::deleteObject):
     16        * platform/graphics/ANGLEWebKitBridge.h:
     17        * platform/graphics/GraphicsContext3D.h:
     18        * platform/graphics/GraphicsContext3DOpenGL.cpp: Removed.
     19        * platform/graphics/mac/GraphicsContext3DMac.mm:
     20        (WebCore::GraphicsContext3D::validateAttributes):
     21        (WebCore::GraphicsContext3D::makeContextCurrent):
     22        (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
     23        (WebCore::GraphicsContext3D::reshape):
     24        (WebCore::ensureContext):
     25        (WebCore::GraphicsContext3D::prepareTexture):
     26        (WebCore::GraphicsContext3D::activeTexture):
     27        (WebCore::GraphicsContext3D::attachShader):
     28        (WebCore::GraphicsContext3D::bindAttribLocation):
     29        (WebCore::GraphicsContext3D::bindBuffer):
     30        (WebCore::GraphicsContext3D::bindFramebuffer):
     31        (WebCore::GraphicsContext3D::bindRenderbuffer):
     32        (WebCore::GraphicsContext3D::bindTexture):
     33        (WebCore::GraphicsContext3D::blendColor):
     34        (WebCore::GraphicsContext3D::blendEquation):
     35        (WebCore::GraphicsContext3D::blendEquationSeparate):
     36        (WebCore::GraphicsContext3D::blendFunc):
     37        (WebCore::GraphicsContext3D::blendFuncSeparate):
     38        (WebCore::GraphicsContext3D::bufferData):
     39        (WebCore::GraphicsContext3D::bufferSubData):
     40        (WebCore::GraphicsContext3D::checkFramebufferStatus):
     41        (WebCore::GraphicsContext3D::clearColor):
     42        (WebCore::GraphicsContext3D::clear):
     43        (WebCore::GraphicsContext3D::clearDepth):
     44        (WebCore::GraphicsContext3D::clearStencil):
     45        (WebCore::GraphicsContext3D::colorMask):
     46        (WebCore::GraphicsContext3D::compileShader):
     47        (WebCore::GraphicsContext3D::copyTexImage2D):
     48        (WebCore::GraphicsContext3D::copyTexSubImage2D):
     49        (WebCore::GraphicsContext3D::cullFace):
     50        (WebCore::GraphicsContext3D::depthFunc):
     51        (WebCore::GraphicsContext3D::depthMask):
     52        (WebCore::GraphicsContext3D::depthRange):
     53        (WebCore::GraphicsContext3D::detachShader):
     54        (WebCore::GraphicsContext3D::disable):
     55        (WebCore::GraphicsContext3D::disableVertexAttribArray):
     56        (WebCore::GraphicsContext3D::drawArrays):
     57        (WebCore::GraphicsContext3D::drawElements):
     58        (WebCore::GraphicsContext3D::enable):
     59        (WebCore::GraphicsContext3D::enableVertexAttribArray):
     60        (WebCore::GraphicsContext3D::finish):
     61        (WebCore::GraphicsContext3D::flush):
     62        (WebCore::GraphicsContext3D::framebufferRenderbuffer):
     63        (WebCore::GraphicsContext3D::framebufferTexture2D):
     64        (WebCore::GraphicsContext3D::frontFace):
     65        (WebCore::GraphicsContext3D::generateMipmap):
     66        (WebCore::GraphicsContext3D::getActiveAttrib):
     67        (WebCore::GraphicsContext3D::getActiveUniform):
     68        (WebCore::GraphicsContext3D::getAttachedShaders):
     69        (WebCore::GraphicsContext3D::getAttribLocation):
     70        (WebCore::GraphicsContext3D::getContextAttributes):
     71        (WebCore::GraphicsContext3D::getError):
     72        (WebCore::GraphicsContext3D::getString):
     73        (WebCore::GraphicsContext3D::hint):
     74        (WebCore::GraphicsContext3D::isBuffer):
     75        (WebCore::GraphicsContext3D::isEnabled):
     76        (WebCore::GraphicsContext3D::isFramebuffer):
     77        (WebCore::GraphicsContext3D::isProgram):
     78        (WebCore::GraphicsContext3D::isRenderbuffer):
     79        (WebCore::GraphicsContext3D::isShader):
     80        (WebCore::GraphicsContext3D::isTexture):
     81        (WebCore::GraphicsContext3D::lineWidth):
     82        (WebCore::GraphicsContext3D::linkProgram):
     83        (WebCore::GraphicsContext3D::pixelStorei):
     84        (WebCore::GraphicsContext3D::polygonOffset):
     85        (WebCore::GraphicsContext3D::readPixels):
     86        (WebCore::GraphicsContext3D::releaseShaderCompiler):
     87        (WebCore::GraphicsContext3D::renderbufferStorage):
     88        (WebCore::GraphicsContext3D::sampleCoverage):
     89        (WebCore::GraphicsContext3D::scissor):
     90        (WebCore::GraphicsContext3D::shaderSource):
     91        (WebCore::GraphicsContext3D::stencilFunc):
     92        (WebCore::GraphicsContext3D::stencilFuncSeparate):
     93        (WebCore::GraphicsContext3D::stencilMask):
     94        (WebCore::GraphicsContext3D::stencilMaskSeparate):
     95        (WebCore::GraphicsContext3D::stencilOp):
     96        (WebCore::GraphicsContext3D::stencilOpSeparate):
     97        (WebCore::GraphicsContext3D::texParameterf):
     98        (WebCore::GraphicsContext3D::texParameteri):
     99        (WebCore::GraphicsContext3D::uniform1f):
     100        (WebCore::GraphicsContext3D::uniform1fv):
     101        (WebCore::GraphicsContext3D::uniform2f):
     102        (WebCore::GraphicsContext3D::uniform2fv):
     103        (WebCore::GraphicsContext3D::uniform3f):
     104        (WebCore::GraphicsContext3D::uniform3fv):
     105        (WebCore::GraphicsContext3D::uniform4f):
     106        (WebCore::GraphicsContext3D::uniform4fv):
     107        (WebCore::GraphicsContext3D::uniform1i):
     108        (WebCore::GraphicsContext3D::uniform1iv):
     109        (WebCore::GraphicsContext3D::uniform2i):
     110        (WebCore::GraphicsContext3D::uniform2iv):
     111        (WebCore::GraphicsContext3D::uniform3i):
     112        (WebCore::GraphicsContext3D::uniform3iv):
     113        (WebCore::GraphicsContext3D::uniform4i):
     114        (WebCore::GraphicsContext3D::uniform4iv):
     115        (WebCore::GraphicsContext3D::uniformMatrix2fv):
     116        (WebCore::GraphicsContext3D::uniformMatrix3fv):
     117        (WebCore::GraphicsContext3D::uniformMatrix4fv):
     118        (WebCore::GraphicsContext3D::useProgram):
     119        (WebCore::GraphicsContext3D::validateProgram):
     120        (WebCore::GraphicsContext3D::vertexAttrib1f):
     121        (WebCore::GraphicsContext3D::vertexAttrib1fv):
     122        (WebCore::GraphicsContext3D::vertexAttrib2f):
     123        (WebCore::GraphicsContext3D::vertexAttrib2fv):
     124        (WebCore::GraphicsContext3D::vertexAttrib3f):
     125        (WebCore::GraphicsContext3D::vertexAttrib3fv):
     126        (WebCore::GraphicsContext3D::vertexAttrib4f):
     127        (WebCore::GraphicsContext3D::vertexAttrib4fv):
     128        (WebCore::GraphicsContext3D::vertexAttribPointer):
     129        (WebCore::GraphicsContext3D::viewport):
     130        (WebCore::GraphicsContext3D::getBooleanv):
     131        (WebCore::GraphicsContext3D::getBufferParameteriv):
     132        (WebCore::GraphicsContext3D::getFloatv):
     133        (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv):
     134        (WebCore::GraphicsContext3D::getIntegerv):
     135        (WebCore::GraphicsContext3D::getProgramiv):
     136        (WebCore::GraphicsContext3D::getProgramInfoLog):
     137        (WebCore::GraphicsContext3D::getRenderbufferParameteriv):
     138        (WebCore::GraphicsContext3D::getShaderiv):
     139        (WebCore::GraphicsContext3D::getShaderInfoLog):
     140        (WebCore::GraphicsContext3D::getShaderSource):
     141        (WebCore::GraphicsContext3D::getTexParameterfv):
     142        (WebCore::GraphicsContext3D::getTexParameteriv):
     143        (WebCore::GraphicsContext3D::getUniformfv):
     144        (WebCore::GraphicsContext3D::getUniformiv):
     145        (WebCore::GraphicsContext3D::getUniformLocation):
     146        (WebCore::GraphicsContext3D::getVertexAttribfv):
     147        (WebCore::GraphicsContext3D::getVertexAttribiv):
     148        (WebCore::GraphicsContext3D::getVertexAttribOffset):
     149        (WebCore::GraphicsContext3D::texImage2D):
     150        (WebCore::GraphicsContext3D::texSubImage2D):
     151        (WebCore::GraphicsContext3D::createBuffer):
     152        (WebCore::GraphicsContext3D::createFramebuffer):
     153        (WebCore::GraphicsContext3D::createProgram):
     154        (WebCore::GraphicsContext3D::createRenderbuffer):
     155        (WebCore::GraphicsContext3D::createShader):
     156        (WebCore::GraphicsContext3D::createTexture):
     157        (WebCore::GraphicsContext3D::deleteBuffer):
     158        (WebCore::GraphicsContext3D::deleteFramebuffer):
     159        (WebCore::GraphicsContext3D::deleteProgram):
     160        (WebCore::GraphicsContext3D::deleteRenderbuffer):
     161        (WebCore::GraphicsContext3D::deleteShader):
     162        (WebCore::GraphicsContext3D::deleteTexture):
     163        (WebCore::GraphicsContext3D::sizeInBytes):
     164        (WebCore::GraphicsContext3D::synthesizeGLError):
     165
    11662010-09-03  James Robinson  <jamesr@chromium.org>
    2167
  • trunk/WebCore/WebCore.gypi

    r66781 r66783  
    26002600            'platform/graphics/GraphicsContext.h',
    26012601            'platform/graphics/GraphicsContext3D.cpp',
    2602             'platform/graphics/GraphicsContext3DOpenGL.cpp',
    26032602            'platform/graphics/GraphicsContext3D.h',
    26042603            'platform/graphics/GraphicsContextPrivate.h',
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r66781 r66783  
    53705370                FAC12CC41120DA6900DACC36 /* RenderMathMLSubSup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAC12CC21120DA6900DACC36 /* RenderMathMLSubSup.cpp */; };
    53715371                FAC12CC51120DA6900DACC36 /* RenderMathMLSubSup.h in Headers */ = {isa = PBXBuildFile; fileRef = FAC12CC31120DA6900DACC36 /* RenderMathMLSubSup.h */; };
    5372                 FB58CB79122F153800878851 /* GraphicsContext3DOpenGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB58CAEA1228586500878851 /* GraphicsContext3DOpenGL.cpp */; };
    53735372                FE6FD4880F676E5700092873 /* Coordinates.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6FD4850F676E5700092873 /* Coordinates.h */; settings = {ATTRIBUTES = (Private, ); }; };
    53745373                FE6FD48D0F676E9300092873 /* JSCoordinates.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE6FD48B0F676E9300092873 /* JSCoordinates.cpp */; };
     
    1124211241                FAC12CC21120DA6900DACC36 /* RenderMathMLSubSup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLSubSup.cpp; sourceTree = "<group>"; };
    1124311242                FAC12CC31120DA6900DACC36 /* RenderMathMLSubSup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLSubSup.h; sourceTree = "<group>"; };
    11244                 FB58CAEA1228586500878851 /* GraphicsContext3DOpenGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGL.cpp; sourceTree = "<group>"; };
    1124511243                FE49EF970DC51462004266E1 /* DashboardSupportCSSPropertyNames.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DashboardSupportCSSPropertyNames.in; sourceTree = "<group>"; };
    1124611244                FE6FD4850F676E5700092873 /* Coordinates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Coordinates.h; sourceTree = "<group>"; };
     
    1591415912                                6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */,
    1591515913                                49C7B9FB1042D3650009D447 /* GraphicsContext3D.h */,
    15916                                 FB58CAEA1228586500878851 /* GraphicsContext3DOpenGL.cpp */,
    1591715914                                A88FE3330E5EEE87008D8C0F /* GraphicsContextPrivate.h */,
    1591815915                                0F580B090F12A2690051D689 /* GraphicsLayer.cpp */,
     
    2049520492                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
    2049620493                        compatibilityVersion = "Xcode 2.4";
    20497                         developmentRegion = English;
    2049820494                        hasScannedForEncodings = 1;
    2049920495                        knownRegions = (
     
    2290022896                                898785F0122E1E87003AABDA /* JSFileException.cpp in Sources */,
    2290122897                                898785F4122E1EAC003AABDA /* JSFileReaderSync.cpp in Sources */,
    22902                                 FB58CB79122F153800878851 /* GraphicsContext3DOpenGL.cpp in Sources */,
    2290322898                        );
    2290422899                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/html/canvas/WebGLObject.cpp

    r66781 r66783  
    6161    if (m_object) {
    6262        if (m_context) {
    63             m_context->graphicsContext3D()->ensureContext();
     63            m_context->graphicsContext3D()->makeContextCurrent();
    6464            deleteObjectImpl(m_object);
    6565        }
  • trunk/WebCore/platform/graphics/ANGLEWebKitBridge.h

    r66781 r66783  
    3939};
    4040
    41 
    4241class ANGLEWebKitBridge {
    4342public:
  • trunk/WebCore/platform/graphics/GraphicsContext3D.h

    r66781 r66783  
    452452#endif
    453453#endif
    454     void ensureContext();
     454    void makeContextCurrent();
    455455
    456456#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
  • trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm

    r66781 r66783  
    3232#import "BlockExceptions.h"
    3333
    34 #include "ANGLE/ShaderLang.h"
    3534#include "ArrayBuffer.h"
    3635#include "ArrayBufferView.h"
     36#include "WebGLObject.h"
    3737#include "CanvasRenderingContext.h"
    38 #include <CoreGraphics/CGBitmapContext.h>
    3938#include "Float32Array.h"
    4039#include "GraphicsContext.h"
     
    4342#include "Int32Array.h"
    4443#include "NotImplemented.h"
     44#include "Uint8Array.h"
     45#include "WebGLLayer.h"
     46#include <CoreGraphics/CGBitmapContext.h>
    4547#include <OpenGL/CGLRenderers.h>
    4648#include <OpenGL/gl.h>
    47 #include "Uint8Array.h"
    48 #include "WebGLLayer.h"
    49 #include "WebGLObject.h"
    5049#include <wtf/UnusedParam.h>
    5150#include <wtf/text/CString.h>
     
    231230}
    232231
    233 void GraphicsContext3D::ensureContext()
    234 {
    235     if (!m_contextObj)
     232void GraphicsContext3D::validateAttributes()
     233{
     234    const char* extensions = reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS));
     235    if (m_attrs.stencil) {
     236        if (std::strstr(extensions, "GL_EXT_packed_depth_stencil")) {
     237            if (!m_attrs.depth)
     238                m_attrs.depth = true;
     239        } else
     240            m_attrs.stencil = false;
     241    }
     242    if (m_attrs.antialias) {
     243        bool isValidVendor = true;
     244        // Currently in Mac we only turn on antialias if vendor is NVIDIA.
     245        const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR));
     246        if (!std::strstr(vendor, "NVIDIA"))
     247            isValidVendor = false;
     248        if (!isValidVendor || !std::strstr(extensions, "GL_EXT_framebuffer_multisample"))
     249            m_attrs.antialias = false;
     250    }
     251    // FIXME: instead of enforcing premultipliedAlpha = true, implement the
     252    // correct behavior when premultipliedAlpha = false is requested.
     253    m_attrs.premultipliedAlpha = true;
     254}
     255
     256void GraphicsContext3D::makeContextCurrent()
     257{
     258    CGLSetCurrentContext(m_contextObj);
     259}
     260
     261void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* context)
     262{
     263    HTMLCanvasElement* canvas = context->canvas();
     264    ImageBuffer* imageBuffer = canvas->buffer();
     265
     266    int rowBytes = m_currentWidth * 4;
     267    int totalBytes = rowBytes * m_currentHeight;
     268
     269    OwnArrayPtr<unsigned char> pixels(new unsigned char[totalBytes]);
     270    if (!pixels)
    236271        return;
    237272
     273    CGLSetCurrentContext(m_contextObj);
     274
     275    bool mustRestoreFBO = false;
     276    if (m_attrs.antialias) {
     277        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     278        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
     279        ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
     280        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     281        mustRestoreFBO = true;
     282    } else {
     283        if (m_boundFBO != m_fbo) {
     284            mustRestoreFBO = true;
     285            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     286        }
     287    }
     288
     289    GLint packAlignment = 4;
     290    bool mustRestorePackAlignment = false;
     291    ::glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment);
     292    if (packAlignment > 4) {
     293        ::glPixelStorei(GL_PACK_ALIGNMENT, 4);
     294        mustRestorePackAlignment = true;
     295    }
     296
     297    ::glReadPixels(0, 0, m_currentWidth, m_currentHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels.get());
     298
     299    if (mustRestorePackAlignment)
     300        ::glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);
     301
     302    if (mustRestoreFBO)
     303        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
     304
     305    paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight,
     306                  canvas->width(), canvas->height(), imageBuffer->context()->platformContext());
     307}
     308
     309bool GraphicsContext3D::isGLES2Compliant() const
     310{
     311    return false;
     312}
     313
     314bool GraphicsContext3D::isGLES2NPOTStrict() const
     315{
     316    return false;
     317}
     318
     319bool GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses() const
     320{
     321    return false;
     322}
     323
     324void GraphicsContext3D::reshape(int width, int height)
     325{
     326    if (width == m_currentWidth && height == m_currentHeight || !m_contextObj)
     327        return;
     328   
     329    m_currentWidth = width;
     330    m_currentHeight = height;
     331   
     332    CGLSetCurrentContext(m_contextObj);
     333   
     334    GLuint internalColorFormat, colorFormat, internalDepthStencilFormat = 0;
     335    if (m_attrs.alpha) {
     336        internalColorFormat = GL_RGBA8;
     337        colorFormat = GL_RGBA;
     338    } else {
     339        internalColorFormat = GL_RGB8;
     340        colorFormat = GL_RGB;
     341    }
     342    if (m_attrs.stencil || m_attrs.depth) {
     343        // We don't allow the logic where stencil is required and depth is not.
     344        // See GraphicsContext3D constructor.
     345        if (m_attrs.stencil && m_attrs.depth)
     346            internalDepthStencilFormat = GL_DEPTH24_STENCIL8_EXT;
     347        else
     348            internalDepthStencilFormat = GL_DEPTH_COMPONENT;
     349    }
     350
     351    bool mustRestoreFBO = false;
     352
     353    // resize multisample FBO
     354    if (m_attrs.antialias) {
     355        GLint maxSampleCount;
     356        ::glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount);
     357        GLint sampleCount = std::min(8, maxSampleCount);
     358        if (sampleCount > maxSampleCount)
     359            sampleCount = maxSampleCount;
     360        if (m_boundFBO != m_multisampleFBO) {
     361            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
     362            mustRestoreFBO = true;
     363        }
     364        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
     365        ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalColorFormat, width, height);
     366        ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
     367        if (m_attrs.stencil || m_attrs.depth) {
     368            ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
     369            ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalDepthStencilFormat, width, height);
     370            if (m_attrs.stencil)
     371                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
     372            if (m_attrs.depth)
     373                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
     374        }
     375        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
     376        if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
     377            // FIXME: cleanup.
     378            notImplemented();
     379        }
     380    }
     381
     382    // resize regular FBO
     383    if (m_boundFBO != m_fbo) {
     384        mustRestoreFBO = true;
     385        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     386    }
     387    ::glBindTexture(GL_TEXTURE_2D, m_texture);
     388    ::glTexImage2D(GL_TEXTURE_2D, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
     389    ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);
     390    ::glBindTexture(GL_TEXTURE_2D, 0);
     391    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) {
     392        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
     393        ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalDepthStencilFormat, width, height);
     394        if (m_attrs.stencil)
     395            ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
     396        if (m_attrs.depth)
     397            ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
     398        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
     399    }
     400    if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
     401        // FIXME: cleanup
     402        notImplemented();
     403    }
     404
     405    if (m_attrs.antialias) {
     406        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
     407        if (m_boundFBO == m_multisampleFBO)
     408            mustRestoreFBO = false;
     409    }
     410
     411    // Initialize renderbuffers to 0.
     412    GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE, stencilMask = GL_TRUE;
     413    GLboolean isScissorEnabled = GL_FALSE;
     414    GLboolean isDitherEnabled = GL_FALSE;
     415    GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
     416    ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
     417    ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
     418    if (m_attrs.depth) {
     419        ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
     420        ::glDepthMask(GL_TRUE);
     421        clearMask |= GL_DEPTH_BUFFER_BIT;
     422    }
     423    if (m_attrs.stencil) {
     424        ::glGetBooleanv(GL_STENCIL_WRITEMASK, &stencilMask);
     425        ::glStencilMask(GL_TRUE);
     426        clearMask |= GL_STENCIL_BUFFER_BIT;
     427    }
     428    isScissorEnabled = ::glIsEnabled(GL_SCISSOR_TEST);
     429    ::glDisable(GL_SCISSOR_TEST);
     430    isDitherEnabled = ::glIsEnabled(GL_DITHER);
     431    ::glDisable(GL_DITHER);
     432
     433    ::glClear(clearMask);
     434
     435    ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
     436    if (m_attrs.depth)
     437        ::glDepthMask(depthMask);
     438    if (m_attrs.stencil)
     439        ::glStencilMask(stencilMask);
     440    if (isScissorEnabled)
     441        ::glEnable(GL_SCISSOR_TEST);
     442    else
     443        ::glDisable(GL_SCISSOR_TEST);
     444    if (isDitherEnabled)
     445        ::glEnable(GL_DITHER);
     446    else
     447        ::glDisable(GL_DITHER);
     448
     449    if (mustRestoreFBO)
     450        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
     451
     452    ::glFlush();
     453}
     454
     455static inline void ensureContext(CGLContextObj context)
     456{
     457    if (!context)
     458        return;
     459       
    238460    CGLContextObj currentContext = CGLGetCurrentContext();
    239     if (currentContext != m_contextObj)
    240         CGLSetCurrentContext(m_contextObj);
    241 }
    242 
    243 bool GraphicsContext3D::isGLES2Compliant() const
    244 {
    245     return false;
    246 }
    247 
    248 bool GraphicsContext3D::isGLES2NPOTStrict() const
    249 {
    250     return false;
    251 }
    252 
    253 bool GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses() const
    254 {
    255     return false;
    256 }
    257    
     461    if (currentContext != context)
     462        CGLSetCurrentContext(context);
     463}
     464
     465void GraphicsContext3D::prepareTexture()
     466{
     467    ensureContext(m_contextObj);
     468    if (m_attrs.antialias) {
     469        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     470        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
     471        ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
     472        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
     473    }
     474    ::glFinish();
     475}
     476
     477void GraphicsContext3D::activeTexture(unsigned long texture)
     478{
     479    ensureContext(m_contextObj);
     480    ::glActiveTexture(texture);
     481}
     482
     483void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader)
     484{
     485    ASSERT(program);
     486    ASSERT(shader);
     487    ensureContext(m_contextObj);
     488    ::glAttachShader((GLuint) program, (GLuint) shader);
     489}
     490
     491void GraphicsContext3D::bindAttribLocation(Platform3DObject program, unsigned long index, const String& name)
     492{
     493    ASSERT(program);
     494    ensureContext(m_contextObj);
     495    ::glBindAttribLocation((GLuint) program, index, name.utf8().data());
     496}
     497
     498void GraphicsContext3D::bindBuffer(unsigned long target, Platform3DObject buffer)
     499{
     500    ensureContext(m_contextObj);
     501    ::glBindBuffer(target, (GLuint) buffer);
     502}
     503
     504
     505void GraphicsContext3D::bindFramebuffer(unsigned long target, Platform3DObject buffer)
     506{
     507    ensureContext(m_contextObj);
     508    GLuint fbo;
     509    if (buffer)
     510        fbo = (GLuint)buffer;
     511    else
     512        fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo);
     513    if (fbo != m_boundFBO) {
     514        ::glBindFramebufferEXT(target, fbo);
     515        m_boundFBO = fbo;
     516    }
     517}
     518
     519void GraphicsContext3D::bindRenderbuffer(unsigned long target, Platform3DObject renderbuffer)
     520{
     521    ensureContext(m_contextObj);
     522    ::glBindRenderbufferEXT(target, (GLuint) renderbuffer);
     523}
     524
     525
     526void GraphicsContext3D::bindTexture(unsigned long target, Platform3DObject texture)
     527{
     528    ensureContext(m_contextObj);
     529    ::glBindTexture(target, (GLuint) texture);
     530}
     531
     532void GraphicsContext3D::blendColor(double red, double green, double blue, double alpha)
     533{
     534    ensureContext(m_contextObj);
     535    ::glBlendColor(static_cast<float>(red), static_cast<float>(green), static_cast<float>(blue), static_cast<float>(alpha));
     536}
     537
     538void GraphicsContext3D::blendEquation( unsigned long mode )
     539{
     540    ensureContext(m_contextObj);
     541    ::glBlendEquation(mode);
     542}
     543
     544void GraphicsContext3D::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha)
     545{
     546    ensureContext(m_contextObj);
     547    ::glBlendEquationSeparate(modeRGB, modeAlpha);
     548}
     549
     550
     551void GraphicsContext3D::blendFunc(unsigned long sfactor, unsigned long dfactor)
     552{
     553    ensureContext(m_contextObj);
     554    ::glBlendFunc(sfactor, dfactor);
     555}       
     556
     557void GraphicsContext3D::blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha)
     558{
     559    ensureContext(m_contextObj);
     560    ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
     561}
     562
     563void GraphicsContext3D::bufferData(unsigned long target, int size, unsigned long usage)
     564{
     565    ensureContext(m_contextObj);
     566    ::glBufferData(target, size, 0, usage);
     567}
     568
     569void GraphicsContext3D::bufferData(unsigned long target, int size, const void* data, unsigned long usage)
     570{
     571    ensureContext(m_contextObj);
     572    ::glBufferData(target, size, data, usage);
     573}
     574
     575void GraphicsContext3D::bufferSubData(unsigned long target, long offset, int size, const void* data)
     576{
     577    ensureContext(m_contextObj);
     578    ::glBufferSubData(target, offset, size, data);
     579}
     580
     581unsigned long GraphicsContext3D::checkFramebufferStatus(unsigned long target)
     582{
     583    ensureContext(m_contextObj);
     584    return ::glCheckFramebufferStatusEXT(target);
     585}
     586
     587void GraphicsContext3D::clearColor(double r, double g, double b, double a)
     588{
     589    ensureContext(m_contextObj);
     590    ::glClearColor(static_cast<float>(r), static_cast<float>(g), static_cast<float>(b), static_cast<float>(a));
     591}
     592
     593void GraphicsContext3D::clear(unsigned long mask)
     594{
     595    ensureContext(m_contextObj);
     596    ::glClear(mask);
     597}
     598
     599void GraphicsContext3D::clearDepth(double depth)
     600{
     601    ensureContext(m_contextObj);
     602    ::glClearDepth(depth);
     603}
     604
     605void GraphicsContext3D::clearStencil(long s)
     606{
     607    ensureContext(m_contextObj);
     608    ::glClearStencil(s);
     609}
     610
     611void GraphicsContext3D::colorMask(bool red, bool green, bool blue, bool alpha)
     612{
     613    ensureContext(m_contextObj);
     614    ::glColorMask(red, green, blue, alpha);
     615}
     616
     617void GraphicsContext3D::compileShader(Platform3DObject shader)
     618{
     619    ASSERT(shader);
     620    ensureContext(m_contextObj);
     621
     622    int GLshaderType;
     623    ANGLEShaderType shaderType;
     624
     625    glGetShaderiv(shader, SHADER_TYPE, &GLshaderType);
     626   
     627    if (GLshaderType == VERTEX_SHADER)
     628        shaderType = SHADER_TYPE_VERTEX;
     629    else if (GLshaderType == FRAGMENT_SHADER)
     630        shaderType = SHADER_TYPE_FRAGMENT;
     631    else
     632        return; // Invalid shader type.
     633
     634    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
     635
     636    if (result == m_shaderSourceMap.end())
     637        return;
     638
     639    ShaderSourceEntry& entry = result->second;
     640
     641    String translatedShaderSource;
     642    String shaderInfoLog;
     643
     644    bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);
     645
     646    entry.log = shaderInfoLog;
     647    entry.isValid = isValid;
     648
     649    if (!isValid)
     650        return; // Shader didn't validate, don't move forward with compiling translated source   
     651
     652    int translatedShaderLength = translatedShaderSource.length();
     653
     654    const CString& translatedShaderCString = translatedShaderSource.utf8();
     655    const char* translatedShaderPtr = translatedShaderCString.data();
     656   
     657    ::glShaderSource((GLuint) shader, 1, &translatedShaderPtr, &translatedShaderLength);
     658   
     659    ::glCompileShader((GLuint) shader);
     660   
     661    int GLCompileSuccess;
     662   
     663    ::glGetShaderiv((GLuint) shader, COMPILE_STATUS, &GLCompileSuccess);
     664   
     665    // ASSERT that ANGLE generated GLSL will be accepted by OpenGL
     666    ASSERT(GLCompileSuccess == GL_TRUE);
     667}
     668
     669void GraphicsContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
     670{
     671    ensureContext(m_contextObj);
     672    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
     673        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     674        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
     675        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
     676        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     677    }
     678    ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
     679    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
     680        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
     681}
     682
     683void GraphicsContext3D::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height)
     684{
     685    ensureContext(m_contextObj);
     686    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
     687        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     688        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
     689        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
     690        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     691    }
     692    ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
     693    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
     694        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
     695}
     696
     697void GraphicsContext3D::cullFace(unsigned long mode)
     698{
     699    ensureContext(m_contextObj);
     700    ::glCullFace(mode);
     701}
     702
     703void GraphicsContext3D::depthFunc(unsigned long func)
     704{
     705    ensureContext(m_contextObj);
     706    ::glDepthFunc(func);
     707}
     708
     709void GraphicsContext3D::depthMask(bool flag)
     710{
     711    ensureContext(m_contextObj);
     712    ::glDepthMask(flag);
     713}
     714
     715void GraphicsContext3D::depthRange(double zNear, double zFar)
     716{
     717    ensureContext(m_contextObj);
     718    ::glDepthRange(zNear, zFar);
     719}
     720
     721void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader)
     722{
     723    ASSERT(program);
     724    ASSERT(shader);
     725    ensureContext(m_contextObj);
     726    ::glDetachShader((GLuint) program, (GLuint) shader);
     727}
     728
     729void GraphicsContext3D::disable(unsigned long cap)
     730{
     731    ensureContext(m_contextObj);
     732    ::glDisable(cap);
     733}
     734
     735void GraphicsContext3D::disableVertexAttribArray(unsigned long index)
     736{
     737    ensureContext(m_contextObj);
     738    ::glDisableVertexAttribArray(index);
     739}
     740
     741void GraphicsContext3D::drawArrays(unsigned long mode, long first, long count)
     742{
     743    ensureContext(m_contextObj);
     744    ::glDrawArrays(mode, first, count);
     745}
     746
     747void GraphicsContext3D::drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset)
     748{
     749    ensureContext(m_contextObj);
     750    ::glDrawElements(mode, count, type, reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
     751}
     752
     753void GraphicsContext3D::enable(unsigned long cap)
     754{
     755    ensureContext(m_contextObj);
     756    ::glEnable(cap);
     757}
     758
     759void GraphicsContext3D::enableVertexAttribArray(unsigned long index)
     760{
     761    ensureContext(m_contextObj);
     762    ::glEnableVertexAttribArray(index);
     763}
     764
     765void GraphicsContext3D::finish()
     766{
     767    ensureContext(m_contextObj);
     768    ::glFinish();
     769}
     770
     771void GraphicsContext3D::flush()
     772{
     773    ensureContext(m_contextObj);
     774    ::glFlush();
     775}
     776
     777void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, Platform3DObject buffer)
     778{
     779    ensureContext(m_contextObj);
     780    GLuint renderbuffer = (GLuint) buffer;
     781    if (attachment == DEPTH_STENCIL_ATTACHMENT) {
     782        ::glFramebufferRenderbufferEXT(target, DEPTH_ATTACHMENT, renderbuffertarget, renderbuffer);
     783        ::glFramebufferRenderbufferEXT(target, STENCIL_ATTACHMENT, renderbuffertarget, renderbuffer);
     784    } else
     785        ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
     786}
     787
     788void GraphicsContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, Platform3DObject texture, long level)
     789{
     790    ensureContext(m_contextObj);
     791    ::glFramebufferTexture2DEXT(target, attachment, textarget, (GLuint) texture, level);
     792}
     793
     794void GraphicsContext3D::frontFace(unsigned long mode)
     795{
     796    ensureContext(m_contextObj);
     797    ::glFrontFace(mode);
     798}
     799
     800void GraphicsContext3D::generateMipmap(unsigned long target)
     801{
     802    ensureContext(m_contextObj);
     803    ::glGenerateMipmapEXT(target);
     804}
     805
     806bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, unsigned long index, ActiveInfo& info)
     807{
     808    if (!program) {
     809        synthesizeGLError(INVALID_VALUE);
     810        return false;
     811    }
     812    ensureContext(m_contextObj);
     813    GLint maxAttributeSize = 0;
     814    ::glGetProgramiv(static_cast<GLuint>(program), GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize);
     815    GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination
     816    GLsizei nameLength = 0;
     817    GLint size = 0;
     818    GLenum type = 0;
     819    ::glGetActiveAttrib(static_cast<GLuint>(program), index, maxAttributeSize, &nameLength, &size, &type, name);
     820    if (!nameLength)
     821        return false;
     822    info.name = String(name, nameLength);
     823    info.type = type;
     824    info.size = size;
     825    return true;
     826}
     827   
     828bool GraphicsContext3D::getActiveUniform(Platform3DObject program, unsigned long index, ActiveInfo& info)
     829{
     830    if (!program) {
     831        synthesizeGLError(INVALID_VALUE);
     832        return false;
     833    }
     834    ensureContext(m_contextObj);
     835    GLint maxUniformSize = 0;
     836    ::glGetProgramiv(static_cast<GLuint>(program), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize);
     837    GLchar name[maxUniformSize]; // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination
     838    GLsizei nameLength = 0;
     839    GLint size = 0;
     840    GLenum type = 0;
     841    ::glGetActiveUniform(static_cast<GLuint>(program), index, maxUniformSize, &nameLength, &size, &type, name);
     842    if (!nameLength)
     843        return false;
     844    info.name = String(name, nameLength);
     845    info.type = type;
     846    info.size = size;
     847    return true;
     848}
     849
     850void GraphicsContext3D::getAttachedShaders(Platform3DObject program, int maxCount, int* count, unsigned int* shaders)
     851{
     852    if (!program) {
     853        synthesizeGLError(INVALID_VALUE);
     854        return;
     855    }
     856    ensureContext(m_contextObj);
     857    ::glGetAttachedShaders(static_cast<GLuint>(program), maxCount, count, shaders);
     858}
     859
     860int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name)
     861{
     862    if (!program)
     863        return -1;
     864   
     865    ensureContext(m_contextObj);
     866    return ::glGetAttribLocation((GLuint) program, name.utf8().data());
     867}
     868
     869GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes()
     870{
     871    return m_attrs;
     872}
     873
     874unsigned long GraphicsContext3D::getError()
     875{
     876    if (m_syntheticErrors.size() > 0) {
     877        ListHashSet<unsigned long>::iterator iter = m_syntheticErrors.begin();
     878        unsigned long err = *iter;
     879        m_syntheticErrors.remove(iter);
     880        return err;
     881    }
     882
     883    ensureContext(m_contextObj);
     884    return ::glGetError();
     885}
     886
     887String GraphicsContext3D::getString(unsigned long name)
     888{
     889    ensureContext(m_contextObj);
     890    return String((const char*) ::glGetString(name));
     891}
     892
     893void GraphicsContext3D::hint(unsigned long target, unsigned long mode)
     894{
     895    ensureContext(m_contextObj);
     896    ::glHint(target, mode);
     897}
     898
     899bool GraphicsContext3D::isBuffer(Platform3DObject buffer)
     900{
     901    if (!buffer)
     902        return false;
     903   
     904    ensureContext(m_contextObj);
     905    return ::glIsBuffer((GLuint) buffer);
     906}
     907
     908bool GraphicsContext3D::isEnabled(unsigned long cap)
     909{
     910    ensureContext(m_contextObj);
     911    return ::glIsEnabled(cap);
     912}
     913
     914bool GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer)
     915{
     916    if (!framebuffer)
     917        return false;
     918   
     919    ensureContext(m_contextObj);
     920    return ::glIsFramebufferEXT((GLuint) framebuffer);
     921}
     922
     923bool GraphicsContext3D::isProgram(Platform3DObject program)
     924{
     925    if (!program)
     926        return false;
     927   
     928    ensureContext(m_contextObj);
     929    return ::glIsProgram((GLuint) program);
     930}
     931
     932bool GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer)
     933{
     934    if (!renderbuffer)
     935        return false;
     936   
     937    ensureContext(m_contextObj);
     938    return ::glIsRenderbufferEXT((GLuint) renderbuffer);
     939}
     940
     941bool GraphicsContext3D::isShader(Platform3DObject shader)
     942{
     943    if (!shader)
     944        return false;
     945   
     946    ensureContext(m_contextObj);
     947    return ::glIsShader((GLuint) shader);
     948}
     949
     950bool GraphicsContext3D::isTexture(Platform3DObject texture)
     951{
     952    if (!texture)
     953        return false;
     954   
     955    ensureContext(m_contextObj);
     956    return ::glIsTexture((GLuint) texture);
     957}
     958
     959void GraphicsContext3D::lineWidth(double width)
     960{
     961    ensureContext(m_contextObj);
     962    ::glLineWidth(static_cast<float>(width));
     963}
     964
     965void GraphicsContext3D::linkProgram(Platform3DObject program)
     966{
     967    ASSERT(program);
     968    ensureContext(m_contextObj);
     969    ::glLinkProgram((GLuint) program);
     970}
     971
     972void GraphicsContext3D::pixelStorei(unsigned long pname, long param)
     973{
     974    ensureContext(m_contextObj);
     975    ::glPixelStorei(pname, param);
     976}
     977
     978void GraphicsContext3D::polygonOffset(double factor, double units)
     979{
     980    ensureContext(m_contextObj);
     981    ::glPolygonOffset(static_cast<float>(factor), static_cast<float>(units));
     982}
     983
     984void GraphicsContext3D::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type, void* data)
     985{
     986    // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
     987    // all previous rendering calls should be done before reading pixels.
     988    ensureContext(m_contextObj);
     989    ::glFlush();
     990    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
     991        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     992        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
     993        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
     994        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     995        ::glFlush();
     996    }
     997    ::glReadPixels(x, y, width, height, format, type, data);
     998    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
     999        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
     1000}
     1001
     1002void GraphicsContext3D::releaseShaderCompiler()
     1003{
     1004    // FIXME: This is not implemented on desktop OpenGL. We need to have ifdefs for the different GL variants
     1005    ensureContext(m_contextObj);
     1006    //::glReleaseShaderCompiler();
     1007}
     1008
     1009void GraphicsContext3D::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height)
     1010{
     1011    ensureContext(m_contextObj);
     1012    switch (internalformat) {
     1013    case DEPTH_STENCIL:
     1014        internalformat = GL_DEPTH24_STENCIL8_EXT;
     1015        break;
     1016    case DEPTH_COMPONENT16:
     1017        internalformat = GL_DEPTH_COMPONENT;
     1018        break;
     1019    case RGBA4:
     1020    case RGB5_A1:
     1021        internalformat = GL_RGBA;
     1022        break;
     1023    case RGB565:
     1024        internalformat = GL_RGB;
     1025        break;
     1026    }
     1027    ::glRenderbufferStorageEXT(target, internalformat, width, height);
     1028}
     1029
     1030void GraphicsContext3D::sampleCoverage(double value, bool invert)
     1031{
     1032    ensureContext(m_contextObj);
     1033    ::glSampleCoverage(static_cast<float>(value), invert);
     1034}
     1035
     1036void GraphicsContext3D::scissor(long x, long y, unsigned long width, unsigned long height)
     1037{
     1038    ensureContext(m_contextObj);
     1039    ::glScissor(x, y, width, height);
     1040}
     1041
     1042void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string)
     1043{
     1044    ASSERT(shader);
     1045   
     1046    ensureContext(m_contextObj);
     1047
     1048    ShaderSourceEntry entry;
     1049
     1050    entry.source = string;
     1051
     1052    m_shaderSourceMap.set(shader, entry);
     1053}
     1054
     1055void GraphicsContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask)
     1056{
     1057    ensureContext(m_contextObj);
     1058    ::glStencilFunc(func, ref, mask);
     1059}
     1060
     1061void GraphicsContext3D::stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask)
     1062{
     1063    ensureContext(m_contextObj);
     1064    ::glStencilFuncSeparate(face, func, ref, mask);
     1065}
     1066
     1067void GraphicsContext3D::stencilMask(unsigned long mask)
     1068{
     1069    ensureContext(m_contextObj);
     1070    ::glStencilMask(mask);
     1071}
     1072
     1073void GraphicsContext3D::stencilMaskSeparate(unsigned long face, unsigned long mask)
     1074{
     1075    ensureContext(m_contextObj);
     1076    ::glStencilMaskSeparate(face, mask);
     1077}
     1078
     1079void GraphicsContext3D::stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass)
     1080{
     1081    ensureContext(m_contextObj);
     1082    ::glStencilOp(fail, zfail, zpass);
     1083}
     1084
     1085void GraphicsContext3D::stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass)
     1086{
     1087    ensureContext(m_contextObj);
     1088    ::glStencilOpSeparate(face, fail, zfail, zpass);
     1089}
     1090
     1091void GraphicsContext3D::texParameterf(unsigned target, unsigned pname, float value)
     1092{
     1093    ensureContext(m_contextObj);
     1094    ::glTexParameterf(target, pname, static_cast<float>(value));
     1095}
     1096
     1097void GraphicsContext3D::texParameteri(unsigned target, unsigned pname, int value)
     1098{
     1099    ensureContext(m_contextObj);
     1100    ::glTexParameteri(target, pname, static_cast<float>(value));
     1101}
     1102
     1103void GraphicsContext3D::uniform1f(long location, float v0)
     1104{
     1105    ensureContext(m_contextObj);
     1106    ::glUniform1f(location, v0);
     1107}
     1108
     1109void GraphicsContext3D::uniform1fv(long location, float* array, int size)
     1110{
     1111    ensureContext(m_contextObj);
     1112    ::glUniform1fv(location, size, array);
     1113}
     1114
     1115void GraphicsContext3D::uniform2f(long location, float v0, float v1)
     1116{
     1117    ensureContext(m_contextObj);
     1118    ::glUniform2f(location, v0, v1);
     1119}
     1120
     1121void GraphicsContext3D::uniform2fv(long location, float* array, int size)
     1122{
     1123    // FIXME: length needs to be a multiple of 2
     1124    ensureContext(m_contextObj);
     1125    ::glUniform2fv(location, size, array);
     1126}
     1127
     1128void GraphicsContext3D::uniform3f(long location, float v0, float v1, float v2)
     1129{
     1130    ensureContext(m_contextObj);
     1131    ::glUniform3f(location, v0, v1, v2);
     1132}
     1133
     1134void GraphicsContext3D::uniform3fv(long location, float* array, int size)
     1135{
     1136    // FIXME: length needs to be a multiple of 3
     1137    ensureContext(m_contextObj);
     1138    ::glUniform3fv(location, size, array);
     1139}
     1140
     1141void GraphicsContext3D::uniform4f(long location, float v0, float v1, float v2, float v3)
     1142{
     1143    ensureContext(m_contextObj);
     1144    ::glUniform4f(location, v0, v1, v2, v3);
     1145}
     1146
     1147void GraphicsContext3D::uniform4fv(long location, float* array, int size)
     1148{
     1149    // FIXME: length needs to be a multiple of 4
     1150    ensureContext(m_contextObj);
     1151    ::glUniform4fv(location, size, array);
     1152}
     1153
     1154void GraphicsContext3D::uniform1i(long location, int v0)
     1155{
     1156    ensureContext(m_contextObj);
     1157    ::glUniform1i(location, v0);
     1158}
     1159
     1160void GraphicsContext3D::uniform1iv(long location, int* array, int size)
     1161{
     1162    ensureContext(m_contextObj);
     1163    ::glUniform1iv(location, size, array);
     1164}
     1165
     1166void GraphicsContext3D::uniform2i(long location, int v0, int v1)
     1167{
     1168    ensureContext(m_contextObj);
     1169    ::glUniform2i(location, v0, v1);
     1170}
     1171
     1172void GraphicsContext3D::uniform2iv(long location, int* array, int size)
     1173{
     1174    // FIXME: length needs to be a multiple of 2
     1175    ensureContext(m_contextObj);
     1176    ::glUniform2iv(location, size, array);
     1177}
     1178
     1179void GraphicsContext3D::uniform3i(long location, int v0, int v1, int v2)
     1180{
     1181    ensureContext(m_contextObj);
     1182    ::glUniform3i(location, v0, v1, v2);
     1183}
     1184
     1185void GraphicsContext3D::uniform3iv(long location, int* array, int size)
     1186{
     1187    // FIXME: length needs to be a multiple of 3
     1188    ensureContext(m_contextObj);
     1189    ::glUniform3iv(location, size, array);
     1190}
     1191
     1192void GraphicsContext3D::uniform4i(long location, int v0, int v1, int v2, int v3)
     1193{
     1194    ensureContext(m_contextObj);
     1195    ::glUniform4i(location, v0, v1, v2, v3);
     1196}
     1197
     1198void GraphicsContext3D::uniform4iv(long location, int* array, int size)
     1199{
     1200    // FIXME: length needs to be a multiple of 4
     1201    ensureContext(m_contextObj);
     1202    ::glUniform4iv(location, size, array);
     1203}
     1204
     1205void GraphicsContext3D::uniformMatrix2fv(long location, bool transpose, float* array, int size)
     1206{
     1207    // FIXME: length needs to be a multiple of 4
     1208    ensureContext(m_contextObj);
     1209    ::glUniformMatrix2fv(location, size, transpose, array);
     1210}
     1211
     1212void GraphicsContext3D::uniformMatrix3fv(long location, bool transpose, float* array, int size)
     1213{
     1214    // FIXME: length needs to be a multiple of 9
     1215    ensureContext(m_contextObj);
     1216    ::glUniformMatrix3fv(location, size, transpose, array);
     1217}
     1218
     1219void GraphicsContext3D::uniformMatrix4fv(long location, bool transpose, float* array, int size)
     1220{
     1221    // FIXME: length needs to be a multiple of 16
     1222    ensureContext(m_contextObj);
     1223    ::glUniformMatrix4fv(location, size, transpose, array);
     1224}
     1225
     1226void GraphicsContext3D::useProgram(Platform3DObject program)
     1227{
     1228    ensureContext(m_contextObj);
     1229    ::glUseProgram((GLuint) program);
     1230}
     1231
     1232void GraphicsContext3D::validateProgram(Platform3DObject program)
     1233{
     1234    ASSERT(program);
     1235   
     1236    ensureContext(m_contextObj);
     1237    ::glValidateProgram((GLuint) program);
     1238}
     1239
     1240void GraphicsContext3D::vertexAttrib1f(unsigned long indx, float v0)
     1241{
     1242    ensureContext(m_contextObj);
     1243    ::glVertexAttrib1f(indx, v0);
     1244}
     1245
     1246void GraphicsContext3D::vertexAttrib1fv(unsigned long indx, float* array)
     1247{
     1248    ensureContext(m_contextObj);
     1249    ::glVertexAttrib1fv(indx, array);
     1250}
     1251
     1252void GraphicsContext3D::vertexAttrib2f(unsigned long indx, float v0, float v1)
     1253{
     1254    ensureContext(m_contextObj);
     1255    ::glVertexAttrib2f(indx, v0, v1);
     1256}
     1257
     1258void GraphicsContext3D::vertexAttrib2fv(unsigned long indx, float* array)
     1259{
     1260    ensureContext(m_contextObj);
     1261    ::glVertexAttrib2fv(indx, array);
     1262}
     1263
     1264void GraphicsContext3D::vertexAttrib3f(unsigned long indx, float v0, float v1, float v2)
     1265{
     1266    ensureContext(m_contextObj);
     1267    ::glVertexAttrib3f(indx, v0, v1, v2);
     1268}
     1269
     1270void GraphicsContext3D::vertexAttrib3fv(unsigned long indx, float* array)
     1271{
     1272    ensureContext(m_contextObj);
     1273    ::glVertexAttrib3fv(indx, array);
     1274}
     1275
     1276void GraphicsContext3D::vertexAttrib4f(unsigned long indx, float v0, float v1, float v2, float v3)
     1277{
     1278    ensureContext(m_contextObj);
     1279    ::glVertexAttrib4f(indx, v0, v1, v2, v3);
     1280}
     1281
     1282void GraphicsContext3D::vertexAttrib4fv(unsigned long indx, float* array)
     1283{
     1284    ensureContext(m_contextObj);
     1285    ::glVertexAttrib4fv(indx, array);
     1286}
     1287
     1288void GraphicsContext3D::vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, unsigned long stride, unsigned long offset)
     1289{
     1290    ensureContext(m_contextObj);
     1291    ::glVertexAttribPointer(indx, size, type, normalized, stride, reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
     1292}
     1293
     1294void GraphicsContext3D::viewport(long x, long y, unsigned long width, unsigned long height)
     1295{
     1296    ensureContext(m_contextObj);
     1297    ::glViewport(static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height));
     1298}
     1299
     1300void GraphicsContext3D::getBooleanv(unsigned long pname, unsigned char* value)
     1301{
     1302    ensureContext(m_contextObj);
     1303    ::glGetBooleanv(pname, value);
     1304}
     1305
     1306void GraphicsContext3D::getBufferParameteriv(unsigned long target, unsigned long pname, int* value)
     1307{
     1308    ensureContext(m_contextObj);
     1309    ::glGetBufferParameteriv(target, pname, value);
     1310}
     1311
     1312void GraphicsContext3D::getFloatv(unsigned long pname, float* value)
     1313{
     1314    ensureContext(m_contextObj);
     1315    ::glGetFloatv(pname, value);
     1316}
     1317
     1318void GraphicsContext3D::getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname, int* value)
     1319{
     1320    ensureContext(m_contextObj);
     1321    if (attachment == DEPTH_STENCIL_ATTACHMENT)
     1322        attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works.
     1323    ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value);
     1324}
     1325
     1326void GraphicsContext3D::getIntegerv(unsigned long pname, int* value)
     1327{
     1328    // Need to emulate IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for GL.  Any valid
     1329    // combination should work, but GL_RGB/GL_UNSIGNED_BYTE might be the most
     1330    // useful for desktop WebGL users.
     1331    // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS
     1332    // because desktop GL's corresponding queries return the number of components
     1333    // whereas GLES2 return the number of vectors (each vector has 4 components).
     1334    // Therefore, the value returned by desktop GL needs to be divided by 4.
     1335    ensureContext(m_contextObj);
     1336    switch (pname) {
     1337    case IMPLEMENTATION_COLOR_READ_FORMAT:
     1338        *value = GL_RGB;
     1339        break;
     1340    case IMPLEMENTATION_COLOR_READ_TYPE:
     1341        *value = GL_UNSIGNED_BYTE;
     1342        break;
     1343    case MAX_FRAGMENT_UNIFORM_VECTORS:
     1344        ::glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value);
     1345        *value /= 4;
     1346        break;
     1347    case MAX_VERTEX_UNIFORM_VECTORS:
     1348        ::glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value);
     1349        *value /= 4;
     1350        break;
     1351    case MAX_VARYING_VECTORS:
     1352        ::glGetIntegerv(GL_MAX_VARYING_FLOATS, value);
     1353        *value /= 4;
     1354        break;
     1355    default:
     1356        ::glGetIntegerv(pname, value);
     1357    }
     1358}
     1359
     1360void GraphicsContext3D::getProgramiv(Platform3DObject program, unsigned long pname, int* value)
     1361{
     1362    ensureContext(m_contextObj);
     1363    ::glGetProgramiv((GLuint) program, pname, value);
     1364}
     1365
     1366String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)
     1367{
     1368    ASSERT(program);
     1369   
     1370    ensureContext(m_contextObj);
     1371    GLint length;
     1372    ::glGetProgramiv((GLuint) program, GL_INFO_LOG_LENGTH, &length);
     1373   
     1374    GLsizei size;
     1375    GLchar* info = (GLchar*) fastMalloc(length);
     1376    if (!info)
     1377        return "";
     1378
     1379    ::glGetProgramInfoLog((GLuint) program, length, &size, info);
     1380    String s(info);
     1381    fastFree(info);
     1382    return s;
     1383}
     1384
     1385void GraphicsContext3D::getRenderbufferParameteriv(unsigned long target, unsigned long pname, int* value)
     1386{
     1387    ensureContext(m_contextObj);
     1388    ::glGetRenderbufferParameterivEXT(target, pname, value);
     1389}
     1390
     1391void GraphicsContext3D::getShaderiv(Platform3DObject shader, unsigned long pname, int* value)
     1392{
     1393    ASSERT(shader);
     1394   
     1395    ensureContext(m_contextObj);
     1396   
     1397    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
     1398   
     1399    switch (pname) {
     1400        case DELETE_STATUS:
     1401        case SHADER_TYPE:
     1402            // Let OpenGL handle these.
     1403       
     1404            ::glGetShaderiv((GLuint) shader, pname, value);
     1405            break;
     1406
     1407        case COMPILE_STATUS:
     1408            if (result == m_shaderSourceMap.end()) {
     1409                (*value) = static_cast<int>(false);
     1410                return;
     1411            }
     1412               
     1413            (*value) = static_cast<int>(result->second.isValid);
     1414            break;
     1415           
     1416        case INFO_LOG_LENGTH:
     1417            if (result == m_shaderSourceMap.end()) {
     1418                (*value) = 0;
     1419                return;
     1420            }
     1421           
     1422            (*value) = getShaderInfoLog(shader).length();
     1423            break;
     1424           
     1425        case SHADER_SOURCE_LENGTH:
     1426            (*value) = getShaderSource(shader).length();
     1427            break;
     1428       
     1429        default:
     1430            synthesizeGLError(INVALID_ENUM);
     1431    }
     1432}
     1433
     1434String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
     1435{
     1436    ASSERT(shader);
     1437
     1438    ensureContext(m_contextObj);
     1439    GLint length;
     1440    ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
     1441
     1442    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
     1443
     1444    if (result == m_shaderSourceMap.end())
     1445         return "";
     1446
     1447     ShaderSourceEntry entry = result->second;
     1448
     1449     if (entry.isValid) {
     1450         GLint length;
     1451         ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
     1452
     1453         GLsizei size;
     1454         GLchar* info = (GLchar*) fastMalloc(length);
     1455         if (!info)
     1456             return "";
     1457
     1458         ::glGetShaderInfoLog((GLuint) shader, length, &size, info);
     1459
     1460         String s(info);
     1461         fastFree(info);
     1462         return s;
     1463     }
     1464     else {
     1465         return entry.log;
     1466     }
     1467}
     1468
     1469String GraphicsContext3D::getShaderSource(Platform3DObject shader)
     1470{
     1471    ASSERT(shader);
     1472
     1473    ensureContext(m_contextObj);
     1474
     1475    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
     1476
     1477    if (result == m_shaderSourceMap.end())
     1478        return "";
     1479
     1480    return result->second.source;
     1481}
     1482
     1483
     1484void GraphicsContext3D::getTexParameterfv(unsigned long target, unsigned long pname, float* value)
     1485{
     1486    ensureContext(m_contextObj);
     1487    ::glGetTexParameterfv(target, pname, value);
     1488}
     1489
     1490void GraphicsContext3D::getTexParameteriv(unsigned long target, unsigned long pname, int* value)
     1491{
     1492    ensureContext(m_contextObj);
     1493    ::glGetTexParameteriv(target, pname, value);
     1494}
     1495
     1496void GraphicsContext3D::getUniformfv(Platform3DObject program, long location, float* value)
     1497{
     1498    ensureContext(m_contextObj);
     1499    ::glGetUniformfv((GLuint) program, location, value);
     1500}
     1501
     1502void GraphicsContext3D::getUniformiv(Platform3DObject program, long location, int* value)
     1503{
     1504    ensureContext(m_contextObj);
     1505    ::glGetUniformiv((GLuint) program, location, value);
     1506}
     1507
     1508long GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name)
     1509{
     1510    ASSERT(program);
     1511   
     1512    ensureContext(m_contextObj);
     1513    return ::glGetUniformLocation((GLuint) program, name.utf8().data());
     1514}
     1515
     1516void GraphicsContext3D::getVertexAttribfv(unsigned long index, unsigned long pname, float* value)
     1517{
     1518    ensureContext(m_contextObj);
     1519    ::glGetVertexAttribfv(index, pname, value);
     1520}
     1521
     1522void GraphicsContext3D::getVertexAttribiv(unsigned long index, unsigned long pname, int* value)
     1523{
     1524    ensureContext(m_contextObj);
     1525    ::glGetVertexAttribiv(index, pname, value);
     1526}
     1527
     1528long GraphicsContext3D::getVertexAttribOffset(unsigned long index, unsigned long pname)
     1529{
     1530    ensureContext(m_contextObj);
     1531   
     1532    void* pointer;
     1533    ::glGetVertexAttribPointerv(index, pname, &pointer);
     1534    return reinterpret_cast<long>(pointer);
     1535}
     1536
     1537int GraphicsContext3D::texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, void* pixels)
     1538{
     1539    ensureContext(m_contextObj);
     1540
     1541    ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
     1542    return 0;
     1543}
     1544
     1545int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoff, unsigned yoff, unsigned width, unsigned height, unsigned format, unsigned type, void* pixels)
     1546{
     1547    ensureContext(m_contextObj);
     1548
     1549    // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size
     1550    ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels);
     1551    return 0;
     1552}
     1553
     1554unsigned GraphicsContext3D::createBuffer()
     1555{
     1556    ensureContext(m_contextObj);
     1557    GLuint o;
     1558    glGenBuffers(1, &o);
     1559    return o;
     1560}
     1561
     1562unsigned GraphicsContext3D::createFramebuffer()
     1563{
     1564    ensureContext(m_contextObj);
     1565    GLuint o;
     1566    glGenFramebuffersEXT(1, &o);
     1567    return o;
     1568}
     1569
     1570unsigned GraphicsContext3D::createProgram()
     1571{
     1572    ensureContext(m_contextObj);
     1573    return glCreateProgram();
     1574}
     1575
     1576unsigned GraphicsContext3D::createRenderbuffer()
     1577{
     1578    ensureContext(m_contextObj);
     1579    GLuint o;
     1580    glGenRenderbuffersEXT(1, &o);
     1581    return o;
     1582}
     1583
     1584unsigned GraphicsContext3D::createShader(unsigned long type)
     1585{
     1586    ensureContext(m_contextObj);
     1587    return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
     1588}
     1589
     1590unsigned GraphicsContext3D::createTexture()
     1591{
     1592    ensureContext(m_contextObj);
     1593    GLuint o;
     1594    glGenTextures(1, &o);
     1595    return o;
     1596}
     1597
     1598void GraphicsContext3D::deleteBuffer(unsigned buffer)
     1599{
     1600    ensureContext(m_contextObj);
     1601    glDeleteBuffers(1, &buffer);
     1602}
     1603
     1604void GraphicsContext3D::deleteFramebuffer(unsigned framebuffer)
     1605{
     1606    ensureContext(m_contextObj);
     1607    glDeleteFramebuffersEXT(1, &framebuffer);
     1608}
     1609
     1610void GraphicsContext3D::deleteProgram(unsigned program)
     1611{
     1612    ensureContext(m_contextObj);
     1613    glDeleteProgram(program);
     1614}
     1615
     1616void GraphicsContext3D::deleteRenderbuffer(unsigned renderbuffer)
     1617{
     1618    ensureContext(m_contextObj);
     1619    glDeleteRenderbuffersEXT(1, &renderbuffer);
     1620}
     1621
     1622void GraphicsContext3D::deleteShader(unsigned shader)
     1623{
     1624    ensureContext(m_contextObj);
     1625    glDeleteShader(shader);
     1626}
     1627
     1628void GraphicsContext3D::deleteTexture(unsigned texture)
     1629{
     1630    ensureContext(m_contextObj);
     1631    glDeleteTextures(1, &texture);
     1632}
     1633
     1634int GraphicsContext3D::sizeInBytes(int type)
     1635{
     1636    switch (type) {
     1637        case GL_BYTE:
     1638            return sizeof(GLbyte);
     1639        case GL_UNSIGNED_BYTE:
     1640            return sizeof(GLubyte);
     1641        case GL_SHORT:
     1642            return sizeof(GLshort);
     1643        case GL_UNSIGNED_SHORT:
     1644            return sizeof(GLushort);
     1645        case GL_INT:
     1646            return sizeof(GLint);
     1647        case GL_UNSIGNED_INT:
     1648            return sizeof(GLuint);
     1649        case GL_FLOAT:
     1650            return sizeof(GLfloat);
     1651        default:
     1652            return 0;
     1653    }
     1654}
     1655
     1656void GraphicsContext3D::synthesizeGLError(unsigned long error)
     1657{
     1658    m_syntheticErrors.add(error);
     1659}
    2581660
    2591661}
Note: See TracChangeset for help on using the changeset viewer.