Changeset 104896 in webkit


Ignore:
Timestamp:
Jan 12, 2012 8:51:22 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Split GraphicsContext3DOpenGL into several files
https://bugs.webkit.org/show_bug.cgi?id=75462

Patch by ChangSeok Oh <ChangSeok Oh> on 2012-01-12
Reviewed by Kenneth Russell.

Split GraphicsContext3DOpenGL.cpp into three files, GraphicsContext3DOpenGLCommon.cpp,
GraphicsContext3DOpenGL.cpp & GraphicsContext3DOpenGLES.cpp so that makes gles support possible
for WebGL etc. Most of common APIs between gl and gles are in GraphicsContext3DOpenGLCommon.cpp.
The other gl and gles specific APIs are placed apart in GraphicsContext3DOpenGL.cpp &
GraphicsContext3DOpenGLES.cpp

No new tests required.

  • GNUmakefile.list.am: Added GraphicsContext3DOpenGLCommon.cpp
  • Target.pri: Added GraphicsContext3DOpenGLCommon.cpp
  • WebCore.gypi: Added GraphicsContext3DOpenGLCommon.cpp
  • WebCore.xcodeproj/project.pbxproj: Added GraphicsContext3DOpenGLCommon.cpp
  • platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:

(WebCore::GraphicsContext3D::readPixels):
(WebCore::GraphicsContext3D::renderbufferStorage):

  • platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: Copied from Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp.

(WebCore::GraphicsContext3D::validateAttributes):
(WebCore::GraphicsContext3D::isResourceSafe):
(WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
(WebCore::GraphicsContext3D::paintCompositedResultsToCanvas):
(WebCore::GraphicsContext3D::paintRenderingResultsToImageData):
(WebCore::GraphicsContext3D::getInternalFramebufferSize):
(WebCore::GraphicsContext3D::activeTexture):
(WebCore::GraphicsContext3D::attachShader):
(WebCore::GraphicsContext3D::bindAttribLocation):
(WebCore::GraphicsContext3D::bindBuffer):
(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::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::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::releaseShaderCompiler):
(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::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::texSubImage2D):
(WebCore::GraphicsContext3D::compressedTexImage2D):
(WebCore::GraphicsContext3D::compressedTexSubImage2D):
(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::synthesizeGLError):
(WebCore::GraphicsContext3D::markContextChanged):
(WebCore::GraphicsContext3D::markLayerComposited):
(WebCore::GraphicsContext3D::layerComposited):
(WebCore::GraphicsContext3D::getExtensions):

  • platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: Added.

(WebCore::GraphicsContext3D::readRenderingResults):
(WebCore::GraphicsContext3D::reshape):
(WebCore::GraphicsContext3D::prepareTexture):
(WebCore::GraphicsContext3D::bindFramebuffer):
(WebCore::GraphicsContext3D::copyTexImage2D):
(WebCore::GraphicsContext3D::copyTexSubImage2D):
(WebCore::GraphicsContext3D::getActiveUniform):
(WebCore::GraphicsContext3D::readPixels):
(WebCore::GraphicsContext3D::renderbufferStorage):
(WebCore::GraphicsContext3D::getIntegerv):
(WebCore::GraphicsContext3D::texImage2D):

Location:
trunk/Source/WebCore
Files:
1 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r104893 r104896  
     12012-01-12  ChangSeok Oh  <shivamidow@gmail.com>
     2
     3        Split GraphicsContext3DOpenGL into several files
     4        https://bugs.webkit.org/show_bug.cgi?id=75462
     5
     6        Reviewed by Kenneth Russell.
     7
     8        Split GraphicsContext3DOpenGL.cpp into three files, GraphicsContext3DOpenGLCommon.cpp,
     9        GraphicsContext3DOpenGL.cpp & GraphicsContext3DOpenGLES.cpp so that makes gles support possible
     10        for WebGL etc. Most of common APIs between gl and gles are in GraphicsContext3DOpenGLCommon.cpp.
     11        The other gl and gles specific APIs are placed apart in GraphicsContext3DOpenGL.cpp &
     12        GraphicsContext3DOpenGLES.cpp
     13
     14        No new tests required.
     15
     16        * GNUmakefile.list.am: Added GraphicsContext3DOpenGLCommon.cpp
     17        * Target.pri: Added GraphicsContext3DOpenGLCommon.cpp
     18        * WebCore.gypi: Added GraphicsContext3DOpenGLCommon.cpp
     19        * WebCore.xcodeproj/project.pbxproj: Added GraphicsContext3DOpenGLCommon.cpp
     20        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
     21        (WebCore::GraphicsContext3D::readPixels):
     22        (WebCore::GraphicsContext3D::renderbufferStorage):
     23        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: Copied from Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp.
     24        (WebCore::GraphicsContext3D::validateAttributes):
     25        (WebCore::GraphicsContext3D::isResourceSafe):
     26        (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
     27        (WebCore::GraphicsContext3D::paintCompositedResultsToCanvas):
     28        (WebCore::GraphicsContext3D::paintRenderingResultsToImageData):
     29        (WebCore::GraphicsContext3D::getInternalFramebufferSize):
     30        (WebCore::GraphicsContext3D::activeTexture):
     31        (WebCore::GraphicsContext3D::attachShader):
     32        (WebCore::GraphicsContext3D::bindAttribLocation):
     33        (WebCore::GraphicsContext3D::bindBuffer):
     34        (WebCore::GraphicsContext3D::bindRenderbuffer):
     35        (WebCore::GraphicsContext3D::bindTexture):
     36        (WebCore::GraphicsContext3D::blendColor):
     37        (WebCore::GraphicsContext3D::blendEquation):
     38        (WebCore::GraphicsContext3D::blendEquationSeparate):
     39        (WebCore::GraphicsContext3D::blendFunc):
     40        (WebCore::GraphicsContext3D::blendFuncSeparate):
     41        (WebCore::GraphicsContext3D::bufferData):
     42        (WebCore::GraphicsContext3D::bufferSubData):
     43        (WebCore::GraphicsContext3D::checkFramebufferStatus):
     44        (WebCore::GraphicsContext3D::clearColor):
     45        (WebCore::GraphicsContext3D::clear):
     46        (WebCore::GraphicsContext3D::clearDepth):
     47        (WebCore::GraphicsContext3D::clearStencil):
     48        (WebCore::GraphicsContext3D::colorMask):
     49        (WebCore::GraphicsContext3D::compileShader):
     50        (WebCore::GraphicsContext3D::cullFace):
     51        (WebCore::GraphicsContext3D::depthFunc):
     52        (WebCore::GraphicsContext3D::depthMask):
     53        (WebCore::GraphicsContext3D::depthRange):
     54        (WebCore::GraphicsContext3D::detachShader):
     55        (WebCore::GraphicsContext3D::disable):
     56        (WebCore::GraphicsContext3D::disableVertexAttribArray):
     57        (WebCore::GraphicsContext3D::drawArrays):
     58        (WebCore::GraphicsContext3D::drawElements):
     59        (WebCore::GraphicsContext3D::enable):
     60        (WebCore::GraphicsContext3D::enableVertexAttribArray):
     61        (WebCore::GraphicsContext3D::finish):
     62        (WebCore::GraphicsContext3D::flush):
     63        (WebCore::GraphicsContext3D::framebufferRenderbuffer):
     64        (WebCore::GraphicsContext3D::framebufferTexture2D):
     65        (WebCore::GraphicsContext3D::frontFace):
     66        (WebCore::GraphicsContext3D::generateMipmap):
     67        (WebCore::GraphicsContext3D::getActiveAttrib):
     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::releaseShaderCompiler):
     86        (WebCore::GraphicsContext3D::sampleCoverage):
     87        (WebCore::GraphicsContext3D::scissor):
     88        (WebCore::GraphicsContext3D::shaderSource):
     89        (WebCore::GraphicsContext3D::stencilFunc):
     90        (WebCore::GraphicsContext3D::stencilFuncSeparate):
     91        (WebCore::GraphicsContext3D::stencilMask):
     92        (WebCore::GraphicsContext3D::stencilMaskSeparate):
     93        (WebCore::GraphicsContext3D::stencilOp):
     94        (WebCore::GraphicsContext3D::stencilOpSeparate):
     95        (WebCore::GraphicsContext3D::texParameterf):
     96        (WebCore::GraphicsContext3D::texParameteri):
     97        (WebCore::GraphicsContext3D::uniform1f):
     98        (WebCore::GraphicsContext3D::uniform1fv):
     99        (WebCore::GraphicsContext3D::uniform2f):
     100        (WebCore::GraphicsContext3D::uniform2fv):
     101        (WebCore::GraphicsContext3D::uniform3f):
     102        (WebCore::GraphicsContext3D::uniform3fv):
     103        (WebCore::GraphicsContext3D::uniform4f):
     104        (WebCore::GraphicsContext3D::uniform4fv):
     105        (WebCore::GraphicsContext3D::uniform1i):
     106        (WebCore::GraphicsContext3D::uniform1iv):
     107        (WebCore::GraphicsContext3D::uniform2i):
     108        (WebCore::GraphicsContext3D::uniform2iv):
     109        (WebCore::GraphicsContext3D::uniform3i):
     110        (WebCore::GraphicsContext3D::uniform3iv):
     111        (WebCore::GraphicsContext3D::uniform4i):
     112        (WebCore::GraphicsContext3D::uniform4iv):
     113        (WebCore::GraphicsContext3D::uniformMatrix2fv):
     114        (WebCore::GraphicsContext3D::uniformMatrix3fv):
     115        (WebCore::GraphicsContext3D::uniformMatrix4fv):
     116        (WebCore::GraphicsContext3D::useProgram):
     117        (WebCore::GraphicsContext3D::validateProgram):
     118        (WebCore::GraphicsContext3D::vertexAttrib1f):
     119        (WebCore::GraphicsContext3D::vertexAttrib1fv):
     120        (WebCore::GraphicsContext3D::vertexAttrib2f):
     121        (WebCore::GraphicsContext3D::vertexAttrib2fv):
     122        (WebCore::GraphicsContext3D::vertexAttrib3f):
     123        (WebCore::GraphicsContext3D::vertexAttrib3fv):
     124        (WebCore::GraphicsContext3D::vertexAttrib4f):
     125        (WebCore::GraphicsContext3D::vertexAttrib4fv):
     126        (WebCore::GraphicsContext3D::vertexAttribPointer):
     127        (WebCore::GraphicsContext3D::viewport):
     128        (WebCore::GraphicsContext3D::getBooleanv):
     129        (WebCore::GraphicsContext3D::getBufferParameteriv):
     130        (WebCore::GraphicsContext3D::getFloatv):
     131        (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv):
     132        (WebCore::GraphicsContext3D::getProgramiv):
     133        (WebCore::GraphicsContext3D::getProgramInfoLog):
     134        (WebCore::GraphicsContext3D::getRenderbufferParameteriv):
     135        (WebCore::GraphicsContext3D::getShaderiv):
     136        (WebCore::GraphicsContext3D::getShaderInfoLog):
     137        (WebCore::GraphicsContext3D::getShaderSource):
     138        (WebCore::GraphicsContext3D::getTexParameterfv):
     139        (WebCore::GraphicsContext3D::getTexParameteriv):
     140        (WebCore::GraphicsContext3D::getUniformfv):
     141        (WebCore::GraphicsContext3D::getUniformiv):
     142        (WebCore::GraphicsContext3D::getUniformLocation):
     143        (WebCore::GraphicsContext3D::getVertexAttribfv):
     144        (WebCore::GraphicsContext3D::getVertexAttribiv):
     145        (WebCore::GraphicsContext3D::getVertexAttribOffset):
     146        (WebCore::GraphicsContext3D::texSubImage2D):
     147        (WebCore::GraphicsContext3D::compressedTexImage2D):
     148        (WebCore::GraphicsContext3D::compressedTexSubImage2D):
     149        (WebCore::GraphicsContext3D::createBuffer):
     150        (WebCore::GraphicsContext3D::createFramebuffer):
     151        (WebCore::GraphicsContext3D::createProgram):
     152        (WebCore::GraphicsContext3D::createRenderbuffer):
     153        (WebCore::GraphicsContext3D::createShader):
     154        (WebCore::GraphicsContext3D::createTexture):
     155        (WebCore::GraphicsContext3D::deleteBuffer):
     156        (WebCore::GraphicsContext3D::deleteFramebuffer):
     157        (WebCore::GraphicsContext3D::deleteProgram):
     158        (WebCore::GraphicsContext3D::deleteRenderbuffer):
     159        (WebCore::GraphicsContext3D::deleteShader):
     160        (WebCore::GraphicsContext3D::deleteTexture):
     161        (WebCore::GraphicsContext3D::synthesizeGLError):
     162        (WebCore::GraphicsContext3D::markContextChanged):
     163        (WebCore::GraphicsContext3D::markLayerComposited):
     164        (WebCore::GraphicsContext3D::layerComposited):
     165        (WebCore::GraphicsContext3D::getExtensions):
     166        * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: Added.
     167        (WebCore::GraphicsContext3D::readRenderingResults):
     168        (WebCore::GraphicsContext3D::reshape):
     169        (WebCore::GraphicsContext3D::prepareTexture):
     170        (WebCore::GraphicsContext3D::bindFramebuffer):
     171        (WebCore::GraphicsContext3D::copyTexImage2D):
     172        (WebCore::GraphicsContext3D::copyTexSubImage2D):
     173        (WebCore::GraphicsContext3D::getActiveUniform):
     174        (WebCore::GraphicsContext3D::readPixels):
     175        (WebCore::GraphicsContext3D::renderbufferStorage):
     176        (WebCore::GraphicsContext3D::getIntegerv):
     177        (WebCore::GraphicsContext3D::texImage2D):
     178
    11792012-01-12  Wei James  <james.wei@intel.com>
    2180
  • trunk/Source/WebCore/GNUmakefile.list.am

    r104827 r104896  
    56175617        Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp \
    56185618        Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h \
    5619         Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
     5619        Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \
     5620        Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
    56205621endif  # END ENABLE_WEBGL
    56215622
  • trunk/Source/WebCore/Target.pri

    r104827 r104896  
    37413741        SOURCES += \
    37423742            platform/graphics/opengl/Extensions3DOpenGL.cpp \
    3743             platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
     3743            platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \
     3744            platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
    37443745
    37453746        ANGLE_DIR = $$replace(PWD, "WebCore", "ThirdParty/ANGLE")
  • trunk/Source/WebCore/WebCore.gypi

    r104876 r104896  
    38433843            'platform/graphics/opengl/Extensions3DOpenGL.h',
    38443844            'platform/graphics/opengl/GraphicsContext3DOpenGL.cpp',
     3845            'platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp',
    38453846            'platform/graphics/opengl/TextureMapperGL.cpp',
    38463847            'platform/graphics/opengl/TextureMapperGL.h',
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r104859 r104896  
    32543254                93F9B7A10BA6032600854064 /* JSCDATASection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F9B79F0BA6032600854064 /* JSCDATASection.h */; };
    32553255                93FDAFCA0B11307400E2746F /* EditorInsertAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDAFC90B11307400E2746F /* EditorInsertAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3256                96ABA42314BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */; };
    32563257                97059977107D975200A50A7C /* PolicyCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059973107D975200A50A7C /* PolicyCallback.cpp */; };
    32573258                97059978107D975200A50A7C /* PolicyCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059974107D975200A50A7C /* PolicyCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1004810049                93F9B79F0BA6032600854064 /* JSCDATASection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCDATASection.h; sourceTree = "<group>"; };
    1004910050                93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; };
     10051                96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGLCommon.cpp; sourceTree = "<group>"; };
    1005010052                97059973107D975200A50A7C /* PolicyCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyCallback.cpp; sourceTree = "<group>"; };
    1005110053                97059974107D975200A50A7C /* PolicyCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyCallback.h; sourceTree = "<group>"; };
     
    2060420606                                6E67D2A51280E8A4008758F7 /* Extensions3DOpenGL.h */,
    2060520607                                FBC220DE1237FBEB00BCF788 /* GraphicsContext3DOpenGL.cpp */,
     20608                                96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */,
    2060620609                        );
    2060720610                        path = opengl;
     
    2510725110                                49FFBF1D11C8550E006A7118 /* GraphicsContext3DMac.mm in Sources */,
    2510825111                                FBC220DF1237FBEB00BCF788 /* GraphicsContext3DOpenGL.cpp in Sources */,
     25112                                96ABA42314BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp in Sources */,
    2510925113                                B2ED97710B1F55CE00257D0F /* GraphicsContextCG.cpp in Sources */,
    2511025114                                B277B4040B22F37C0004BEC6 /* GraphicsContextMac.mm in Sources */,
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp

    r104430 r104896  
    3030#include "GraphicsContext3D.h"
    3131
    32 #include "CanvasRenderingContext.h"
    3332#include "Extensions3DOpenGL.h"
    34 #include "GraphicsContext.h"
    35 #include "HTMLCanvasElement.h"
    36 #include "ImageBuffer.h"
    37 #include "ImageData.h"
    3833#include "NotImplemented.h"
    39 #include "WebGLObject.h"
    40 #include <cstring>
    41 #include <wtf/ArrayBuffer.h>
    42 #include <wtf/ArrayBufferView.h>
    43 #include <wtf/Float32Array.h>
    44 #include <wtf/Int32Array.h>
    45 #include <wtf/Uint8Array.h>
    46 #include <wtf/UnusedParam.h>
    47 #include <wtf/text/CString.h>
    4834
    4935#if PLATFORM(MAC)
     
    5743
    5844namespace WebCore {
    59 
    60 void GraphicsContext3D::validateAttributes()
    61 {
    62     Extensions3D* extensions = getExtensions();
    63     if (m_attrs.stencil) {
    64         if (extensions->supports("GL_EXT_packed_depth_stencil")) {
    65             extensions->ensureEnabled("GL_EXT_packed_depth_stencil");
    66             // Force depth if stencil is true.
    67             m_attrs.depth = true;
    68         } else
    69             m_attrs.stencil = false;
    70     }
    71     if (m_attrs.antialias) {
    72         bool isValidVendor = true;
    73         // Currently in Mac we only turn on antialias if vendor is NVIDIA.
    74         const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR));
    75         if (!std::strstr(vendor, "NVIDIA"))
    76             isValidVendor = false;
    77         if (!isValidVendor || !extensions->supports("GL_ANGLE_framebuffer_multisample"))
    78             m_attrs.antialias = false;
    79         else
    80             extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample");
    81     }
    82 }
    8345
    8446void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSize)
     
    11880    if (mustRestoreFBO)
    11981        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
    120 }
    121 
    122 bool GraphicsContext3D::isResourceSafe()
    123 {
    124     return false;
    125 }
    126 
    127 #if !PLATFORM(QT)
    128 void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* context, DrawingBuffer*)
    129 {
    130     HTMLCanvasElement* canvas = context->canvas();
    131     ImageBuffer* imageBuffer = canvas->buffer();
    132 
    133     int rowBytes = m_currentWidth * 4;
    134     int totalBytes = rowBytes * m_currentHeight;
    135 
    136     OwnArrayPtr<unsigned char> pixels = adoptArrayPtr(new unsigned char[totalBytes]);
    137     if (!pixels)
    138         return;
    139 
    140     readRenderingResults(pixels.get(), totalBytes);
    141 
    142     if (!m_attrs.premultipliedAlpha) {
    143         for (int i = 0; i < totalBytes; i += 4) {
    144             // Premultiply alpha
    145             pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255);
    146             pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255);
    147             pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255);
    148         }
    149     }
    150 
    151     paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight,
    152                   canvas->width(), canvas->height(), imageBuffer->context()->platformContext());
    153 }
    154 #endif
    155 
    156 bool GraphicsContext3D::paintCompositedResultsToCanvas(CanvasRenderingContext*)
    157 {
    158     // Not needed at the moment, so return that nothing was done.
    159     return false;
    160 }
    161 
    162 PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(DrawingBuffer*)
    163 {
    164     // Reading premultiplied alpha would involve unpremultiplying, which is
    165     // lossy
    166     if (m_attrs.premultipliedAlpha)
    167         return 0;
    168 
    169     RefPtr<ImageData> imageData = ImageData::create(IntSize(m_currentWidth, m_currentHeight));
    170     unsigned char* pixels = imageData->data()->data()->data();
    171     int totalBytes = 4 * m_currentWidth * m_currentHeight;
    172 
    173     readRenderingResults(pixels, totalBytes);
    174 
    175     // Convert to RGBA
    176     for (int i = 0; i < totalBytes; i += 4)
    177         std::swap(pixels[i], pixels[i + 2]);
    178 
    179     return imageData.release();
    18082}
    18183
     
    334236}
    335237
    336 IntSize GraphicsContext3D::getInternalFramebufferSize() const
    337 {
    338     return IntSize(m_currentWidth, m_currentHeight);
    339 }
    340 
    341238void GraphicsContext3D::prepareTexture()
    342239{
     
    360257}
    361258
    362 void GraphicsContext3D::activeTexture(GC3Denum texture)
    363 {
    364     makeContextCurrent();
    365     m_activeTexture = texture;
    366     ::glActiveTexture(texture);
    367 }
    368 
    369 void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader)
    370 {
    371     ASSERT(program);
    372     ASSERT(shader);
    373     makeContextCurrent();
    374     ::glAttachShader(program, shader);
    375 }
    376 
    377 void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name)
    378 {
    379     ASSERT(program);
    380     makeContextCurrent();
    381     ::glBindAttribLocation(program, index, name.utf8().data());
    382 }
    383 
    384 void GraphicsContext3D::bindBuffer(GC3Denum target, Platform3DObject buffer)
    385 {
    386     makeContextCurrent();
    387     ::glBindBuffer(target, buffer);
    388 }
    389 
    390 
    391259void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer)
    392260{
     
    403271}
    404272
    405 void GraphicsContext3D::bindRenderbuffer(GC3Denum target, Platform3DObject renderbuffer)
    406 {
    407     makeContextCurrent();
    408     ::glBindRenderbufferEXT(target, renderbuffer);
    409 }
    410 
    411 
    412 void GraphicsContext3D::bindTexture(GC3Denum target, Platform3DObject texture)
    413 {
    414     makeContextCurrent();
    415     if (m_activeTexture && target == GL_TEXTURE_2D)
    416         m_boundTexture0 = texture;
    417     ::glBindTexture(target, texture);
    418 }
    419 
    420 void GraphicsContext3D::blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha)
    421 {
    422     makeContextCurrent();
    423     ::glBlendColor(red, green, blue, alpha);
    424 }
    425 
    426 void GraphicsContext3D::blendEquation(GC3Denum mode)
    427 {
    428     makeContextCurrent();
    429     ::glBlendEquation(mode);
    430 }
    431 
    432 void GraphicsContext3D::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha)
    433 {
    434     makeContextCurrent();
    435     ::glBlendEquationSeparate(modeRGB, modeAlpha);
    436 }
    437 
    438 
    439 void GraphicsContext3D::blendFunc(GC3Denum sfactor, GC3Denum dfactor)
    440 {
    441     makeContextCurrent();
    442     ::glBlendFunc(sfactor, dfactor);
    443 }       
    444 
    445 void GraphicsContext3D::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha)
    446 {
    447     makeContextCurrent();
    448     ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
    449 }
    450 
    451 void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage)
    452 {
    453     makeContextCurrent();
    454     ::glBufferData(target, size, 0, usage);
    455 }
    456 
    457 void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage)
    458 {
    459     makeContextCurrent();
    460     ::glBufferData(target, size, data, usage);
    461 }
    462 
    463 void GraphicsContext3D::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data)
    464 {
    465     makeContextCurrent();
    466     ::glBufferSubData(target, offset, size, data);
    467 }
    468 
    469 GC3Denum GraphicsContext3D::checkFramebufferStatus(GC3Denum target)
    470 {
    471     makeContextCurrent();
    472     return ::glCheckFramebufferStatusEXT(target);
    473 }
    474 
    475 void GraphicsContext3D::clearColor(GC3Dclampf r, GC3Dclampf g, GC3Dclampf b, GC3Dclampf a)
    476 {
    477     makeContextCurrent();
    478     ::glClearColor(r, g, b, a);
    479 }
    480 
    481 void GraphicsContext3D::clear(GC3Dbitfield mask)
    482 {
    483     makeContextCurrent();
    484     ::glClear(mask);
    485 }
    486 
    487 void GraphicsContext3D::clearDepth(GC3Dclampf depth)
    488 {
    489     makeContextCurrent();
    490     ::glClearDepth(depth);
    491 }
    492 
    493 void GraphicsContext3D::clearStencil(GC3Dint s)
    494 {
    495     makeContextCurrent();
    496     ::glClearStencil(s);
    497 }
    498 
    499 void GraphicsContext3D::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha)
    500 {
    501     makeContextCurrent();
    502     ::glColorMask(red, green, blue, alpha);
    503 }
    504 
    505 void GraphicsContext3D::compileShader(Platform3DObject shader)
    506 {
    507     ASSERT(shader);
    508     makeContextCurrent();
    509 
    510     int GLshaderType;
    511     ANGLEShaderType shaderType;
    512 
    513     glGetShaderiv(shader, SHADER_TYPE, &GLshaderType);
    514    
    515     if (GLshaderType == VERTEX_SHADER)
    516         shaderType = SHADER_TYPE_VERTEX;
    517     else if (GLshaderType == FRAGMENT_SHADER)
    518         shaderType = SHADER_TYPE_FRAGMENT;
    519     else
    520         return; // Invalid shader type.
    521 
    522     HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
    523 
    524     if (result == m_shaderSourceMap.end())
    525         return;
    526 
    527     ShaderSourceEntry& entry = result->second;
    528 
    529     String translatedShaderSource;
    530     String shaderInfoLog;
    531 
    532     bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);
    533 
    534     entry.log = shaderInfoLog;
    535     entry.isValid = isValid;
    536 
    537     if (!isValid)
    538         return; // Shader didn't validate, don't move forward with compiling translated source   
    539 
    540     int translatedShaderLength = translatedShaderSource.length();
    541 
    542     const CString& translatedShaderCString = translatedShaderSource.utf8();
    543     const char* translatedShaderPtr = translatedShaderCString.data();
    544    
    545     ::glShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength);
    546    
    547     ::glCompileShader(shader);
    548    
    549     int GLCompileSuccess;
    550    
    551     ::glGetShaderiv(shader, COMPILE_STATUS, &GLCompileSuccess);
    552    
    553     // ASSERT that ANGLE generated GLSL will be accepted by OpenGL
    554     ASSERT(GLCompileSuccess == GL_TRUE);
    555 }
    556 
    557273void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
    558274{
     
    583299}
    584300
    585 void GraphicsContext3D::cullFace(GC3Denum mode)
    586 {
    587     makeContextCurrent();
    588     ::glCullFace(mode);
    589 }
    590 
    591 void GraphicsContext3D::depthFunc(GC3Denum func)
    592 {
    593     makeContextCurrent();
    594     ::glDepthFunc(func);
    595 }
    596 
    597 void GraphicsContext3D::depthMask(GC3Dboolean flag)
    598 {
    599     makeContextCurrent();
    600     ::glDepthMask(flag);
    601 }
    602 
    603 void GraphicsContext3D::depthRange(GC3Dclampf zNear, GC3Dclampf zFar)
    604 {
    605     makeContextCurrent();
    606     ::glDepthRange(zNear, zFar);
    607 }
    608 
    609 void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader)
    610 {
    611     ASSERT(program);
    612     ASSERT(shader);
    613     makeContextCurrent();
    614     ::glDetachShader(program, shader);
    615 }
    616 
    617 void GraphicsContext3D::disable(GC3Denum cap)
    618 {
    619     makeContextCurrent();
    620     ::glDisable(cap);
    621 }
    622 
    623 void GraphicsContext3D::disableVertexAttribArray(GC3Duint index)
    624 {
    625     makeContextCurrent();
    626     ::glDisableVertexAttribArray(index);
    627 }
    628 
    629 void GraphicsContext3D::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count)
    630 {
    631     makeContextCurrent();
    632     ::glDrawArrays(mode, first, count);
    633 }
    634 
    635 void GraphicsContext3D::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset)
    636 {
    637     makeContextCurrent();
    638     ::glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
    639 }
    640 
    641 void GraphicsContext3D::enable(GC3Denum cap)
    642 {
    643     makeContextCurrent();
    644     ::glEnable(cap);
    645 }
    646 
    647 void GraphicsContext3D::enableVertexAttribArray(GC3Duint index)
    648 {
    649     makeContextCurrent();
    650     ::glEnableVertexAttribArray(index);
    651 }
    652 
    653 void GraphicsContext3D::finish()
    654 {
    655     makeContextCurrent();
    656     ::glFinish();
    657 }
    658 
    659 void GraphicsContext3D::flush()
    660 {
    661     makeContextCurrent();
    662     ::glFlush();
    663 }
    664 
    665 void GraphicsContext3D::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject buffer)
    666 {
    667     makeContextCurrent();
    668     ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer);
    669 }
    670 
    671 void GraphicsContext3D::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject texture, GC3Dint level)
    672 {
    673     makeContextCurrent();
    674     ::glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
    675 }
    676 
    677 void GraphicsContext3D::frontFace(GC3Denum mode)
    678 {
    679     makeContextCurrent();
    680     ::glFrontFace(mode);
    681 }
    682 
    683 void GraphicsContext3D::generateMipmap(GC3Denum target)
    684 {
    685     makeContextCurrent();
    686     ::glGenerateMipmapEXT(target);
    687 }
    688 
    689 bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info)
    690 {
    691     if (!program) {
    692         synthesizeGLError(INVALID_VALUE);
    693         return false;
    694     }
    695     makeContextCurrent();
    696     GLint maxAttributeSize = 0;
    697     ::glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize);
    698     GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination
    699     GLsizei nameLength = 0;
    700     GLint size = 0;
    701     GLenum type = 0;
    702     ::glGetActiveAttrib(program, index, maxAttributeSize, &nameLength, &size, &type, name);
    703     if (!nameLength)
    704         return false;
    705     info.name = String(name, nameLength);
    706     info.type = type;
    707     info.size = size;
    708     return true;
    709 }
    710    
    711301bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info)
    712302{
     
    731321}
    732322
    733 void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders)
    734 {
    735     if (!program) {
    736         synthesizeGLError(INVALID_VALUE);
    737         return;
    738     }
    739     makeContextCurrent();
    740     ::glGetAttachedShaders(program, maxCount, count, shaders);
    741 }
    742 
    743 int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name)
    744 {
    745     if (!program)
    746         return -1;
    747 
    748     makeContextCurrent();
    749     return ::glGetAttribLocation(program, name.utf8().data());
    750 }
    751 
    752 GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes()
    753 {
    754     return m_attrs;
    755 }
    756 
    757 GC3Denum GraphicsContext3D::getError()
    758 {
    759     if (m_syntheticErrors.size() > 0) {
    760         ListHashSet<GC3Denum>::iterator iter = m_syntheticErrors.begin();
    761         GC3Denum err = *iter;
    762         m_syntheticErrors.remove(iter);
    763         return err;
    764     }
    765 
    766     makeContextCurrent();
    767     return ::glGetError();
    768 }
    769 
    770 String GraphicsContext3D::getString(GC3Denum name)
    771 {
    772     makeContextCurrent();
    773     return String(reinterpret_cast<const char*>(::glGetString(name)));
    774 }
    775 
    776 void GraphicsContext3D::hint(GC3Denum target, GC3Denum mode)
    777 {
    778     makeContextCurrent();
    779     ::glHint(target, mode);
    780 }
    781 
    782 GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject buffer)
    783 {
    784     if (!buffer)
    785         return GL_FALSE;
    786 
    787     makeContextCurrent();
    788     return ::glIsBuffer(buffer);
    789 }
    790 
    791 GC3Dboolean GraphicsContext3D::isEnabled(GC3Denum cap)
    792 {
    793     makeContextCurrent();
    794     return ::glIsEnabled(cap);
    795 }
    796 
    797 GC3Dboolean GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer)
    798 {
    799     if (!framebuffer)
    800         return GL_FALSE;
    801 
    802     makeContextCurrent();
    803     return ::glIsFramebufferEXT(framebuffer);
    804 }
    805 
    806 GC3Dboolean GraphicsContext3D::isProgram(Platform3DObject program)
    807 {
    808     if (!program)
    809         return GL_FALSE;
    810 
    811     makeContextCurrent();
    812     return ::glIsProgram(program);
    813 }
    814 
    815 GC3Dboolean GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer)
    816 {
    817     if (!renderbuffer)
    818         return GL_FALSE;
    819 
    820     makeContextCurrent();
    821     return ::glIsRenderbufferEXT(renderbuffer);
    822 }
    823 
    824 GC3Dboolean GraphicsContext3D::isShader(Platform3DObject shader)
    825 {
    826     if (!shader)
    827         return GL_FALSE;
    828 
    829     makeContextCurrent();
    830     return ::glIsShader(shader);
    831 }
    832 
    833 GC3Dboolean GraphicsContext3D::isTexture(Platform3DObject texture)
    834 {
    835     if (!texture)
    836         return GL_FALSE;
    837 
    838     makeContextCurrent();
    839     return ::glIsTexture(texture);
    840 }
    841 
    842 void GraphicsContext3D::lineWidth(GC3Dfloat width)
    843 {
    844     makeContextCurrent();
    845     ::glLineWidth(width);
    846 }
    847 
    848 void GraphicsContext3D::linkProgram(Platform3DObject program)
    849 {
    850     ASSERT(program);
    851     makeContextCurrent();
    852     ::glLinkProgram(program);
    853 }
    854 
    855 void GraphicsContext3D::pixelStorei(GC3Denum pname, GC3Dint param)
    856 {
    857     makeContextCurrent();
    858     ::glPixelStorei(pname, param);
    859 }
    860 
    861 void GraphicsContext3D::polygonOffset(GC3Dfloat factor, GC3Dfloat units)
    862 {
    863     makeContextCurrent();
    864     ::glPolygonOffset(factor, units);
    865 }
    866323
    867324void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data)
     
    883340}
    884341
    885 void GraphicsContext3D::releaseShaderCompiler()
    886 {
    887     // FIXME: This is not implemented on desktop OpenGL. We need to have ifdefs for the different GL variants.
    888     makeContextCurrent();
    889     notImplemented();
    890 }
    891 
    892342void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height)
    893343{
     
    909359    }
    910360    ::glRenderbufferStorageEXT(target, internalformat, width, height);
    911 }
    912 
    913 void GraphicsContext3D::sampleCoverage(GC3Dclampf value, GC3Dboolean invert)
    914 {
    915     makeContextCurrent();
    916     ::glSampleCoverage(value, invert);
    917 }
    918 
    919 void GraphicsContext3D::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    920 {
    921     makeContextCurrent();
    922     ::glScissor(x, y, width, height);
    923 }
    924 
    925 void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string)
    926 {
    927     ASSERT(shader);
    928 
    929     makeContextCurrent();
    930 
    931     ShaderSourceEntry entry;
    932 
    933     entry.source = string;
    934 
    935     m_shaderSourceMap.set(shader, entry);
    936 }
    937 
    938 void GraphicsContext3D::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask)
    939 {
    940     makeContextCurrent();
    941     ::glStencilFunc(func, ref, mask);
    942 }
    943 
    944 void GraphicsContext3D::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask)
    945 {
    946     makeContextCurrent();
    947     ::glStencilFuncSeparate(face, func, ref, mask);
    948 }
    949 
    950 void GraphicsContext3D::stencilMask(GC3Duint mask)
    951 {
    952     makeContextCurrent();
    953     ::glStencilMask(mask);
    954 }
    955 
    956 void GraphicsContext3D::stencilMaskSeparate(GC3Denum face, GC3Duint mask)
    957 {
    958     makeContextCurrent();
    959     ::glStencilMaskSeparate(face, mask);
    960 }
    961 
    962 void GraphicsContext3D::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass)
    963 {
    964     makeContextCurrent();
    965     ::glStencilOp(fail, zfail, zpass);
    966 }
    967 
    968 void GraphicsContext3D::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass)
    969 {
    970     makeContextCurrent();
    971     ::glStencilOpSeparate(face, fail, zfail, zpass);
    972 }
    973 
    974 void GraphicsContext3D::texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat value)
    975 {
    976     makeContextCurrent();
    977     ::glTexParameterf(target, pname, value);
    978 }
    979 
    980 void GraphicsContext3D::texParameteri(GC3Denum target, GC3Denum pname, GC3Dint value)
    981 {
    982     makeContextCurrent();
    983     ::glTexParameteri(target, pname, value);
    984 }
    985 
    986 void GraphicsContext3D::uniform1f(GC3Dint location, GC3Dfloat v0)
    987 {
    988     makeContextCurrent();
    989     ::glUniform1f(location, v0);
    990 }
    991 
    992 void GraphicsContext3D::uniform1fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size)
    993 {
    994     makeContextCurrent();
    995     ::glUniform1fv(location, size, array);
    996 }
    997 
    998 void GraphicsContext3D::uniform2f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1)
    999 {
    1000     makeContextCurrent();
    1001     ::glUniform2f(location, v0, v1);
    1002 }
    1003 
    1004 void GraphicsContext3D::uniform2fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size)
    1005 {
    1006     // FIXME: length needs to be a multiple of 2
    1007     makeContextCurrent();
    1008     ::glUniform2fv(location, size, array);
    1009 }
    1010 
    1011 void GraphicsContext3D::uniform3f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2)
    1012 {
    1013     makeContextCurrent();
    1014     ::glUniform3f(location, v0, v1, v2);
    1015 }
    1016 
    1017 void GraphicsContext3D::uniform3fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size)
    1018 {
    1019     // FIXME: length needs to be a multiple of 3
    1020     makeContextCurrent();
    1021     ::glUniform3fv(location, size, array);
    1022 }
    1023 
    1024 void GraphicsContext3D::uniform4f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3)
    1025 {
    1026     makeContextCurrent();
    1027     ::glUniform4f(location, v0, v1, v2, v3);
    1028 }
    1029 
    1030 void GraphicsContext3D::uniform4fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size)
    1031 {
    1032     // FIXME: length needs to be a multiple of 4
    1033     makeContextCurrent();
    1034     ::glUniform4fv(location, size, array);
    1035 }
    1036 
    1037 void GraphicsContext3D::uniform1i(GC3Dint location, GC3Dint v0)
    1038 {
    1039     makeContextCurrent();
    1040     ::glUniform1i(location, v0);
    1041 }
    1042 
    1043 void GraphicsContext3D::uniform1iv(GC3Dint location, GC3Dint* array, GC3Dsizei size)
    1044 {
    1045     makeContextCurrent();
    1046     ::glUniform1iv(location, size, array);
    1047 }
    1048 
    1049 void GraphicsContext3D::uniform2i(GC3Dint location, GC3Dint v0, GC3Dint v1)
    1050 {
    1051     makeContextCurrent();
    1052     ::glUniform2i(location, v0, v1);
    1053 }
    1054 
    1055 void GraphicsContext3D::uniform2iv(GC3Dint location, GC3Dint* array, GC3Dsizei size)
    1056 {
    1057     // FIXME: length needs to be a multiple of 2
    1058     makeContextCurrent();
    1059     ::glUniform2iv(location, size, array);
    1060 }
    1061 
    1062 void GraphicsContext3D::uniform3i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2)
    1063 {
    1064     makeContextCurrent();
    1065     ::glUniform3i(location, v0, v1, v2);
    1066 }
    1067 
    1068 void GraphicsContext3D::uniform3iv(GC3Dint location, GC3Dint* array, GC3Dsizei size)
    1069 {
    1070     // FIXME: length needs to be a multiple of 3
    1071     makeContextCurrent();
    1072     ::glUniform3iv(location, size, array);
    1073 }
    1074 
    1075 void GraphicsContext3D::uniform4i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2, GC3Dint v3)
    1076 {
    1077     makeContextCurrent();
    1078     ::glUniform4i(location, v0, v1, v2, v3);
    1079 }
    1080 
    1081 void GraphicsContext3D::uniform4iv(GC3Dint location, GC3Dint* array, GC3Dsizei size)
    1082 {
    1083     // FIXME: length needs to be a multiple of 4
    1084     makeContextCurrent();
    1085     ::glUniform4iv(location, size, array);
    1086 }
    1087 
    1088 void GraphicsContext3D::uniformMatrix2fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size)
    1089 {
    1090     // FIXME: length needs to be a multiple of 4
    1091     makeContextCurrent();
    1092     ::glUniformMatrix2fv(location, size, transpose, array);
    1093 }
    1094 
    1095 void GraphicsContext3D::uniformMatrix3fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size)
    1096 {
    1097     // FIXME: length needs to be a multiple of 9
    1098     makeContextCurrent();
    1099     ::glUniformMatrix3fv(location, size, transpose, array);
    1100 }
    1101 
    1102 void GraphicsContext3D::uniformMatrix4fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size)
    1103 {
    1104     // FIXME: length needs to be a multiple of 16
    1105     makeContextCurrent();
    1106     ::glUniformMatrix4fv(location, size, transpose, array);
    1107 }
    1108 
    1109 void GraphicsContext3D::useProgram(Platform3DObject program)
    1110 {
    1111     makeContextCurrent();
    1112     ::glUseProgram(program);
    1113 }
    1114 
    1115 void GraphicsContext3D::validateProgram(Platform3DObject program)
    1116 {
    1117     ASSERT(program);
    1118 
    1119     makeContextCurrent();
    1120     ::glValidateProgram(program);
    1121 }
    1122 
    1123 void GraphicsContext3D::vertexAttrib1f(GC3Duint index, GC3Dfloat v0)
    1124 {
    1125     makeContextCurrent();
    1126     ::glVertexAttrib1f(index, v0);
    1127 }
    1128 
    1129 void GraphicsContext3D::vertexAttrib1fv(GC3Duint index, GC3Dfloat* array)
    1130 {
    1131     makeContextCurrent();
    1132     ::glVertexAttrib1fv(index, array);
    1133 }
    1134 
    1135 void GraphicsContext3D::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1)
    1136 {
    1137     makeContextCurrent();
    1138     ::glVertexAttrib2f(index, v0, v1);
    1139 }
    1140 
    1141 void GraphicsContext3D::vertexAttrib2fv(GC3Duint index, GC3Dfloat* array)
    1142 {
    1143     makeContextCurrent();
    1144     ::glVertexAttrib2fv(index, array);
    1145 }
    1146 
    1147 void GraphicsContext3D::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2)
    1148 {
    1149     makeContextCurrent();
    1150     ::glVertexAttrib3f(index, v0, v1, v2);
    1151 }
    1152 
    1153 void GraphicsContext3D::vertexAttrib3fv(GC3Duint index, GC3Dfloat* array)
    1154 {
    1155     makeContextCurrent();
    1156     ::glVertexAttrib3fv(index, array);
    1157 }
    1158 
    1159 void GraphicsContext3D::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3)
    1160 {
    1161     makeContextCurrent();
    1162     ::glVertexAttrib4f(index, v0, v1, v2, v3);
    1163 }
    1164 
    1165 void GraphicsContext3D::vertexAttrib4fv(GC3Duint index, GC3Dfloat* array)
    1166 {
    1167     makeContextCurrent();
    1168     ::glVertexAttrib4fv(index, array);
    1169 }
    1170 
    1171 void GraphicsContext3D::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset)
    1172 {
    1173     makeContextCurrent();
    1174     ::glVertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
    1175 }
    1176 
    1177 void GraphicsContext3D::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    1178 {
    1179     makeContextCurrent();
    1180     ::glViewport(x, y, width, height);
    1181 }
    1182 
    1183 void GraphicsContext3D::getBooleanv(GC3Denum pname, GC3Dboolean* value)
    1184 {
    1185     makeContextCurrent();
    1186     ::glGetBooleanv(pname, value);
    1187 }
    1188 
    1189 void GraphicsContext3D::getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value)
    1190 {
    1191     makeContextCurrent();
    1192     ::glGetBufferParameteriv(target, pname, value);
    1193 }
    1194 
    1195 void GraphicsContext3D::getFloatv(GC3Denum pname, GC3Dfloat* value)
    1196 {
    1197     makeContextCurrent();
    1198     ::glGetFloatv(pname, value);
    1199 }
    1200 
    1201 void GraphicsContext3D::getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value)
    1202 {
    1203     makeContextCurrent();
    1204     if (attachment == DEPTH_STENCIL_ATTACHMENT)
    1205         attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works.
    1206     ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value);
    1207361}
    1208362
     
    1230384        ::glGetIntegerv(pname, value);
    1231385    }
    1232 }
    1233 
    1234 void GraphicsContext3D::getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value)
    1235 {
    1236     makeContextCurrent();
    1237     ::glGetProgramiv(program, pname, value);
    1238 }
    1239 
    1240 String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)
    1241 {
    1242     ASSERT(program);
    1243 
    1244     makeContextCurrent();
    1245     GLint length = 0;
    1246     ::glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
    1247     if (!length)
    1248         return String();
    1249 
    1250     GLsizei size = 0;
    1251     OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]);
    1252     ::glGetProgramInfoLog(program, length, &size, info.get());
    1253 
    1254     return String(info.get());
    1255 }
    1256 
    1257 void GraphicsContext3D::getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value)
    1258 {
    1259     makeContextCurrent();
    1260     ::glGetRenderbufferParameterivEXT(target, pname, value);
    1261 }
    1262 
    1263 void GraphicsContext3D::getShaderiv(Platform3DObject shader, GC3Denum pname, GC3Dint* value)
    1264 {
    1265     ASSERT(shader);
    1266 
    1267     makeContextCurrent();
    1268 
    1269     HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
    1270    
    1271     switch (pname) {
    1272     case DELETE_STATUS:
    1273     case SHADER_TYPE:
    1274         ::glGetShaderiv(shader, pname, value);
    1275         break;
    1276     case COMPILE_STATUS:
    1277         if (result == m_shaderSourceMap.end()) {
    1278             *value = static_cast<int>(false);
    1279             return;
    1280         }
    1281         *value = static_cast<int>(result->second.isValid);
    1282         break;
    1283     case INFO_LOG_LENGTH:
    1284         if (result == m_shaderSourceMap.end()) {
    1285             *value = 0;
    1286             return;
    1287         }
    1288         *value = getShaderInfoLog(shader).length();
    1289         break;
    1290     case SHADER_SOURCE_LENGTH:
    1291         *value = getShaderSource(shader).length();
    1292         break;
    1293     default:
    1294         synthesizeGLError(INVALID_ENUM);
    1295     }
    1296 }
    1297 
    1298 String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
    1299 {
    1300     ASSERT(shader);
    1301 
    1302     makeContextCurrent();
    1303 
    1304     HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
    1305     if (result == m_shaderSourceMap.end())
    1306         return String();
    1307 
    1308     ShaderSourceEntry entry = result->second;
    1309     if (!entry.isValid)
    1310         return entry.log;
    1311 
    1312     GLint length = 0;
    1313     ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
    1314     if (!length)
    1315         return String();
    1316 
    1317     GLsizei size = 0;
    1318     OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]);
    1319     ::glGetShaderInfoLog(shader, length, &size, info.get());
    1320 
    1321     return String(info.get());
    1322 }
    1323 
    1324 String GraphicsContext3D::getShaderSource(Platform3DObject shader)
    1325 {
    1326     ASSERT(shader);
    1327 
    1328     makeContextCurrent();
    1329 
    1330     HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
    1331     if (result == m_shaderSourceMap.end())
    1332         return String();
    1333 
    1334     return result->second.source;
    1335 }
    1336 
    1337 
    1338 void GraphicsContext3D::getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value)
    1339 {
    1340     makeContextCurrent();
    1341     ::glGetTexParameterfv(target, pname, value);
    1342 }
    1343 
    1344 void GraphicsContext3D::getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value)
    1345 {
    1346     makeContextCurrent();
    1347     ::glGetTexParameteriv(target, pname, value);
    1348 }
    1349 
    1350 void GraphicsContext3D::getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value)
    1351 {
    1352     makeContextCurrent();
    1353     ::glGetUniformfv(program, location, value);
    1354 }
    1355 
    1356 void GraphicsContext3D::getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value)
    1357 {
    1358     makeContextCurrent();
    1359     ::glGetUniformiv(program, location, value);
    1360 }
    1361 
    1362 GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name)
    1363 {
    1364     ASSERT(program);
    1365 
    1366     makeContextCurrent();
    1367     return ::glGetUniformLocation(program, name.utf8().data());
    1368 }
    1369 
    1370 void GraphicsContext3D::getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value)
    1371 {
    1372     makeContextCurrent();
    1373     ::glGetVertexAttribfv(index, pname, value);
    1374 }
    1375 
    1376 void GraphicsContext3D::getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value)
    1377 {
    1378     makeContextCurrent();
    1379     ::glGetVertexAttribiv(index, pname, value);
    1380 }
    1381 
    1382 GC3Dsizeiptr GraphicsContext3D::getVertexAttribOffset(GC3Duint index, GC3Denum pname)
    1383 {
    1384     makeContextCurrent();
    1385 
    1386     GLvoid* pointer = 0;
    1387     ::glGetVertexAttribPointerv(index, pname, &pointer);
    1388     return static_cast<GC3Dsizeiptr>(reinterpret_cast<intptr_t>(pointer));
    1389386}
    1390387
     
    1408405}
    1409406
    1410 void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoff, GC3Dint yoff, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels)
    1411 {
    1412     makeContextCurrent();
    1413 
    1414     // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size
    1415     ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels);
    1416 }
    1417 
    1418 void GraphicsContext3D::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data)
    1419 {
    1420     makeContextCurrent();
    1421     ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
    1422 }
    1423 
    1424 void GraphicsContext3D::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data)
    1425 {
    1426     makeContextCurrent();
    1427     ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
    1428 }
    1429 
    1430 Platform3DObject GraphicsContext3D::createBuffer()
    1431 {
    1432     makeContextCurrent();
    1433     GLuint o = 0;
    1434     glGenBuffers(1, &o);
    1435     return o;
    1436 }
    1437 
    1438 Platform3DObject GraphicsContext3D::createFramebuffer()
    1439 {
    1440     makeContextCurrent();
    1441     GLuint o = 0;
    1442     glGenFramebuffersEXT(1, &o);
    1443     return o;
    1444 }
    1445 
    1446 Platform3DObject GraphicsContext3D::createProgram()
    1447 {
    1448     makeContextCurrent();
    1449     return glCreateProgram();
    1450 }
    1451 
    1452 Platform3DObject GraphicsContext3D::createRenderbuffer()
    1453 {
    1454     makeContextCurrent();
    1455     GLuint o = 0;
    1456     glGenRenderbuffersEXT(1, &o);
    1457     return o;
    1458 }
    1459 
    1460 Platform3DObject GraphicsContext3D::createShader(GC3Denum type)
    1461 {
    1462     makeContextCurrent();
    1463     return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
    1464 }
    1465 
    1466 Platform3DObject GraphicsContext3D::createTexture()
    1467 {
    1468     makeContextCurrent();
    1469     GLuint o = 0;
    1470     glGenTextures(1, &o);
    1471     return o;
    1472 }
    1473 
    1474 void GraphicsContext3D::deleteBuffer(Platform3DObject buffer)
    1475 {
    1476     makeContextCurrent();
    1477     glDeleteBuffers(1, &buffer);
    1478 }
    1479 
    1480 void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer)
    1481 {
    1482     makeContextCurrent();
    1483     glDeleteFramebuffersEXT(1, &framebuffer);
    1484 }
    1485 
    1486 void GraphicsContext3D::deleteProgram(Platform3DObject program)
    1487 {
    1488     makeContextCurrent();
    1489     glDeleteProgram(program);
    1490 }
    1491 
    1492 void GraphicsContext3D::deleteRenderbuffer(Platform3DObject renderbuffer)
    1493 {
    1494     makeContextCurrent();
    1495     glDeleteRenderbuffersEXT(1, &renderbuffer);
    1496 }
    1497 
    1498 void GraphicsContext3D::deleteShader(Platform3DObject shader)
    1499 {
    1500     makeContextCurrent();
    1501     glDeleteShader(shader);
    1502 }
    1503 
    1504 void GraphicsContext3D::deleteTexture(Platform3DObject texture)
    1505 {
    1506     makeContextCurrent();
    1507     glDeleteTextures(1, &texture);
    1508 }
    1509 
    1510 void GraphicsContext3D::synthesizeGLError(GC3Denum error)
    1511 {
    1512     m_syntheticErrors.add(error);
    1513 }
    1514 
    1515 void GraphicsContext3D::markContextChanged()
    1516 {
    1517     m_layerComposited = false;
    1518 }
    1519 
    1520 void GraphicsContext3D::markLayerComposited()
    1521 {
    1522     m_layerComposited = true;
    1523 }
    1524 
    1525 bool GraphicsContext3D::layerComposited() const
    1526 {
    1527     return m_layerComposited;
    1528 }
    1529 
    1530 Extensions3D* GraphicsContext3D::getExtensions()
    1531 {
    1532     if (!m_extensions)
    1533         m_extensions = adoptPtr(new Extensions3DOpenGL(this));
    1534     return m_extensions.get();
    1535 }
    1536 
    1537407}
    1538408
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

    r104895 r104896  
    8282}
    8383
    84 void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSize)
    85 {
    86     if (pixelsSize < m_currentWidth * m_currentHeight * 4)
    87         return;
    88 
    89     makeContextCurrent();
    90 
    91     bool mustRestoreFBO = false;
    92     if (m_attrs.antialias) {
    93         ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
    94         ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
    95         ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
    96         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    97         mustRestoreFBO = true;
    98     } else {
    99         if (m_boundFBO != m_fbo) {
    100             mustRestoreFBO = true;
    101             ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    102         }
    103     }
    104 
    105     GLint packAlignment = 4;
    106     bool mustRestorePackAlignment = false;
    107     ::glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment);
    108     if (packAlignment > 4) {
    109         ::glPixelStorei(GL_PACK_ALIGNMENT, 4);
    110         mustRestorePackAlignment = true;
    111     }
    112 
    113     ::glReadPixels(0, 0, m_currentWidth, m_currentHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
    114 
    115     if (mustRestorePackAlignment)
    116         ::glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);
    117 
    118     if (mustRestoreFBO)
    119         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
    120 }
    121 
    12284bool GraphicsContext3D::isResourceSafe()
    12385{
     
    180142}
    181143
    182 void GraphicsContext3D::reshape(int width, int height)
    183 {
    184     if (!platformGraphicsContext3D())
    185         return;
    186 
    187     if (width == m_currentWidth && height == m_currentHeight)
    188         return;
    189    
    190     m_currentWidth = width;
    191     m_currentHeight = height;
    192    
    193     makeContextCurrent();
    194     validateAttributes();
    195 
    196     GLuint colorFormat, internalDepthStencilFormat = 0;
    197     if (m_attrs.alpha) {
    198         m_internalColorFormat = GL_RGBA8;
    199         colorFormat = GL_RGBA;
    200     } else {
    201         m_internalColorFormat = GL_RGB8;
    202         colorFormat = GL_RGB;
    203     }
    204     if (m_attrs.stencil || m_attrs.depth) {
    205         // We don't allow the logic where stencil is required and depth is not.
    206         // See GraphicsContext3D::validateAttributes.
    207 
    208         Extensions3D* extensions = getExtensions();
    209         // Use a 24 bit depth buffer where we know we have it
    210         if (extensions->supports("GL_EXT_packed_depth_stencil"))
    211             internalDepthStencilFormat = GL_DEPTH24_STENCIL8_EXT;
    212         else
    213             internalDepthStencilFormat = GL_DEPTH_COMPONENT;
    214     }
    215 
    216     bool mustRestoreFBO = false;
    217 
    218     // resize multisample FBO
    219     if (m_attrs.antialias) {
    220         GLint maxSampleCount;
    221         ::glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount);
    222         GLint sampleCount = std::min(8, maxSampleCount);
    223         if (sampleCount > maxSampleCount)
    224             sampleCount = maxSampleCount;
    225         if (m_boundFBO != m_multisampleFBO) {
    226             ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
    227             mustRestoreFBO = true;
    228         }
    229         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
    230         ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, m_internalColorFormat, width, height);
    231         ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
    232         if (m_attrs.stencil || m_attrs.depth) {
    233             ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
    234             ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalDepthStencilFormat, width, height);
    235             if (m_attrs.stencil)
    236                 ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
    237             if (m_attrs.depth)
    238                 ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
    239         }
    240         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
    241         if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
    242             // FIXME: cleanup.
    243             notImplemented();
    244         }
    245     }
    246 
    247     // resize regular FBO
    248     if (m_boundFBO != m_fbo) {
    249         mustRestoreFBO = true;
    250         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    251     }
    252     ::glBindTexture(GL_TEXTURE_2D, m_texture);
    253     ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
    254     ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);
    255     ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture);
    256     ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
    257     ::glBindTexture(GL_TEXTURE_2D, 0);
    258     if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) {
    259         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
    260         ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalDepthStencilFormat, width, height);
    261         if (m_attrs.stencil)
    262             ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
    263         if (m_attrs.depth)
    264             ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
    265         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
    266     }
    267     if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
    268         // FIXME: cleanup
    269         notImplemented();
    270     }
    271 
    272     if (m_attrs.antialias) {
    273         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
    274         if (m_boundFBO == m_multisampleFBO)
    275             mustRestoreFBO = false;
    276     }
    277 
    278     // Initialize renderbuffers to 0.
    279     GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0;
    280     GLint clearStencil = 0;
    281     GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE;
    282     GLuint stencilMask = 0xffffffff;
    283     GLboolean isScissorEnabled = GL_FALSE;
    284     GLboolean isDitherEnabled = GL_FALSE;
    285     GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
    286     ::glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
    287     ::glClearColor(0, 0, 0, 0);
    288     ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
    289     ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    290     if (m_attrs.depth) {
    291         ::glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth);
    292         ::glClearDepth(1);
    293         ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
    294         ::glDepthMask(GL_TRUE);
    295         clearMask |= GL_DEPTH_BUFFER_BIT;
    296     }
    297     if (m_attrs.stencil) {
    298         ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil);
    299         ::glClearStencil(0);
    300         ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask));
    301         ::glStencilMaskSeparate(GL_FRONT, 0xffffffff);
    302         clearMask |= GL_STENCIL_BUFFER_BIT;
    303     }
    304     isScissorEnabled = ::glIsEnabled(GL_SCISSOR_TEST);
    305     ::glDisable(GL_SCISSOR_TEST);
    306     isDitherEnabled = ::glIsEnabled(GL_DITHER);
    307     ::glDisable(GL_DITHER);
    308 
    309     ::glClear(clearMask);
    310 
    311     ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
    312     ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
    313     if (m_attrs.depth) {
    314         ::glClearDepth(clearDepth);
    315         ::glDepthMask(depthMask);
    316     }
    317     if (m_attrs.stencil) {
    318         ::glClearStencil(clearStencil);
    319         ::glStencilMaskSeparate(GL_FRONT, stencilMask);
    320     }
    321     if (isScissorEnabled)
    322         ::glEnable(GL_SCISSOR_TEST);
    323     else
    324         ::glDisable(GL_SCISSOR_TEST);
    325     if (isDitherEnabled)
    326         ::glEnable(GL_DITHER);
    327     else
    328         ::glDisable(GL_DITHER);
    329 
    330     if (mustRestoreFBO)
    331         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
    332 
    333     ::glFlush();
    334 }
    335 
    336144IntSize GraphicsContext3D::getInternalFramebufferSize() const
    337145{
    338146    return IntSize(m_currentWidth, m_currentHeight);
    339 }
    340 
    341 void GraphicsContext3D::prepareTexture()
    342 {
    343     if (m_layerComposited)
    344         return;
    345     makeContextCurrent();
    346     if (m_attrs.antialias) {
    347         ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
    348         ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
    349         ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
    350     }
    351     ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    352     ::glActiveTexture(GL_TEXTURE0);
    353     ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture);
    354     ::glCopyTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, 0, 0, m_currentWidth, m_currentHeight, 0);
    355     ::glBindTexture(GL_TEXTURE_2D, m_boundTexture0);
    356     ::glActiveTexture(m_activeTexture);
    357     ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
    358     ::glFinish();
    359     m_layerComposited = true;
    360147}
    361148
     
    386173    makeContextCurrent();
    387174    ::glBindBuffer(target, buffer);
    388 }
    389 
    390 
    391 void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer)
    392 {
    393     makeContextCurrent();
    394     GLuint fbo;
    395     if (buffer)
    396         fbo = buffer;
    397     else
    398         fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo);
    399     if (fbo != m_boundFBO) {
    400         ::glBindFramebufferEXT(target, fbo);
    401         m_boundFBO = fbo;
    402     }
    403175}
    404176
     
    555327}
    556328
    557 void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
    558 {
    559     makeContextCurrent();
    560     if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
    561         ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
    562         ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
    563         ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
    564         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    565     }
    566     ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
    567     if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
    568         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
    569 }
    570 
    571 void GraphicsContext3D::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
    572 {
    573     makeContextCurrent();
    574     if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
    575         ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
    576         ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
    577         ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
    578         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    579     }
    580     ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
    581     if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
    582         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
    583 }
    584 
    585329void GraphicsContext3D::cullFace(GC3Denum mode)
    586330{
     
    709453}
    710454   
    711 bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info)
    712 {
    713     if (!program) {
    714         synthesizeGLError(INVALID_VALUE);
    715         return false;
    716     }
    717     makeContextCurrent();
    718     GLint maxUniformSize = 0;
    719     ::glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize);
    720     GLchar name[maxUniformSize]; // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination
    721     GLsizei nameLength = 0;
    722     GLint size = 0;
    723     GLenum type = 0;
    724     ::glGetActiveUniform(program, index, maxUniformSize, &nameLength, &size, &type, name);
    725     if (!nameLength)
    726         return false;
    727     info.name = String(name, nameLength);
    728     info.type = type;
    729     info.size = size;
    730     return true;
    731 }
    732 
    733455void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders)
    734456{
     
    865587}
    866588
    867 void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data)
    868 {
    869     // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
    870     // all previous rendering calls should be done before reading pixels.
    871     makeContextCurrent();
    872     ::glFlush();
    873     if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
    874         ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
    875         ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
    876         ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
    877         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
    878         ::glFlush();
    879     }
    880     ::glReadPixels(x, y, width, height, format, type, data);
    881     if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
    882         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
    883 }
    884 
    885589void GraphicsContext3D::releaseShaderCompiler()
    886590{
     
    888592    makeContextCurrent();
    889593    notImplemented();
    890 }
    891 
    892 void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height)
    893 {
    894     makeContextCurrent();
    895     switch (internalformat) {
    896     case DEPTH_STENCIL:
    897         internalformat = GL_DEPTH24_STENCIL8_EXT;
    898         break;
    899     case DEPTH_COMPONENT16:
    900         internalformat = GL_DEPTH_COMPONENT;
    901         break;
    902     case RGBA4:
    903     case RGB5_A1:
    904         internalformat = GL_RGBA;
    905         break;
    906     case RGB565:
    907         internalformat = GL_RGB;
    908         break;
    909     }
    910     ::glRenderbufferStorageEXT(target, internalformat, width, height);
    911594}
    912595
     
    1205888        attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works.
    1206889    ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value);
    1207 }
    1208 
    1209 void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value)
    1210 {
    1211     // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS
    1212     // because desktop GL's corresponding queries return the number of components
    1213     // whereas GLES2 return the number of vectors (each vector has 4 components).
    1214     // Therefore, the value returned by desktop GL needs to be divided by 4.
    1215     makeContextCurrent();
    1216     switch (pname) {
    1217     case MAX_FRAGMENT_UNIFORM_VECTORS:
    1218         ::glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value);
    1219         *value /= 4;
    1220         break;
    1221     case MAX_VERTEX_UNIFORM_VECTORS:
    1222         ::glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value);
    1223         *value /= 4;
    1224         break;
    1225     case MAX_VARYING_VECTORS:
    1226         ::glGetIntegerv(GL_MAX_VARYING_FLOATS, value);
    1227         *value /= 4;
    1228         break;
    1229     default:
    1230         ::glGetIntegerv(pname, value);
    1231     }
    1232890}
    1233891
     
    13891047}
    13901048
    1391 bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
    1392 {
    1393     if (width && height && !pixels) {
    1394         synthesizeGLError(INVALID_VALUE);
    1395         return false;
    1396     }
    1397     makeContextCurrent();
    1398     GC3Denum openGLInternalFormat = internalformat;
    1399     if (type == GL_FLOAT) {
    1400         if (format == GL_RGBA)
    1401             openGLInternalFormat = GL_RGBA32F_ARB;
    1402         else if (format == GL_RGB)
    1403             openGLInternalFormat = GL_RGB32F_ARB;
    1404     }
    1405 
    1406     ::glTexImage2D(target, level, openGLInternalFormat, width, height, border, format, type, pixels);
    1407     return true;
    1408 }
    1409 
    14101049void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoff, GC3Dint yoff, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels)
    14111050{
Note: See TracChangeset for help on using the changeset viewer.