WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-75462-20120111025944.patch (text/plain), 87.40 KB, created by
ChangSeok Oh
on 2012-01-10 09:59:47 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
ChangSeok Oh
Created:
2012-01-10 09:59:47 PST
Size:
87.40 KB
patch
obsolete
>Subversion Revision: 104585 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e6ed4945ce50167aca3d93b94e4f7e4f0179c97d..e45ccedf97b22e7fd8d6abd5b021fd8e85de2b2b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,180 @@ >+2012-01-10 ChangSeok Oh <shivamidow@gmail.com> >+ >+ Split GraphicsContext3DOpenGL into several files >+ https://bugs.webkit.org/show_bug.cgi?id=75462 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Split GraphicsContext3DOpenGL.cpp into >+ GraphicsContext3DOpenGLCommon.cpp, GraphicsContext3DOpenGL.cpp & GraphicsContext3DOpenGLES.cpp. >+ 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): >+ > 2012-01-10 Stephen Chenney <schenney@chromium.org> > > [Chromium] Shift PathSkia to use Skia's new RawIter >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index 0671bd79c6232913a6f3cb3b2cb8cd96ece7779f..56fa23c9702fdad9a06f30e69c9b624881bbf19a 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -5606,7 +5606,8 @@ webcore_sources += \ > Source/WebCore/platform/graphics/gtk/GraphicsContext3DPrivate.h \ > Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp \ > Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h \ >- Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >+ Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \ >+ Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp > endif # END ENABLE_WEBGL > > # --- >diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri >index 278ac9b21e34cf3de7889d055d9ce2a04e128ce0..bdabdab2454f357dba98ff0fdd44fcadb43cadae 100644 >--- a/Source/WebCore/Target.pri >+++ b/Source/WebCore/Target.pri >@@ -3731,7 +3731,8 @@ contains(DEFINES, ENABLE_WEBGL=1) { > > SOURCES += \ > platform/graphics/opengl/Extensions3DOpenGL.cpp \ >- platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >+ platform/graphics/opengl/GraphicsContext3DOpenGL.cpp \ >+ platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp > > ANGLE_DIR = $$replace(PWD, "WebCore", "ThirdParty/ANGLE") > >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 7d9bec7753978c83b9d96a5083c8fc17479d74fe..64c6875ab99d205243bc41d1e7cd710b14c013b6 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -3833,6 +3833,7 @@ > 'platform/graphics/opengl/Extensions3DOpenGL.cpp', > 'platform/graphics/opengl/Extensions3DOpenGL.h', > 'platform/graphics/opengl/GraphicsContext3DOpenGL.cpp', >+ 'platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp', > 'platform/graphics/opengl/TextureMapperGL.cpp', > 'platform/graphics/opengl/TextureMapperGL.h', > 'platform/graphics/opentype/OpenTypeSanitizer.cpp', >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index aac6099cf728021eff9bf33d99fd260850bab8fd..0d6fe7696cd19dd45badd5d8f171a05e31e7096c 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -3246,6 +3246,7 @@ > 93F9B7A00BA6032600854064 /* JSCDATASection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F9B79E0BA6032600854064 /* JSCDATASection.cpp */; }; > 93F9B7A10BA6032600854064 /* JSCDATASection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F9B79F0BA6032600854064 /* JSCDATASection.h */; }; > 93FDAFCA0B11307400E2746F /* EditorInsertAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDAFC90B11307400E2746F /* EditorInsertAction.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 96ABA41014BCAA6000D56204 /* GraphicsContext3DOpenGLCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96ABA40F14BCAA6000D56204 /* GraphicsContext3DOpenGLCommon.cpp */; }; > 97059977107D975200A50A7C /* PolicyCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059973107D975200A50A7C /* PolicyCallback.cpp */; }; > 97059978107D975200A50A7C /* PolicyCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059974107D975200A50A7C /* PolicyCallback.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059975107D975200A50A7C /* PolicyChecker.cpp */; }; >@@ -10508,6 +10509,7 @@ > 93F9B79E0BA6032600854064 /* JSCDATASection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCDATASection.cpp; sourceTree = "<group>"; }; > 93F9B79F0BA6032600854064 /* JSCDATASection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCDATASection.h; sourceTree = "<group>"; }; > 93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; }; >+ 96ABA40F14BCAA6000D56204 /* GraphicsContext3DOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGLCommon.cpp; sourceTree = "<group>"; }; > 97059973107D975200A50A7C /* PolicyCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyCallback.cpp; sourceTree = "<group>"; }; > 97059974107D975200A50A7C /* PolicyCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyCallback.h; sourceTree = "<group>"; }; > 97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; }; >@@ -21528,6 +21530,7 @@ > 6E67D2A41280E8A4008758F7 /* Extensions3DOpenGL.cpp */, > 6E67D2A51280E8A4008758F7 /* Extensions3DOpenGL.h */, > FBC220DE1237FBEB00BCF788 /* GraphicsContext3DOpenGL.cpp */, >+ 96ABA40F14BCAA6000D56204 /* GraphicsContext3DOpenGLCommon.cpp */, > ); > path = opengl; > sourceTree = "<group>"; >@@ -27803,6 +27806,7 @@ > FD537352137B651800008DCE /* ZeroPole.cpp in Sources */, > 974A862214B7ADBB003FDC76 /* FrameDestructionObserver.cpp in Sources */, > 97D2AD0314B823A60093DF32 /* DOMWindowProperty.cpp in Sources */, >+ 96ABA41014BCAA6000D56204 /* GraphicsContext3DOpenGLCommon.cpp in Sources */, > ); > runOnlyForDeploymentPostprocessing = 0; > }; >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >index 16a3b4a9c6dcaea2441f4f042f5026a2221a4e61..47a41c6d00265b0cba9a44ffcc41106ae9ba0775 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >@@ -29,22 +29,8 @@ > > #include "GraphicsContext3D.h" > >-#include "CanvasRenderingContext.h" > #include "Extensions3DOpenGL.h" >-#include "GraphicsContext.h" >-#include "HTMLCanvasElement.h" >-#include "ImageBuffer.h" >-#include "ImageData.h" > #include "NotImplemented.h" >-#include "WebGLObject.h" >-#include <cstring> >-#include <wtf/ArrayBuffer.h> >-#include <wtf/ArrayBufferView.h> >-#include <wtf/Float32Array.h> >-#include <wtf/Int32Array.h> >-#include <wtf/Uint8Array.h> >-#include <wtf/UnusedParam.h> >-#include <wtf/text/CString.h> > > #if PLATFORM(MAC) > #include <OpenGL/gl.h> >@@ -57,30 +43,6 @@ > > namespace WebCore { > >-void GraphicsContext3D::validateAttributes() >-{ >- Extensions3D* extensions = getExtensions(); >- if (m_attrs.stencil) { >- if (extensions->supports("GL_EXT_packed_depth_stencil")) { >- extensions->ensureEnabled("GL_EXT_packed_depth_stencil"); >- // Force depth if stencil is true. >- m_attrs.depth = true; >- } else >- m_attrs.stencil = false; >- } >- if (m_attrs.antialias) { >- bool isValidVendor = true; >- // Currently in Mac we only turn on antialias if vendor is NVIDIA. >- const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR)); >- if (!std::strstr(vendor, "NVIDIA")) >- isValidVendor = false; >- if (!isValidVendor || !extensions->supports("GL_ANGLE_framebuffer_multisample")) >- m_attrs.antialias = false; >- else >- extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample"); >- } >-} >- > void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSize) > { > if (pixelsSize < m_currentWidth * m_currentHeight * 4) >@@ -119,66 +81,6 @@ void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSi > ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO); > } > >-bool GraphicsContext3D::isResourceSafe() >-{ >- return false; >-} >- >-#if !PLATFORM(QT) >-void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* context, DrawingBuffer*) >-{ >- HTMLCanvasElement* canvas = context->canvas(); >- ImageBuffer* imageBuffer = canvas->buffer(); >- >- int rowBytes = m_currentWidth * 4; >- int totalBytes = rowBytes * m_currentHeight; >- >- OwnArrayPtr<unsigned char> pixels = adoptArrayPtr(new unsigned char[totalBytes]); >- if (!pixels) >- return; >- >- readRenderingResults(pixels.get(), totalBytes); >- >- if (!m_attrs.premultipliedAlpha) { >- for (int i = 0; i < totalBytes; i += 4) { >- // Premultiply alpha >- pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255); >- pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255); >- pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255); >- } >- } >- >- paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight, >- canvas->width(), canvas->height(), imageBuffer->context()->platformContext()); >-} >-#endif >- >-bool GraphicsContext3D::paintCompositedResultsToCanvas(CanvasRenderingContext*) >-{ >- // Not needed at the moment, so return that nothing was done. >- return false; >-} >- >-PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(DrawingBuffer*) >-{ >- // Reading premultiplied alpha would involve unpremultiplying, which is >- // lossy >- if (m_attrs.premultipliedAlpha) >- return 0; >- >- RefPtr<ImageData> imageData = ImageData::create(IntSize(m_currentWidth, m_currentHeight)); >- unsigned char* pixels = imageData->data()->data()->data(); >- int totalBytes = 4 * m_currentWidth * m_currentHeight; >- >- readRenderingResults(pixels, totalBytes); >- >- // Convert to RGBA >- for (int i = 0; i < totalBytes; i += 4) >- std::swap(pixels[i], pixels[i + 2]); >- >- return imageData.release(); >-} >- > void GraphicsContext3D::reshape(int width, int height) > { > if (!platformGraphicsContext3D()) >@@ -333,11 +235,6 @@ void GraphicsContext3D::reshape(int width, int height) > ::glFlush(); > } > >-IntSize GraphicsContext3D::getInternalFramebufferSize() const >-{ >- return IntSize(m_currentWidth, m_currentHeight); >-} >- > void GraphicsContext3D::prepareTexture() > { > if (m_layerComposited) >@@ -359,35 +256,6 @@ void GraphicsContext3D::prepareTexture() > m_layerComposited = true; > } > >-void GraphicsContext3D::activeTexture(GC3Denum texture) >-{ >- makeContextCurrent(); >- m_activeTexture = texture; >- ::glActiveTexture(texture); >-} >- >-void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader) >-{ >- ASSERT(program); >- ASSERT(shader); >- makeContextCurrent(); >- ::glAttachShader(program, shader); >-} >- >-void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name) >-{ >- ASSERT(program); >- makeContextCurrent(); >- ::glBindAttribLocation(program, index, name.utf8().data()); >-} >- >-void GraphicsContext3D::bindBuffer(GC3Denum target, Platform3DObject buffer) >-{ >- makeContextCurrent(); >- ::glBindBuffer(target, buffer); >-} >- >- > void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer) > { > makeContextCurrent(); >@@ -402,158 +270,6 @@ void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer > } > } > >-void GraphicsContext3D::bindRenderbuffer(GC3Denum target, Platform3DObject renderbuffer) >-{ >- makeContextCurrent(); >- ::glBindRenderbufferEXT(target, renderbuffer); >-} >- >- >-void GraphicsContext3D::bindTexture(GC3Denum target, Platform3DObject texture) >-{ >- makeContextCurrent(); >- if (m_activeTexture && target == GL_TEXTURE_2D) >- m_boundTexture0 = texture; >- ::glBindTexture(target, texture); >-} >- >-void GraphicsContext3D::blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) >-{ >- makeContextCurrent(); >- ::glBlendColor(red, green, blue, alpha); >-} >- >-void GraphicsContext3D::blendEquation(GC3Denum mode) >-{ >- makeContextCurrent(); >- ::glBlendEquation(mode); >-} >- >-void GraphicsContext3D::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) >-{ >- makeContextCurrent(); >- ::glBlendEquationSeparate(modeRGB, modeAlpha); >-} >- >- >-void GraphicsContext3D::blendFunc(GC3Denum sfactor, GC3Denum dfactor) >-{ >- makeContextCurrent(); >- ::glBlendFunc(sfactor, dfactor); >-} >- >-void GraphicsContext3D::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) >-{ >- makeContextCurrent(); >- ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); >-} >- >-void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage) >-{ >- makeContextCurrent(); >- ::glBufferData(target, size, 0, usage); >-} >- >-void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage) >-{ >- makeContextCurrent(); >- ::glBufferData(target, size, data, usage); >-} >- >-void GraphicsContext3D::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data) >-{ >- makeContextCurrent(); >- ::glBufferSubData(target, offset, size, data); >-} >- >-GC3Denum GraphicsContext3D::checkFramebufferStatus(GC3Denum target) >-{ >- makeContextCurrent(); >- return ::glCheckFramebufferStatusEXT(target); >-} >- >-void GraphicsContext3D::clearColor(GC3Dclampf r, GC3Dclampf g, GC3Dclampf b, GC3Dclampf a) >-{ >- makeContextCurrent(); >- ::glClearColor(r, g, b, a); >-} >- >-void GraphicsContext3D::clear(GC3Dbitfield mask) >-{ >- makeContextCurrent(); >- ::glClear(mask); >-} >- >-void GraphicsContext3D::clearDepth(GC3Dclampf depth) >-{ >- makeContextCurrent(); >- ::glClearDepth(depth); >-} >- >-void GraphicsContext3D::clearStencil(GC3Dint s) >-{ >- makeContextCurrent(); >- ::glClearStencil(s); >-} >- >-void GraphicsContext3D::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha) >-{ >- makeContextCurrent(); >- ::glColorMask(red, green, blue, alpha); >-} >- >-void GraphicsContext3D::compileShader(Platform3DObject shader) >-{ >- ASSERT(shader); >- makeContextCurrent(); >- >- int GLshaderType; >- ANGLEShaderType shaderType; >- >- glGetShaderiv(shader, SHADER_TYPE, &GLshaderType); >- >- if (GLshaderType == VERTEX_SHADER) >- shaderType = SHADER_TYPE_VERTEX; >- else if (GLshaderType == FRAGMENT_SHADER) >- shaderType = SHADER_TYPE_FRAGMENT; >- else >- return; // Invalid shader type. >- >- HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >- >- if (result == m_shaderSourceMap.end()) >- return; >- >- ShaderSourceEntry& entry = result->second; >- >- String translatedShaderSource; >- String shaderInfoLog; >- >- bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog); >- >- entry.log = shaderInfoLog; >- entry.isValid = isValid; >- >- if (!isValid) >- return; // Shader didn't validate, don't move forward with compiling translated source >- >- int translatedShaderLength = translatedShaderSource.length(); >- >- const CString& translatedShaderCString = translatedShaderSource.utf8(); >- const char* translatedShaderPtr = translatedShaderCString.data(); >- >- ::glShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength); >- >- ::glCompileShader(shader); >- >- int GLCompileSuccess; >- >- ::glGetShaderiv(shader, COMPILE_STATUS, &GLCompileSuccess); >- >- // ASSERT that ANGLE generated GLSL will be accepted by OpenGL >- ASSERT(GLCompileSuccess == GL_TRUE); >-} >- > void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) > { > makeContextCurrent(); >@@ -582,132 +298,6 @@ void GraphicsContext3D::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Din > ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO); > } > >-void GraphicsContext3D::cullFace(GC3Denum mode) >-{ >- makeContextCurrent(); >- ::glCullFace(mode); >-} >- >-void GraphicsContext3D::depthFunc(GC3Denum func) >-{ >- makeContextCurrent(); >- ::glDepthFunc(func); >-} >- >-void GraphicsContext3D::depthMask(GC3Dboolean flag) >-{ >- makeContextCurrent(); >- ::glDepthMask(flag); >-} >- >-void GraphicsContext3D::depthRange(GC3Dclampf zNear, GC3Dclampf zFar) >-{ >- makeContextCurrent(); >- ::glDepthRange(zNear, zFar); >-} >- >-void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader) >-{ >- ASSERT(program); >- ASSERT(shader); >- makeContextCurrent(); >- ::glDetachShader(program, shader); >-} >- >-void GraphicsContext3D::disable(GC3Denum cap) >-{ >- makeContextCurrent(); >- ::glDisable(cap); >-} >- >-void GraphicsContext3D::disableVertexAttribArray(GC3Duint index) >-{ >- makeContextCurrent(); >- ::glDisableVertexAttribArray(index); >-} >- >-void GraphicsContext3D::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count) >-{ >- makeContextCurrent(); >- ::glDrawArrays(mode, first, count); >-} >- >-void GraphicsContext3D::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset) >-{ >- makeContextCurrent(); >- ::glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); >-} >- >-void GraphicsContext3D::enable(GC3Denum cap) >-{ >- makeContextCurrent(); >- ::glEnable(cap); >-} >- >-void GraphicsContext3D::enableVertexAttribArray(GC3Duint index) >-{ >- makeContextCurrent(); >- ::glEnableVertexAttribArray(index); >-} >- >-void GraphicsContext3D::finish() >-{ >- makeContextCurrent(); >- ::glFinish(); >-} >- >-void GraphicsContext3D::flush() >-{ >- makeContextCurrent(); >- ::glFlush(); >-} >- >-void GraphicsContext3D::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject buffer) >-{ >- makeContextCurrent(); >- ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer); >-} >- >-void GraphicsContext3D::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject texture, GC3Dint level) >-{ >- makeContextCurrent(); >- ::glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); >-} >- >-void GraphicsContext3D::frontFace(GC3Denum mode) >-{ >- makeContextCurrent(); >- ::glFrontFace(mode); >-} >- >-void GraphicsContext3D::generateMipmap(GC3Denum target) >-{ >- makeContextCurrent(); >- ::glGenerateMipmapEXT(target); >-} >- >-bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info) >-{ >- if (!program) { >- synthesizeGLError(INVALID_VALUE); >- return false; >- } >- makeContextCurrent(); >- GLint maxAttributeSize = 0; >- ::glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize); >- GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination >- GLsizei nameLength = 0; >- GLint size = 0; >- GLenum type = 0; >- ::glGetActiveAttrib(program, index, maxAttributeSize, &nameLength, &size, &type, name); >- if (!nameLength) >- return false; >- info.name = String(name, nameLength); >- info.type = type; >- info.size = size; >- return true; >-} >- > bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info) > { > if (!program) { >@@ -730,166 +320,26 @@ bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint inde > return true; > } > >-void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders) >-{ >- if (!program) { >- synthesizeGLError(INVALID_VALUE); >- return; >- } >- makeContextCurrent(); >- ::glGetAttachedShaders(program, maxCount, count, shaders); >-} > >-int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name) >+void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) > { >- if (!program) >- return -1; >- >+ // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e., >+ // all previous rendering calls should be done before reading pixels. > makeContextCurrent(); >- return ::glGetAttribLocation(program, name.utf8().data()); >-} >- >-GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes() >-{ >- return m_attrs; >+ ::glFlush(); >+ if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) { >+ ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); >+ ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo); >+ ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR); >+ ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); >+ ::glFlush(); >+ } >+ ::glReadPixels(x, y, width, height, format, type, data); >+ if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) >+ ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO); > } > >-GC3Denum GraphicsContext3D::getError() >-{ >- if (m_syntheticErrors.size() > 0) { >- ListHashSet<GC3Denum>::iterator iter = m_syntheticErrors.begin(); >- GC3Denum err = *iter; >- m_syntheticErrors.remove(iter); >- return err; >- } >- >- makeContextCurrent(); >- return ::glGetError(); >-} >- >-String GraphicsContext3D::getString(GC3Denum name) >-{ >- makeContextCurrent(); >- return String(reinterpret_cast<const char*>(::glGetString(name))); >-} >- >-void GraphicsContext3D::hint(GC3Denum target, GC3Denum mode) >-{ >- makeContextCurrent(); >- ::glHint(target, mode); >-} >- >-GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject buffer) >-{ >- if (!buffer) >- return GL_FALSE; >- >- makeContextCurrent(); >- return ::glIsBuffer(buffer); >-} >- >-GC3Dboolean GraphicsContext3D::isEnabled(GC3Denum cap) >-{ >- makeContextCurrent(); >- return ::glIsEnabled(cap); >-} >- >-GC3Dboolean GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer) >-{ >- if (!framebuffer) >- return GL_FALSE; >- >- makeContextCurrent(); >- return ::glIsFramebufferEXT(framebuffer); >-} >- >-GC3Dboolean GraphicsContext3D::isProgram(Platform3DObject program) >-{ >- if (!program) >- return GL_FALSE; >- >- makeContextCurrent(); >- return ::glIsProgram(program); >-} >- >-GC3Dboolean GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer) >-{ >- if (!renderbuffer) >- return GL_FALSE; >- >- makeContextCurrent(); >- return ::glIsRenderbufferEXT(renderbuffer); >-} >- >-GC3Dboolean GraphicsContext3D::isShader(Platform3DObject shader) >-{ >- if (!shader) >- return GL_FALSE; >- >- makeContextCurrent(); >- return ::glIsShader(shader); >-} >- >-GC3Dboolean GraphicsContext3D::isTexture(Platform3DObject texture) >-{ >- if (!texture) >- return GL_FALSE; >- >- makeContextCurrent(); >- return ::glIsTexture(texture); >-} >- >-void GraphicsContext3D::lineWidth(GC3Dfloat width) >-{ >- makeContextCurrent(); >- ::glLineWidth(width); >-} >- >-void GraphicsContext3D::linkProgram(Platform3DObject program) >-{ >- ASSERT(program); >- makeContextCurrent(); >- ::glLinkProgram(program); >-} >- >-void GraphicsContext3D::pixelStorei(GC3Denum pname, GC3Dint param) >-{ >- makeContextCurrent(); >- ::glPixelStorei(pname, param); >-} >- >-void GraphicsContext3D::polygonOffset(GC3Dfloat factor, GC3Dfloat units) >-{ >- makeContextCurrent(); >- ::glPolygonOffset(factor, units); >-} >- >-void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) >-{ >- // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e., >- // all previous rendering calls should be done before reading pixels. >- makeContextCurrent(); >- ::glFlush(); >- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) { >- ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO); >- ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo); >- ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR); >- ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); >- ::glFlush(); >- } >- ::glReadPixels(x, y, width, height, format, type, data); >- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) >- ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO); >-} >- >-void GraphicsContext3D::releaseShaderCompiler() >-{ >- // FIXME: This is not implemented on desktop OpenGL. We need to have ifdefs for the different GL variants. >- makeContextCurrent(); >- notImplemented(); >-} >- >-void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) >+void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) > { > makeContextCurrent(); > switch (internalformat) { >@@ -910,302 +360,6 @@ void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalfo > ::glRenderbufferStorageEXT(target, internalformat, width, height); > } > >-void GraphicsContext3D::sampleCoverage(GC3Dclampf value, GC3Dboolean invert) >-{ >- makeContextCurrent(); >- ::glSampleCoverage(value, invert); >-} >- >-void GraphicsContext3D::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) >-{ >- makeContextCurrent(); >- ::glScissor(x, y, width, height); >-} >- >-void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string) >-{ >- ASSERT(shader); >- >- makeContextCurrent(); >- >- ShaderSourceEntry entry; >- >- entry.source = string; >- >- m_shaderSourceMap.set(shader, entry); >-} >- >-void GraphicsContext3D::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) >-{ >- makeContextCurrent(); >- ::glStencilFunc(func, ref, mask); >-} >- >-void GraphicsContext3D::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask) >-{ >- makeContextCurrent(); >- ::glStencilFuncSeparate(face, func, ref, mask); >-} >- >-void GraphicsContext3D::stencilMask(GC3Duint mask) >-{ >- makeContextCurrent(); >- ::glStencilMask(mask); >-} >- >-void GraphicsContext3D::stencilMaskSeparate(GC3Denum face, GC3Duint mask) >-{ >- makeContextCurrent(); >- ::glStencilMaskSeparate(face, mask); >-} >- >-void GraphicsContext3D::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass) >-{ >- makeContextCurrent(); >- ::glStencilOp(fail, zfail, zpass); >-} >- >-void GraphicsContext3D::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) >-{ >- makeContextCurrent(); >- ::glStencilOpSeparate(face, fail, zfail, zpass); >-} >- >-void GraphicsContext3D::texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat value) >-{ >- makeContextCurrent(); >- ::glTexParameterf(target, pname, value); >-} >- >-void GraphicsContext3D::texParameteri(GC3Denum target, GC3Denum pname, GC3Dint value) >-{ >- makeContextCurrent(); >- ::glTexParameteri(target, pname, value); >-} >- >-void GraphicsContext3D::uniform1f(GC3Dint location, GC3Dfloat v0) >-{ >- makeContextCurrent(); >- ::glUniform1f(location, v0); >-} >- >-void GraphicsContext3D::uniform1fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size) >-{ >- makeContextCurrent(); >- ::glUniform1fv(location, size, array); >-} >- >-void GraphicsContext3D::uniform2f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1) >-{ >- makeContextCurrent(); >- ::glUniform2f(location, v0, v1); >-} >- >-void GraphicsContext3D::uniform2fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 2 >- makeContextCurrent(); >- ::glUniform2fv(location, size, array); >-} >- >-void GraphicsContext3D::uniform3f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) >-{ >- makeContextCurrent(); >- ::glUniform3f(location, v0, v1, v2); >-} >- >-void GraphicsContext3D::uniform3fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 3 >- makeContextCurrent(); >- ::glUniform3fv(location, size, array); >-} >- >-void GraphicsContext3D::uniform4f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) >-{ >- makeContextCurrent(); >- ::glUniform4f(location, v0, v1, v2, v3); >-} >- >-void GraphicsContext3D::uniform4fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 4 >- makeContextCurrent(); >- ::glUniform4fv(location, size, array); >-} >- >-void GraphicsContext3D::uniform1i(GC3Dint location, GC3Dint v0) >-{ >- makeContextCurrent(); >- ::glUniform1i(location, v0); >-} >- >-void GraphicsContext3D::uniform1iv(GC3Dint location, GC3Dint* array, GC3Dsizei size) >-{ >- makeContextCurrent(); >- ::glUniform1iv(location, size, array); >-} >- >-void GraphicsContext3D::uniform2i(GC3Dint location, GC3Dint v0, GC3Dint v1) >-{ >- makeContextCurrent(); >- ::glUniform2i(location, v0, v1); >-} >- >-void GraphicsContext3D::uniform2iv(GC3Dint location, GC3Dint* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 2 >- makeContextCurrent(); >- ::glUniform2iv(location, size, array); >-} >- >-void GraphicsContext3D::uniform3i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2) >-{ >- makeContextCurrent(); >- ::glUniform3i(location, v0, v1, v2); >-} >- >-void GraphicsContext3D::uniform3iv(GC3Dint location, GC3Dint* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 3 >- makeContextCurrent(); >- ::glUniform3iv(location, size, array); >-} >- >-void GraphicsContext3D::uniform4i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2, GC3Dint v3) >-{ >- makeContextCurrent(); >- ::glUniform4i(location, v0, v1, v2, v3); >-} >- >-void GraphicsContext3D::uniform4iv(GC3Dint location, GC3Dint* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 4 >- makeContextCurrent(); >- ::glUniform4iv(location, size, array); >-} >- >-void GraphicsContext3D::uniformMatrix2fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 4 >- makeContextCurrent(); >- ::glUniformMatrix2fv(location, size, transpose, array); >-} >- >-void GraphicsContext3D::uniformMatrix3fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 9 >- makeContextCurrent(); >- ::glUniformMatrix3fv(location, size, transpose, array); >-} >- >-void GraphicsContext3D::uniformMatrix4fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size) >-{ >- // FIXME: length needs to be a multiple of 16 >- makeContextCurrent(); >- ::glUniformMatrix4fv(location, size, transpose, array); >-} >- >-void GraphicsContext3D::useProgram(Platform3DObject program) >-{ >- makeContextCurrent(); >- ::glUseProgram(program); >-} >- >-void GraphicsContext3D::validateProgram(Platform3DObject program) >-{ >- ASSERT(program); >- >- makeContextCurrent(); >- ::glValidateProgram(program); >-} >- >-void GraphicsContext3D::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) >-{ >- makeContextCurrent(); >- ::glVertexAttrib1f(index, v0); >-} >- >-void GraphicsContext3D::vertexAttrib1fv(GC3Duint index, GC3Dfloat* array) >-{ >- makeContextCurrent(); >- ::glVertexAttrib1fv(index, array); >-} >- >-void GraphicsContext3D::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1) >-{ >- makeContextCurrent(); >- ::glVertexAttrib2f(index, v0, v1); >-} >- >-void GraphicsContext3D::vertexAttrib2fv(GC3Duint index, GC3Dfloat* array) >-{ >- makeContextCurrent(); >- ::glVertexAttrib2fv(index, array); >-} >- >-void GraphicsContext3D::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) >-{ >- makeContextCurrent(); >- ::glVertexAttrib3f(index, v0, v1, v2); >-} >- >-void GraphicsContext3D::vertexAttrib3fv(GC3Duint index, GC3Dfloat* array) >-{ >- makeContextCurrent(); >- ::glVertexAttrib3fv(index, array); >-} >- >-void GraphicsContext3D::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) >-{ >- makeContextCurrent(); >- ::glVertexAttrib4f(index, v0, v1, v2, v3); >-} >- >-void GraphicsContext3D::vertexAttrib4fv(GC3Duint index, GC3Dfloat* array) >-{ >- makeContextCurrent(); >- ::glVertexAttrib4fv(index, array); >-} >- >-void GraphicsContext3D::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset) >-{ >- makeContextCurrent(); >- ::glVertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); >-} >- >-void GraphicsContext3D::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) >-{ >- makeContextCurrent(); >- ::glViewport(x, y, width, height); >-} >- >-void GraphicsContext3D::getBooleanv(GC3Denum pname, GC3Dboolean* value) >-{ >- makeContextCurrent(); >- ::glGetBooleanv(pname, value); >-} >- >-void GraphicsContext3D::getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >-{ >- makeContextCurrent(); >- ::glGetBufferParameteriv(target, pname, value); >-} >- >-void GraphicsContext3D::getFloatv(GC3Denum pname, GC3Dfloat* value) >-{ >- makeContextCurrent(); >- ::glGetFloatv(pname, value); >-} >- >-void GraphicsContext3D::getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value) >-{ >- makeContextCurrent(); >- if (attachment == DEPTH_STENCIL_ATTACHMENT) >- attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works. >- ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value); >-} >- > void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value) > { > // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS >@@ -1231,163 +385,6 @@ void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value) > } > } > >-void GraphicsContext3D::getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value) >-{ >- makeContextCurrent(); >- ::glGetProgramiv(program, pname, value); >-} >- >-String GraphicsContext3D::getProgramInfoLog(Platform3DObject program) >-{ >- ASSERT(program); >- >- makeContextCurrent(); >- GLint length = 0; >- ::glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length); >- if (!length) >- return String(); >- >- GLsizei size = 0; >- OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]); >- ::glGetProgramInfoLog(program, length, &size, info.get()); >- >- return String(info.get()); >-} >- >-void GraphicsContext3D::getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >-{ >- makeContextCurrent(); >- ::glGetRenderbufferParameterivEXT(target, pname, value); >-} >- >-void GraphicsContext3D::getShaderiv(Platform3DObject shader, GC3Denum pname, GC3Dint* value) >-{ >- ASSERT(shader); >- >- makeContextCurrent(); >- >- HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >- >- switch (pname) { >- case DELETE_STATUS: >- case SHADER_TYPE: >- ::glGetShaderiv(shader, pname, value); >- break; >- case COMPILE_STATUS: >- if (result == m_shaderSourceMap.end()) { >- *value = static_cast<int>(false); >- return; >- } >- *value = static_cast<int>(result->second.isValid); >- break; >- case INFO_LOG_LENGTH: >- if (result == m_shaderSourceMap.end()) { >- *value = 0; >- return; >- } >- *value = getShaderInfoLog(shader).length(); >- break; >- case SHADER_SOURCE_LENGTH: >- *value = getShaderSource(shader).length(); >- break; >- default: >- synthesizeGLError(INVALID_ENUM); >- } >-} >- >-String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader) >-{ >- ASSERT(shader); >- >- makeContextCurrent(); >- >- HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >- if (result == m_shaderSourceMap.end()) >- return String(); >- >- ShaderSourceEntry entry = result->second; >- if (!entry.isValid) >- return entry.log; >- >- GLint length = 0; >- ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); >- if (!length) >- return String(); >- >- GLsizei size = 0; >- OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]); >- ::glGetShaderInfoLog(shader, length, &size, info.get()); >- >- return String(info.get()); >-} >- >-String GraphicsContext3D::getShaderSource(Platform3DObject shader) >-{ >- ASSERT(shader); >- >- makeContextCurrent(); >- >- HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >- if (result == m_shaderSourceMap.end()) >- return String(); >- >- return result->second.source; >-} >- >- >-void GraphicsContext3D::getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value) >-{ >- makeContextCurrent(); >- ::glGetTexParameterfv(target, pname, value); >-} >- >-void GraphicsContext3D::getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >-{ >- makeContextCurrent(); >- ::glGetTexParameteriv(target, pname, value); >-} >- >-void GraphicsContext3D::getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value) >-{ >- makeContextCurrent(); >- ::glGetUniformfv(program, location, value); >-} >- >-void GraphicsContext3D::getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value) >-{ >- makeContextCurrent(); >- ::glGetUniformiv(program, location, value); >-} >- >-GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name) >-{ >- ASSERT(program); >- >- makeContextCurrent(); >- return ::glGetUniformLocation(program, name.utf8().data()); >-} >- >-void GraphicsContext3D::getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value) >-{ >- makeContextCurrent(); >- ::glGetVertexAttribfv(index, pname, value); >-} >- >-void GraphicsContext3D::getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value) >-{ >- makeContextCurrent(); >- ::glGetVertexAttribiv(index, pname, value); >-} >- >-GC3Dsizeiptr GraphicsContext3D::getVertexAttribOffset(GC3Duint index, GC3Denum pname) >-{ >- makeContextCurrent(); >- >- GLvoid* pointer = 0; >- ::glGetVertexAttribPointerv(index, pname, &pointer); >- return static_cast<GC3Dsizeiptr>(reinterpret_cast<intptr_t>(pointer)); >-} >- > bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) > { > if (width && height && !pixels) { >@@ -1407,133 +404,6 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte > return true; > } > >-void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoff, GC3Dint yoff, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels) >-{ >- makeContextCurrent(); >- >- // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size >- ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels); >-} >- >-void GraphicsContext3D::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data) >-{ >- makeContextCurrent(); >- ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); >-} >- >-void GraphicsContext3D::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data) >-{ >- makeContextCurrent(); >- ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); >-} >- >-Platform3DObject GraphicsContext3D::createBuffer() >-{ >- makeContextCurrent(); >- GLuint o = 0; >- glGenBuffers(1, &o); >- return o; >-} >- >-Platform3DObject GraphicsContext3D::createFramebuffer() >-{ >- makeContextCurrent(); >- GLuint o = 0; >- glGenFramebuffersEXT(1, &o); >- return o; >-} >- >-Platform3DObject GraphicsContext3D::createProgram() >-{ >- makeContextCurrent(); >- return glCreateProgram(); >-} >- >-Platform3DObject GraphicsContext3D::createRenderbuffer() >-{ >- makeContextCurrent(); >- GLuint o = 0; >- glGenRenderbuffersEXT(1, &o); >- return o; >-} >- >-Platform3DObject GraphicsContext3D::createShader(GC3Denum type) >-{ >- makeContextCurrent(); >- return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER); >-} >- >-Platform3DObject GraphicsContext3D::createTexture() >-{ >- makeContextCurrent(); >- GLuint o = 0; >- glGenTextures(1, &o); >- return o; >-} >- >-void GraphicsContext3D::deleteBuffer(Platform3DObject buffer) >-{ >- makeContextCurrent(); >- glDeleteBuffers(1, &buffer); >-} >- >-void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer) >-{ >- makeContextCurrent(); >- glDeleteFramebuffersEXT(1, &framebuffer); >-} >- >-void GraphicsContext3D::deleteProgram(Platform3DObject program) >-{ >- makeContextCurrent(); >- glDeleteProgram(program); >-} >- >-void GraphicsContext3D::deleteRenderbuffer(Platform3DObject renderbuffer) >-{ >- makeContextCurrent(); >- glDeleteRenderbuffersEXT(1, &renderbuffer); >-} >- >-void GraphicsContext3D::deleteShader(Platform3DObject shader) >-{ >- makeContextCurrent(); >- glDeleteShader(shader); >-} >- >-void GraphicsContext3D::deleteTexture(Platform3DObject texture) >-{ >- makeContextCurrent(); >- glDeleteTextures(1, &texture); >-} >- >-void GraphicsContext3D::synthesizeGLError(GC3Denum error) >-{ >- m_syntheticErrors.add(error); >-} >- >-void GraphicsContext3D::markContextChanged() >-{ >- m_layerComposited = false; >-} >- >-void GraphicsContext3D::markLayerComposited() >-{ >- m_layerComposited = true; >-} >- >-bool GraphicsContext3D::layerComposited() const >-{ >- return m_layerComposited; >-} >- >-Extensions3D* GraphicsContext3D::getExtensions() >-{ >- if (!m_extensions) >- m_extensions = adoptPtr(new Extensions3DOpenGL(this)); >- return m_extensions.get(); >-} >- > } > > #endif // ENABLE(WEBGL) >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..e68bba7fd7f519fd78c169a7293c9b2ad5260de8 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >@@ -0,0 +1,1178 @@ >+/* >+ * Copyright (C) 2010 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(WEBGL) >+ >+#include "GraphicsContext3D.h" >+ >+#include "CanvasRenderingContext.h" >+#include "Extensions3DOpenGL.h" >+#include "GraphicsContext.h" >+#include "HTMLCanvasElement.h" >+#include "ImageBuffer.h" >+#include "ImageData.h" >+#include "NotImplemented.h" >+#include "WebGLObject.h" >+#include <cstring> >+#include <wtf/ArrayBuffer.h> >+#include <wtf/ArrayBufferView.h> >+#include <wtf/Float32Array.h> >+#include <wtf/Int32Array.h> >+#include <wtf/Uint8Array.h> >+#include <wtf/UnusedParam.h> >+#include <wtf/text/CString.h> >+ >+#if PLATFORM(MAC) >+#include <OpenGL/gl.h> >+#elif PLATFORM(GTK) >+#include "OpenGLShims.h" >+#elif PLATFORM(QT) >+#include <QtGlobal> >+#include <cairo/OpenGLShims.h> >+#endif >+ >+namespace WebCore { >+ >+void GraphicsContext3D::validateAttributes() >+{ >+ Extensions3D* extensions = getExtensions(); >+ if (m_attrs.stencil) { >+ if (extensions->supports("GL_EXT_packed_depth_stencil")) { >+ extensions->ensureEnabled("GL_EXT_packed_depth_stencil"); >+ // Force depth if stencil is true. >+ m_attrs.depth = true; >+ } else >+ m_attrs.stencil = false; >+ } >+ if (m_attrs.antialias) { >+ bool isValidVendor = true; >+ // Currently in Mac we only turn on antialias if vendor is NVIDIA. >+ const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR)); >+ if (!std::strstr(vendor, "NVIDIA")) >+ isValidVendor = false; >+ if (!isValidVendor || !extensions->supports("GL_ANGLE_framebuffer_multisample")) >+ m_attrs.antialias = false; >+ else >+ extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample"); >+ } >+} >+ >+bool GraphicsContext3D::isResourceSafe() >+{ >+ return false; >+} >+ >+#if !PLATFORM(QT) >+void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* context, DrawingBuffer*) >+{ >+ HTMLCanvasElement* canvas = context->canvas(); >+ ImageBuffer* imageBuffer = canvas->buffer(); >+ >+ int rowBytes = m_currentWidth * 4; >+ int totalBytes = rowBytes * m_currentHeight; >+ >+ OwnArrayPtr<unsigned char> pixels = adoptArrayPtr(new unsigned char[totalBytes]); >+ if (!pixels) >+ return; >+ >+ readRenderingResults(pixels.get(), totalBytes); >+ >+ if (!m_attrs.premultipliedAlpha) { >+ for (int i = 0; i < totalBytes; i += 4) { >+ // Premultiply alpha >+ pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255); >+ pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255); >+ pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255); >+ } >+ } >+ >+ paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight, >+ canvas->width(), canvas->height(), imageBuffer->context()->platformContext()); >+} >+#endif >+ >+bool GraphicsContext3D::paintCompositedResultsToCanvas(CanvasRenderingContext*) >+{ >+ // Not needed at the moment, so return that nothing was done. >+ return false; >+} >+ >+PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(DrawingBuffer*) >+{ >+ // Reading premultiplied alpha would involve unpremultiplying, which is >+ // lossy >+ if (m_attrs.premultipliedAlpha) >+ return 0; >+ >+ RefPtr<ImageData> imageData = ImageData::create(IntSize(m_currentWidth, m_currentHeight)); >+ unsigned char* pixels = imageData->data()->data()->data(); >+ int totalBytes = 4 * m_currentWidth * m_currentHeight; >+ >+ readRenderingResults(pixels, totalBytes); >+ >+ // Convert to RGBA >+ for (int i = 0; i < totalBytes; i += 4) >+ std::swap(pixels[i], pixels[i + 2]); >+ >+ return imageData.release(); >+} >+ >+IntSize GraphicsContext3D::getInternalFramebufferSize() const >+{ >+ return IntSize(m_currentWidth, m_currentHeight); >+} >+ >+void GraphicsContext3D::activeTexture(GC3Denum texture) >+{ >+ makeContextCurrent(); >+ m_activeTexture = texture; >+ ::glActiveTexture(texture); >+} >+ >+void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader) >+{ >+ ASSERT(program); >+ ASSERT(shader); >+ makeContextCurrent(); >+ ::glAttachShader(program, shader); >+} >+ >+void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name) >+{ >+ ASSERT(program); >+ makeContextCurrent(); >+ ::glBindAttribLocation(program, index, name.utf8().data()); >+} >+ >+void GraphicsContext3D::bindBuffer(GC3Denum target, Platform3DObject buffer) >+{ >+ makeContextCurrent(); >+ ::glBindBuffer(target, buffer); >+} >+ >+void GraphicsContext3D::bindRenderbuffer(GC3Denum target, Platform3DObject renderbuffer) >+{ >+ makeContextCurrent(); >+ ::glBindRenderbufferEXT(target, renderbuffer); >+} >+ >+ >+void GraphicsContext3D::bindTexture(GC3Denum target, Platform3DObject texture) >+{ >+ makeContextCurrent(); >+ if (m_activeTexture && target == GL_TEXTURE_2D) >+ m_boundTexture0 = texture; >+ ::glBindTexture(target, texture); >+} >+ >+void GraphicsContext3D::blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) >+{ >+ makeContextCurrent(); >+ ::glBlendColor(red, green, blue, alpha); >+} >+ >+void GraphicsContext3D::blendEquation(GC3Denum mode) >+{ >+ makeContextCurrent(); >+ ::glBlendEquation(mode); >+} >+ >+void GraphicsContext3D::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) >+{ >+ makeContextCurrent(); >+ ::glBlendEquationSeparate(modeRGB, modeAlpha); >+} >+ >+ >+void GraphicsContext3D::blendFunc(GC3Denum sfactor, GC3Denum dfactor) >+{ >+ makeContextCurrent(); >+ ::glBlendFunc(sfactor, dfactor); >+} >+ >+void GraphicsContext3D::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) >+{ >+ makeContextCurrent(); >+ ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); >+} >+ >+void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage) >+{ >+ makeContextCurrent(); >+ ::glBufferData(target, size, 0, usage); >+} >+ >+void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage) >+{ >+ makeContextCurrent(); >+ ::glBufferData(target, size, data, usage); >+} >+ >+void GraphicsContext3D::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data) >+{ >+ makeContextCurrent(); >+ ::glBufferSubData(target, offset, size, data); >+} >+ >+GC3Denum GraphicsContext3D::checkFramebufferStatus(GC3Denum target) >+{ >+ makeContextCurrent(); >+ return ::glCheckFramebufferStatusEXT(target); >+} >+ >+void GraphicsContext3D::clearColor(GC3Dclampf r, GC3Dclampf g, GC3Dclampf b, GC3Dclampf a) >+{ >+ makeContextCurrent(); >+ ::glClearColor(r, g, b, a); >+} >+ >+void GraphicsContext3D::clear(GC3Dbitfield mask) >+{ >+ makeContextCurrent(); >+ ::glClear(mask); >+} >+ >+void GraphicsContext3D::clearDepth(GC3Dclampf depth) >+{ >+ makeContextCurrent(); >+ ::glClearDepth(depth); >+} >+ >+void GraphicsContext3D::clearStencil(GC3Dint s) >+{ >+ makeContextCurrent(); >+ ::glClearStencil(s); >+} >+ >+void GraphicsContext3D::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha) >+{ >+ makeContextCurrent(); >+ ::glColorMask(red, green, blue, alpha); >+} >+ >+void GraphicsContext3D::compileShader(Platform3DObject shader) >+{ >+ ASSERT(shader); >+ makeContextCurrent(); >+ >+ int GLshaderType; >+ ANGLEShaderType shaderType; >+ >+ glGetShaderiv(shader, SHADER_TYPE, &GLshaderType); >+ >+ if (GLshaderType == VERTEX_SHADER) >+ shaderType = SHADER_TYPE_VERTEX; >+ else if (GLshaderType == FRAGMENT_SHADER) >+ shaderType = SHADER_TYPE_FRAGMENT; >+ else >+ return; // Invalid shader type. >+ >+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >+ >+ if (result == m_shaderSourceMap.end()) >+ return; >+ >+ ShaderSourceEntry& entry = result->second; >+ >+ String translatedShaderSource; >+ String shaderInfoLog; >+ >+ bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog); >+ >+ entry.log = shaderInfoLog; >+ entry.isValid = isValid; >+ >+ if (!isValid) >+ return; // Shader didn't validate, don't move forward with compiling translated source >+ >+ int translatedShaderLength = translatedShaderSource.length(); >+ >+ const CString& translatedShaderCString = translatedShaderSource.utf8(); >+ const char* translatedShaderPtr = translatedShaderCString.data(); >+ >+ ::glShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength); >+ >+ ::glCompileShader(shader); >+ >+ int GLCompileSuccess; >+ >+ ::glGetShaderiv(shader, COMPILE_STATUS, &GLCompileSuccess); >+ >+ // ASSERT that ANGLE generated GLSL will be accepted by OpenGL >+ ASSERT(GLCompileSuccess == GL_TRUE); >+} >+ >+void GraphicsContext3D::cullFace(GC3Denum mode) >+{ >+ makeContextCurrent(); >+ ::glCullFace(mode); >+} >+ >+void GraphicsContext3D::depthFunc(GC3Denum func) >+{ >+ makeContextCurrent(); >+ ::glDepthFunc(func); >+} >+ >+void GraphicsContext3D::depthMask(GC3Dboolean flag) >+{ >+ makeContextCurrent(); >+ ::glDepthMask(flag); >+} >+ >+void GraphicsContext3D::depthRange(GC3Dclampf zNear, GC3Dclampf zFar) >+{ >+ makeContextCurrent(); >+ ::glDepthRange(zNear, zFar); >+} >+ >+void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader) >+{ >+ ASSERT(program); >+ ASSERT(shader); >+ makeContextCurrent(); >+ ::glDetachShader(program, shader); >+} >+ >+void GraphicsContext3D::disable(GC3Denum cap) >+{ >+ makeContextCurrent(); >+ ::glDisable(cap); >+} >+ >+void GraphicsContext3D::disableVertexAttribArray(GC3Duint index) >+{ >+ makeContextCurrent(); >+ ::glDisableVertexAttribArray(index); >+} >+ >+void GraphicsContext3D::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count) >+{ >+ makeContextCurrent(); >+ ::glDrawArrays(mode, first, count); >+} >+ >+void GraphicsContext3D::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset) >+{ >+ makeContextCurrent(); >+ ::glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); >+} >+ >+void GraphicsContext3D::enable(GC3Denum cap) >+{ >+ makeContextCurrent(); >+ ::glEnable(cap); >+} >+ >+void GraphicsContext3D::enableVertexAttribArray(GC3Duint index) >+{ >+ makeContextCurrent(); >+ ::glEnableVertexAttribArray(index); >+} >+ >+void GraphicsContext3D::finish() >+{ >+ makeContextCurrent(); >+ ::glFinish(); >+} >+ >+void GraphicsContext3D::flush() >+{ >+ makeContextCurrent(); >+ ::glFlush(); >+} >+ >+void GraphicsContext3D::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject buffer) >+{ >+ makeContextCurrent(); >+ ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer); >+} >+ >+void GraphicsContext3D::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject texture, GC3Dint level) >+{ >+ makeContextCurrent(); >+ ::glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); >+} >+ >+void GraphicsContext3D::frontFace(GC3Denum mode) >+{ >+ makeContextCurrent(); >+ ::glFrontFace(mode); >+} >+ >+void GraphicsContext3D::generateMipmap(GC3Denum target) >+{ >+ makeContextCurrent(); >+ ::glGenerateMipmapEXT(target); >+} >+ >+bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info) >+{ >+ if (!program) { >+ synthesizeGLError(INVALID_VALUE); >+ return false; >+ } >+ makeContextCurrent(); >+ GLint maxAttributeSize = 0; >+ ::glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize); >+ GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination >+ GLsizei nameLength = 0; >+ GLint size = 0; >+ GLenum type = 0; >+ ::glGetActiveAttrib(program, index, maxAttributeSize, &nameLength, &size, &type, name); >+ if (!nameLength) >+ return false; >+ info.name = String(name, nameLength); >+ info.type = type; >+ info.size = size; >+ return true; >+} >+ >+void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders) >+{ >+ if (!program) { >+ synthesizeGLError(INVALID_VALUE); >+ return; >+ } >+ makeContextCurrent(); >+ ::glGetAttachedShaders(program, maxCount, count, shaders); >+} >+ >+int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name) >+{ >+ if (!program) >+ return -1; >+ >+ makeContextCurrent(); >+ return ::glGetAttribLocation(program, name.utf8().data()); >+} >+ >+GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes() >+{ >+ return m_attrs; >+} >+ >+GC3Denum GraphicsContext3D::getError() >+{ >+ if (m_syntheticErrors.size() > 0) { >+ ListHashSet<GC3Denum>::iterator iter = m_syntheticErrors.begin(); >+ GC3Denum err = *iter; >+ m_syntheticErrors.remove(iter); >+ return err; >+ } >+ >+ makeContextCurrent(); >+ return ::glGetError(); >+} >+ >+String GraphicsContext3D::getString(GC3Denum name) >+{ >+ makeContextCurrent(); >+ return String(reinterpret_cast<const char*>(::glGetString(name))); >+} >+ >+void GraphicsContext3D::hint(GC3Denum target, GC3Denum mode) >+{ >+ makeContextCurrent(); >+ ::glHint(target, mode); >+} >+ >+GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject buffer) >+{ >+ if (!buffer) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return ::glIsBuffer(buffer); >+} >+ >+GC3Dboolean GraphicsContext3D::isEnabled(GC3Denum cap) >+{ >+ makeContextCurrent(); >+ return ::glIsEnabled(cap); >+} >+ >+GC3Dboolean GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer) >+{ >+ if (!framebuffer) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return ::glIsFramebufferEXT(framebuffer); >+} >+ >+GC3Dboolean GraphicsContext3D::isProgram(Platform3DObject program) >+{ >+ if (!program) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return ::glIsProgram(program); >+} >+ >+GC3Dboolean GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer) >+{ >+ if (!renderbuffer) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return ::glIsRenderbufferEXT(renderbuffer); >+} >+ >+GC3Dboolean GraphicsContext3D::isShader(Platform3DObject shader) >+{ >+ if (!shader) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return ::glIsShader(shader); >+} >+ >+GC3Dboolean GraphicsContext3D::isTexture(Platform3DObject texture) >+{ >+ if (!texture) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return ::glIsTexture(texture); >+} >+ >+void GraphicsContext3D::lineWidth(GC3Dfloat width) >+{ >+ makeContextCurrent(); >+ ::glLineWidth(width); >+} >+ >+void GraphicsContext3D::linkProgram(Platform3DObject program) >+{ >+ ASSERT(program); >+ makeContextCurrent(); >+ ::glLinkProgram(program); >+} >+ >+void GraphicsContext3D::pixelStorei(GC3Denum pname, GC3Dint param) >+{ >+ makeContextCurrent(); >+ ::glPixelStorei(pname, param); >+} >+ >+void GraphicsContext3D::polygonOffset(GC3Dfloat factor, GC3Dfloat units) >+{ >+ makeContextCurrent(); >+ ::glPolygonOffset(factor, units); >+} >+ >+void GraphicsContext3D::releaseShaderCompiler() >+{ >+ // FIXME: This is not implemented on desktop OpenGL. We need to have ifdefs for the different GL variants. >+ makeContextCurrent(); >+ notImplemented(); >+} >+ >+void GraphicsContext3D::sampleCoverage(GC3Dclampf value, GC3Dboolean invert) >+{ >+ makeContextCurrent(); >+ ::glSampleCoverage(value, invert); >+} >+ >+void GraphicsContext3D::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) >+{ >+ makeContextCurrent(); >+ ::glScissor(x, y, width, height); >+} >+ >+void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string) >+{ >+ ASSERT(shader); >+ >+ makeContextCurrent(); >+ >+ ShaderSourceEntry entry; >+ >+ entry.source = string; >+ >+ m_shaderSourceMap.set(shader, entry); >+} >+ >+void GraphicsContext3D::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) >+{ >+ makeContextCurrent(); >+ ::glStencilFunc(func, ref, mask); >+} >+ >+void GraphicsContext3D::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask) >+{ >+ makeContextCurrent(); >+ ::glStencilFuncSeparate(face, func, ref, mask); >+} >+ >+void GraphicsContext3D::stencilMask(GC3Duint mask) >+{ >+ makeContextCurrent(); >+ ::glStencilMask(mask); >+} >+ >+void GraphicsContext3D::stencilMaskSeparate(GC3Denum face, GC3Duint mask) >+{ >+ makeContextCurrent(); >+ ::glStencilMaskSeparate(face, mask); >+} >+ >+void GraphicsContext3D::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass) >+{ >+ makeContextCurrent(); >+ ::glStencilOp(fail, zfail, zpass); >+} >+ >+void GraphicsContext3D::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) >+{ >+ makeContextCurrent(); >+ ::glStencilOpSeparate(face, fail, zfail, zpass); >+} >+ >+void GraphicsContext3D::texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat value) >+{ >+ makeContextCurrent(); >+ ::glTexParameterf(target, pname, value); >+} >+ >+void GraphicsContext3D::texParameteri(GC3Denum target, GC3Denum pname, GC3Dint value) >+{ >+ makeContextCurrent(); >+ ::glTexParameteri(target, pname, value); >+} >+ >+void GraphicsContext3D::uniform1f(GC3Dint location, GC3Dfloat v0) >+{ >+ makeContextCurrent(); >+ ::glUniform1f(location, v0); >+} >+ >+void GraphicsContext3D::uniform1fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size) >+{ >+ makeContextCurrent(); >+ ::glUniform1fv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform2f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1) >+{ >+ makeContextCurrent(); >+ ::glUniform2f(location, v0, v1); >+} >+ >+void GraphicsContext3D::uniform2fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 2 >+ makeContextCurrent(); >+ ::glUniform2fv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform3f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) >+{ >+ makeContextCurrent(); >+ ::glUniform3f(location, v0, v1, v2); >+} >+ >+void GraphicsContext3D::uniform3fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 3 >+ makeContextCurrent(); >+ ::glUniform3fv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform4f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) >+{ >+ makeContextCurrent(); >+ ::glUniform4f(location, v0, v1, v2, v3); >+} >+ >+void GraphicsContext3D::uniform4fv(GC3Dint location, GC3Dfloat* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 4 >+ makeContextCurrent(); >+ ::glUniform4fv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform1i(GC3Dint location, GC3Dint v0) >+{ >+ makeContextCurrent(); >+ ::glUniform1i(location, v0); >+} >+ >+void GraphicsContext3D::uniform1iv(GC3Dint location, GC3Dint* array, GC3Dsizei size) >+{ >+ makeContextCurrent(); >+ ::glUniform1iv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform2i(GC3Dint location, GC3Dint v0, GC3Dint v1) >+{ >+ makeContextCurrent(); >+ ::glUniform2i(location, v0, v1); >+} >+ >+void GraphicsContext3D::uniform2iv(GC3Dint location, GC3Dint* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 2 >+ makeContextCurrent(); >+ ::glUniform2iv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform3i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2) >+{ >+ makeContextCurrent(); >+ ::glUniform3i(location, v0, v1, v2); >+} >+ >+void GraphicsContext3D::uniform3iv(GC3Dint location, GC3Dint* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 3 >+ makeContextCurrent(); >+ ::glUniform3iv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform4i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2, GC3Dint v3) >+{ >+ makeContextCurrent(); >+ ::glUniform4i(location, v0, v1, v2, v3); >+} >+ >+void GraphicsContext3D::uniform4iv(GC3Dint location, GC3Dint* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 4 >+ makeContextCurrent(); >+ ::glUniform4iv(location, size, array); >+} >+ >+void GraphicsContext3D::uniformMatrix2fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 4 >+ makeContextCurrent(); >+ ::glUniformMatrix2fv(location, size, transpose, array); >+} >+ >+void GraphicsContext3D::uniformMatrix3fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 9 >+ makeContextCurrent(); >+ ::glUniformMatrix3fv(location, size, transpose, array); >+} >+ >+void GraphicsContext3D::uniformMatrix4fv(GC3Dint location, GC3Dboolean transpose, GC3Dfloat* array, GC3Dsizei size) >+{ >+ // FIXME: length needs to be a multiple of 16 >+ makeContextCurrent(); >+ ::glUniformMatrix4fv(location, size, transpose, array); >+} >+ >+void GraphicsContext3D::useProgram(Platform3DObject program) >+{ >+ makeContextCurrent(); >+ ::glUseProgram(program); >+} >+ >+void GraphicsContext3D::validateProgram(Platform3DObject program) >+{ >+ ASSERT(program); >+ >+ makeContextCurrent(); >+ ::glValidateProgram(program); >+} >+ >+void GraphicsContext3D::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) >+{ >+ makeContextCurrent(); >+ ::glVertexAttrib1f(index, v0); >+} >+ >+void GraphicsContext3D::vertexAttrib1fv(GC3Duint index, GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ ::glVertexAttrib1fv(index, array); >+} >+ >+void GraphicsContext3D::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1) >+{ >+ makeContextCurrent(); >+ ::glVertexAttrib2f(index, v0, v1); >+} >+ >+void GraphicsContext3D::vertexAttrib2fv(GC3Duint index, GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ ::glVertexAttrib2fv(index, array); >+} >+ >+void GraphicsContext3D::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) >+{ >+ makeContextCurrent(); >+ ::glVertexAttrib3f(index, v0, v1, v2); >+} >+ >+void GraphicsContext3D::vertexAttrib3fv(GC3Duint index, GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ ::glVertexAttrib3fv(index, array); >+} >+ >+void GraphicsContext3D::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) >+{ >+ makeContextCurrent(); >+ ::glVertexAttrib4f(index, v0, v1, v2, v3); >+} >+ >+void GraphicsContext3D::vertexAttrib4fv(GC3Duint index, GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ ::glVertexAttrib4fv(index, array); >+} >+ >+void GraphicsContext3D::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset) >+{ >+ makeContextCurrent(); >+ ::glVertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); >+} >+ >+void GraphicsContext3D::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) >+{ >+ makeContextCurrent(); >+ ::glViewport(x, y, width, height); >+} >+ >+void GraphicsContext3D::getBooleanv(GC3Denum pname, GC3Dboolean* value) >+{ >+ makeContextCurrent(); >+ ::glGetBooleanv(pname, value); >+} >+ >+void GraphicsContext3D::getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ ::glGetBufferParameteriv(target, pname, value); >+} >+ >+void GraphicsContext3D::getFloatv(GC3Denum pname, GC3Dfloat* value) >+{ >+ makeContextCurrent(); >+ ::glGetFloatv(pname, value); >+} >+ >+void GraphicsContext3D::getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ if (attachment == DEPTH_STENCIL_ATTACHMENT) >+ attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works. >+ ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value); >+} >+ >+void GraphicsContext3D::getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ ::glGetProgramiv(program, pname, value); >+} >+ >+String GraphicsContext3D::getProgramInfoLog(Platform3DObject program) >+{ >+ ASSERT(program); >+ >+ makeContextCurrent(); >+ GLint length = 0; >+ ::glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length); >+ if (!length) >+ return String(); >+ >+ GLsizei size = 0; >+ OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]); >+ ::glGetProgramInfoLog(program, length, &size, info.get()); >+ >+ return String(info.get()); >+} >+ >+void GraphicsContext3D::getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ ::glGetRenderbufferParameterivEXT(target, pname, value); >+} >+ >+void GraphicsContext3D::getShaderiv(Platform3DObject shader, GC3Denum pname, GC3Dint* value) >+{ >+ ASSERT(shader); >+ >+ makeContextCurrent(); >+ >+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >+ >+ switch (pname) { >+ case DELETE_STATUS: >+ case SHADER_TYPE: >+ ::glGetShaderiv(shader, pname, value); >+ break; >+ case COMPILE_STATUS: >+ if (result == m_shaderSourceMap.end()) { >+ *value = static_cast<int>(false); >+ return; >+ } >+ *value = static_cast<int>(result->second.isValid); >+ break; >+ case INFO_LOG_LENGTH: >+ if (result == m_shaderSourceMap.end()) { >+ *value = 0; >+ return; >+ } >+ *value = getShaderInfoLog(shader).length(); >+ break; >+ case SHADER_SOURCE_LENGTH: >+ *value = getShaderSource(shader).length(); >+ break; >+ default: >+ synthesizeGLError(INVALID_ENUM); >+ } >+} >+ >+String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader) >+{ >+ ASSERT(shader); >+ >+ makeContextCurrent(); >+ >+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >+ if (result == m_shaderSourceMap.end()) >+ return String(); >+ >+ ShaderSourceEntry entry = result->second; >+ if (!entry.isValid) >+ return entry.log; >+ >+ GLint length = 0; >+ ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); >+ if (!length) >+ return String(); >+ >+ GLsizei size = 0; >+ OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]); >+ ::glGetShaderInfoLog(shader, length, &size, info.get()); >+ >+ return String(info.get()); >+} >+ >+String GraphicsContext3D::getShaderSource(Platform3DObject shader) >+{ >+ ASSERT(shader); >+ >+ makeContextCurrent(); >+ >+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >+ if (result == m_shaderSourceMap.end()) >+ return String(); >+ >+ return result->second.source; >+} >+ >+ >+void GraphicsContext3D::getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value) >+{ >+ makeContextCurrent(); >+ ::glGetTexParameterfv(target, pname, value); >+} >+ >+void GraphicsContext3D::getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ ::glGetTexParameteriv(target, pname, value); >+} >+ >+void GraphicsContext3D::getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value) >+{ >+ makeContextCurrent(); >+ ::glGetUniformfv(program, location, value); >+} >+ >+void GraphicsContext3D::getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ ::glGetUniformiv(program, location, value); >+} >+ >+GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name) >+{ >+ ASSERT(program); >+ >+ makeContextCurrent(); >+ return ::glGetUniformLocation(program, name.utf8().data()); >+} >+ >+void GraphicsContext3D::getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value) >+{ >+ makeContextCurrent(); >+ ::glGetVertexAttribfv(index, pname, value); >+} >+ >+void GraphicsContext3D::getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ ::glGetVertexAttribiv(index, pname, value); >+} >+ >+GC3Dsizeiptr GraphicsContext3D::getVertexAttribOffset(GC3Duint index, GC3Denum pname) >+{ >+ makeContextCurrent(); >+ >+ GLvoid* pointer = 0; >+ ::glGetVertexAttribPointerv(index, pname, &pointer); >+ return static_cast<GC3Dsizeiptr>(reinterpret_cast<intptr_t>(pointer)); >+} >+ >+void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoff, GC3Dint yoff, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels) >+{ >+ makeContextCurrent(); >+ >+ // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size >+ ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels); >+} >+ >+void GraphicsContext3D::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data) >+{ >+ makeContextCurrent(); >+ ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); >+} >+ >+void GraphicsContext3D::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data) >+{ >+ makeContextCurrent(); >+ ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); >+} >+ >+Platform3DObject GraphicsContext3D::createBuffer() >+{ >+ makeContextCurrent(); >+ GLuint o = 0; >+ glGenBuffers(1, &o); >+ return o; >+} >+ >+Platform3DObject GraphicsContext3D::createFramebuffer() >+{ >+ makeContextCurrent(); >+ GLuint o = 0; >+ glGenFramebuffersEXT(1, &o); >+ return o; >+} >+ >+Platform3DObject GraphicsContext3D::createProgram() >+{ >+ makeContextCurrent(); >+ return glCreateProgram(); >+} >+ >+Platform3DObject GraphicsContext3D::createRenderbuffer() >+{ >+ makeContextCurrent(); >+ GLuint o = 0; >+ glGenRenderbuffersEXT(1, &o); >+ return o; >+} >+ >+Platform3DObject GraphicsContext3D::createShader(GC3Denum type) >+{ >+ makeContextCurrent(); >+ return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER); >+} >+ >+Platform3DObject GraphicsContext3D::createTexture() >+{ >+ makeContextCurrent(); >+ GLuint o = 0; >+ glGenTextures(1, &o); >+ return o; >+} >+ >+void GraphicsContext3D::deleteBuffer(Platform3DObject buffer) >+{ >+ makeContextCurrent(); >+ glDeleteBuffers(1, &buffer); >+} >+ >+void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer) >+{ >+ makeContextCurrent(); >+ glDeleteFramebuffersEXT(1, &framebuffer); >+} >+ >+void GraphicsContext3D::deleteProgram(Platform3DObject program) >+{ >+ makeContextCurrent(); >+ glDeleteProgram(program); >+} >+ >+void GraphicsContext3D::deleteRenderbuffer(Platform3DObject renderbuffer) >+{ >+ makeContextCurrent(); >+ glDeleteRenderbuffersEXT(1, &renderbuffer); >+} >+ >+void GraphicsContext3D::deleteShader(Platform3DObject shader) >+{ >+ makeContextCurrent(); >+ glDeleteShader(shader); >+} >+ >+void GraphicsContext3D::deleteTexture(Platform3DObject texture) >+{ >+ makeContextCurrent(); >+ glDeleteTextures(1, &texture); >+} >+ >+void GraphicsContext3D::synthesizeGLError(GC3Denum error) >+{ >+ m_syntheticErrors.add(error); >+} >+ >+void GraphicsContext3D::markContextChanged() >+{ >+ m_layerComposited = false; >+} >+ >+void GraphicsContext3D::markLayerComposited() >+{ >+ m_layerComposited = true; >+} >+ >+bool GraphicsContext3D::layerComposited() const >+{ >+ return m_layerComposited; >+} >+ >+Extensions3D* GraphicsContext3D::getExtensions() >+{ >+ if (!m_extensions) >+ m_extensions = adoptPtr(new Extensions3DOpenGL(this)); >+ return m_extensions.get(); >+} >+ >+} >+ >+#endif // ENABLE(WEBGL) >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..90ff5a0a345bdf64b9780d48db64250667df3125 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp >@@ -0,0 +1,100 @@ >+/* >+ * Copyright (C) 2010 Apple Inc. All rights reserved. >+ * Copyright (C) 2012 ChangSeok Oh <shivamidow@gmail.com> >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(WEBGL) >+ >+#include "GraphicsContext3D.h" >+ >+#include "NotImplemented.h" >+ >+#if PLATFORM(GTK) >+#include "OpenGLShims.h" >+#endif >+ >+namespace WebCore { >+ >+void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSize) >+{ >+ notImplemented(); >+} >+ >+void GraphicsContext3D::reshape(int width, int height) >+{ >+ notImplemented(); >+} >+ >+void GraphicsContext3D::prepareTexture() >+{ >+ notImplemented(); >+} >+ >+void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer) >+{ >+ notImplemented(); >+} >+ >+void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) >+{ >+ notImplemented(); >+} >+ >+void GraphicsContext3D::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) >+{ >+ notImplemented(); >+} >+ >+bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info) >+{ >+ notImplemented(); >+} >+ >+ >+void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) >+{ >+ notImplemented(); >+} >+ >+void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) >+{ >+ notImplemented(); >+} >+ >+void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value) >+{ >+ notImplemented(); >+} >+ >+bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) >+{ >+ notImplemented(); >+ return false; >+} >+ >+} >+ >+#endif // ENABLE(WEBGL)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 75462
:
121852
|
121862
|
121866
|
122251