summaryrefslogtreecommitdiffstats
path: root/WebCore/html/canvas
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html/canvas')
-rw-r--r--WebCore/html/canvas/CanvasGradient.idl3
-rw-r--r--WebCore/html/canvas/CanvasPattern.idl3
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.cpp10
-rw-r--r--WebCore/html/canvas/CanvasRenderingContext2D.idl2
-rw-r--r--WebCore/html/canvas/Float32Array.cpp (renamed from WebCore/html/canvas/FloatArray.cpp)20
-rw-r--r--WebCore/html/canvas/Float32Array.h (renamed from WebCore/html/canvas/FloatArray.h)16
-rw-r--r--WebCore/html/canvas/Float32Array.idl (renamed from WebCore/html/canvas/FloatArray.idl)6
-rw-r--r--WebCore/html/canvas/Int16Array.idl2
-rw-r--r--WebCore/html/canvas/Int32Array.idl2
-rw-r--r--WebCore/html/canvas/Int8Array.idl2
-rw-r--r--WebCore/html/canvas/Uint16Array.idl2
-rw-r--r--WebCore/html/canvas/Uint32Array.idl2
-rw-r--r--WebCore/html/canvas/Uint8Array.idl2
-rw-r--r--WebCore/html/canvas/WebGLFramebuffer.cpp18
-rw-r--r--WebCore/html/canvas/WebGLFramebuffer.h2
-rw-r--r--WebCore/html/canvas/WebGLGetInfo.cpp6
-rw-r--r--WebCore/html/canvas/WebGLGetInfo.h8
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.cpp731
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.h96
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.idl63
-rw-r--r--WebCore/html/canvas/WebGLTexture.cpp1
-rw-r--r--WebCore/html/canvas/WebGLTexture.h5
22 files changed, 725 insertions, 277 deletions
diff --git a/WebCore/html/canvas/CanvasGradient.idl b/WebCore/html/canvas/CanvasGradient.idl
index 32813bc..a925a26 100644
--- a/WebCore/html/canvas/CanvasGradient.idl
+++ b/WebCore/html/canvas/CanvasGradient.idl
@@ -27,8 +27,7 @@ module html {
interface [
InterfaceUUID=bb1108ea-6b8c-4a08-894a-218628630cdb,
- ImplementationUUID=a2942ae6-2731-4286-98cc-9d5e79e20de1,
- OmitConstructor
+ ImplementationUUID=a2942ae6-2731-4286-98cc-9d5e79e20de1
] CanvasGradient {
void addColorStop(in float offset, in DOMString color)
diff --git a/WebCore/html/canvas/CanvasPattern.idl b/WebCore/html/canvas/CanvasPattern.idl
index 492c93f..1cac8f8 100644
--- a/WebCore/html/canvas/CanvasPattern.idl
+++ b/WebCore/html/canvas/CanvasPattern.idl
@@ -27,8 +27,7 @@ module html {
interface [
InterfaceUUID=c2131348-6d8c-47b5-86cc-d41aff34ce15,
- ImplementationUUID=82f5d713-3d17-44dd-aa4a-7766fe345940,
- OmitConstructor
+ ImplementationUUID=82f5d713-3d17-44dd-aa4a-7766fe345940
] CanvasPattern {
};
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
index 184cc14..8531bd5 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp
@@ -753,6 +753,12 @@ void CanvasRenderingContext2D::fillRect(float x, float y, float width, float hei
if (!state().m_invertibleCTM)
return;
+ // from the HTML5 Canvas spec:
+ // If x0 = x1 and y0 = y1, then the linear gradient must paint nothing
+ Gradient* gradient = c->fillGradient();
+ if (gradient && gradient->isZeroSize() && !gradient->isRadial())
+ return;
+
FloatRect rect(x, y, width, height);
willDraw(rect);
@@ -1265,10 +1271,8 @@ PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageEleme
if (ec)
return 0;
- if (!image->complete()) {
- ec = INVALID_STATE_ERR;
+ if (!image->complete())
return 0;
- }
CachedImage* cachedImage = image->cachedImage();
if (!cachedImage || !image->cachedImage()->image())
diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.idl b/WebCore/html/canvas/CanvasRenderingContext2D.idl
index da4dd72..23afc11 100644
--- a/WebCore/html/canvas/CanvasRenderingContext2D.idl
+++ b/WebCore/html/canvas/CanvasRenderingContext2D.idl
@@ -90,10 +90,12 @@ module html {
void setAlpha(in float alpha);
void setCompositeOperation(in DOMString compositeOperation);
+#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
void setLineWidth(in float width);
void setLineCap(in DOMString cap);
void setLineJoin(in DOMString join);
void setMiterLimit(in float limit);
+#endif
void clearShadow();
diff --git a/WebCore/html/canvas/FloatArray.cpp b/WebCore/html/canvas/Float32Array.cpp
index 942a123..c95fb48 100644
--- a/WebCore/html/canvas/FloatArray.cpp
+++ b/WebCore/html/canvas/Float32Array.cpp
@@ -28,33 +28,33 @@
#if ENABLE(3D_CANVAS)
-#include "FloatArray.h"
+#include "Float32Array.h"
namespace WebCore {
-PassRefPtr<FloatArray> FloatArray::create(unsigned length)
+PassRefPtr<Float32Array> Float32Array::create(unsigned length)
{
- return TypedArrayBase<float>::create<FloatArray>(length);
+ return TypedArrayBase<float>::create<Float32Array>(length);
}
-PassRefPtr<FloatArray> FloatArray::create(float* array, unsigned length)
+PassRefPtr<Float32Array> Float32Array::create(float* array, unsigned length)
{
- return TypedArrayBase<float>::create<FloatArray>(array, length);
+ return TypedArrayBase<float>::create<Float32Array>(array, length);
}
-PassRefPtr<FloatArray> FloatArray::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+PassRefPtr<Float32Array> Float32Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
{
- return TypedArrayBase<float>::create<FloatArray>(buffer, byteOffset, length);
+ return TypedArrayBase<float>::create<Float32Array>(buffer, byteOffset, length);
}
-FloatArray::FloatArray(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+Float32Array::Float32Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
: TypedArrayBase<float>(buffer, byteOffset, length)
{
}
-PassRefPtr<ArrayBufferView> FloatArray::slice(int start, int end) const
+PassRefPtr<ArrayBufferView> Float32Array::slice(int start, int end) const
{
- return sliceImpl<FloatArray>(start, end);
+ return sliceImpl<Float32Array>(start, end);
}
}
diff --git a/WebCore/html/canvas/FloatArray.h b/WebCore/html/canvas/Float32Array.h
index 9211a40..8112264 100644
--- a/WebCore/html/canvas/FloatArray.h
+++ b/WebCore/html/canvas/Float32Array.h
@@ -24,19 +24,19 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef FloatArray_h
-#define FloatArray_h
+#ifndef Float32Array_h
+#define Float32Array_h
#include "TypedArrayBase.h"
#include <wtf/MathExtras.h>
namespace WebCore {
-class FloatArray : public TypedArrayBase<float> {
+class Float32Array : public TypedArrayBase<float> {
public:
- static PassRefPtr<FloatArray> create(unsigned length);
- static PassRefPtr<FloatArray> create(float* array, unsigned length);
- static PassRefPtr<FloatArray> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
+ static PassRefPtr<Float32Array> create(unsigned length);
+ static PassRefPtr<Float32Array> create(float* array, unsigned length);
+ static PassRefPtr<Float32Array> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length);
using TypedArrayBase<float>::set;
@@ -63,7 +63,7 @@ class FloatArray : public TypedArrayBase<float> {
}
private:
- FloatArray(PassRefPtr<ArrayBuffer> buffer,
+ Float32Array(PassRefPtr<ArrayBuffer> buffer,
unsigned byteOffset,
unsigned length);
// Make constructor visible to superclass.
@@ -76,4 +76,4 @@ class FloatArray : public TypedArrayBase<float> {
} // namespace WebCore
-#endif // FloatArray_h
+#endif // Float32Array_h
diff --git a/WebCore/html/canvas/FloatArray.idl b/WebCore/html/canvas/Float32Array.idl
index 41b2c94..91a9f4e 100644
--- a/WebCore/html/canvas/FloatArray.idl
+++ b/WebCore/html/canvas/Float32Array.idl
@@ -32,8 +32,10 @@ module html {
GenerateNativeConverter,
CustomConstructor,
CustomToJS
- ] FloatArray : ArrayBufferView {
- // void set(in FloatArray array, [Optional] in unsigned long offset);
+ ] Float32Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 4;
+
+ // void set(in Float32Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
};
diff --git a/WebCore/html/canvas/Int16Array.idl b/WebCore/html/canvas/Int16Array.idl
index 2ac52fe..95c8204 100644
--- a/WebCore/html/canvas/Int16Array.idl
+++ b/WebCore/html/canvas/Int16Array.idl
@@ -32,6 +32,8 @@ module html {
CustomConstructor,
CustomToJS
] Int16Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 2;
+
// void set(in Int16Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
diff --git a/WebCore/html/canvas/Int32Array.idl b/WebCore/html/canvas/Int32Array.idl
index 80a885e..9c9a50f 100644
--- a/WebCore/html/canvas/Int32Array.idl
+++ b/WebCore/html/canvas/Int32Array.idl
@@ -33,6 +33,8 @@ module html {
CustomConstructor,
CustomToJS
] Int32Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 4;
+
// void set(in Int32Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
diff --git a/WebCore/html/canvas/Int8Array.idl b/WebCore/html/canvas/Int8Array.idl
index 1124ac1..9aefd34 100644
--- a/WebCore/html/canvas/Int8Array.idl
+++ b/WebCore/html/canvas/Int8Array.idl
@@ -33,6 +33,8 @@ module html {
CustomConstructor,
CustomToJS
] Int8Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 1;
+
// void set(in Int8Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
diff --git a/WebCore/html/canvas/Uint16Array.idl b/WebCore/html/canvas/Uint16Array.idl
index 2d5b34e..baba0d9 100644
--- a/WebCore/html/canvas/Uint16Array.idl
+++ b/WebCore/html/canvas/Uint16Array.idl
@@ -33,6 +33,8 @@ module html {
GenerateNativeConverter,
CustomToJS
] Uint16Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 2;
+
// void set(in Uint16Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
diff --git a/WebCore/html/canvas/Uint32Array.idl b/WebCore/html/canvas/Uint32Array.idl
index bab0f8d..b7573e6 100644
--- a/WebCore/html/canvas/Uint32Array.idl
+++ b/WebCore/html/canvas/Uint32Array.idl
@@ -33,6 +33,8 @@ module html {
GenerateNativeConverter,
CustomToJS
] Uint32Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 4;
+
// void set(in Uint32Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
diff --git a/WebCore/html/canvas/Uint8Array.idl b/WebCore/html/canvas/Uint8Array.idl
index 7031bfc..ea4c0f5 100644
--- a/WebCore/html/canvas/Uint8Array.idl
+++ b/WebCore/html/canvas/Uint8Array.idl
@@ -33,6 +33,8 @@ module html {
CustomConstructor,
CustomToJS
] Uint8Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 1;
+
// void set(in Uint8Array array, [Optional] in unsigned long offset);
// void set(in sequence<long> array, [Optional] in unsigned long offset);
[Custom] void set();
diff --git a/WebCore/html/canvas/WebGLFramebuffer.cpp b/WebCore/html/canvas/WebGLFramebuffer.cpp
index c783553..db88b1c 100644
--- a/WebCore/html/canvas/WebGLFramebuffer.cpp
+++ b/WebCore/html/canvas/WebGLFramebuffer.cpp
@@ -87,6 +87,24 @@ void WebGLFramebuffer::onAttachedObjectChange(CanvasObject* object)
initializeRenderbuffers();
}
+unsigned long WebGLFramebuffer::getColorBufferFormat()
+{
+ if (object() && m_colorAttachment && m_colorAttachment->object()) {
+ if (m_colorAttachment->isRenderbuffer()) {
+ unsigned long format = (reinterpret_cast<WebGLRenderbuffer*>(m_colorAttachment))->getInternalformat();
+ switch (format) {
+ case GraphicsContext3D::RGBA4:
+ case GraphicsContext3D::RGB5_A1:
+ return GraphicsContext3D::RGBA;
+ case GraphicsContext3D::RGB565:
+ return GraphicsContext3D::RGB;
+ }
+ } else if (m_colorAttachment->isTexture())
+ return (reinterpret_cast<WebGLTexture*>(m_colorAttachment))->getInternalformat();
+ }
+ return 0;
+}
+
void WebGLFramebuffer::_deleteObject(Platform3DObject object)
{
context()->graphicsContext3D()->deleteFramebuffer(object);
diff --git a/WebCore/html/canvas/WebGLFramebuffer.h b/WebCore/html/canvas/WebGLFramebuffer.h
index 93ab97c..ae1f4dc 100644
--- a/WebCore/html/canvas/WebGLFramebuffer.h
+++ b/WebCore/html/canvas/WebGLFramebuffer.h
@@ -57,6 +57,8 @@ namespace WebCore {
// clear un-initialized renderbuffers.
void onAttachedObjectChange(CanvasObject*);
+ unsigned long getColorBufferFormat();
+
protected:
WebGLFramebuffer(WebGLRenderingContext*);
diff --git a/WebCore/html/canvas/WebGLGetInfo.cpp b/WebCore/html/canvas/WebGLGetInfo.cpp
index d5fcd92..79fc971 100644
--- a/WebCore/html/canvas/WebGLGetInfo.cpp
+++ b/WebCore/html/canvas/WebGLGetInfo.cpp
@@ -30,7 +30,7 @@
#include "WebGLGetInfo.h"
#include "WebGLBuffer.h"
-#include "FloatArray.h"
+#include "Float32Array.h"
#include "WebGLFramebuffer.h"
#include "Int32Array.h"
#include "WebGLProgram.h"
@@ -81,7 +81,7 @@ WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLBuffer> value)
{
}
-WebGLGetInfo::WebGLGetInfo(PassRefPtr<FloatArray> value)
+WebGLGetInfo::WebGLGetInfo(PassRefPtr<Float32Array> value)
: m_type(kTypeWebGLFloatArray)
, m_webglFloatArray(value)
{
@@ -168,7 +168,7 @@ PassRefPtr<WebGLBuffer> WebGLGetInfo::getWebGLBuffer() const
return m_webglBuffer;
}
-PassRefPtr<FloatArray> WebGLGetInfo::getWebGLFloatArray() const
+PassRefPtr<Float32Array> WebGLGetInfo::getWebGLFloatArray() const
{
ASSERT(getType() == kTypeWebGLFloatArray);
return m_webglFloatArray;
diff --git a/WebCore/html/canvas/WebGLGetInfo.h b/WebCore/html/canvas/WebGLGetInfo.h
index 969e05d..b35add8 100644
--- a/WebCore/html/canvas/WebGLGetInfo.h
+++ b/WebCore/html/canvas/WebGLGetInfo.h
@@ -32,7 +32,7 @@
#include "PlatformString.h"
#include "WebGLBuffer.h"
-#include "FloatArray.h"
+#include "Float32Array.h"
#include "WebGLFramebuffer.h"
#include "Int32Array.h"
// FIXME: implement WebGLObjectArray
@@ -77,7 +77,7 @@ public:
WebGLGetInfo(const String& value);
WebGLGetInfo(unsigned long value);
WebGLGetInfo(PassRefPtr<WebGLBuffer> value);
- WebGLGetInfo(PassRefPtr<FloatArray> value);
+ WebGLGetInfo(PassRefPtr<Float32Array> value);
WebGLGetInfo(PassRefPtr<WebGLFramebuffer> value);
WebGLGetInfo(PassRefPtr<Int32Array> value);
// FIXME: implement WebGLObjectArray
@@ -97,7 +97,7 @@ public:
const String& getString() const;
unsigned long getUnsignedLong() const;
PassRefPtr<WebGLBuffer> getWebGLBuffer() const;
- PassRefPtr<FloatArray> getWebGLFloatArray() const;
+ PassRefPtr<Float32Array> getWebGLFloatArray() const;
PassRefPtr<WebGLFramebuffer> getWebGLFramebuffer() const;
PassRefPtr<Int32Array> getWebGLIntArray() const;
// FIXME: implement WebGLObjectArray
@@ -115,7 +115,7 @@ private:
String m_string;
unsigned long m_unsignedLong;
RefPtr<WebGLBuffer> m_webglBuffer;
- RefPtr<FloatArray> m_webglFloatArray;
+ RefPtr<Float32Array> m_webglFloatArray;
RefPtr<WebGLFramebuffer> m_webglFramebuffer;
RefPtr<Int32Array> m_webglIntArray;
// FIXME: implement WebGLObjectArray
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index ca1d375..82a0f8f 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -30,6 +30,8 @@
#include "WebGLRenderingContext.h"
#include "CanvasPixelArray.h"
+#include "Console.h"
+#include "DOMWindow.h"
#include "FrameView.h"
#include "HTMLCanvasElement.h"
#include "HTMLImageElement.h"
@@ -50,6 +52,7 @@
#include "WebGLUniformLocation.h"
#include <wtf/ByteArray.h>
+#include <wtf/MathExtras.h>
namespace WebCore {
@@ -91,17 +94,33 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
, m_activeTextureUnit(0)
, m_packAlignment(4)
, m_unpackAlignment(4)
+ , m_unpackFlipY(false)
+ , m_unpackPremultiplyAlpha(false)
{
ASSERT(m_context);
+
+ int numCombinedTextureImageUnits = 0;
+ m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTextureImageUnits);
+ m_textureUnits.resize(numCombinedTextureImageUnits);
+
int numVertexAttribs = 0;
m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &numVertexAttribs);
m_maxVertexAttribs = numVertexAttribs;
+
int implementationColorReadFormat = GraphicsContext3D::RGBA;
m_context->getIntegerv(GraphicsContext3D::IMPLEMENTATION_COLOR_READ_FORMAT, &implementationColorReadFormat);
m_implementationColorReadFormat = implementationColorReadFormat;
int implementationColorReadType = GraphicsContext3D::UNSIGNED_BYTE;
m_context->getIntegerv(GraphicsContext3D::IMPLEMENTATION_COLOR_READ_TYPE, &implementationColorReadType);
m_implementationColorReadType = implementationColorReadType;
+
+ int maxTextureSize = 0;
+ m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize);
+ m_maxTextureSize = maxTextureSize;
+ int maxCubeMapTextureSize = 0;
+ m_context->getIntegerv(GraphicsContext3D::MAX_CUBE_MAP_TEXTURE_SIZE, &maxCubeMapTextureSize);
+ m_maxCubeMapTextureSize = maxCubeMapTextureSize;
+
if (!isGLES2Compliant())
createFallbackBlackTextures1x1();
m_context->reshape(canvas()->width(), canvas()->height());
@@ -433,36 +452,45 @@ void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec
void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
{
- RefPtr<WebGLTexture> tex = 0;
- switch (target) {
- case GraphicsContext3D::TEXTURE_2D:
- tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
- break;
- case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
- tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
- break;
- }
+ if (!validateTexFuncParameters(target, level, internalformat, width, height, border, internalformat, GraphicsContext3D::UNSIGNED_BYTE))
+ return;
if (!isGLES2Compliant()) {
+ if (m_framebufferBinding && m_framebufferBinding->object()
+ && !isTexInternalformatColorBufferCombinationValid(internalformat,
+ m_framebufferBinding->getColorBufferFormat())) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
+ }
if (level && WebGLTexture::isNPOT(width, height)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
+ }
+ m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border);
+ // FIXME: if the framebuffer is not complete, none of the below should be executed.
+ WebGLTexture* tex = getTextureBinding(target);
+ if (!isGLES2Compliant()) {
if (tex && !level) // only for level 0
tex->setSize(target, width, height);
+ if (tex)
+ tex->setInternalformat(internalformat);
}
- m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border);
if (m_framebufferBinding && tex)
- m_framebufferBinding->onAttachedObjectChange(tex.get());
+ m_framebufferBinding->onAttachedObjectChange(tex);
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height)
{
+ if (!isGLES2Compliant()) {
+ WebGLTexture* tex = getTextureBinding(target);
+ if (m_framebufferBinding && m_framebufferBinding->object() && tex
+ && !isTexInternalformatColorBufferCombinationValid(tex->getInternalformat(),
+ m_framebufferBinding->getColorBufferFormat())) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
+ }
+ }
m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
cleanupAfterGraphicsCall(false);
}
@@ -731,7 +759,14 @@ bool WebGLRenderingContext::validateRenderingState(long numElementsRequired)
if (!m_currentProgram)
return false;
- // Look in each enabled vertex attrib and find the smallest buffer size
+ // Look in each enabled vertex attrib and check if they've been bound to a buffer.
+ for (size_t i = 0; i < m_vertexAttribState.size(); ++i) {
+ if (m_vertexAttribState[i].enabled
+ && (!m_vertexAttribState[i].bufferBinding || !m_vertexAttribState[i].bufferBinding->object()))
+ return false;
+ }
+
+ // Look in each consumed vertex attrib (by the current program) and find the smallest buffer size
long smallestNumElements = LONG_MAX;
int numActiveAttribLocations = m_currentProgram->numActiveAttribLocations();
int numAttribStates = static_cast<int>(m_vertexAttribState.size());
@@ -766,8 +801,20 @@ bool WebGLRenderingContext::validateWebGLObject(CanvasObject* object)
void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long count, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
+
+ if (!validateDrawMode(mode))
+ return;
+
+ if (first < 0 || count < 0) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+
+ if (!count)
+ return;
+
// Ensure we have a valid rendering state
- if (first < 0 || count < 0 || !validateRenderingState(first + count)) {
+ if (!validateRenderingState(first + count)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
@@ -778,13 +825,34 @@ void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long coun
cleanupAfterGraphicsCall(true);
}
-void WebGLRenderingContext::drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset, ExceptionCode& ec)
+void WebGLRenderingContext::drawElements(unsigned long mode, long count, unsigned long type, long offset, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
+
+ if (!validateDrawMode(mode))
+ return;
+
+ switch (type) {
+ case GraphicsContext3D::UNSIGNED_BYTE:
+ case GraphicsContext3D::UNSIGNED_SHORT:
+ break;
+ default:
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return;
+ }
+
+ if (count < 0 || offset < 0) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+
+ if (!count)
+ return;
+
// Ensure we have a valid rendering state
long numElements;
- if (offset < 0 || !validateElementArraySize(count, type, offset)) {
+ if (!validateElementArraySize(count, type, offset)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
@@ -946,6 +1014,10 @@ PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram
if (!m_context->getActiveUniform(program, index, info)) {
return 0;
}
+ if (!isGLES2Compliant()) {
+ if (info.size > 1 && !info.name.endsWith("[0]"))
+ info.name.append("[0]");
+ }
return WebGLActiveInfo::create(info.name, info.type, info.size);
}
@@ -1200,6 +1272,10 @@ WebGLGetInfo WebGLRenderingContext::getParameter(unsigned long pname, ExceptionC
case GraphicsContext3D::UNPACK_ALIGNMENT:
// FIXME: should this be "long" in the spec?
return getIntParameter(pname);
+ case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL:
+ return WebGLGetInfo(m_unpackFlipY);
+ case GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL:
+ return WebGLGetInfo(m_unpackPremultiplyAlpha);
case GraphicsContext3D::VIEWPORT:
return getWebGLIntArrayParameter(pname);
default:
@@ -1449,7 +1525,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
if (length == 1)
return WebGLGetInfo(value[0]);
else
- return WebGLGetInfo(FloatArray::create(value, length));
+ return WebGLGetInfo(Float32Array::create(value, length));
}
case GraphicsContext3D::INT: {
int value[16] = {0};
@@ -1527,7 +1603,7 @@ WebGLGetInfo WebGLRenderingContext::getVertexAttrib(unsigned long index, unsigne
case GraphicsContext3D::CURRENT_VERTEX_ATTRIB: {
float value[4] = {0};
m_context->getVertexAttribfv(index, pname, value);
- return WebGLGetInfo(FloatArray::create(value, 4));
+ return WebGLGetInfo(Float32Array::create(value, 4));
}
default: {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
@@ -1620,15 +1696,21 @@ void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec
void WebGLRenderingContext::pixelStorei(unsigned long pname, long param)
{
- m_context->pixelStorei(pname, param);
- if (param == 1 || param == 2 || param == 4 || param == 8) {
- switch (pname) {
- case GraphicsContext3D::PACK_ALIGNMENT:
- m_packAlignment = static_cast<int>(param);
- break;
- case GraphicsContext3D::UNPACK_ALIGNMENT:
- m_unpackAlignment = static_cast<int>(param);
- break;
+ if (pname == GraphicsContext3D::UNPACK_FLIP_Y_WEBGL) {
+ m_unpackFlipY = param;
+ } else if (pname == GraphicsContext3D::UNPACK_PREMULTIPLY_ALPHA_WEBGL) {
+ m_unpackPremultiplyAlpha = param;
+ } else {
+ m_context->pixelStorei(pname, param);
+ if (param == 1 || param == 2 || param == 4 || param == 8) {
+ switch (pname) {
+ case GraphicsContext3D::PACK_ALIGNMENT:
+ m_packAlignment = static_cast<int>(param);
+ break;
+ case GraphicsContext3D::UNPACK_ALIGNMENT:
+ m_unpackAlignment = static_cast<int>(param);
+ break;
+ }
}
}
cleanupAfterGraphicsCall(false);
@@ -1640,9 +1722,9 @@ void WebGLRenderingContext::polygonOffset(double factor, double units)
cleanupAfterGraphicsCall(false);
}
-PassRefPtr<ArrayBufferView> WebGLRenderingContext::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type)
+void WebGLRenderingContext::readPixels(long x, long y, long width, long height, unsigned long format, unsigned long type, ArrayBufferView* pixels)
{
- // Validate enums.
+ // Validate input parameters.
unsigned long componentsPerPixel = 0;
switch (format) {
case GraphicsContext3D::ALPHA:
@@ -1656,7 +1738,7 @@ PassRefPtr<ArrayBufferView> WebGLRenderingContext::readPixels(long x, long y, un
break;
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
- return 0;
+ return;
}
unsigned long bytesPerComponent = 0;
switch (type) {
@@ -1671,11 +1753,25 @@ PassRefPtr<ArrayBufferView> WebGLRenderingContext::readPixels(long x, long y, un
break;
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
- return 0;
+ return;
+ }
+ if (!pixels) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ if (width < 0 || height < 0) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
}
if (!((format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE) || (format == m_implementationColorReadFormat && type == m_implementationColorReadType))) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
- return 0;
+ return;
+ }
+ // Validate array type against pixel type.
+ if (type == GraphicsContext3D::UNSIGNED_BYTE && !pixels->isUnsignedByteArray()
+ || type != GraphicsContext3D::UNSIGNED_BYTE && !pixels->isUnsignedShortArray()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
}
// Calculate array size, taking into consideration of PACK_ALIGNMENT.
unsigned long bytesPerRow = componentsPerPixel * bytesPerComponent * width;
@@ -1688,12 +1784,11 @@ PassRefPtr<ArrayBufferView> WebGLRenderingContext::readPixels(long x, long y, un
// The last row needs no padding.
unsigned long totalBytes = bytesPerRow * height - padding;
unsigned long num = totalBytes / bytesPerComponent;
- RefPtr<ArrayBufferView> array;
- if (type == GraphicsContext3D::UNSIGNED_BYTE)
- array = Uint8Array::create(num);
- else
- array = Uint16Array::create(num);
- void* data = array->baseAddress();
+ if (pixels->length() < num) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
+ }
+ void* data = pixels->baseAddress();
m_context->readPixels(x, y, width, height, format, type, data);
#if PLATFORM(CG)
// FIXME: remove this section when GL driver bug on Mac is fixed, i.e.,
@@ -1701,8 +1796,8 @@ PassRefPtr<ArrayBufferView> WebGLRenderingContext::readPixels(long x, long y, un
if ((format == GraphicsContext3D::ALPHA || format == GraphicsContext3D::RGBA) && !m_context->getContextAttributes().alpha) {
if (type == GraphicsContext3D::UNSIGNED_BYTE) {
unsigned char* pixels = reinterpret_cast<unsigned char*>(data);
- for (unsigned long iy = 0; iy < height; ++iy) {
- for (unsigned long ix = 0; ix < width; ++ix) {
+ for (long iy = 0; iy < height; ++iy) {
+ for (long ix = 0; ix < width; ++ix) {
pixels[componentsPerPixel - 1] = 255;
pixels += componentsPerPixel;
}
@@ -1713,7 +1808,6 @@ PassRefPtr<ArrayBufferView> WebGLRenderingContext::readPixels(long x, long y, un
}
#endif
cleanupAfterGraphicsCall(false);
- return array;
}
void WebGLRenderingContext::releaseShaderCompiler()
@@ -1805,43 +1899,39 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
unsigned width, unsigned height, unsigned border,
unsigned format, unsigned type, void* pixels, ExceptionCode& ec)
{
- RefPtr<WebGLTexture> tex = 0;
- switch (target) {
- case GraphicsContext3D::TEXTURE_2D:
- tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
- break;
- case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
- tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
- break;
- }
// FIXME: For now we ignore any errors returned
ec = 0;
+ if (!validateTexFuncParameters(target, level, internalformat, width, height, border, format, type))
+ return;
if (!isGLES2Compliant()) {
if (level && WebGLTexture::isNPOT(width, height)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
- if (tex && !level) // only for level 0
- tex->setSize(target, width, height);
}
m_context->texImage2D(target, level, internalformat, width, height,
border, format, type, pixels);
+ WebGLTexture* tex = getTextureBinding(target);
+ if (!isGLES2Compliant()) {
+ if (tex && !level) // only for level 0
+ tex->setSize(target, width, height);
+ if (tex)
+ tex->setInternalformat(internalformat);
+ }
if (m_framebufferBinding && tex)
- m_framebufferBinding->onAttachedObjectChange(tex.get());
+ m_framebufferBinding->onAttachedObjectChange(tex);
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, Image* image,
- bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+void WebGLRenderingContext::texImage2DImpl(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, Image* image,
+ bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
{
+ // FIXME: pay attention to the user's supplied internalformat, format and type
+ // FIXME: pay attention to UNPACK_ROW_WIDTH
+ UNUSED_PARAM(type);
ec = 0;
Vector<uint8_t> data;
- unsigned int format, internalformat;
if (!m_context->extractImageData(image, flipY, premultiplyAlpha, data, &format, &internalformat)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
@@ -1859,21 +1949,82 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned
format, type, pixels ? pixels->baseAddress() : 0, ec);
}
+void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, ImageData* pixels, ExceptionCode& ec)
+{
+ UNUSED_PARAM(internalformat);
+ UNUSED_PARAM(format);
+ UNUSED_PARAM(type);
+ // FIXME: pay attention to the user's supplied internalformat, format and type
+ ec = 0;
+ Vector<uint8_t> data;
+ if (!m_context->extractImageData(pixels, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ texImage2DBase(target, level, GraphicsContext3D::RGBA, pixels->width(), pixels->height(), 0,
+ GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, data.data(), ec);
+}
+
+void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode& ec)
+{
+ ec = 0;
+ if (!image || !image->cachedImage()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ texImage2DImpl(target, level, internalformat, format, type, image->cachedImage()->image(),
+ m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+}
+
+void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode& ec)
+{
+ ec = 0;
+ if (!canvas || !canvas->buffer()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ texImage2DImpl(target, level, internalformat, format, type, canvas->buffer()->image(),
+ m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+}
+
+void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode& ec)
+{
+ // FIXME: Need to implement this call
+ UNUSED_PARAM(target);
+ UNUSED_PARAM(level);
+ UNUSED_PARAM(internalformat);
+ UNUSED_PARAM(format);
+ UNUSED_PARAM(type);
+ UNUSED_PARAM(video);
+
+ ec = 0;
+ cleanupAfterGraphicsCall(false);
+}
+
+// Obsolete texImage2D entry points -- to be removed shortly. (FIXME)
+
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, ImageData* pixels,
ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, ImageData pixels)");
texImage2D(target, level, pixels, 0, 0, ec);
}
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, ImageData* pixels,
bool flipY, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, ImageData pixels, GLboolean flipY)");
texImage2D(target, level, pixels, flipY, 0, ec);
}
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, ImageData* pixels,
bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, ImageData pixels, GLboolean flipY, GLboolean premultiplyAlpha)");
ec = 0;
Vector<uint8_t> data;
if (!m_context->extractImageData(pixels, flipY, premultiplyAlpha, data)) {
@@ -1888,47 +2039,53 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, ImageDat
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLImageElement* image,
ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, HTMLImageElement image)");
texImage2D(target, level, image, 0, 0, ec);
}
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLImageElement* image,
bool flipY, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, HTMLImageElement image, GLboolean flipY)");
texImage2D(target, level, image, flipY, 0, ec);
}
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLImageElement* image,
bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, HTMLImageElement image, GLboolean flipY, GLboolean premultiplyAlpha)");
ec = 0;
if (!image || !image->cachedImage()) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
- texImage2D(target, level, image->cachedImage()->image(), flipY, premultiplyAlpha, ec);
+ texImage2DImpl(target, level, GraphicsContext3D::RGBA, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, image->cachedImage()->image(), flipY, premultiplyAlpha, ec);
}
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas,
ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, HTMLCanvasElement canvas)");
texImage2D(target, level, canvas, 0, 0, ec);
}
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas,
bool flipY, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, HTMLCanvasElement canvas, GLboolean flipY)");
texImage2D(target, level, canvas, flipY, 0, ec);
}
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas,
bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texImage2D(GLenum target, GLint level, HTMLCanvasElement canvas, GLboolean flipY, GLboolean premultiplyAlpha)");
ec = 0;
if (!canvas || !canvas->buffer()) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
- texImage2D(target, level, canvas->buffer()->image(), flipY, premultiplyAlpha, ec);
+ texImage2DImpl(target, level, GraphicsContext3D::RGBA, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, canvas->buffer()->image(), flipY, premultiplyAlpha, ec);
}
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLVideoElement* video,
@@ -1957,34 +2114,59 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLVide
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::texParameterf(unsigned target, unsigned pname, float param)
+void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pname, float paramf, int parami, bool isFloat)
{
- m_context->texParameterf(target, pname, param);
if (!isGLES2Compliant()) {
RefPtr<WebGLTexture> tex = 0;
- if (target == GraphicsContext3D::TEXTURE_2D)
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_2D:
tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
- else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP:
tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
- if (tex)
- tex->setParameterf(pname, param);
+ break;
+ default:
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return;
+ }
+ switch (pname) {
+ case GraphicsContext3D::TEXTURE_MIN_FILTER:
+ case GraphicsContext3D::TEXTURE_MAG_FILTER:
+ break;
+ case GraphicsContext3D::TEXTURE_WRAP_S:
+ case GraphicsContext3D::TEXTURE_WRAP_T:
+ if (isFloat && paramf != GraphicsContext3D::CLAMP_TO_EDGE && paramf != GraphicsContext3D::MIRRORED_REPEAT && paramf != GraphicsContext3D::REPEAT
+ || !isFloat && parami != GraphicsContext3D::CLAMP_TO_EDGE && parami != GraphicsContext3D::MIRRORED_REPEAT && parami != GraphicsContext3D::REPEAT) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return;
+ }
+ break;
+ default:
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return;
+ }
+ if (tex) {
+ if (isFloat)
+ tex->setParameterf(pname, paramf);
+ else
+ tex->setParameteri(pname, parami);
+ }
}
+ if (isFloat)
+ m_context->texParameterf(target, pname, paramf);
+ else
+ m_context->texParameteri(target, pname, parami);
cleanupAfterGraphicsCall(false);
}
+void WebGLRenderingContext::texParameterf(unsigned target, unsigned pname, float param)
+{
+ texParameter(target, pname, param, 0, true);
+}
+
void WebGLRenderingContext::texParameteri(unsigned target, unsigned pname, int param)
{
- m_context->texParameteri(target, pname, param);
- if (!isGLES2Compliant()) {
- RefPtr<WebGLTexture> tex = 0;
- if (target == GraphicsContext3D::TEXTURE_2D)
- tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
- else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
- tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
- if (tex)
- tex->setParameteri(pname, param);
- }
- cleanupAfterGraphicsCall(false);
+ texParameter(target, pname, 0, param, false);
}
void WebGLRenderingContext::texSubImage2DBase(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
@@ -1993,16 +2175,23 @@ void WebGLRenderingContext::texSubImage2DBase(unsigned target, unsigned level, u
{
// FIXME: For now we ignore any errors returned
ec = 0;
+ if (!validateTexFuncFormatAndType(format, type))
+ return;
+
m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
- Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
+void WebGLRenderingContext::texSubImage2DImpl(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type,
+ Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
{
+ UNUSED_PARAM(type);
+ // FIXME: pay attention to the user's supplied format and type
+ // FIXME: pay attention to UNPACK_ROW_WIDTH
ec = 0;
Vector<uint8_t> data;
- unsigned int format, internalformat;
+ unsigned int internalformat;
if (!m_context->extractImageData(image, flipY, premultiplyAlpha, data, &format, &internalformat)) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
@@ -2020,20 +2209,80 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsig
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type, ImageData* pixels, ExceptionCode& ec)
+{
+ UNUSED_PARAM(format);
+ UNUSED_PARAM(type);
+ // FIXME: pay attention to the user's supplied format and type
+ ec = 0;
+ Vector<uint8_t> data;
+ if (!m_context->extractImageData(pixels, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(),
+ GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, data.data(), ec);
+}
+
+void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode& ec)
+{
+ ec = 0;
+ if (!image || !image->cachedImage()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image->cachedImage()->image(),
+ m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+}
+
+void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode& ec)
+{
+ ec = 0;
+ if (!canvas || !canvas->buffer()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->buffer()->image(),
+ m_unpackFlipY, m_unpackPremultiplyAlpha, ec);
+}
+
+void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode& ec)
+{
+ // FIXME: Need to implement this call
+ UNUSED_PARAM(target);
+ UNUSED_PARAM(level);
+ UNUSED_PARAM(xoffset);
+ UNUSED_PARAM(yoffset);
+ UNUSED_PARAM(format);
+ UNUSED_PARAM(type);
+ UNUSED_PARAM(video);
+ ec = 0;
+ cleanupAfterGraphicsCall(false);
+}
+
+// Obsolete texSubImage2D entry points -- to be removed shortly. (FIXME)
+
+void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
ImageData* pixels, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, ImageData pixels)");
texSubImage2D(target, level, xoffset, yoffset, pixels, 0, 0, ec);
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
ImageData* pixels, bool flipY, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, ImageData pixels, GLboolean flipY)");
texSubImage2D(target, level, xoffset, yoffset, pixels, flipY, 0, ec);
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, ImageData pixels, GLboolean flipY, GLboolean premultiplyAlpha)");
ec = 0;
Vector<uint8_t> data;
if (!m_context->extractImageData(pixels, flipY, premultiplyAlpha, data)) {
@@ -2047,49 +2296,55 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsig
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
HTMLImageElement* image, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, HTMLImageElement image)");
texSubImage2D(target, level, xoffset, yoffset, image, 0, 0, ec);
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
HTMLImageElement* image, bool flipY, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, HTMLImageElement image, GLboolean flipY)");
texSubImage2D(target, level, xoffset, yoffset, image, flipY, 0, ec);
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
HTMLImageElement* image, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, HTMLImageElement image, GLboolean flipY, GLboolean premultiplyAlpha)");
ec = 0;
if (!image || !image->cachedImage()) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
- texSubImage2D(target, level, xoffset, yoffset, image->cachedImage()->image(),
- flipY, premultiplyAlpha, ec);
+ texSubImage2DImpl(target, level, xoffset, yoffset, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, image->cachedImage()->image(),
+ flipY, premultiplyAlpha, ec);
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
HTMLCanvasElement* canvas, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, HTMLCanvasElement canvas)");
texSubImage2D(target, level, xoffset, yoffset, canvas, 0, 0, ec);
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
HTMLCanvasElement* canvas, bool flipY, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, HTMLCanvasElement canvas, GLboolean flipY)");
texSubImage2D(target, level, xoffset, yoffset, canvas, flipY, 0, ec);
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
HTMLCanvasElement* canvas, bool flipY, bool premultiplyAlpha, ExceptionCode& ec)
{
+ printWarningToConsole("Calling obsolete texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, HTMLCanvasElement canvas, GLboolean flipY, GLboolean premultiplyAlpha)");
ec = 0;
if (!canvas || !canvas->buffer()) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
return;
}
- texSubImage2D(target, level, xoffset, yoffset, canvas->buffer()->image(),
- flipY, premultiplyAlpha, ec);
+ texSubImage2DImpl(target, level, xoffset, yoffset, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, canvas->buffer()->image(),
+ flipY, premultiplyAlpha, ec);
}
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
@@ -2122,10 +2377,8 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsig
void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, float x, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2136,13 +2389,11 @@ void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2160,10 +2411,8 @@ void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Flo
void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2181,10 +2430,8 @@ void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, flo
void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, int x, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2198,10 +2445,8 @@ void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, int
void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2219,10 +2464,8 @@ void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int
void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2240,10 +2483,8 @@ void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, int
void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, float x, float y, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2254,13 +2495,11 @@ void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2279,10 +2518,8 @@ void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Flo
void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2301,10 +2538,8 @@ void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, flo
void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, int x, int y, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2318,10 +2553,8 @@ void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, int
void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2340,10 +2573,8 @@ void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int
void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2362,10 +2593,8 @@ void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, int
void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, float x, float y, float z, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2376,13 +2605,11 @@ void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2401,10 +2628,8 @@ void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Flo
void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2423,10 +2648,8 @@ void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, flo
void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, int x, int y, int z, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2440,10 +2663,8 @@ void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, int
void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2462,10 +2683,8 @@ void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int
void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2484,10 +2703,8 @@ void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, int
void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, float x, float y, float z, float w, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2498,13 +2715,11 @@ void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2523,10 +2738,8 @@ void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Flo
void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2545,10 +2758,8 @@ void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, flo
void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, int x, int y, int z, int w, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2562,10 +2773,8 @@ void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, int
void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2584,10 +2793,8 @@ void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int
void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2603,13 +2810,11 @@ void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2628,10 +2833,8 @@ void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio
void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2647,13 +2850,11 @@ void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2672,10 +2873,8 @@ void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio
void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2691,13 +2890,11 @@ void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, Float32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2716,10 +2913,8 @@ void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio
void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* v, int size, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
- if (!location) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ if (!location)
return;
- }
if (location->program() != m_currentProgram) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
@@ -2766,7 +2961,7 @@ void WebGLRenderingContext::vertexAttrib1f(unsigned long indx, float v0)
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib1fv(unsigned long indx, FloatArray* v)
+void WebGLRenderingContext::vertexAttrib1fv(unsigned long indx, Float32Array* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib1fv(indx, v->data());
@@ -2788,7 +2983,7 @@ void WebGLRenderingContext::vertexAttrib2f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib2fv(unsigned long indx, FloatArray* v)
+void WebGLRenderingContext::vertexAttrib2fv(unsigned long indx, Float32Array* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib2fv(indx, v->data());
@@ -2810,7 +3005,7 @@ void WebGLRenderingContext::vertexAttrib3f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib3fv(unsigned long indx, FloatArray* v)
+void WebGLRenderingContext::vertexAttrib3fv(unsigned long indx, Float32Array* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib3fv(indx, v->data());
@@ -2832,7 +3027,7 @@ void WebGLRenderingContext::vertexAttrib4f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib4fv(unsigned long indx, FloatArray* v)
+void WebGLRenderingContext::vertexAttrib4fv(unsigned long indx, Float32Array* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib4fv(indx, v->data());
@@ -2872,7 +3067,8 @@ void WebGLRenderingContext::vertexAttribPointer(unsigned long indx, long size, u
validatedStride = stride;
}
-
+
+ m_vertexAttribState[indx].bufferBinding = m_boundArrayBuffer;
// Avoid off-by-one errors in numElements computation.
// For the last element, we will only touch the data for the
// element and nothing beyond it.
@@ -2995,7 +3191,7 @@ WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(unsigned long pn
default:
notImplemented();
}
- return WebGLGetInfo(FloatArray::create(value, length));
+ return WebGLGetInfo(Float32Array::create(value, length));
}
WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(unsigned long pname)
@@ -3042,8 +3238,7 @@ void WebGLRenderingContext::handleNPOTTextures(bool prepareToDraw)
if (isGLES2Compliant())
return;
bool resetActiveUnit = false;
- // FIXME: active texture unit limits should be queries instead of 32.
- for (unsigned long ii = 0; ii < 32; ++ii) {
+ for (unsigned ii = 0; ii < m_textureUnits.size(); ++ii) {
if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture()
|| m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture()) {
if (ii != m_activeTextureUnit) {
@@ -3097,6 +3292,150 @@ void WebGLRenderingContext::createFallbackBlackTextures1x1()
m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, 0);
}
+bool WebGLRenderingContext::isTexInternalformatColorBufferCombinationValid(unsigned long texInternalformat,
+ unsigned long colorBufferFormat)
+{
+ switch (colorBufferFormat) {
+ case GraphicsContext3D::ALPHA:
+ if (texInternalformat == GraphicsContext3D::ALPHA)
+ return true;
+ break;
+ case GraphicsContext3D::RGB:
+ if (texInternalformat == GraphicsContext3D::LUMINANCE
+ || texInternalformat == GraphicsContext3D::RGB)
+ return true;
+ break;
+ case GraphicsContext3D::RGBA:
+ return true;
+ }
+ return false;
+}
+
+WebGLTexture* WebGLRenderingContext::getTextureBinding(unsigned long target)
+{
+ RefPtr<WebGLTexture> tex = 0;
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_2D:
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ break;
+ }
+ if (tex && tex->object())
+ return tex.get();
+ return 0;
+}
+
+bool WebGLRenderingContext::validateTexFuncFormatAndType(unsigned long format, unsigned long type)
+{
+ switch (format) {
+ case GraphicsContext3D::ALPHA:
+ case GraphicsContext3D::LUMINANCE:
+ case GraphicsContext3D::LUMINANCE_ALPHA:
+ case GraphicsContext3D::RGB:
+ case GraphicsContext3D::RGBA:
+ break;
+ default:
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return false;
+ }
+
+ switch (type) {
+ case GraphicsContext3D::UNSIGNED_BYTE:
+ case GraphicsContext3D::UNSIGNED_SHORT_5_6_5:
+ case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4:
+ case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1:
+ break;
+ default:
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return false;
+ }
+
+ return true;
+}
+
+bool WebGLRenderingContext::validateTexFuncParameters(unsigned long target, long level,
+ unsigned long internalformat,
+ long width, long height, long border,
+ unsigned long format, unsigned long type)
+{
+ if (isGLES2Compliant())
+ return true;
+
+ if (width < 0 || height < 0 || level < 0) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_2D:
+ if (width > m_maxTextureSize ||
+ height > m_maxTextureSize ||
+ level > log(static_cast<double>(m_maxTextureSize)) / log(2.0)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ if (width != height ||
+ width > m_maxCubeMapTextureSize ||
+ level > log(static_cast<double>(m_maxCubeMapTextureSize)) / log(2.0)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+ break;
+ default:
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return false;
+ }
+
+ if (format != internalformat) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return false;
+ }
+
+ if (border) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return false;
+ }
+
+ return validateTexFuncFormatAndType(format, type);
+}
+
+bool WebGLRenderingContext::validateDrawMode(unsigned long mode)
+{
+ switch (mode) {
+ case GraphicsContext3D::POINTS:
+ case GraphicsContext3D::LINE_STRIP:
+ case GraphicsContext3D::LINE_LOOP:
+ case GraphicsContext3D::LINES:
+ case GraphicsContext3D::TRIANGLE_STRIP:
+ case GraphicsContext3D::TRIANGLE_FAN:
+ case GraphicsContext3D::TRIANGLES:
+ return true;
+ default:
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+ return false;
+ }
+}
+
+void WebGLRenderingContext::printWarningToConsole(const String& message)
+{
+ canvas()->document()->frame()->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel,
+ message, 0, canvas()->document()->url().string());
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h
index d447529..552efa9 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.h
+++ b/WebCore/html/canvas/WebGLRenderingContext.h
@@ -28,7 +28,7 @@
#include "CanvasRenderingContext.h"
#include "ExceptionCode.h"
-#include "FloatArray.h"
+#include "Float32Array.h"
#include "WebGLGetInfo.h"
#include "Int32Array.h"
#include "Uint8Array.h"
@@ -117,7 +117,7 @@ class WebKitCSSMatrix;
void disable(unsigned long cap);
void disableVertexAttribArray(unsigned long index, ExceptionCode&);
void drawArrays(unsigned long mode, long first, long count, ExceptionCode&);
- void drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset, ExceptionCode&);
+ void drawElements(unsigned long mode, long count, unsigned long type, long offset, ExceptionCode&);
void enable(unsigned long cap);
void enableVertexAttribArray(unsigned long index, ExceptionCode&);
@@ -181,9 +181,7 @@ class WebKitCSSMatrix;
void linkProgram(WebGLProgram*, ExceptionCode&);
void pixelStorei(unsigned long pname, long param);
void polygonOffset(double factor, double units);
-
- PassRefPtr<ArrayBufferView> readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type);
-
+ void readPixels(long x, long y, long width, long height, unsigned long format, unsigned long type, ArrayBufferView* pixels);
void releaseShaderCompiler();
void renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height);
void sampleCoverage(double value, bool invert);
@@ -199,6 +197,15 @@ class WebKitCSSMatrix;
void texImage2D(unsigned target, unsigned level, unsigned internalformat,
unsigned width, unsigned height, unsigned border,
unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&);
+ void texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, ImageData* pixels, ExceptionCode&);
+ void texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode&);
+ void texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode&);
+ void texImage2D(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode&);
+ // Obsolete entry points -- to be removed shortly. (FIXME)
void texImage2D(unsigned target, unsigned level, ImageData* pixels, ExceptionCode&);
void texImage2D(unsigned target, unsigned level, ImageData* pixels, bool flipY, ExceptionCode&);
void texImage2D(unsigned target, unsigned level, ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode&);
@@ -218,6 +225,15 @@ class WebKitCSSMatrix;
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
unsigned width, unsigned height,
unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode&);
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type, ImageData* pixels, ExceptionCode&);
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type, HTMLImageElement* image, ExceptionCode&);
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type, HTMLCanvasElement* canvas, ExceptionCode&);
+ void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type, HTMLVideoElement* video, ExceptionCode&);
+ // Obsolete entry points -- to be removed shortly. (FIXME)
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, ExceptionCode&);
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, bool flipY, ExceptionCode&);
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, ImageData* pixels, bool flipY, bool premultiplyAlpha, ExceptionCode&);
@@ -232,50 +248,50 @@ class WebKitCSSMatrix;
void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset, HTMLVideoElement* video, bool flipY, bool premultiplyAlpha, ExceptionCode&);
void uniform1f(const WebGLUniformLocation* location, float x, ExceptionCode&);
- void uniform1fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode&);
+ void uniform1fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&);
void uniform1fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&);
void uniform1i(const WebGLUniformLocation* location, int x, ExceptionCode&);
void uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&);
void uniform1iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&);
void uniform2f(const WebGLUniformLocation* location, float x, float y, ExceptionCode&);
- void uniform2fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode&);
+ void uniform2fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&);
void uniform2fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&);
void uniform2i(const WebGLUniformLocation* location, int x, int y, ExceptionCode&);
void uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&);
void uniform2iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&);
void uniform3f(const WebGLUniformLocation* location, float x, float y, float z, ExceptionCode&);
- void uniform3fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode&);
+ void uniform3fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&);
void uniform3fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&);
void uniform3i(const WebGLUniformLocation* location, int x, int y, int z, ExceptionCode&);
void uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&);
void uniform3iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&);
void uniform4f(const WebGLUniformLocation* location, float x, float y, float z, float w, ExceptionCode&);
- void uniform4fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode&);
+ void uniform4fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&);
void uniform4fv(const WebGLUniformLocation* location, float* v, int size, ExceptionCode&);
void uniform4i(const WebGLUniformLocation* location, int x, int y, int z, int w, ExceptionCode&);
void uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&);
void uniform4iv(const WebGLUniformLocation* location, int* v, int size, ExceptionCode&);
- void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, FloatArray* value, ExceptionCode&);
+ void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&);
void uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&);
- void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, FloatArray* value, ExceptionCode&);
+ void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&);
void uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&);
- void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, FloatArray* value, ExceptionCode&);
+ void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, Float32Array* value, ExceptionCode&);
void uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, float* value, int size, ExceptionCode&);
void useProgram(WebGLProgram*, ExceptionCode&);
void validateProgram(WebGLProgram*, ExceptionCode&);
void vertexAttrib1f(unsigned long indx, float x);
- void vertexAttrib1fv(unsigned long indx, FloatArray* values);
+ void vertexAttrib1fv(unsigned long indx, Float32Array* values);
void vertexAttrib1fv(unsigned long indx, float* values, int size);
void vertexAttrib2f(unsigned long indx, float x, float y);
- void vertexAttrib2fv(unsigned long indx, FloatArray* values);
+ void vertexAttrib2fv(unsigned long indx, Float32Array* values);
void vertexAttrib2fv(unsigned long indx, float* values, int size);
void vertexAttrib3f(unsigned long indx, float x, float y, float z);
- void vertexAttrib3fv(unsigned long indx, FloatArray* values);
+ void vertexAttrib3fv(unsigned long indx, Float32Array* values);
void vertexAttrib3fv(unsigned long indx, float* values, int size);
void vertexAttrib4f(unsigned long indx, float x, float y, float z, float w);
- void vertexAttrib4fv(unsigned long indx, FloatArray* values);
+ void vertexAttrib4fv(unsigned long indx, Float32Array* values);
void vertexAttrib4fv(unsigned long indx, float* values, int size);
void vertexAttribPointer(unsigned long indx, long size, unsigned long type, bool normalized,
unsigned long stride, unsigned long offset, ExceptionCode&);
@@ -340,6 +356,7 @@ class WebKitCSSMatrix;
VertexAttribState() : enabled(false), numElements(0) { }
bool enabled;
long numElements;
+ RefPtr<WebGLBuffer> bufferBinding;
};
Vector<VertexAttribState> m_vertexAttribState;
@@ -353,16 +370,21 @@ class WebKitCSSMatrix;
RefPtr<WebGLTexture> m_texture2DBinding;
RefPtr<WebGLTexture> m_textureCubeMapBinding;
};
- TextureUnitState m_textureUnits[32];
+ Vector<TextureUnitState> m_textureUnits;
unsigned long m_activeTextureUnit;
RefPtr<WebGLTexture> m_blackTexture2D;
RefPtr<WebGLTexture> m_blackTextureCubeMap;
+ long m_maxTextureSize;
+ long m_maxCubeMapTextureSize;
+
int m_packAlignment;
int m_unpackAlignment;
unsigned long m_implementationColorReadFormat;
unsigned long m_implementationColorReadType;
+ bool m_unpackFlipY;
+ bool m_unpackPremultiplyAlpha;
// Helpers for getParameter and others
WebGLGetInfo getBooleanParameter(unsigned long pname);
@@ -377,18 +399,50 @@ class WebKitCSSMatrix;
void texImage2DBase(unsigned target, unsigned level, unsigned internalformat,
unsigned width, unsigned height, unsigned border,
unsigned format, unsigned type, void* pixels, ExceptionCode&);
- void texImage2D(unsigned target, unsigned level, Image* image,
- bool flipY, bool premultiplyAlpha, ExceptionCode&);
+ void texImage2DImpl(unsigned target, unsigned level, unsigned internalformat,
+ unsigned format, unsigned type, Image* image,
+ bool flipY, bool premultiplyAlpha, ExceptionCode&);
void texSubImage2DBase(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
unsigned width, unsigned height,
unsigned format, unsigned type, void* pixels, ExceptionCode&);
- void texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
- Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode&);
+ void texSubImage2DImpl(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
+ unsigned format, unsigned type,
+ Image* image, bool flipY, bool premultiplyAlpha, ExceptionCode&);
void handleNPOTTextures(bool prepareToDraw);
void createFallbackBlackTextures1x1();
+ // Helper function for copyTex{Sub}Image, check whether the internalformat
+ // and the color buffer format of the current bound framebuffer combination
+ // is valid.
+ bool isTexInternalformatColorBufferCombinationValid(unsigned long texInternalformat,
+ unsigned long colorBufferFormat);
+
+ // Helper function to get the current bound texture.
+ WebGLTexture* getTextureBinding(unsigned long target);
+
+ // Helper function to check input format/type for functions {copy}Tex{Sub}Image.
+ // Generate GL error and return false if parameters are invalid.
+ bool validateTexFuncFormatAndType(unsigned long format, unsigned long type);
+
+ // Helper function to check input parameters for functions {copy}Tex{Sub}Image.
+ // Generate GL error and return false if parameters are invalid.
+ bool validateTexFuncParameters(unsigned long target, long level,
+ unsigned long internalformat,
+ long width, long height, long border,
+ unsigned long format, unsigned long type);
+
+ // Helper function to validate mode for draw{Arrays/Elements}.
+ bool validateDrawMode(unsigned long);
+
+ // Helper function for texParameterf and texParameteri.
+ void texParameter(unsigned long target, unsigned long pname, float parami, int paramf, bool isFloat);
+
+ // Helper function to print warnings to console. Currently
+ // used only to warn about use of obsolete functions.
+ void printWarningToConsole(const String& message);
+
friend class WebGLStateRestorer;
};
diff --git a/WebCore/html/canvas/WebGLRenderingContext.idl b/WebCore/html/canvas/WebGLRenderingContext.idl
index 029cae3..b3793f5 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.idl
+++ b/WebCore/html/canvas/WebGLRenderingContext.idl
@@ -459,6 +459,10 @@ module html {
const unsigned int INVALID_FRAMEBUFFER_OPERATION = 0x0506;
+ /* WebGL-specific enums */
+ const unsigned int UNPACK_FLIP_Y_WEBGL = 0x9240;
+ const unsigned int UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
+
long sizeInBytes(in unsigned long type) raises(DOMException);
void activeTexture(in unsigned long texture) raises(DOMException);
@@ -474,15 +478,9 @@ module html {
void blendFunc(in unsigned long sfactor, in unsigned long dfactor);
void blendFuncSeparate(in unsigned long srcRGB, in unsigned long dstRGB, in unsigned long srcAlpha, in unsigned long dstAlpha);
-#if defined(V8_BINDING) && V8_BINDING
void bufferData(in unsigned long target, in ArrayBufferView data, in unsigned long usage) raises (DOMException);
void bufferData(in unsigned long target, in long size, in unsigned long usage) raises (DOMException);
void bufferSubData(in unsigned long target, in long offset, in ArrayBufferView data) raises (DOMException);
-#else
- // FIXME: Unfork once JSC supports overload generation too.
- [Custom] void bufferData() raises(DOMException);
- [Custom] void bufferSubData() raises(DOMException);
-#endif
unsigned long checkFramebufferStatus(in unsigned long target);
void clear(in unsigned long mask);
@@ -521,8 +519,8 @@ module html {
void detachShader(in WebGLProgram program, in WebGLShader shader) raises(DOMException);
void disable(in unsigned long cap);
void disableVertexAttribArray(in unsigned long index) raises(DOMException);
- void drawArrays(in unsigned long mode, in long first, in unsigned long count) raises(DOMException);
- void drawElements(in unsigned long mode, in long count, in unsigned long type, in unsigned long offset) raises(DOMException);
+ void drawArrays(in unsigned long mode, in long first, in long count) raises(DOMException);
+ void drawElements(in unsigned long mode, in long count, in unsigned long type, in long offset) raises(DOMException);
void enable(in unsigned long cap);
void enableVertexAttribArray(in unsigned long index) raises(DOMException);
@@ -595,7 +593,7 @@ module html {
void pixelStorei(in unsigned long pname, in long param);
void polygonOffset(in double factor, in double units);
- ArrayBufferView readPixels(in long x, in long y, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long type);
+ void readPixels(in long x, in long y, in long width, in long height, in unsigned long format, in unsigned long type, in ArrayBufferView pixels);
void releaseShaderCompiler();
void renderbufferStorage(in unsigned long target, in unsigned long internalformat, in unsigned long width, in unsigned long height);
@@ -613,9 +611,17 @@ module html {
void texParameteri(in unsigned long target, in unsigned long pname, in long param);
// Supported forms:
-#if defined(V8_BINDING) && V8_BINDING
void texImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long width, in long height,
in long border, in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
+ void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+ in unsigned long format, in unsigned long type, in ImageData pixels) raises (DOMException);
+ void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+ in unsigned long format, in unsigned long type, in HTMLImageElement image) raises (DOMException);
+ void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+ in unsigned long format, in unsigned long type, in HTMLCanvasElement canvas) raises (DOMException);
+ void texImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+ in unsigned long format, in unsigned long type, in HTMLVideoElement video) raises (DOMException);
+ // Obsolete entry points -- to be removed shortly. (FIXME)
void texImage2D(in unsigned long target, in long level, in ImageData pixels,
in [Optional] boolean flipY, in [Optional] boolean premultiplyAlpha) raises (DOMException);
void texImage2D(in unsigned long target, in long level, in HTMLImageElement image,
@@ -629,6 +635,15 @@ module html {
in long width, in long height,
in unsigned long format, in unsigned long type, in ArrayBufferView pixels) raises (DOMException);
void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in unsigned long format, in unsigned long type, in ImageData pixels) raises (DOMException);
+ void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in unsigned long format, in unsigned long type, in HTMLImageElement image) raises (DOMException);
+ void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in unsigned long format, in unsigned long type, in HTMLCanvasElement canvas) raises (DOMException);
+ void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+ in unsigned long format, in unsigned long type, in HTMLVideoElement video) raises (DOMException);
+ // Obsolete entry points -- to be removed shortly. (FIXME)
+ void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
in ImageData pixels, in [Optional] boolean flipY, in [Optional] boolean premultiplyAlpha) raises (DOMException);
void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
in HTMLImageElement image, in [Optional] boolean flipY, in [Optional] boolean premultiplyAlpha) raises (DOMException);
@@ -636,43 +651,39 @@ module html {
in HTMLCanvasElement canvas, in [Optional] boolean flipY, in [Optional] boolean premultiplyAlpha) raises (DOMException);
void texSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
in HTMLVideoElement video, in [Optional] boolean flipY, in [Optional] boolean premultiplyAlpha) raises (DOMException);
-#else
- // FIXME: Unfork once JSC supports overload generation too.
- [Custom] void texImage2D();
- [Custom] void texSubImage2D();
-#endif
+
void uniform1f(in WebGLUniformLocation location, in float x) raises(DOMException);
- [Custom] void uniform1fv(in WebGLUniformLocation location, in FloatArray v) raises(DOMException);
+ [Custom] void uniform1fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
void uniform1i(in WebGLUniformLocation location, in long x) raises(DOMException);
[Custom] void uniform1iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
void uniform2f(in WebGLUniformLocation location, in float x, in float y) raises(DOMException);
- [Custom] void uniform2fv(in WebGLUniformLocation location, in FloatArray v) raises(DOMException);
+ [Custom] void uniform2fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
void uniform2i(in WebGLUniformLocation location, in long x, in long y) raises(DOMException);
[Custom] void uniform2iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
void uniform3f(in WebGLUniformLocation location, in float x, in float y, in float z) raises(DOMException);
- [Custom] void uniform3fv(in WebGLUniformLocation location, in FloatArray v) raises(DOMException);
+ [Custom] void uniform3fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
void uniform3i(in WebGLUniformLocation location, in long x, in long y, in long z) raises(DOMException);
[Custom] void uniform3iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
void uniform4f(in WebGLUniformLocation location, in float x, in float y, in float z, in float w) raises(DOMException);
- [Custom] void uniform4fv(in WebGLUniformLocation location, in FloatArray v) raises(DOMException);
+ [Custom] void uniform4fv(in WebGLUniformLocation location, in Float32Array v) raises(DOMException);
void uniform4i(in WebGLUniformLocation location, in long x, in long y, in long z, in long w) raises(DOMException);
[Custom] void uniform4iv(in WebGLUniformLocation location, in Int32Array v) raises(DOMException);
- [Custom] void uniformMatrix2fv(in WebGLUniformLocation location, in boolean transpose, in FloatArray array) raises(DOMException);
- [Custom] void uniformMatrix3fv(in WebGLUniformLocation location, in boolean transpose, in FloatArray array) raises(DOMException);
- [Custom] void uniformMatrix4fv(in WebGLUniformLocation location, in boolean transpose, in FloatArray array) raises(DOMException);
+ [Custom] void uniformMatrix2fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
+ [Custom] void uniformMatrix3fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
+ [Custom] void uniformMatrix4fv(in WebGLUniformLocation location, in boolean transpose, in Float32Array array) raises(DOMException);
void useProgram(in WebGLProgram program) raises(DOMException);
void validateProgram(in WebGLProgram program) raises(DOMException);
void vertexAttrib1f(in unsigned long indx, in float x);
- [Custom] void vertexAttrib1fv(in unsigned long indx, in FloatArray values);
+ [Custom] void vertexAttrib1fv(in unsigned long indx, in Float32Array values);
void vertexAttrib2f(in unsigned long indx, in float x, in float y);
- [Custom] void vertexAttrib2fv(in unsigned long indx, in FloatArray values);
+ [Custom] void vertexAttrib2fv(in unsigned long indx, in Float32Array values);
void vertexAttrib3f(in unsigned long indx, in float x, in float y, in float z);
- [Custom] void vertexAttrib3fv(in unsigned long indx, in FloatArray values);
+ [Custom] void vertexAttrib3fv(in unsigned long indx, in Float32Array values);
void vertexAttrib4f(in unsigned long indx, in float x, in float y, in float z, in float w);
- [Custom] void vertexAttrib4fv(in unsigned long indx, in FloatArray values);
+ [Custom] void vertexAttrib4fv(in unsigned long indx, in Float32Array values);
void vertexAttribPointer(in unsigned long indx, in long size, in unsigned long type, in boolean normalized,
in long stride, in unsigned long offset) raises(DOMException);
diff --git a/WebCore/html/canvas/WebGLTexture.cpp b/WebCore/html/canvas/WebGLTexture.cpp
index 4e4096b..d24405a 100644
--- a/WebCore/html/canvas/WebGLTexture.cpp
+++ b/WebCore/html/canvas/WebGLTexture.cpp
@@ -45,6 +45,7 @@ WebGLTexture::WebGLTexture(WebGLRenderingContext* ctx)
, m_magFilter(GraphicsContext3D::LINEAR)
, m_wrapS(GraphicsContext3D::REPEAT)
, m_wrapT(GraphicsContext3D::REPEAT)
+ , m_internalformat(0)
, m_isNPOT(false)
, m_needToUseBlackTexture(false)
{
diff --git a/WebCore/html/canvas/WebGLTexture.h b/WebCore/html/canvas/WebGLTexture.h
index 864533e..889e902 100644
--- a/WebCore/html/canvas/WebGLTexture.h
+++ b/WebCore/html/canvas/WebGLTexture.h
@@ -52,6 +52,9 @@ namespace WebCore {
void setParameterf(unsigned long pname, float param);
void setSize(unsigned long target, unsigned width, unsigned height);
+ void setInternalformat(unsigned long internalformat) { m_internalformat = internalformat; }
+ unsigned long getInternalformat() const { return m_internalformat; }
+
static bool isNPOT(unsigned, unsigned);
bool isNPOT() const { return m_isNPOT; }
@@ -77,6 +80,8 @@ namespace WebCore {
int m_wrapS;
int m_wrapT;
+ unsigned long m_internalformat;
+
unsigned m_width[6];
unsigned m_height[6];