Changeset 73806 in webkit


Ignore:
Timestamp:
Dec 10, 2010 2:50:02 PM (13 years ago)
Author:
kbr@google.com
Message:

2010-12-10 Kenneth Russell <kbr@google.com>

Reviewed by James Robinson.

Implement extension entry points and remove EXTENSIONS enum
https://bugs.webkit.org/show_bug.cgi?id=40316

Added support for ensuring that a particular OpenGL extension is
enabled.

  • public/WebGraphicsContext3D.h:
  • src/Extensions3DChromium.cpp: (WebCore::Extensions3DChromium::ensureEnabled):
  • src/GraphicsContext3DChromium.cpp: (WebCore::GraphicsContext3DInternal::initializeExtensions): (WebCore::GraphicsContext3DInternal::supportsExtension): (WebCore::GraphicsContext3DInternal::ensureExtensionEnabled):
  • src/GraphicsContext3DInternal.h:
  • src/WebGraphicsContext3DDefaultImpl.cpp: (WebKit::WebGraphicsContext3DDefaultImpl::getRequestableExtensionsCHROMIUM): (WebKit::WebGraphicsContext3DDefaultImpl::requestExtensionCHROMIUM):
  • src/WebGraphicsContext3DDefaultImpl.h:

2010-12-10 Kenneth Russell <kbr@google.com>

Reviewed by James Robinson.

Implement extension entry points and remove EXTENSIONS enum
https://bugs.webkit.org/show_bug.cgi?id=40316

Implemented WebGLRenderingContext's getSupportedExtensions and
getExtensions entry points, and, to verify them, added support for
the first specified WebGL extension, OES_texture_float. This
extension is now advertised in the Chromium and WebKit ports when
the underlying hardware supports it.

The new OES_texture_float test in the WebGL conformance suite
verifies the allocation and population of floating point textures,
and their use as render targets. However, because this extension
is optional, it is not easily testable with a layout test; there
is only one set of expectations for a given test, and two would be
needed, one when the extension is available and one when it is not.

Tested with the oes-texture-float.html WebGL conformance test in
Chromium and WebKit on Mac OS X on hardware that supports the
extension. Also verified with a configuration that does not
advertise the extension that this same test passes.

  • CMakeLists.txt:
  • DerivedSources.make:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pri:
  • WebCore.pro:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSWebGLRenderingContextCustom.cpp: (WebCore::toJS): (WebCore::JSWebGLRenderingContext::markChildren): (WebCore::JSWebGLRenderingContext::getExtension): (WebCore::JSWebGLRenderingContext::getSupportedExtensions):
  • bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: (WebCore::toV8Object): (WebCore::V8WebGLRenderingContext::getExtensionCallback): (WebCore::V8WebGLRenderingContext::getSupportedExtensionsCallback):
  • html/canvas/OESTextureFloat.cpp: Added. (WebCore::OESTextureFloat::OESTextureFloat): (WebCore::OESTextureFloat::~OESTextureFloat): (WebCore::OESTextureFloat::getName): (WebCore::OESTextureFloat::create):
  • html/canvas/OESTextureFloat.h: Added.
  • html/canvas/OESTextureFloat.idl: Added.
  • html/canvas/WebGLExtension.cpp: Added. (WebCore::WebGLExtension::WebGLExtension): (WebCore::WebGLExtension::~WebGLExtension):
  • html/canvas/WebGLExtension.h: Added.
  • html/canvas/WebGLRenderingContext.cpp: (WebCore::WebGLRenderingContext::getExtension): (WebCore::WebGLRenderingContext::getSupportedExtensions): (WebCore::WebGLRenderingContext::validateTexFuncFormatAndType): (WebCore::WebGLRenderingContext::validateTexFuncData): (WebCore::WebGLRenderingContext::getNumberOfExtensions): (WebCore::WebGLRenderingContext::getExtensionNumber):
  • html/canvas/WebGLRenderingContext.h:
  • html/canvas/WebGLRenderingContext.idl:
  • platform/graphics/Extensions3D.h:
  • platform/graphics/GraphicsContext3D.cpp: (WebCore::GraphicsContext3D::computeFormatAndTypeParameters): (WebCore::GraphicsContext3D::extractTextureData): (WebCore::doUnpackingAndPacking): (WebCore::doPacking): (WebCore::doFloatingPointPacking): (WebCore::GraphicsContext3D::packPixels):
  • platform/graphics/GraphicsContext3D.h:
  • platform/graphics/chromium/Extensions3DChromium.h:
  • platform/graphics/opengl/Extensions3DOpenGL.cpp: (WebCore::Extensions3DOpenGL::supports): (WebCore::Extensions3DOpenGL::ensureEnabled):
  • platform/graphics/opengl/Extensions3DOpenGL.h:
  • platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: (WebCore::GraphicsContext3D::texImage2D):
  • platform/graphics/qt/Extensions3DQt.cpp: (WebCore::Extensions3DQt::ensureEnabled):
  • platform/graphics/qt/Extensions3DQt.h:
Location:
trunk
Files:
5 added
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/CMakeLists.txt

    r73756 r73806  
    288288    html/canvas/Int32Array.idl
    289289    html/canvas/Int8Array.idl
     290    html/canvas/OESTextureFloat.idl
    290291    html/canvas/Uint16Array.idl
    291292    html/canvas/Uint32Array.idl
  • trunk/WebCore/ChangeLog

    r73805 r73806  
     12010-12-10  Kenneth Russell  <kbr@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        Implement extension entry points and remove EXTENSIONS enum
     6        https://bugs.webkit.org/show_bug.cgi?id=40316
     7
     8        Implemented WebGLRenderingContext's getSupportedExtensions and
     9        getExtensions entry points, and, to verify them, added support for
     10        the first specified WebGL extension, OES_texture_float. This
     11        extension is now advertised in the Chromium and WebKit ports when
     12        the underlying hardware supports it.
     13
     14        The new OES_texture_float test in the WebGL conformance suite
     15        verifies the allocation and population of floating point textures,
     16        and their use as render targets. However, because this extension
     17        is optional, it is not easily testable with a layout test; there
     18        is only one set of expectations for a given test, and two would be
     19        needed, one when the extension is available and one when it is not.
     20
     21        Tested with the oes-texture-float.html WebGL conformance test in
     22        Chromium and WebKit on Mac OS X on hardware that supports the
     23        extension. Also verified with a configuration that does not
     24        advertise the extension that this same test passes.
     25
     26        * CMakeLists.txt:
     27        * DerivedSources.make:
     28        * GNUmakefile.am:
     29        * WebCore.gypi:
     30        * WebCore.pri:
     31        * WebCore.pro:
     32        * WebCore.xcodeproj/project.pbxproj:
     33        * bindings/js/JSWebGLRenderingContextCustom.cpp:
     34        (WebCore::toJS):
     35        (WebCore::JSWebGLRenderingContext::markChildren):
     36        (WebCore::JSWebGLRenderingContext::getExtension):
     37        (WebCore::JSWebGLRenderingContext::getSupportedExtensions):
     38        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
     39        (WebCore::toV8Object):
     40        (WebCore::V8WebGLRenderingContext::getExtensionCallback):
     41        (WebCore::V8WebGLRenderingContext::getSupportedExtensionsCallback):
     42        * html/canvas/OESTextureFloat.cpp: Added.
     43        (WebCore::OESTextureFloat::OESTextureFloat):
     44        (WebCore::OESTextureFloat::~OESTextureFloat):
     45        (WebCore::OESTextureFloat::getName):
     46        (WebCore::OESTextureFloat::create):
     47        * html/canvas/OESTextureFloat.h: Added.
     48        * html/canvas/OESTextureFloat.idl: Added.
     49        * html/canvas/WebGLExtension.cpp: Added.
     50        (WebCore::WebGLExtension::WebGLExtension):
     51        (WebCore::WebGLExtension::~WebGLExtension):
     52        * html/canvas/WebGLExtension.h: Added.
     53        * html/canvas/WebGLRenderingContext.cpp:
     54        (WebCore::WebGLRenderingContext::getExtension):
     55        (WebCore::WebGLRenderingContext::getSupportedExtensions):
     56        (WebCore::WebGLRenderingContext::validateTexFuncFormatAndType):
     57        (WebCore::WebGLRenderingContext::validateTexFuncData):
     58        (WebCore::WebGLRenderingContext::getNumberOfExtensions):
     59        (WebCore::WebGLRenderingContext::getExtensionNumber):
     60        * html/canvas/WebGLRenderingContext.h:
     61        * html/canvas/WebGLRenderingContext.idl:
     62        * platform/graphics/Extensions3D.h:
     63        * platform/graphics/GraphicsContext3D.cpp:
     64        (WebCore::GraphicsContext3D::computeFormatAndTypeParameters):
     65        (WebCore::GraphicsContext3D::extractTextureData):
     66        (WebCore::doUnpackingAndPacking):
     67        (WebCore::doPacking):
     68        (WebCore::doFloatingPointPacking):
     69        (WebCore::GraphicsContext3D::packPixels):
     70        * platform/graphics/GraphicsContext3D.h:
     71        * platform/graphics/chromium/Extensions3DChromium.h:
     72        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
     73        (WebCore::Extensions3DOpenGL::supports):
     74        (WebCore::Extensions3DOpenGL::ensureEnabled):
     75        * platform/graphics/opengl/Extensions3DOpenGL.h:
     76        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
     77        (WebCore::GraphicsContext3D::texImage2D):
     78        * platform/graphics/qt/Extensions3DQt.cpp:
     79        (WebCore::Extensions3DQt::ensureEnabled):
     80        * platform/graphics/qt/Extensions3DQt.h:
     81
    1822010-12-10  Darin Adler  <darin@apple.com>
    283
  • trunk/WebCore/DerivedSources.make

    r73346 r73806  
    311311    Notification \
    312312    NotificationCenter \
     313    OESTextureFloat \
    313314    OverflowEvent \
    314315    PageTransitionEvent \
  • trunk/WebCore/GNUmakefile.am

    r73756 r73806  
    474474        DerivedSources/WebCore/JSNotification.cpp \
    475475        DerivedSources/WebCore/JSNotification.h \
     476        DerivedSources/WebCore/JSOESTextureFloat.cpp \
     477        DerivedSources/WebCore/JSOESTextureFloat.h \
    476478        DerivedSources/WebCore/JSOverflowEvent.cpp \
    477479        DerivedSources/WebCore/JSOverflowEvent.h \
     
    15661568        WebCore/html/canvas/Int8Array.cpp \
    15671569        WebCore/html/canvas/Int8Array.h \
     1570        WebCore/html/canvas/OESTextureFloat.cpp \
     1571        WebCore/html/canvas/OESTextureFloat.h \
    15681572        WebCore/html/canvas/Uint16Array.cpp \
    15691573        WebCore/html/canvas/Uint16Array.h \
  • trunk/WebCore/WebCore.gypi

    r73756 r73806  
    214214            'html/canvas/Int32Array.idl',
    215215            'html/canvas/Int8Array.idl',
     216            'html/canvas/OESTextureFloat.idl',
    216217            'html/canvas/Uint16Array.idl',
    217218            'html/canvas/Uint32Array.idl',
     
    19141915            'html/canvas/Int8Array.h',
    19151916            'html/canvas/IntegralTypedArrayBase.h',
     1917            'html/canvas/OESTextureFloat.cpp',
     1918            'html/canvas/OESTextureFloat.h',
    19161919            'html/canvas/TypedArrayBase.h',
    19171920            'html/canvas/Uint16Array.cpp',
     
    19271930            'html/canvas/WebGLContextEvent.cpp',
    19281931            'html/canvas/WebGLContextEvent.h',
     1932            'html/canvas/WebGLExtension.cpp',
     1933            'html/canvas/WebGLExtension.h',
    19291934            'html/canvas/WebGLFramebuffer.cpp',
    19301935            'html/canvas/WebGLFramebuffer.h',
  • trunk/WebCore/WebCore.pri

    r73358 r73806  
    192192    html/canvas/CanvasRenderingContext.idl \
    193193    html/canvas/CanvasRenderingContext2D.idl \
     194    html/canvas/OESTextureFloat.idl \
    194195    html/canvas/WebGLActiveInfo.idl \
    195196    html/canvas/WebGLBuffer.idl \
  • trunk/WebCore/WebCore.pro

    r73756 r73806  
    37293729        html/canvas/WebGLContextAttributes.h \
    37303730        html/canvas/Float32Array.h \
     3731        html/canvas/WebGLExtension.h \
    37313732        html/canvas/WebGLFramebuffer.h \
    37323733        html/canvas/WebGLGetInfo.h \
     
    37373738        html/canvas/WebGLShader.h \
    37383739        html/canvas/Int16Array.h \
     3740        html/canvas/OESTextureFloat.h \
    37393741        html/canvas/WebGLTexture.h \
    37403742        html/canvas/WebGLUniformLocation.h \
     
    37693771        html/canvas/WebGLContextAttributes.cpp \
    37703772        html/canvas/Float32Array.cpp \
     3773        html/canvas/WebGLExtension.cpp \
    37713774        html/canvas/WebGLFramebuffer.cpp \
    37723775        html/canvas/WebGLGetInfo.cpp \
     
    37773780        html/canvas/WebGLShader.cpp \
    37783781        html/canvas/Int16Array.cpp \
     3782        html/canvas/OESTextureFloat.cpp \
    37793783        html/canvas/WebGLTexture.cpp \
    37803784        html/canvas/WebGLUniformLocation.cpp \
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r73756 r73806  
    15241524                6E96BB1C11986EE2007D94CD /* IntegralTypedArrayBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E96BB1A11986EE1007D94CD /* IntegralTypedArrayBase.h */; };
    15251525                6E96BB1D11986EE2007D94CD /* TypedArrayBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E96BB1B11986EE1007D94CD /* TypedArrayBase.h */; };
     1526                6EBF0E4812A8926100DB1709 /* OESTextureFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EBF0E4512A8926100DB1709 /* OESTextureFloat.cpp */; };
     1527                6EBF0E4912A8926100DB1709 /* OESTextureFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */; };
     1528                6EBF0E5412A8929800DB1709 /* WebGLExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EBF0E5212A8929800DB1709 /* WebGLExtension.cpp */; };
     1529                6EBF0E5512A8929800DB1709 /* WebGLExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EBF0E5312A8929800DB1709 /* WebGLExtension.h */; };
     1530                6EBF0E7612A9868800DB1709 /* JSOESTextureFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EBF0E7412A9868800DB1709 /* JSOESTextureFloat.cpp */; };
     1531                6EBF0E7712A9868800DB1709 /* JSOESTextureFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */; };
    15261532                6EE8A77210F803F3005A4A24 /* JSWebGLContextAttributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */; };
    15271533                6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */; };
     
    78877893                6E96BB1A11986EE1007D94CD /* IntegralTypedArrayBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IntegralTypedArrayBase.h; path = canvas/IntegralTypedArrayBase.h; sourceTree = "<group>"; };
    78887894                6E96BB1B11986EE1007D94CD /* TypedArrayBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TypedArrayBase.h; path = canvas/TypedArrayBase.h; sourceTree = "<group>"; };
     7895                6EBF0E4512A8926100DB1709 /* OESTextureFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OESTextureFloat.cpp; path = canvas/OESTextureFloat.cpp; sourceTree = "<group>"; };
     7896                6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESTextureFloat.h; path = canvas/OESTextureFloat.h; sourceTree = "<group>"; };
     7897                6EBF0E4712A8926100DB1709 /* OESTextureFloat.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OESTextureFloat.idl; path = canvas/OESTextureFloat.idl; sourceTree = "<group>"; };
     7898                6EBF0E5212A8929800DB1709 /* WebGLExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLExtension.cpp; path = canvas/WebGLExtension.cpp; sourceTree = "<group>"; };
     7899                6EBF0E5312A8929800DB1709 /* WebGLExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLExtension.h; path = canvas/WebGLExtension.h; sourceTree = "<group>"; };
     7900                6EBF0E7412A9868800DB1709 /* JSOESTextureFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESTextureFloat.cpp; sourceTree = "<group>"; };
     7901                6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESTextureFloat.h; sourceTree = "<group>"; };
    78897902                6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextAttributes.cpp; sourceTree = "<group>"; };
    78907903                6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
     
    1306013073                                49C7B9AD1042D32E0009D447 /* Int8Array.idl */,
    1306113074                                6E96BB1A11986EE1007D94CD /* IntegralTypedArrayBase.h */,
     13075                                6EBF0E4512A8926100DB1709 /* OESTextureFloat.cpp */,
     13076                                6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */,
     13077                                6EBF0E4712A8926100DB1709 /* OESTextureFloat.idl */,
    1306213078                                6E96BB1B11986EE1007D94CD /* TypedArrayBase.h */,
    1306313079                                49EECDDC10503C2300099FAB /* Uint16Array.cpp */,
     
    1308113097                                93F6F1EB127F70B10055CB06 /* WebGLContextEvent.h */,
    1308213098                                93F6F1EC127F70B10055CB06 /* WebGLContextEvent.idl */,
     13099                                6EBF0E5212A8929800DB1709 /* WebGLExtension.cpp */,
     13100                                6EBF0E5312A8929800DB1709 /* WebGLExtension.h */,
    1308313101                                49C7B9AE1042D32E0009D447 /* WebGLFramebuffer.cpp */,
    1308413102                                49C7B9AF1042D32E0009D447 /* WebGLFramebuffer.h */,
     
    1593915957                                E44614100CD6826900FADA75 /* JSMediaError.cpp */,
    1594015958                                E44614110CD6826900FADA75 /* JSMediaError.h */,
     15959                                6EBF0E7412A9868800DB1709 /* JSOESTextureFloat.cpp */,
     15960                                6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */,
    1594115961                                BCEF45F30E687B5C001C1287 /* JSTextMetrics.cpp */,
    1594215962                                BCEF45F40E687B5C001C1287 /* JSTextMetrics.h */,
     
    2216822188                                FDA15ECE12B03F61003A583A /* JSJavaScriptAudioNode.h in Headers */,
    2216922189                                FDA15ED212B03F94003A583A /* JSDelayNode.h in Headers */,
     22190                                6EBF0E4912A8926100DB1709 /* OESTextureFloat.h in Headers */,
     22191                                6EBF0E5512A8929800DB1709 /* WebGLExtension.h in Headers */,
     22192                                6EBF0E7712A9868800DB1709 /* JSOESTextureFloat.h in Headers */,
    2217022193                        );
    2217122194                        runOnlyForDeploymentPostprocessing = 0;
     
    2483524858                                494BC40D12AEDD9E00743BD2 /* TransformationMatrixCA.cpp in Sources */,
    2483624859                                BC51156E12B1749C00C96754 /* ScrollAnimatorMac.mm in Sources */,
     24860                                6EBF0E4812A8926100DB1709 /* OESTextureFloat.cpp in Sources */,
     24861                                6EBF0E5412A8929800DB1709 /* WebGLExtension.cpp in Sources */,
     24862                                6EBF0E7612A9868800DB1709 /* JSOESTextureFloat.cpp in Sources */,
    2483724863                        );
    2483824864                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp

    r71274 r73806  
    3636#include "JSHTMLImageElement.h"
    3737#include "JSImageData.h"
     38#include "JSOESTextureFloat.h"
    3839#include "JSWebGLBuffer.h"
    3940#include "JSFloat32Array.h"
     
    4849#include "JSWebKitCSSMatrix.h"
    4950#include "NotImplemented.h"
     51#include "OESTextureFloat.h"
    5052#include "WebGLBuffer.h"
    5153#include "Float32Array.h"
     54#include "WebGLExtension.h"
    5255#include "WebGLFramebuffer.h"
    5356#include "WebGLGetInfo.h"
     
    162165};
    163166
     167static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExtension* extension)
     168{
     169    if (!extension)
     170        return jsNull();
     171    switch (extension->getName()) {
     172    case WebGLExtension::OESTextureFloatName:
     173        return toJS(exec, globalObject, static_cast<OESTextureFloat*>(extension));
     174    }
     175    ASSERT_NOT_REACHED();
     176    return jsNull();
     177}
     178
     179void JSWebGLRenderingContext::markChildren(MarkStack& markStack)
     180{
     181    Base::markChildren(markStack);
     182
     183    WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
     184    for (int i = 0; i < context->getNumberOfExtensions(); ++i)
     185        markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), context->getExtensionNumber(i));
     186}
     187
    164188JSValue JSWebGLRenderingContext::getAttachedShaders(ExecState* exec)
    165189{
     
    187211}
    188212
     213JSValue JSWebGLRenderingContext::getExtension(ExecState* exec)
     214{
     215    if (exec->argumentCount() < 1)
     216        return throwSyntaxError(exec);
     217
     218    WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
     219    const String& name = ustringToString(exec->argument(0).toString(exec));
     220    if (exec->hadException())
     221        return jsUndefined();
     222    WebGLExtension* extension = context->getExtension(name);
     223    return toJS(exec, globalObject(), extension);
     224}
     225
    189226JSValue JSWebGLRenderingContext::getBufferParameter(ExecState* exec)
    190227{
     
    279316    }
    280317    return toJS(exec, globalObject(), info);
     318}
     319
     320JSValue JSWebGLRenderingContext::getSupportedExtensions(ExecState* exec)
     321{
     322    WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
     323    Vector<String> value = context->getSupportedExtensions();
     324    MarkedArgumentBuffer list;
     325    for (size_t ii = 0; ii < value.size(); ++ii)
     326        list.append(jsString(exec, value[ii]));
     327    return constructArray(exec, list);
    281328}
    282329
  • trunk/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp

    r72123 r73806  
    4242
    4343#include "V8Binding.h"
     44#include "V8BindingMacros.h"
    4445#include "V8ArrayBufferView.h"
    4546#include "V8WebGLBuffer.h"
     
    6162#include "V8HTMLVideoElement.h"
    6263#include "V8ImageData.h"
     64#include "V8OESTextureFloat.h"
    6365#include "V8Proxy.h"
    6466#include "WebGLRenderingContext.h"
     
    152154}
    153155
     156static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8::Object> contextObject)
     157{
     158    if (!extension)
     159        return v8::Null();
     160    v8::Handle<v8::Value> extensionObject;
     161    switch (extension->getName()) {
     162    case WebGLExtension::OESTextureFloatName:
     163        extensionObject = toV8(static_cast<OESTextureFloat*>(extension));
     164        break;
     165    }
     166    ASSERT(!extensionObject.IsEmpty());
     167    V8DOMWrapper::setHiddenReference(contextObject, extensionObject);
     168    return extensionObject;
     169}
     170
    154171enum ObjectType {
    155172    kBuffer, kRenderbuffer, kTexture, kVertexAttrib
     
    244261}
    245262
     263v8::Handle<v8::Value> V8WebGLRenderingContext::getExtensionCallback(const v8::Arguments& args)
     264{
     265    INC_STATS("DOM.WebGLRenderingContext.getExtensionCallback()");
     266    WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder());
     267    if (args.Length() < 1) {
     268        V8Proxy::setDOMException(SYNTAX_ERR);
     269        return notHandledByInterceptor();
     270    }
     271    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, name, args[0]);
     272    WebGLExtension* extension = imp->getExtension(name);
     273    return toV8Object(extension, args.Holder());
     274}
     275
    246276v8::Handle<v8::Value> V8WebGLRenderingContext::getFramebufferAttachmentParameterCallback(const v8::Arguments& args)
    247277{
     
    340370    }
    341371    return toV8Object(info);
     372}
     373
     374v8::Handle<v8::Value> V8WebGLRenderingContext::getSupportedExtensionsCallback(const v8::Arguments& args)
     375{
     376    INC_STATS("DOM.WebGLRenderingContext.getSupportedExtensionsCallback()");
     377    WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder());
     378    Vector<String> value = imp->getSupportedExtensions();
     379    v8::Local<v8::Array> array = v8::Array::New(value.size());
     380    for (size_t ii = 0; ii < value.size(); ++ii)
     381        array->Set(v8::Integer::New(ii), v8::String::New(fromWebCoreString(value[ii]), value[ii].length()));
     382    return array;
    342383}
    343384
  • trunk/WebCore/html/canvas/WebGLRenderingContext.cpp

    r73573 r73806  
    4444#include "IntSize.h"
    4545#include "NotImplemented.h"
     46#include "OESTextureFloat.h"
    4647#include "RenderBox.h"
    4748#include "RenderLayer.h"
     
    14611462{
    14621463    return m_context->getError();
     1464}
     1465
     1466WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
     1467{
     1468    if (equalIgnoringCase(name, "OES_texture_float")
     1469        && m_context->getExtensions()->supports("GL_OES_texture_float")) {
     1470        if (!m_oesTextureFloat) {
     1471            m_context->getExtensions()->ensureEnabled("GL_OES_texture_float");
     1472            m_oesTextureFloat = OESTextureFloat::create();
     1473        }
     1474        return m_oesTextureFloat.get();
     1475    }
     1476
     1477    return 0;
    14631478}
    14641479
     
    18581873}
    18591874
     1875Vector<String> WebGLRenderingContext::getSupportedExtensions()
     1876{
     1877    Vector<String> result;
     1878    if (m_context->getExtensions()->supports("GL_OES_texture_float"))
     1879        result.append("OES_texture_float");
     1880    return result;
     1881}
     1882
    18601883WebGLGetInfo WebGLRenderingContext::getTexParameter(unsigned long target, unsigned long pname, ExceptionCode& ec)
    18611884{
     
    35973620    case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1:
    35983621        break;
     3622    case GraphicsContext3D::FLOAT:
     3623        if (m_oesTextureFloat)
     3624            break;
     3625        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     3626        return false;
    35993627    default:
    36003628        m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
     
    36073635    case GraphicsContext3D::LUMINANCE:
    36083636    case GraphicsContext3D::LUMINANCE_ALPHA:
    3609         if (type != GraphicsContext3D::UNSIGNED_BYTE) {
     3637        if (type != GraphicsContext3D::UNSIGNED_BYTE
     3638            && type != GraphicsContext3D::FLOAT) {
    36103639            m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    36113640            return false;
     
    36143643    case GraphicsContext3D::RGB:
    36153644        if (type != GraphicsContext3D::UNSIGNED_BYTE
    3616             && type != GraphicsContext3D::UNSIGNED_SHORT_5_6_5) {
     3645            && type != GraphicsContext3D::UNSIGNED_SHORT_5_6_5
     3646            && type != GraphicsContext3D::FLOAT) {
    36173647            m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    36183648            return false;
     
    36223652        if (type != GraphicsContext3D::UNSIGNED_BYTE
    36233653            && type != GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4
    3624             && type != GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1) {
     3654            && type != GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1
     3655            && type != GraphicsContext3D::FLOAT) {
    36253656            m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    36263657            return false;
     
    37073738    case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1:
    37083739        if (!pixels->isUnsignedShortArray()) {
     3740            m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
     3741            return false;
     3742        }
     3743        break;
     3744    case GraphicsContext3D::FLOAT: // OES_texture_float
     3745        if (!pixels->isFloatArray()) {
    37093746            m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    37103747            return false;
     
    40804117}
    40814118
     4119int WebGLRenderingContext::getNumberOfExtensions()
     4120{
     4121    return (m_oesTextureFloat ? 1 : 0);
     4122}
     4123
     4124WebGLExtension* WebGLRenderingContext::getExtensionNumber(int i)
     4125{
     4126    if (m_oesTextureFloat) {
     4127        if (!i)
     4128            return m_oesTextureFloat.get();
     4129        --i;
     4130    }
     4131    // Similar tests for other extensions would go here.
     4132    return 0;
     4133}
     4134
    40824135WebGLRenderingContext::LRUImageBufferCache::LRUImageBufferCache(int capacity)
    40834136    : m_buffers(new OwnPtr<ImageBuffer>[capacity])
  • trunk/WebCore/html/canvas/WebGLRenderingContext.h

    r73424 r73806  
    4444class WebGLBuffer;
    4545class WebGLContextAttributes;
     46class WebGLExtension;
    4647class WebGLFramebuffer;
    4748class WebGLObject;
     
    5657class ImageData;
    5758class IntSize;
     59class OESTextureFloat;
    5860
    5961class WebGLRenderingContext : public CanvasRenderingContext {
     
    146148    unsigned long getError();
    147149
     150    WebGLExtension* getExtension(const String& name);
     151
    148152    WebGLGetInfo getFramebufferAttachmentParameter(unsigned long target, unsigned long attachment, unsigned long pname, ExceptionCode&);
    149153
     
    164168
    165169    String getShaderSource(WebGLShader*, ExceptionCode&);
     170
     171    Vector<String> getSupportedExtensions();
    166172
    167173    WebGLGetInfo getTexParameter(unsigned long target, unsigned long pname, ExceptionCode&);
     
    293299    void removeObject(WebGLObject*);
    294300
     301    // Helpers for JSC bindings.
     302    int getNumberOfExtensions();
     303    WebGLExtension* getExtensionNumber(int i);
     304
    295305  private:
    296306    friend class WebGLObject;
     
    457467    bool m_isDepthStencilSupported;
    458468
     469    // Enabled extension objects.
     470    RefPtr<OESTextureFloat> m_oesTextureFloat;
     471
    459472    // Helpers for getParameter and others
    460473    WebGLGetInfo getBooleanParameter(unsigned long pname);
  • trunk/WebCore/html/canvas/WebGLRenderingContext.idl

    r71855 r73806  
    3030        InterfaceUUID=98fb48ae-7216-489c-862b-8e1217fc4443,
    3131        ImplementationUUID=ab4f0781-152f-450e-9546-5b3987491a54,
     32        CustomMarkFunction,
    3233        DontCheckEnums
    3334    ] WebGLRenderingContext : CanvasRenderingContext {
     
    288289        const unsigned int RENDERER                       = 0x1F01;
    289290        const unsigned int VERSION                        = 0x1F02;
    290         const unsigned int EXTENSIONS                     = 0x1F03;
    291291
    292292        /* TextureMagFilter */
     
    536536        [StrictTypeChecking] unsigned long getError();
    537537
     538        // object getExtension(in DOMString name);
     539        [StrictTypeChecking, Custom] void getExtension(in DOMString name);
     540
    538541        // any getFramebufferAttachmentParameter(in unsigned long target, in unsigned long attachment, in unsigned long pname) raises(DOMException);
    539542        [StrictTypeChecking, Custom] void getFramebufferAttachmentParameter();
     
    554557
    555558        [StrictTypeChecking, ConvertNullStringTo=Null] DOMString    getShaderSource(in WebGLShader shader) raises(DOMException);
     559
     560        // DOMString[] getSupportedExtensions()
     561        [StrictTypeChecking, Custom] void getSupportedExtensions();
    556562
    557563        // any getTexParameter(in unsigned long target, in unsigned long pname) raises(DOMException);
  • trunk/WebCore/platform/graphics/Extensions3D.h

    r72124 r73806  
    5151    //   GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil
    5252    //   GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample
     53    //   GL_OES_texture_float
    5354
    5455    // Takes full name of extension; for example,
    5556    // "GL_EXT_texture_format_BGRA8888".
    5657    virtual bool supports(const String&) = 0;
     58
     59    // Certain OpenGL and WebGL implementations may support enabling
     60    // extensions lazily. This method may only be called with
     61    // extension names for which supports returns true.
     62    virtual void ensureEnabled(const String&) = 0;
    5763
    5864    enum ExtensionsEnumType {
  • trunk/WebCore/platform/graphics/GraphicsContext3D.cpp

    r72130 r73806  
    8686        *componentsPerPixel = 1;
    8787        *bytesPerComponent = sizeof(unsigned short);
     88        break;
     89    case GraphicsContext3D::FLOAT: // OES_texture_float
     90        *bytesPerComponent = sizeof(float);
    8891        break;
    8992    default:
     
    189192        }
    190193        break;
     194    case FLOAT: // OES_texture_float
     195        switch (format) {
     196        case RGBA:
     197            sourceDataFormat = SourceFormatRGBA32F;
     198            break;
     199        case RGB:
     200            sourceDataFormat = SourceFormatRGB32F;
     201            break;
     202        case ALPHA:
     203            sourceDataFormat = SourceFormatA32F;
     204            break;
     205        case LUMINANCE:
     206            sourceDataFormat = SourceFormatR32F;
     207            break;
     208        case LUMINANCE_ALPHA:
     209            sourceDataFormat = SourceFormatRA32F;
     210            break;
     211        default:
     212            ASSERT_NOT_REACHED();
     213        }
     214        break;
    191215    case UNSIGNED_SHORT_5_5_5_1:
    192216        sourceDataFormat = SourceFormatRGBA5551;
     
    502526}
    503527
     528void unpackRGB32FToRGBA32F(const float* source, float* destination)
     529{
     530    destination[0] = source[0];
     531    destination[1] = source[1];
     532    destination[2] = source[2];
     533    destination[3] = 1;
     534}
     535
     536void unpackR32FToRGBA32F(const float* source, float* destination)
     537{
     538    destination[0] = source[0];
     539    destination[1] = source[0];
     540    destination[2] = source[0];
     541    destination[3] = 1;
     542}
     543
     544void unpackRA32FToRGBA32F(const float* source, float* destination)
     545{
     546    destination[0] = source[0];
     547    destination[1] = source[0];
     548    destination[2] = source[0];
     549    destination[3] = source[1];
     550}
     551
     552void unpackA32FToRGBA32F(const float* source, float* destination)
     553{
     554    destination[0] = 0;
     555    destination[1] = 0;
     556    destination[2] = 0;
     557    destination[3] = source[0];
     558}
     559
    504560//----------------------------------------------------------------------
    505561// Pixel packing routines.
     
    714770}
    715771
     772void packRGBA32FToRGB32F(const float* source, float* destination)
     773{
     774    destination[0] = source[0];
     775    destination[1] = source[1];
     776    destination[2] = source[2];
     777}
     778
     779void packRGBA32FToRGB32FPremultiply(const float* source, float* destination)
     780{
     781    float scaleFactor = source[3];
     782    destination[0] = source[0] * scaleFactor;
     783    destination[1] = source[1] * scaleFactor;
     784    destination[2] = source[2] * scaleFactor;
     785}
     786
     787void packRGBA32FToRGBA32FPremultiply(const float* source, float* destination)
     788{
     789    float scaleFactor = source[3];
     790    destination[0] = source[0] * scaleFactor;
     791    destination[1] = source[1] * scaleFactor;
     792    destination[2] = source[2] * scaleFactor;
     793    destination[3] = source[3];
     794}
     795
     796void packRGBA32FToA32F(const float* source, float* destination)
     797{
     798    destination[0] = source[3];
     799}
     800
     801void packRGBA32FToR32F(const float* source, float* destination)
     802{
     803    destination[0] = source[0];
     804}
     805
     806void packRGBA32FToR32FPremultiply(const float* source, float* destination)
     807{
     808    float scaleFactor = source[3];
     809    destination[0] = source[0] * scaleFactor;
     810}
     811
     812
     813void packRGBA32FToRA32F(const float* source, float* destination)
     814{
     815    destination[0] = source[0];
     816    destination[1] = source[3];
     817}
     818
     819void packRGBA32FToRA32FPremultiply(const float* source, float* destination)
     820{
     821    float scaleFactor = source[3];
     822    destination[0] = source[0] * scaleFactor;
     823    destination[1] = scaleFactor;
     824}
     825
    716826} // anonymous namespace
    717827
    718828// This is used whenever unpacking is necessary; i.e., the source data
    719 // is not in RGBA8 format, or the unpack alignment specifies that rows
    720 // are not tightly packed.
    721 template<typename SourceType, typename DestType,
    722          void unpackingFunc(const SourceType*, uint8_t*),
    723          void packingFunc(const uint8_t*, DestType*)>
     829// is not in RGBA8/RGBA32F format, or the unpack alignment specifies
     830// that rows are not tightly packed.
     831template<typename SourceType, typename IntermediateType, typename DestType,
     832         void unpackingFunc(const SourceType*, IntermediateType*),
     833         void packingFunc(const IntermediateType*, DestType*)>
    724834static void doUnpackingAndPacking(const SourceType* sourceData,
    725835                                  unsigned int width,
     
    733843        unsigned int numElements = width * height * sourceElementsPerPixel;
    734844        const SourceType* endPointer = sourceData + numElements;
    735         uint8_t temporaryRGBAData[4];
     845        IntermediateType temporaryRGBAData[4];
    736846        while (sourceData < endPointer) {
    737847            unpackingFunc(sourceData, temporaryRGBAData);
     
    741851        }
    742852    } else {
    743         uint8_t temporaryRGBAData[4];
     853        IntermediateType temporaryRGBAData[4];
    744854        for (unsigned int y = 0; y < height; ++y) {
    745855            const SourceType* currentSource = sourceData;
     
    803913            }
    804914        } else {
    805             doUnpackingAndPacking<uint8_t, DestType, unpackRGBA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     915            doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackRGBA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    806916        }
    807917        break;
     
    810920        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    811921        computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    812         doUnpackingAndPacking<uint16_t, DestType, unpackRGBA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     922        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGBA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    813923        break;
    814924    }
     
    816926        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    817927        computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    818         doUnpackingAndPacking<uint16_t, DestType, unpackRGBA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     928        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGBA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    819929        break;
    820930    }
     
    822932        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    823933        computeIncrementParameters<uint8_t>(width, 3, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    824         doUnpackingAndPacking<uint8_t, DestType, unpackRGB8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     934        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackRGB8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    825935        break;
    826936    }
     
    828938        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    829939        computeIncrementParameters<uint16_t>(width, 6, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    830         doUnpackingAndPacking<uint16_t, DestType, unpackRGB16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     940        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGB16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    831941        break;
    832942    }
     
    834944        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    835945        computeIncrementParameters<uint16_t>(width, 6, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    836         doUnpackingAndPacking<uint16_t, DestType, unpackRGB16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     946        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGB16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    837947        break;
    838948    }
     
    840950        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    841951        computeIncrementParameters<uint8_t>(width, 3, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    842         doUnpackingAndPacking<uint8_t, DestType, unpackBGR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     952        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackBGR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    843953        break;
    844954    }
     
    846956        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    847957        computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    848         doUnpackingAndPacking<uint8_t, DestType, unpackARGB8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     958        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackARGB8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    849959        break;
    850960    }
     
    852962        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    853963        computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    854         doUnpackingAndPacking<uint16_t, DestType, unpackARGB16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     964        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackARGB16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    855965        break;
    856966    }
     
    858968        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    859969        computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    860         doUnpackingAndPacking<uint16_t, DestType, unpackARGB16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     970        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackARGB16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    861971        break;
    862972    }
     
    864974        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    865975        computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    866         doUnpackingAndPacking<uint8_t, DestType, unpackABGR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     976        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackABGR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    867977        break;
    868978    }
     
    870980        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    871981        computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    872         doUnpackingAndPacking<uint8_t, DestType, unpackBGRA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     982        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackBGRA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    873983        break;
    874984    }
     
    876986        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    877987        computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    878         doUnpackingAndPacking<uint16_t, DestType, unpackBGRA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     988        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackBGRA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    879989        break;
    880990    }
     
    882992        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    883993        computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    884         doUnpackingAndPacking<uint16_t, DestType, unpackBGRA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     994        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackBGRA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    885995        break;
    886996    }
     
    888998        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    889999        computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    890         doUnpackingAndPacking<uint16_t, DestType, unpackRGBA5551ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1000        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGBA5551ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    8911001        break;
    8921002    }
     
    8941004        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    8951005        computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    896         doUnpackingAndPacking<uint16_t, DestType, unpackRGBA4444ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1006        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGBA4444ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    8971007        break;
    8981008    }
     
    9001010        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9011011        computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    902         doUnpackingAndPacking<uint16_t, DestType, unpackRGB565ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1012        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRGB565ToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9031013        break;
    9041014    }
     
    9061016        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9071017        computeIncrementParameters<uint8_t>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    908         doUnpackingAndPacking<uint8_t, DestType, unpackR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1018        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9091019        break;
    9101020    }
     
    9121022        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9131023        computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    914         doUnpackingAndPacking<uint16_t, DestType, unpackR16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1024        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackR16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9151025        break;
    9161026    }
     
    9181028        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9191029        computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    920         doUnpackingAndPacking<uint16_t, DestType, unpackR16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1030        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackR16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9211031        break;
    9221032    }
     
    9241034        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9251035        computeIncrementParameters<uint8_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    926         doUnpackingAndPacking<uint8_t, DestType, unpackRA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1036        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackRA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9271037        break;
    9281038    }
     
    9301040        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9311041        computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    932         doUnpackingAndPacking<uint16_t, DestType, unpackRA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1042        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9331043        break;
    9341044    }
     
    9361046        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9371047        computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    938         doUnpackingAndPacking<uint16_t, DestType, unpackRA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1048        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackRA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9391049        break;
    9401050    }
     
    9421052        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9431053        computeIncrementParameters<uint8_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    944         doUnpackingAndPacking<uint8_t, DestType, unpackAR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1054        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackAR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9451055        break;
    9461056    }
     
    9481058        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9491059        computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    950         doUnpackingAndPacking<uint16_t, DestType, unpackAR16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1060        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackAR16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9511061        break;
    9521062    }
     
    9541064        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9551065        computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    956         doUnpackingAndPacking<uint16_t, DestType, unpackAR16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1066        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackAR16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9571067        break;
    9581068    }
     
    9601070        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9611071        computeIncrementParameters<uint8_t>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    962         doUnpackingAndPacking<uint8_t, DestType, unpackA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1072        doUnpackingAndPacking<uint8_t, uint8_t, DestType, unpackA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9631073        break;
    9641074    }
     
    9661076        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9671077        computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    968         doUnpackingAndPacking<uint16_t, DestType, unpackA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1078        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9691079        break;
    9701080    }
     
    9721082        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
    9731083        computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
    974         doUnpackingAndPacking<uint16_t, DestType, unpackA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1084        doUnpackingAndPacking<uint16_t, uint8_t, DestType, unpackA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
    9751085        break;
    9761086    }
    9771087    default:
    9781088        ASSERT(false);
     1089    }
     1090}
     1091
     1092// This specialized routine is used only for floating-point texture uploads. It
     1093// does not need to be as general as doPacking, above; because there are
     1094// currently no native floating-point image formats in WebKit, there are only a
     1095// few upload paths.
     1096template<void packingFunc(const float*, float*)>
     1097static void doFloatingPointPacking(const void* sourceData,
     1098                                   GraphicsContext3D::SourceDataFormat sourceDataFormat,
     1099                                   unsigned int width,
     1100                                   unsigned int height,
     1101                                   unsigned int sourceUnpackAlignment,
     1102                                   float* destinationData,
     1103                                   unsigned int destinationElementsPerPixel)
     1104{
     1105    switch (sourceDataFormat) {
     1106    case GraphicsContext3D::SourceFormatRGBA8: {
     1107        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
     1108        computeIncrementParameters<float>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
     1109        ASSERT(!sourceElementsPerRow); // Guaranteed because each color channel is sizeof(float) bytes.
     1110        const float* source = static_cast<const float*>(sourceData);
     1111        unsigned int numElements = width * height * 4;
     1112        const float* endPointer = source + numElements;
     1113        while (source < endPointer) {
     1114            packingFunc(source, destinationData);
     1115            source += sourceElementsPerPixel;
     1116            destinationData += destinationElementsPerPixel;
     1117        }
     1118        break;
     1119    }
     1120    case GraphicsContext3D::SourceFormatRGB32F: {
     1121        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
     1122        computeIncrementParameters<float>(width, 3, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
     1123        doUnpackingAndPacking<float, float, float, unpackRGB32FToRGBA32F, packingFunc>(static_cast<const float*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1124        break;
     1125    }
     1126    case GraphicsContext3D::SourceFormatR32F: {
     1127        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
     1128        computeIncrementParameters<float>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
     1129        doUnpackingAndPacking<float, float, float, unpackR32FToRGBA32F, packingFunc>(static_cast<const float*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1130        break;
     1131    }
     1132    case GraphicsContext3D::SourceFormatRA32F: {
     1133        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
     1134        computeIncrementParameters<float>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
     1135        doUnpackingAndPacking<float, float, float, unpackRA32FToRGBA32F, packingFunc>(static_cast<const float*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1136        break;
     1137    }
     1138    case GraphicsContext3D::SourceFormatA32F: {
     1139        unsigned int sourceElementsPerPixel, sourceElementsPerRow;
     1140        computeIncrementParameters<float>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow);
     1141        doUnpackingAndPacking<float, float, float, unpackA32FToRGBA32F, packingFunc>(static_cast<const float*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel);
     1142        break;
     1143    }
     1144    default:
     1145        ASSERT_NOT_REACHED();
    9791146    }
    9801147}
     
    11141281        break;
    11151282    }
     1283    case FLOAT: {
     1284        // OpenGL ES, and therefore WebGL, require that the format and
     1285        // internalformat be identical, which implies that the source and
     1286        // destination formats will both be floating-point in this branch -- at
     1287        // least, until WebKit supports floating-point image formats natively.
     1288        ASSERT(sourceDataFormat == SourceFormatRGBA32F || sourceDataFormat == SourceFormatRGB32F
     1289               || sourceDataFormat == SourceFormatRA32F || sourceDataFormat == SourceFormatR32F
     1290               || sourceDataFormat == SourceFormatA32F);
     1291        // Because WebKit doesn't use floating-point color channels for anything
     1292        // internally, there's no chance we have to do a (lossy) unmultiply
     1293        // operation.
     1294        ASSERT(alphaOp == AlphaDoNothing || alphaOp == AlphaDoPremultiply);
     1295        // For the source formats with an even number of channels (RGBA32F,
     1296        // RA32F) it is guaranteed that the pixel data is tightly packed because
     1297        // unpack alignment <= sizeof(float) * number of channels.
     1298        float* destination = static_cast<float*>(destinationData);
     1299        if (alphaOp == AlphaDoNothing
     1300            && ((sourceDataFormat == SourceFormatRGBA32F && destinationFormat == RGBA)
     1301                || (sourceDataFormat == SourceFormatRA32F && destinationFormat == LUMINANCE_ALPHA))) {
     1302            // No conversion necessary.
     1303            int numChannels = (sourceDataFormat == SourceFormatRGBA32F ? 4 : 2);
     1304            memcpy(destinationData, sourceData, width * height * numChannels * sizeof(float));
     1305            break;
     1306        }
     1307        switch (destinationFormat) {
     1308        case RGB:
     1309            switch (alphaOp) {
     1310            case AlphaDoNothing:
     1311                doFloatingPointPacking<packRGBA32FToRGB32F>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 3);
     1312                break;
     1313            case AlphaDoPremultiply:
     1314                doFloatingPointPacking<packRGBA32FToRGB32FPremultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 3);
     1315                break;
     1316            default:
     1317                ASSERT_NOT_REACHED();
     1318            }
     1319            break;
     1320        case RGBA:
     1321            // AlphaDoNothing is handled above with fast path.
     1322            ASSERT(alphaOp == AlphaDoPremultiply);
     1323            doFloatingPointPacking<packRGBA32FToRGBA32FPremultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 4);
     1324            break;
     1325        case ALPHA:
     1326            // From the desktop OpenGL conversion rules (OpenGL 2.1
     1327            // specification, Table 3.15), the alpha channel is chosen
     1328            // from the RGBA data.
     1329            doFloatingPointPacking<packRGBA32FToA32F>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);
     1330            break;
     1331        case LUMINANCE:
     1332            // From the desktop OpenGL conversion rules (OpenGL 2.1
     1333            // specification, Table 3.15), the red channel is chosen
     1334            // from the RGBA data.
     1335            switch (alphaOp) {
     1336            case AlphaDoNothing:
     1337                doFloatingPointPacking<packRGBA32FToR32F>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);
     1338                break;
     1339            case AlphaDoPremultiply:
     1340                doFloatingPointPacking<packRGBA32FToR32FPremultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 1);
     1341                break;
     1342            default:
     1343                ASSERT_NOT_REACHED();
     1344            }
     1345            break;
     1346        case LUMINANCE_ALPHA:
     1347            // From the desktop OpenGL conversion rules (OpenGL 2.1
     1348            // specification, Table 3.15), the red and alpha channels
     1349            // are chosen from the RGBA data.
     1350            switch (alphaOp) {
     1351            case AlphaDoNothing:
     1352                doFloatingPointPacking<packRGBA32FToRA32F>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 2);
     1353                break;
     1354            case AlphaDoPremultiply:
     1355                doFloatingPointPacking<packRGBA32FToRA32FPremultiply>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 2);
     1356                break;
     1357            default:
     1358                ASSERT_NOT_REACHED();
     1359            }
     1360            break;
     1361        }
     1362        break;
     1363    }
    11161364    }
    11171365    return true;
  • trunk/WebCore/platform/graphics/GraphicsContext3D.h

    r72130 r73806  
    537537        SourceFormatRGBA16Little,
    538538        SourceFormatRGBA16Big,
     539        SourceFormatRGBA32F,
    539540        SourceFormatRGB8,
    540541        SourceFormatRGB16Little,
    541542        SourceFormatRGB16Big,
     543        SourceFormatRGB32F,
    542544        SourceFormatBGR8,
    543545        SourceFormatBGRA8,
     
    554556        SourceFormatR16Little,
    555557        SourceFormatR16Big,
     558        SourceFormatR32F,
    556559        SourceFormatRA8,
    557560        SourceFormatRA16Little,
    558561        SourceFormatRA16Big,
     562        SourceFormatRA32F,
    559563        SourceFormatAR8,
    560564        SourceFormatAR16Little,
     
    563567        SourceFormatA16Little,
    564568        SourceFormatA16Big,
     569        SourceFormatA32F,
    565570        SourceFormatNumFormats
    566571    };
  • trunk/WebCore/platform/graphics/chromium/Extensions3DChromium.h

    r72124 r73806  
    4343    // Extensions3D methods.
    4444    virtual bool supports(const String&);
     45    virtual void ensureEnabled(const String&);
    4546    virtual int getGraphicsResetStatusARB();
    4647    virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) { }
  • trunk/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp

    r71853 r73806  
    7777    if (name == "GL_ANGLE_framebuffer_multisample")
    7878        return m_availableExtensions.contains("GL_EXT_framebuffer_multisample");
    79        
     79
     80    // If GL_ARB_texture_float is available then we report GL_OES_texture_float and
     81    // GL_OES_texture_half_float as available.
     82    if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float")
     83        return m_availableExtensions.contains("GL_ARB_texture_float");
     84
    8085    return m_availableExtensions.contains(name);
     86}
     87
     88void Extensions3DOpenGL::ensureEnabled(const String& name)
     89{
     90#ifndef NDEBUG
     91    UNUSED_PARAM(name);
     92#endif
     93    ASSERT(supports(name));
    8194}
    8295
  • trunk/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h

    r71853 r73806  
    4141    // Extensions3D methods.
    4242    virtual bool supports(const String&);
     43    virtual void ensureEnabled(const String&);
    4344    virtual int getGraphicsResetStatusARB();
    4445    virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter);
  • trunk/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp

    r73543 r73806  
    13301330    makeContextCurrent();
    13311331
    1332     ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
     1332    unsigned openGLInternalFormat = internalformat;
     1333    if (type == GL_FLOAT) {
     1334        if (format == GL_RGBA)
     1335            openGLInternalFormat = GL_RGBA32F_ARB;
     1336        else if (format == GL_RGB)
     1337            openGLInternalFormat = GL_RGB32F_ARB;
     1338    }
     1339
     1340    ::glTexImage2D(target, level, openGLInternalFormat, width, height, border, format, type, pixels);
    13331341    return 0;
    13341342}
  • trunk/WebCore/platform/graphics/qt/Extensions3DQt.cpp

    r71272 r73806  
    4747}
    4848
     49void Extensions3DQt::ensureEnabled(const String& name)
     50{
     51    ASSERT(supports(name));
     52}
     53
    4954int Extensions3DQt::getGraphicsResetStatusARB()
    5055{
  • trunk/WebCore/platform/graphics/qt/Extensions3DQt.h

    r71272 r73806  
    3737    // Extensions3D methods.
    3838    virtual bool supports(const String&);
     39    virtual void ensureEnabled(const String&);
    3940    virtual int getGraphicsResetStatusARB();
    4041
  • trunk/WebKit/chromium/ChangeLog

    r73745 r73806  
     12010-12-10  Kenneth Russell  <kbr@google.com>
     2
     3        Reviewed by James Robinson.
     4
     5        Implement extension entry points and remove EXTENSIONS enum
     6        https://bugs.webkit.org/show_bug.cgi?id=40316
     7
     8        Added support for ensuring that a particular OpenGL extension is
     9        enabled.
     10
     11        * public/WebGraphicsContext3D.h:
     12        * src/Extensions3DChromium.cpp:
     13        (WebCore::Extensions3DChromium::ensureEnabled):
     14        * src/GraphicsContext3DChromium.cpp:
     15        (WebCore::GraphicsContext3DInternal::initializeExtensions):
     16        (WebCore::GraphicsContext3DInternal::supportsExtension):
     17        (WebCore::GraphicsContext3DInternal::ensureExtensionEnabled):
     18        * src/GraphicsContext3DInternal.h:
     19        * src/WebGraphicsContext3DDefaultImpl.cpp:
     20        (WebKit::WebGraphicsContext3DDefaultImpl::getRequestableExtensionsCHROMIUM):
     21        (WebKit::WebGraphicsContext3DDefaultImpl::requestExtensionCHROMIUM):
     22        * src/WebGraphicsContext3DDefaultImpl.h:
     23
    1242010-12-10  John Knottenbelt  <jknotten@chromium.org>
    225
  • trunk/WebKit/chromium/public/WebGraphicsContext3D.h

    r72587 r73806  
    141141    virtual void copyTextureToParentTextureCHROMIUM(unsigned texture, unsigned parentTexture) = 0;
    142142
     143    // GL_CHROMIUM_request_extension
     144    virtual WebString getRequestableExtensionsCHROMIUM() = 0;
     145    virtual void requestExtensionCHROMIUM(const char*) = 0;
     146
    143147    // The entry points below map directly to the OpenGL ES 2.0 API.
    144148    // See: http://www.khronos.org/registry/gles/
  • trunk/WebKit/chromium/src/Extensions3DChromium.cpp

    r72587 r73806  
    4949}
    5050
     51void Extensions3DChromium::ensureEnabled(const String& name)
     52{
     53#ifndef NDEBUG
     54    bool result =
     55#endif
     56        m_internal->ensureExtensionEnabled(name);
     57    ASSERT(result);
     58}
     59
    5160int Extensions3DChromium::getGraphicsResetStatusARB()
    5261{
  • trunk/WebKit/chromium/src/GraphicsContext3DChromium.cpp

    r72587 r73806  
    682682}
    683683
    684 bool GraphicsContext3DInternal::supportsExtension(const String& name)
     684namespace {
     685
     686void splitStringHelper(const String& str, HashSet<String>& set)
     687{
     688    Vector<String> substrings;
     689    str.split(" ", substrings);
     690    for (size_t i = 0; i < substrings.size(); ++i)
     691        set.add(substrings[i]);
     692}
     693
     694} // anonymous namespace
     695
     696void GraphicsContext3DInternal::initializeExtensions()
    685697{
    686698    if (!m_initializedAvailableExtensions) {
    687699        String extensionsString = getString(GraphicsContext3D::EXTENSIONS);
    688         Vector<String> availableExtensions;
    689         extensionsString.split(" ", availableExtensions);
    690         for (size_t i = 0; i < availableExtensions.size(); ++i)
    691             m_availableExtensions.add(availableExtensions[i]);
     700        splitStringHelper(extensionsString, m_enabledExtensions);
     701
     702        String requestableExtensionsString = m_impl->getRequestableExtensionsCHROMIUM();
     703        splitStringHelper(requestableExtensionsString, m_requestableExtensions);
     704
    692705        m_initializedAvailableExtensions = true;
    693706    }
    694     return m_availableExtensions.contains(name);
     707}
     708
     709
     710bool GraphicsContext3DInternal::supportsExtension(const String& name)
     711{
     712    initializeExtensions();
     713    return m_enabledExtensions.contains(name) || m_requestableExtensions.contains(name);
     714}
     715
     716bool GraphicsContext3DInternal::ensureExtensionEnabled(const String& name)
     717{
     718    initializeExtensions();
     719
     720    if (m_enabledExtensions.contains(name))
     721        return true;
     722
     723    if (m_requestableExtensions.contains(name)) {
     724        m_impl->requestExtensionCHROMIUM(name.ascii().data());
     725        m_enabledExtensions.clear();
     726        m_requestableExtensions.clear();
     727        m_initializedAvailableExtensions = false;
     728    }
     729
     730    initializeExtensions();
     731    return m_enabledExtensions.contains(name);
    695732}
    696733
  • trunk/WebKit/chromium/src/GraphicsContext3DInternal.h

    r72587 r73806  
    266266    Extensions3D* getExtensions();
    267267    bool supportsExtension(const String& name);
     268    bool ensureExtensionEnabled(const String& name);
    268269
    269270    // EXT_texture_format_BGRA8888
     
    286287    WebKit::WebViewImpl* m_webViewImpl;
    287288    bool m_initializedAvailableExtensions;
    288     HashSet<String> m_availableExtensions;
     289    HashSet<String> m_enabledExtensions;
     290    HashSet<String> m_requestableExtensions;
    289291#if USE(ACCELERATED_COMPOSITING)
    290292    RefPtr<WebGLLayerChromium> m_compositingLayer;
     
    302304    unsigned char* m_renderOutput;
    303305#endif
     306
     307    void initializeExtensions();
    304308};
    305309
  • trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp

    r72587 r73806  
    625625}
    626626
     627WebString WebGraphicsContext3DDefaultImpl::getRequestableExtensionsCHROMIUM()
     628{
     629    return WebString();
     630}
     631
     632void WebGraphicsContext3DDefaultImpl::requestExtensionCHROMIUM(const char*)
     633{
     634}
     635
    627636// Helper macros to reduce the amount of code.
    628637
  • trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h

    r72587 r73806  
    8686    virtual void copyTextureToParentTextureCHROMIUM(unsigned texture, unsigned parentTexture);
    8787
     88    virtual WebString getRequestableExtensionsCHROMIUM();
     89    virtual void requestExtensionCHROMIUM(const char*);
     90
    8891    virtual void activeTexture(unsigned long texture);
    8992    virtual void attachShader(WebGLId program, WebGLId shader);
Note: See TracChangeset for help on using the changeset viewer.