[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
eric at webkit.org
eric at webkit.org
Thu Oct 29 20:34:37 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 8461e9a7a545545ddb63434c53a435e209896198
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Sep 26 02:13:16 2009 +0000
2009-09-25 Kenneth Russell <kbr at google.com>
Reviewed by Dimitri Glazkov.
[Chromium] Add initial V8 bindings for WebGL
https://bugs.webkit.org/show_bug.cgi?id=29664
* WebCore.gypi:
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/v8/DOMObjectsInclude.h:
* bindings/v8/DerivedSourcesAllInOne.cpp:
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::getTemplate):
* bindings/v8/V8Index.cpp:
* bindings/v8/V8Index.h:
* bindings/v8/custom/V8CanvasArrayBufferCustom.cpp: Added.
(WebCore::CALLBACK_FUNC_DECL):
* bindings/v8/custom/V8CanvasArrayCustom.h: Added.
(WebCore::constructCanvasArray):
* bindings/v8/custom/V8CanvasByteArrayCustom.cpp: Added.
(WebCore::CALLBACK_FUNC_DECL):
(WebCore::INDEXED_PROPERTY_GETTER):
(WebCore::INDEXED_PROPERTY_SETTER):
* bindings/v8/custom/V8CanvasFloatArrayCustom.cpp: Added.
(WebCore::CALLBACK_FUNC_DECL):
(WebCore::INDEXED_PROPERTY_GETTER):
(WebCore::INDEXED_PROPERTY_SETTER):
* bindings/v8/custom/V8CanvasIntArrayCustom.cpp: Added.
(WebCore::CALLBACK_FUNC_DECL):
(WebCore::INDEXED_PROPERTY_GETTER):
(WebCore::INDEXED_PROPERTY_SETTER):
* bindings/v8/custom/V8CanvasRenderingContext3DCustom.cpp: Added.
(WebCore::jsArrayToFloatArray):
(WebCore::jsArrayToIntArray):
(WebCore::CALLBACK_FUNC_DECL):
(WebCore::):
(WebCore::vertexAttribAndUniformHelperf):
(WebCore::uniformHelperi):
(WebCore::uniformMatrixHelper):
* bindings/v8/custom/V8CanvasShortArrayCustom.cpp: Added.
(WebCore::CALLBACK_FUNC_DECL):
(WebCore::INDEXED_PROPERTY_GETTER):
(WebCore::INDEXED_PROPERTY_SETTER):
* bindings/v8/custom/V8CanvasUnsignedByteArrayCustom.cpp: Added.
(WebCore::CALLBACK_FUNC_DECL):
(WebCore::INDEXED_PROPERTY_GETTER):
(WebCore::INDEXED_PROPERTY_SETTER):
* bindings/v8/custom/V8CanvasUnsignedIntArrayCustom.cpp: Added.
(WebCore::CALLBACK_FUNC_DECL):
(WebCore::INDEXED_PROPERTY_GETTER):
(WebCore::INDEXED_PROPERTY_SETTER):
* bindings/v8/custom/V8CanvasUnsignedShortArrayCustom.cpp: Added.
(WebCore::CALLBACK_FUNC_DECL):
(WebCore::INDEXED_PROPERTY_GETTER):
(WebCore::INDEXED_PROPERTY_SETTER):
* bindings/v8/custom/V8CustomBinding.h:
* bindings/v8/custom/V8DocumentCustom.cpp:
(WebCore::CALLBACK_FUNC_DECL):
* bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
(WebCore::CALLBACK_FUNC_DECL):
* platform/graphics/GraphicsContext3D.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48781 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index de8f2ba..0ff1729 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,65 @@
+2009-09-25 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Dimitri Glazkov.
+
+ [Chromium] Add initial V8 bindings for WebGL
+ https://bugs.webkit.org/show_bug.cgi?id=29664
+
+ * WebCore.gypi:
+ * bindings/scripts/CodeGeneratorV8.pm:
+ * bindings/v8/DOMObjectsInclude.h:
+ * bindings/v8/DerivedSourcesAllInOne.cpp:
+ * bindings/v8/V8DOMWrapper.cpp:
+ (WebCore::V8DOMWrapper::getTemplate):
+ * bindings/v8/V8Index.cpp:
+ * bindings/v8/V8Index.h:
+ * bindings/v8/custom/V8CanvasArrayBufferCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8CanvasArrayCustom.h: Added.
+ (WebCore::constructCanvasArray):
+ * bindings/v8/custom/V8CanvasByteArrayCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ (WebCore::INDEXED_PROPERTY_GETTER):
+ (WebCore::INDEXED_PROPERTY_SETTER):
+ * bindings/v8/custom/V8CanvasFloatArrayCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ (WebCore::INDEXED_PROPERTY_GETTER):
+ (WebCore::INDEXED_PROPERTY_SETTER):
+ * bindings/v8/custom/V8CanvasIntArrayCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ (WebCore::INDEXED_PROPERTY_GETTER):
+ (WebCore::INDEXED_PROPERTY_SETTER):
+ * bindings/v8/custom/V8CanvasRenderingContext3DCustom.cpp: Added.
+ (WebCore::jsArrayToFloatArray):
+ (WebCore::jsArrayToIntArray):
+ (WebCore::CALLBACK_FUNC_DECL):
+ (WebCore::):
+ (WebCore::vertexAttribAndUniformHelperf):
+ (WebCore::uniformHelperi):
+ (WebCore::uniformMatrixHelper):
+ * bindings/v8/custom/V8CanvasShortArrayCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ (WebCore::INDEXED_PROPERTY_GETTER):
+ (WebCore::INDEXED_PROPERTY_SETTER):
+ * bindings/v8/custom/V8CanvasUnsignedByteArrayCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ (WebCore::INDEXED_PROPERTY_GETTER):
+ (WebCore::INDEXED_PROPERTY_SETTER):
+ * bindings/v8/custom/V8CanvasUnsignedIntArrayCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ (WebCore::INDEXED_PROPERTY_GETTER):
+ (WebCore::INDEXED_PROPERTY_SETTER):
+ * bindings/v8/custom/V8CanvasUnsignedShortArrayCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ (WebCore::INDEXED_PROPERTY_GETTER):
+ (WebCore::INDEXED_PROPERTY_SETTER):
+ * bindings/v8/custom/V8CustomBinding.h:
+ * bindings/v8/custom/V8DocumentCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * platform/graphics/GraphicsContext3D.h:
+
2009-09-25 Jeremy Orlow <jorlow at chromium.org>
This is breaking Chromium try bots, so I'm counting this as a build fix.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 1bef8cf..e91076b 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -76,11 +76,27 @@
'dom/WebKitAnimationEvent.idl',
'dom/WebKitTransitionEvent.idl',
'dom/WheelEvent.idl',
+ 'html/canvas/CanvasArray.idl',
+ 'html/canvas/CanvasArrayBuffer.idl',
+ 'html/canvas/CanvasBuffer.idl',
+ 'html/canvas/CanvasByteArray.idl',
+ 'html/canvas/CanvasFloatArray.idl',
+ 'html/canvas/CanvasFramebuffer.idl',
'html/canvas/CanvasGradient.idl',
+ 'html/canvas/CanvasIntArray.idl',
'html/canvas/CanvasPattern.idl',
'html/canvas/CanvasPixelArray.idl',
+ 'html/canvas/CanvasProgram.idl',
+ 'html/canvas/CanvasRenderbuffer.idl',
'html/canvas/CanvasRenderingContext.idl',
'html/canvas/CanvasRenderingContext2D.idl',
+ 'html/canvas/CanvasRenderingContext3D.idl',
+ 'html/canvas/CanvasShader.idl',
+ 'html/canvas/CanvasShortArray.idl',
+ 'html/canvas/CanvasUnsignedByteArray.idl',
+ 'html/canvas/CanvasUnsignedIntArray.idl',
+ 'html/canvas/CanvasUnsignedShortArray.idl',
+ 'html/canvas/CanvasTexture.idl',
'html/DataGridColumn.idl',
'html/DataGridColumnList.idl',
'html/File.idl',
@@ -607,7 +623,17 @@
'bindings/v8/custom/V8AbstractWorkerCustom.cpp',
'bindings/v8/custom/V8AttrCustom.cpp',
'bindings/v8/custom/V8CanvasPixelArrayCustom.cpp',
+ 'bindings/v8/custom/V8CanvasArrayCustom.h',
+ 'bindings/v8/custom/V8CanvasArrayBufferCustom.cpp',
+ 'bindings/v8/custom/V8CanvasByteArrayCustom.cpp',
+ 'bindings/v8/custom/V8CanvasIntArrayCustom.cpp',
+ 'bindings/v8/custom/V8CanvasFloatArrayCustom.cpp',
+ 'bindings/v8/custom/V8CanvasShortArrayCustom.cpp',
+ 'bindings/v8/custom/V8CanvasUnsignedByteArrayCustom.cpp',
+ 'bindings/v8/custom/V8CanvasUnsignedIntArrayCustom.cpp',
+ 'bindings/v8/custom/V8CanvasUnsignedShortArrayCustom.cpp',
'bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp',
+ 'bindings/v8/custom/V8CanvasRenderingContext3DCustom.cpp',
'bindings/v8/custom/V8ClientRectListCustom.cpp',
'bindings/v8/custom/V8ClipboardCustom.cpp',
'bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp',
@@ -1221,18 +1247,52 @@
'history/HistoryItem.h',
'history/PageCache.cpp',
'history/PageCache.h',
+ 'html/canvas/CanvasArray.cpp',
+ 'html/canvas/CanvasArray.h',
+ 'html/canvas/CanvasArrayBuffer.cpp',
+ 'html/canvas/CanvasArrayBuffer.h',
+ 'html/canvas/CanvasBuffer.cpp',
+ 'html/canvas/CanvasBuffer.h',
+ 'html/canvas/CanvasByteArray.cpp',
+ 'html/canvas/CanvasByteArray.h',
+ 'html/canvas/CanvasFloatArray.cpp',
+ 'html/canvas/CanvasFloatArray.h',
+ 'html/canvas/CanvasFramebuffer.cpp',
+ 'html/canvas/CanvasFramebuffer.h',
'html/canvas/CanvasGradient.cpp',
'html/canvas/CanvasGradient.h',
+ 'html/canvas/CanvasIntArray.cpp',
+ 'html/canvas/CanvasIntArray.h',
+ 'html/canvas/CanvasObject.cpp',
+ 'html/canvas/CanvasObject.h',
'html/canvas/CanvasPattern.cpp',
'html/canvas/CanvasPattern.h',
'html/canvas/CanvasPixelArray.cpp',
'html/canvas/CanvasPixelArray.h',
+ 'html/canvas/CanvasProgram.cpp',
+ 'html/canvas/CanvasProgram.h',
+ 'html/canvas/CanvasRenderbuffer.cpp',
+ 'html/canvas/CanvasRenderbuffer.h',
'html/canvas/CanvasRenderingContext.cpp',
'html/canvas/CanvasRenderingContext.h',
'html/canvas/CanvasRenderingContext2D.cpp',
'html/canvas/CanvasRenderingContext2D.h',
+ 'html/canvas/CanvasRenderingContext3D.cpp',
+ 'html/canvas/CanvasRenderingContext3D.h',
+ 'html/canvas/CanvasShader.cpp',
+ 'html/canvas/CanvasShader.h',
+ 'html/canvas/CanvasShortArray.cpp',
+ 'html/canvas/CanvasShortArray.h',
'html/canvas/CanvasStyle.cpp',
'html/canvas/CanvasStyle.h',
+ 'html/canvas/CanvasTexture.cpp',
+ 'html/canvas/CanvasTexture.h',
+ 'html/canvas/CanvasUnsignedByteArray.cpp',
+ 'html/canvas/CanvasUnsignedByteArray.h',
+ 'html/canvas/CanvasUnsignedIntArray.cpp',
+ 'html/canvas/CanvasUnsignedIntArray.h',
+ 'html/canvas/CanvasUnsignedShortArray.cpp',
+ 'html/canvas/CanvasUnsignedShortArray.h',
'html/CollectionCache.cpp',
'html/CollectionCache.h',
'html/CollectionType.h',
@@ -2085,6 +2145,7 @@
'platform/graphics/Gradient.h',
'platform/graphics/GraphicsContext.cpp',
'platform/graphics/GraphicsContext.h',
+ 'platform/graphics/GraphicsContext3D.h',
'platform/graphics/GraphicsContextPrivate.h',
'platform/graphics/GraphicsLayer.cpp',
'platform/graphics/GraphicsLayer.h',
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index a18de49..1cbe8d2 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -1596,7 +1596,24 @@ sub IsRefPtrType
{
my $type = shift;
return 1 if $type eq "Attr";
+ return 1 if $type eq "CanvasArray";
+ return 1 if $type eq "CanvasArrayBuffer";
+ return 1 if $type eq "CanvasBooleanArray";
+ return 1 if $type eq "CanvasByteArray";
+ return 1 if $type eq "CanvasBuffer";
+ return 1 if $type eq "CanvasFloatArray";
+ return 1 if $type eq "CanvasFramebuffer";
return 1 if $type eq "CanvasGradient";
+ return 1 if $type eq "CanvasIntArray";
+ return 1 if $type eq "CanvasObject";
+ return 1 if $type eq "CanvasProgram";
+ return 1 if $type eq "CanvasRenderbuffer";
+ return 1 if $type eq "CanvasShader";
+ return 1 if $type eq "CanvasShortArray";
+ return 1 if $type eq "CanvasTexture";
+ return 1 if $type eq "CanvasUnsignedByteArray";
+ return 1 if $type eq "CanvasUnsignedIntArray";
+ return 1 if $type eq "CanvasUnsignedShortArray";
return 1 if $type eq "ClientRect";
return 1 if $type eq "ClientRectList";
return 1 if $type eq "CDATASection";
@@ -1725,6 +1742,19 @@ sub GetNativeType
my %typeCanFailConversion = (
"AtomicString" => 0,
"Attr" => 1,
+ "CanvasArray" => 0,
+ "CanvasBuffer" => 0,
+ "CanvasByteArray" => 0,
+ "CanvasFloatArray" => 0,
+ "CanvasFramebuffer" => 0,
+ "CanvasGradient" => 0,
+ "CanvasIntArray" => 0,
+ "CanvasPixelArray" => 0,
+ "CanvasProgram" => 0,
+ "CanvasRenderbuffer" => 0,
+ "CanvasShader" => 0,
+ "CanvasShortArray" => 0,
+ "CanvasTexture" => 0,
"CompareHow" => 0,
"DataGridColumn" => 0,
"DOMString" => 0,
@@ -1734,8 +1764,11 @@ my %typeCanFailConversion = (
"Event" => 0,
"EventListener" => 0,
"EventTarget" => 0,
+ "HTMLCanvasElement" => 0,
"HTMLElement" => 0,
+ "HTMLImageElement" => 0,
"HTMLOptionElement" => 0,
+ "HTMLVideoElement" => 0,
"Node" => 0,
"NodeFilter" => 0,
"MessagePort" => 0,
diff --git a/WebCore/bindings/v8/DOMObjectsInclude.h b/WebCore/bindings/v8/DOMObjectsInclude.h
index 029c4c0..e5796e7 100644
--- a/WebCore/bindings/v8/DOMObjectsInclude.h
+++ b/WebCore/bindings/v8/DOMObjectsInclude.h
@@ -33,12 +33,29 @@
#include "AbstractWorker.h"
#include "BarInfo.h"
+#include "CanvasArray.h"
+#include "CanvasArrayBuffer.h"
+#include "CanvasBuffer.h"
+#include "CanvasByteArray.h"
+#include "CanvasFloatArray.h"
+#include "CanvasFramebuffer.h"
#include "CanvasGradient.h"
+#include "CanvasIntArray.h"
+#include "CanvasObject.h"
#include "CanvasPattern.h"
#include "CanvasPixelArray.h"
+#include "CanvasProgram.h"
+#include "CanvasRenderbuffer.h"
#include "CanvasRenderingContext.h"
#include "CanvasRenderingContext2D.h"
+#include "CanvasRenderingContext3D.h"
+#include "CanvasShader.h"
+#include "CanvasShortArray.h"
+#include "CanvasUnsignedByteArray.h"
+#include "CanvasUnsignedIntArray.h"
+#include "CanvasUnsignedShortArray.h"
#include "CanvasStyle.h"
+#include "CanvasTexture.h"
#include "CharacterData.h"
#include "ClientRect.h"
#include "ClientRectList.h"
diff --git a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
index a898af8..626d3f2 100644
--- a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
+++ b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
@@ -34,11 +34,27 @@
#include "bindings/V8AbstractWorker.cpp"
#include "bindings/V8Attr.cpp"
#include "bindings/V8BarInfo.cpp"
+#include "bindings/V8CanvasArray.cpp"
+#include "bindings/V8CanvasArrayBuffer.cpp"
+#include "bindings/V8CanvasBuffer.cpp"
+#include "bindings/V8CanvasByteArray.cpp"
+#include "bindings/V8CanvasFloatArray.cpp"
+#include "bindings/V8CanvasFramebuffer.cpp"
#include "bindings/V8CanvasGradient.cpp"
+#include "bindings/V8CanvasIntArray.cpp"
#include "bindings/V8CanvasPattern.cpp"
#include "bindings/V8CanvasPixelArray.cpp"
+#include "bindings/V8CanvasProgram.cpp"
+#include "bindings/V8CanvasRenderbuffer.cpp"
#include "bindings/V8CanvasRenderingContext.cpp"
#include "bindings/V8CanvasRenderingContext2D.cpp"
+#include "bindings/V8CanvasRenderingContext3D.cpp"
+#include "bindings/V8CanvasShader.cpp"
+#include "bindings/V8CanvasShortArray.cpp"
+#include "bindings/V8CanvasTexture.cpp"
+#include "bindings/V8CanvasUnsignedByteArray.cpp"
+#include "bindings/V8CanvasUnsignedIntArray.cpp"
+#include "bindings/V8CanvasUnsignedShortArray.cpp"
#include "bindings/V8CDATASection.cpp"
#include "bindings/V8CharacterData.cpp"
#include "bindings/V8ClientRect.cpp"
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index e992c1d..10df85c 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -436,7 +436,40 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
}
#endif
+#if ENABLE(3D_CANVAS)
// The following objects are created from JavaScript.
+ case V8ClassIndex::CANVASARRAYBUFFER:
+ descriptor->SetCallHandler(USE_CALLBACK(CanvasArrayBufferConstructor));
+ break;
+ case V8ClassIndex::CANVASBYTEARRAY:
+ descriptor->SetCallHandler(USE_CALLBACK(CanvasByteArrayConstructor));
+ descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(CanvasByteArray), USE_INDEXED_PROPERTY_SETTER(CanvasByteArray));
+ break;
+ case V8ClassIndex::CANVASFLOATARRAY:
+ descriptor->SetCallHandler(USE_CALLBACK(CanvasFloatArrayConstructor));
+ descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(CanvasFloatArray), USE_INDEXED_PROPERTY_SETTER(CanvasFloatArray));
+ break;
+ case V8ClassIndex::CANVASINTARRAY:
+ descriptor->SetCallHandler(USE_CALLBACK(CanvasIntArrayConstructor));
+ descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(CanvasIntArray), USE_INDEXED_PROPERTY_SETTER(CanvasIntArray));
+ break;
+ case V8ClassIndex::CANVASSHORTARRAY:
+ descriptor->SetCallHandler(USE_CALLBACK(CanvasShortArrayConstructor));
+ descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(CanvasShortArray), USE_INDEXED_PROPERTY_SETTER(CanvasShortArray));
+ break;
+ case V8ClassIndex::CANVASUNSIGNEDBYTEARRAY:
+ descriptor->SetCallHandler(USE_CALLBACK(CanvasUnsignedByteArrayConstructor));
+ descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(CanvasUnsignedByteArray), USE_INDEXED_PROPERTY_SETTER(CanvasUnsignedByteArray));
+ break;
+ case V8ClassIndex::CANVASUNSIGNEDINTARRAY:
+ descriptor->SetCallHandler(USE_CALLBACK(CanvasUnsignedIntArrayConstructor));
+ descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(CanvasUnsignedIntArray), USE_INDEXED_PROPERTY_SETTER(CanvasUnsignedIntArray));
+ break;
+ case V8ClassIndex::CANVASUNSIGNEDSHORTARRAY:
+ descriptor->SetCallHandler(USE_CALLBACK(CanvasUnsignedShortArrayConstructor));
+ descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(CanvasUnsignedShortArray), USE_INDEXED_PROPERTY_SETTER(CanvasUnsignedShortArray));
+ break;
+#endif
case V8ClassIndex::DOMPARSER:
descriptor->SetCallHandler(USE_CALLBACK(DOMParserConstructor));
break;
diff --git a/WebCore/bindings/v8/V8Index.cpp b/WebCore/bindings/v8/V8Index.cpp
index 9cb4c41..a3e27e9 100644
--- a/WebCore/bindings/v8/V8Index.cpp
+++ b/WebCore/bindings/v8/V8Index.cpp
@@ -399,6 +399,25 @@
#include "V8SharedWorker.h"
#endif
+#if ENABLE(3D_CANVAS)
+#include "V8CanvasRenderingContext3D.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CanvasArray.h"
+#include "V8CanvasByteArray.h"
+#include "V8CanvasBuffer.h"
+#include "V8CanvasFloatArray.h"
+#include "V8CanvasFramebuffer.h"
+#include "V8CanvasIntArray.h"
+#include "V8CanvasProgram.h"
+#include "V8CanvasRenderbuffer.h"
+#include "V8CanvasShader.h"
+#include "V8CanvasShortArray.h"
+#include "V8CanvasTexture.h"
+#include "V8CanvasUnsignedByteArray.h"
+#include "V8CanvasUnsignedIntArray.h"
+#include "V8CanvasUnsignedShortArray.h"
+#endif
+
namespace WebCore {
FunctionTemplateFactory V8ClassIndex::GetFactory(V8WrapperType type)
diff --git a/WebCore/bindings/v8/V8Index.h b/WebCore/bindings/v8/V8Index.h
index e209fc7..e199326 100644
--- a/WebCore/bindings/v8/V8Index.h
+++ b/WebCore/bindings/v8/V8Index.h
@@ -444,12 +444,35 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
#define DOM_OBJECT_WORKERS_TYPES(V)
#endif
+#if ENABLE(3D_CANVAS)
+#define DOM_OBJECT_3D_CANVAS_TYPES(V) \
+ V(CANVASARRAY, CanvasArray) \
+ V(CANVASARRAYBUFFER, CanvasArrayBuffer) \
+ V(CANVASBUFFER, CanvasBuffer) \
+ V(CANVASBYTEARRAY, CanvasByteArray) \
+ V(CANVASFLOATARRAY, CanvasFloatArray) \
+ V(CANVASFRAMEBUFFER, CanvasFramebuffer) \
+ V(CANVASINTARRAY, CanvasIntArray) \
+ V(CANVASPROGRAM, CanvasProgram) \
+ V(CANVASRENDERBUFFER, CanvasRenderbuffer) \
+ V(CANVASRENDERINGCONTEXT3D, CanvasRenderingContext3D) \
+ V(CANVASSHADER, CanvasShader) \
+ V(CANVASSHORTARRAY, CanvasShortArray) \
+ V(CANVASTEXTURE, CanvasTexture) \
+ V(CANVASUNSIGNEDBYTEARRAY, CanvasUnsignedByteArray) \
+ V(CANVASUNSIGNEDINTARRAY, CanvasUnsignedIntArray) \
+ V(CANVASUNSIGNEDSHORTARRAY, CanvasUnsignedShortArray)
+#else
+#define DOM_OBJECT_3D_CANVAS_TYPES(V)
+#endif
+
#define DOM_OBJECT_TYPES(V) \
DOM_OBJECT_TYPES_1(V) \
DOM_OBJECT_TYPES_2(V) \
DOM_OBJECT_DATABASE_TYPES(V) \
DOM_OBJECT_STORAGE_TYPES(V) \
- DOM_OBJECT_WORKERS_TYPES(V)
+ DOM_OBJECT_WORKERS_TYPES(V) \
+ DOM_OBJECT_3D_CANVAS_TYPES(V)
#if ENABLE(SVG)
// SVG_OBJECT_TYPES are svg non-node, non-pod types.
diff --git a/WebCore/bindings/v8/custom/V8CanvasArrayBufferCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasArrayBufferCustom.cpp
new file mode 100644
index 0000000..4a85e82
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasArrayBufferCustom.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(CanvasArrayBufferConstructor)
+{
+ INC_STATS("DOM.CanvasArrayBuffer.Contructor");
+
+ if (!args.IsConstructCall())
+ return throwError("DOM object constructor cannot be called as a function.");
+
+ int argLen = args.Length();
+ // Supported constructors:
+ // CanvasArrayBuffer(n) where n is an integer:
+ // -- create an empty buffer of n bytes
+
+ if (argLen != 1)
+ return throwError("Wrong number of arguments specified to constructor (requires 1)");
+
+ int len = 0;
+ if (!args[0]->IsInt32())
+ return throwError("Argument to CanvasArrayBuffer constructor was not an integer");
+ len = toInt32(args[0]);
+ RefPtr<CanvasArrayBuffer> buffer = CanvasArrayBuffer::create(len);
+ // Transform the holder into a wrapper object for the array.
+ V8DOMWrapper::setDOMWrapper(args.Holder(), V8ClassIndex::ToInt(V8ClassIndex::CANVASARRAYBUFFER), buffer.get());
+ return toV8(buffer.release(), args.Holder());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasArrayCustom.h b/WebCore/bindings/v8/custom/V8CanvasArrayCustom.h
new file mode 100644
index 0000000..311b838
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasArrayCustom.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+ // Template function used by the CanvasArray*Constructor callbacks.
+ template<class ArrayClass>
+ v8::Handle<v8::Value> constructCanvasArray(const v8::Arguments& args,
+ int classIndex)
+ {
+ if (!args.IsConstructCall())
+ return throwError("DOM object constructor cannot be called as a function.");
+
+ int argLen = args.Length();
+ // Supported constructors:
+ // Canvas<T>Array(n) where n is an integer:
+ // -- create an empty array of n elements
+ // Canvas<T>Array(arr) where arr is an array:
+ // -- create a Canvas<T>Array containing the contents of "arr"
+ // Canvas<T>Array(buf, offset, length)
+ // -- create a Canvas<T>Array pointing to the CanvasArrayBuffer
+ // "buf", starting at the specified offset, for the given
+ // length
+
+ if (argLen == 0)
+ return throwError("No arguments specified to constructor");
+
+ // See whether the first argument is a CanvasArrayBuffer.
+ if (V8CanvasArrayBuffer::HasInstance(args[0])) {
+ if (argLen > 3)
+ return throwError("Wrong number of arguments to new Canvas<T>Array(CanvasArrayBuffer, int, int)");
+
+ CanvasArrayBuffer* buf =
+ V8DOMWrapper::convertToNativeObject<CanvasArrayBuffer>(V8ClassIndex::CANVASARRAYBUFFER,
+ args[0]->ToObject());
+ if (buf == NULL)
+ return throwError("Could not convert argument 0 to a CanvasArrayBuffer");
+ bool ok;
+ int offset = 0;
+ if (argLen > 1) {
+ offset = toInt32(args[1], ok);
+ if (!ok)
+ return throwError("Could not convert argument 1 to an integer");
+ }
+ int length = buf->byteLength() - offset;
+ if (argLen > 2) {
+ length = toInt32(args[2], ok);
+ if (!ok)
+ return throwError("Could not convert argument 2 to an integer");
+ }
+ if (length < 0)
+ return throwError("Length / offset out of range");
+
+ RefPtr<ArrayClass> array = ArrayClass::create(buf, offset, length);
+ if (array == NULL)
+ return throwError("Invalid arguments to new Canvas<T>Array(CanvasArrayBuffer, int, int)");
+ // Transform the holder into a wrapper object for the array.
+ V8DOMWrapper::setDOMWrapper(args.Holder(), classIndex, array.get());
+ return toV8(array.release(), args.Holder());
+ }
+
+ int len = 0;
+ v8::Handle<v8::Array> srcArray;
+ if (argLen != 1)
+ return throwError("Wrong number of arguments to new Canvas<T>Array(int / array)");
+
+ if (args[0]->IsInt32()) {
+ len = toInt32(args[0]);
+ } else if (args[0]->IsArray()) {
+ srcArray = v8::Local<v8::Array>::Cast(args[0]);
+ if (srcArray.IsEmpty())
+ return throwError("Could not convert argument 0 to an array");
+ len = srcArray->Length();
+ } else
+ return throwError("Could not convert argument 0 to either an int32 or an array");
+
+ RefPtr<ArrayClass> array = ArrayClass::create(len);
+ if (!srcArray.IsEmpty()) {
+ // Need to copy the incoming array into the newly created CanvasArray.
+ for (int i = 0; i < len; i++) {
+ v8::Local<v8::Value> val = srcArray->Get(v8::Integer::New(i));
+ if (!val->IsNumber()) {
+ char buf[256];
+ sprintf(buf, "Could not convert array element %d to a number", i);
+ return throwError(buf);
+ }
+ array->set(i, val->NumberValue());
+ }
+ }
+
+ // Transform the holder into a wrapper object for the array.
+ V8DOMWrapper::setDOMWrapper(args.Holder(), classIndex, array.get());
+ return toV8(array.release(), args.Holder());
+ }
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasByteArrayCustom.cpp
new file mode 100644
index 0000000..503e5e8
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasByteArrayCustom.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasByteArray.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CanvasArrayCustom.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(CanvasByteArrayConstructor)
+{
+ INC_STATS("DOM.CanvasByteArray.Contructor");
+
+ return constructCanvasArray<CanvasByteArray>(args, V8ClassIndex::ToInt(V8ClassIndex::CANVASBYTEARRAY));
+}
+
+// Get the specified value from the byte buffer and return it wrapped as a JavaScript Number object to V8. Accesses outside the valid byte buffer range return "undefined".
+INDEXED_PROPERTY_GETTER(CanvasByteArray)
+{
+ INC_STATS("DOM.CanvasByteArray.IndexedPropertyGetter");
+ CanvasByteArray* byteBuffer = V8DOMWrapper::convertToNativeObject<CanvasByteArray>(V8ClassIndex::CANVASBYTEARRAY, info.Holder());
+
+ if ((index < 0) || (index >= byteBuffer->length()))
+ return v8::Undefined();
+ signed char result;
+ if (!byteBuffer->get(index, result))
+ return v8::Undefined();
+ return v8::Number::New(result);
+}
+
+// Set the specified value in the byte buffer. Accesses outside the valid byte buffer range are silently ignored.
+INDEXED_PROPERTY_SETTER(CanvasByteArray)
+{
+ INC_STATS("DOM.CanvasByteArray.IndexedPropertySetter");
+ CanvasByteArray* array = V8DOMWrapper::convertToNativeObject<CanvasByteArray>(V8ClassIndex::CANVASBYTEARRAY, info.Holder());
+
+ if ((index >= 0) && (index < array->length())) {
+ if (!value->IsNumber())
+ return throwError("Could not convert value argument to a number");
+ array->set(index, value->NumberValue());
+ }
+ return value;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasFloatArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasFloatArrayCustom.cpp
new file mode 100644
index 0000000..b3c1d62
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasFloatArrayCustom.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasFloatArray.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CanvasArrayCustom.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(CanvasFloatArrayConstructor)
+{
+ INC_STATS("DOM.CanvasFloatArray.Contructor");
+
+ return constructCanvasArray<CanvasFloatArray>(args, V8ClassIndex::ToInt(V8ClassIndex::CANVASFLOATARRAY));
+}
+
+// Get the specified value from the array and return it wrapped as a JavaScript Number object to V8. Accesses outside the valid array range return "undefined".
+INDEXED_PROPERTY_GETTER(CanvasFloatArray)
+{
+ INC_STATS("DOM.CanvasFloatArray.IndexedPropertyGetter");
+ CanvasFloatArray* array = V8DOMWrapper::convertToNativeObject<CanvasFloatArray>(V8ClassIndex::CANVASFLOATARRAY, info.Holder());
+
+ if ((index < 0) || (index >= array->length()))
+ return v8::Undefined();
+ float result;
+ if (!array->get(index, result))
+ return v8::Undefined();
+ return v8::Number::New(result);
+}
+
+// Set the specified value in the array. Accesses outside the valid array range are silently ignored.
+INDEXED_PROPERTY_SETTER(CanvasFloatArray)
+{
+ INC_STATS("DOM.CanvasFloatArray.IndexedPropertySetter");
+ CanvasFloatArray* array = V8DOMWrapper::convertToNativeObject<CanvasFloatArray>(V8ClassIndex::CANVASFLOATARRAY, info.Holder());
+
+ if ((index >= 0) && (index < array->length()))
+ array->set(index, value->NumberValue());
+ return value;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasIntArrayCustom.cpp
new file mode 100644
index 0000000..6f35db8
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasIntArrayCustom.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasIntArray.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CanvasArrayCustom.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(CanvasIntArrayConstructor)
+{
+ INC_STATS("DOM.CanvasIntArray.Contructor");
+
+ return constructCanvasArray<CanvasIntArray>(args, V8ClassIndex::ToInt(V8ClassIndex::CANVASINTARRAY));
+}
+
+// Get the specified value from the integer array and return it wrapped as a JavaScript Number object to V8. Accesses outside the valid pixel buffer range return "undefined".
+INDEXED_PROPERTY_GETTER(CanvasIntArray)
+{
+ INC_STATS("DOM.CanvasIntArray.IndexedPropertyGetter");
+ CanvasIntArray* array = V8DOMWrapper::convertToNativeObject<CanvasIntArray>(V8ClassIndex::CANVASINTARRAY, info.Holder());
+
+ if ((index < 0) || (index >= array->length()))
+ return v8::Undefined();
+ int result;
+ if (!array->get(index, result))
+ return v8::Undefined();
+ return v8::Number::New(result);
+}
+
+// Set the specified value in the integer array. Accesses outside the valid integer array range are silently ignored.
+INDEXED_PROPERTY_SETTER(CanvasIntArray)
+{
+ INC_STATS("DOM.CanvasIntArray.IndexedPropertySetter");
+ CanvasIntArray* array = V8DOMWrapper::convertToNativeObject<CanvasIntArray>(V8ClassIndex::CANVASINTARRAY, info.Holder());
+
+ if ((index >= 0) && (index < array->length())) {
+ if (!value->IsNumber())
+ return throwError("Could not convert value argument to a number");
+ array->set(index, value->NumberValue());
+ }
+ return value;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasRenderingContext3DCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasRenderingContext3DCustom.cpp
new file mode 100644
index 0000000..c109bb8
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasRenderingContext3DCustom.cpp
@@ -0,0 +1,597 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasRenderingContext3D.h"
+
+#include "ExceptionCode.h"
+
+#include "NotImplemented.h"
+
+#include <wtf/FastMalloc.h>
+
+#include "V8Binding.h"
+#include "V8CanvasArray.h"
+#include "V8CanvasByteArray.h"
+#include "V8CanvasFloatArray.h"
+#include "V8CanvasIntArray.h"
+#include "V8CanvasShortArray.h"
+#include "V8CanvasUnsignedByteArray.h"
+#include "V8CanvasUnsignedIntArray.h"
+#include "V8CanvasUnsignedShortArray.h"
+#include "V8HTMLImageElement.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+// Allocates new storage via tryFastMalloc.
+// Returns NULL if array failed to convert for any reason.
+static float* jsArrayToFloatArray(v8::Handle<v8::Array> array, uint32_t len)
+{
+ // Convert the data element-by-element.
+ float* data;
+ if (!tryFastMalloc(len * sizeof(float)).getValue(data))
+ return 0;
+ for (uint32_t i = 0; i < len; i++) {
+ v8::Local<v8::Value> val = array->Get(v8::Integer::New(i));
+ if (!val->IsNumber()) {
+ fastFree(data);
+ return 0;
+ }
+ data[i] = toFloat(val);
+ }
+ return data;
+}
+
+// Allocates new storage via tryFastMalloc.
+// Returns NULL if array failed to convert for any reason.
+static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len)
+{
+ // Convert the data element-by-element.
+ int* data;
+ if (!tryFastMalloc(len * sizeof(int)).getValue(data))
+ return 0;
+ for (uint32_t i = 0; i < len; i++) {
+ v8::Local<v8::Value> val = array->Get(v8::Integer::New(i));
+ bool ok;
+ int ival = toInt32(val, ok);
+ if (!ok) {
+ fastFree(data);
+ return 0;
+ }
+ data[i] = ival;
+ }
+ return data;
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DBufferData)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.bufferData()");
+
+ // Forms:
+ // * bufferData(GLenum target, CanvasArray data, GLenum usage);
+ // - Sets the buffer's data from the given CanvasArray
+ // * bufferData(GLenum target, GLsizeiptr size, GLenum usage);
+ // - Sets the size of the buffer to the given size in bytes
+ if (args.Length() != 3) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ CanvasRenderingContext3D* context =
+ V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext3D>(args.Holder());
+ bool ok;
+ int target = toInt32(args[0], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ int usage = toInt32(args[2], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ if (args[1]->IsInt32()) {
+ int size = toInt32(args[1]);
+ context->bufferData(target, size, usage);
+ } else if (V8CanvasArray::HasInstance(args[1])) {
+ CanvasArray* array = V8DOMWrapper::convertToNativeObject<CanvasArray>(V8ClassIndex::CANVASARRAY, args[1]->ToObject());
+ context->bufferData(target, array, usage);
+ } else {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DBufferSubData)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.bufferSubData()");
+
+ // Forms:
+ // * bufferSubData(GLenum target, GLintptr offset, CanvasArray data);
+ if (args.Length() != 3) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ CanvasRenderingContext3D* context =
+ V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext3D>(args.Holder());
+ bool ok;
+ int target = toInt32(args[0], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ int offset = toInt32(args[1], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ if (!V8CanvasArray::HasInstance(args[2])) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ CanvasArray* array = V8DOMWrapper::convertToNativeObject<CanvasArray>(V8ClassIndex::CANVASARRAY, args[2]->ToObject());
+ context->bufferSubData(target, offset, array);
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DTexImage2D)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.texImage2D()");
+
+ // Currently supported forms:
+ // * void texImage2D(in GLenum target, in GLint level,
+ // in GLint internalformat,
+ // in GLsizei width, in GLsizei height, in GLint border,
+ // in GLenum format, in GLenum type, in CanvasArray pixels);
+ // * void texImage2D(in GLenum target, in GLint level, in HTMLImageElement image,
+ // [Optional] in GLboolean flipY, [Optional] in GLboolean premultiplyAlpha);
+ if (args.Length() != 3 &&
+ args.Length() != 4 &&
+ args.Length() != 5 &&
+ args.Length() != 9) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ CanvasRenderingContext3D* context =
+ V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext3D>(args.Holder());
+ bool ok;
+ int target = toInt32(args[0], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ int level = toInt32(args[1], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ ExceptionCode ec = 0;
+ if (args.Length() == 3 ||
+ args.Length() == 4 ||
+ args.Length() == 5) {
+ v8::Handle<v8::Value> arg = args[2];
+ if (V8HTMLImageElement::HasInstance(arg)) {
+ HTMLImageElement* image_element = V8DOMWrapper::convertDOMWrapperToNode<HTMLImageElement>(v8::Handle<v8::Object>::Cast(arg));
+ bool flipY = false;
+ bool premultiplyAlpha = false;
+ if (args.Length() >= 4)
+ flipY = args[3]->BooleanValue();
+ if (args.Length() >= 5)
+ premultiplyAlpha = args[4]->BooleanValue();
+ context->texImage2D(target, level, image_element, flipY, premultiplyAlpha, ec);
+ } else {
+ // FIXME: consider different / better exception type.
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ // Fall through
+ } else if (args.Length() == 9) {
+ int internalformat = toInt32(args[2], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ int width = toInt32(args[3], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ int height = toInt32(args[4], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ int border = toInt32(args[5], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ int format = toInt32(args[6], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ int type = toInt32(args[7], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ v8::Handle<v8::Value> arg = args[8];
+ if (V8CanvasArray::HasInstance(arg)) {
+ CanvasArray* array = V8DOMWrapper::convertToNativeObject<CanvasArray>(V8ClassIndex::CANVASARRAY, arg->ToObject());
+ // FIXME: must do validation similar to JOGL's to ensure that
+ // the incoming array is of the appropriate length and type
+ context->texImage2D(target,
+ level,
+ internalformat,
+ width,
+ height,
+ border,
+ format,
+ type,
+ array,
+ ec);
+ // Fall through
+ } else {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ } else {
+ ASSERT_NOT_REACHED();
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ if (ec) {
+ V8Proxy::setDOMException(ec);
+ return v8::Handle<v8::Value>();
+ }
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DTexSubImage2D)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.texSubImage2D()");
+
+ // FIXME: implement
+ notImplemented();
+
+ return v8::Undefined();
+}
+
+enum FunctionToCall {
+ kUniform1v, kUniform2v, kUniform3v, kUniform4v,
+ kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v
+};
+
+static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& args,
+ FunctionToCall functionToCall) {
+ // Forms:
+ // * glUniform1fv(GLint location, Array data);
+ // * glUniform1fv(GLint location, CanvasFloatArray data);
+ // * glUniform2fv(GLint location, Array data);
+ // * glUniform2fv(GLint location, CanvasFloatArray data);
+ // * glUniform3fv(GLint location, Array data);
+ // * glUniform3fv(GLint location, CanvasFloatArray data);
+ // * glUniform4fv(GLint location, Array data);
+ // * glUniform4fv(GLint location, CanvasFloatArray data);
+ // * glVertexAttrib1fv(GLint location, Array data);
+ // * glVertexAttrib1fv(GLint location, CanvasFloatArray data);
+ // * glVertexAttrib2fv(GLint location, Array data);
+ // * glVertexAttrib2fv(GLint location, CanvasFloatArray data);
+ // * glVertexAttrib3fv(GLint location, Array data);
+ // * glVertexAttrib3fv(GLint location, CanvasFloatArray data);
+ // * glVertexAttrib4fv(GLint location, Array data);
+ // * glVertexAttrib4fv(GLint location, CanvasFloatArray data);
+
+ if (args.Length() != 3) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ CanvasRenderingContext3D* context =
+ V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext3D>(args.Holder());
+ bool ok;
+ int location = toInt32(args[0], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ if (V8CanvasFloatArray::HasInstance(args[1])) {
+ CanvasFloatArray* array =
+ V8DOMWrapper::convertToNativeObject<CanvasFloatArray>(V8ClassIndex::CANVASFLOATARRAY, args[1]->ToObject());
+ ASSERT(array != NULL);
+ switch (functionToCall) {
+ case kUniform1v: context->uniform1fv(location, array); break;
+ case kUniform2v: context->uniform2fv(location, array); break;
+ case kUniform3v: context->uniform3fv(location, array); break;
+ case kUniform4v: context->uniform4fv(location, array); break;
+ case kVertexAttrib1v: context->vertexAttrib1fv(location, array); break;
+ case kVertexAttrib2v: context->vertexAttrib2fv(location, array); break;
+ case kVertexAttrib3v: context->vertexAttrib3fv(location, array); break;
+ case kVertexAttrib4v: context->vertexAttrib4fv(location, array); break;
+ default: ASSERT_NOT_REACHED(); break;
+ }
+ return v8::Undefined();
+ }
+
+ v8::Handle<v8::Array> array =
+ v8::Local<v8::Array>::Cast(args[1]);
+ if (array.IsEmpty()) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ uint32_t len = array->Length();
+ float* data = jsArrayToFloatArray(array, len);
+ if (!data) {
+ // FIXME: consider different / better exception type.
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ switch (functionToCall) {
+ case kUniform1v: context->uniform1fv(location, data, len); break;
+ case kUniform2v: context->uniform2fv(location, data, len); break;
+ case kUniform3v: context->uniform3fv(location, data, len); break;
+ case kUniform4v: context->uniform4fv(location, data, len); break;
+ case kVertexAttrib1v: context->vertexAttrib1fv(location, data, len); break;
+ case kVertexAttrib2v: context->vertexAttrib2fv(location, data, len); break;
+ case kVertexAttrib3v: context->vertexAttrib3fv(location, data, len); break;
+ case kVertexAttrib4v: context->vertexAttrib4fv(location, data, len); break;
+ default: ASSERT_NOT_REACHED(); break;
+ }
+ fastFree(data);
+ return v8::Undefined();
+}
+
+static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args,
+ FunctionToCall functionToCall) {
+ // Forms:
+ // * glUniform1iv(GLint location, Array data);
+ // * glUniform1iv(GLint location, CanvasIntArray data);
+ // * glUniform2iv(GLint location, Array data);
+ // * glUniform2iv(GLint location, CanvasIntArray data);
+ // * glUniform3iv(GLint location, Array data);
+ // * glUniform3iv(GLint location, CanvasIntArray data);
+ // * glUniform4iv(GLint location, Array data);
+ // * glUniform4iv(GLint location, CanvasIntArray data);
+
+ if (args.Length() != 3) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ CanvasRenderingContext3D* context =
+ V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext3D>(args.Holder());
+ bool ok;
+ int location = toInt32(args[0], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ if (V8CanvasIntArray::HasInstance(args[1])) {
+ CanvasIntArray* array =
+ V8DOMWrapper::convertToNativeObject<CanvasIntArray>(V8ClassIndex::CANVASINTARRAY, args[1]->ToObject());
+ ASSERT(array != NULL);
+ switch (functionToCall) {
+ case kUniform1v: context->uniform1iv(location, array); break;
+ case kUniform2v: context->uniform2iv(location, array); break;
+ case kUniform3v: context->uniform3iv(location, array); break;
+ case kUniform4v: context->uniform4iv(location, array); break;
+ default: ASSERT_NOT_REACHED(); break;
+ }
+ return v8::Undefined();
+ }
+
+ v8::Handle<v8::Array> array =
+ v8::Local<v8::Array>::Cast(args[1]);
+ if (array.IsEmpty()) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ uint32_t len = array->Length();
+ int* data = jsArrayToIntArray(array, len);
+ if (!data) {
+ // FIXME: consider different / better exception type.
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ switch (functionToCall) {
+ case kUniform1v: context->uniform1iv(location, data, len); break;
+ case kUniform2v: context->uniform2iv(location, data, len); break;
+ case kUniform3v: context->uniform3iv(location, data, len); break;
+ case kUniform4v: context->uniform4iv(location, data, len); break;
+ default: ASSERT_NOT_REACHED(); break;
+ }
+ fastFree(data);
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniform1fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniform1fv()");
+ return vertexAttribAndUniformHelperf(args, kUniform1v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniform1iv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniform1iv()");
+ return uniformHelperi(args, kUniform1v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniform2fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniform2fv()");
+ return vertexAttribAndUniformHelperf(args, kUniform2v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniform2iv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniform2iv()");
+ return uniformHelperi(args, kUniform2v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniform3fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniform3fv()");
+ return vertexAttribAndUniformHelperf(args, kUniform3v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniform3iv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniform3iv()");
+ return uniformHelperi(args, kUniform3v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniform4fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniform4fv()");
+ return vertexAttribAndUniformHelperf(args, kUniform4v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniform4iv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniform4iv()");
+ return uniformHelperi(args, kUniform4v);
+}
+
+static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args,
+ int matrixSize)
+{
+ // Forms:
+ // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data);
+ // * glUniformMatrix2fv(GLint location, GLboolean transpose, CanvasFloatArray data);
+ // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data);
+ // * glUniformMatrix3fv(GLint location, GLboolean transpose, CanvasFloatArray data);
+ // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data);
+ // * glUniformMatrix4fv(GLint location, GLboolean transpose, CanvasFloatArray data);
+ //
+ // FIXME: need to change to accept CanvasFloatArray as well.
+ if (args.Length() != 3) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ CanvasRenderingContext3D* context =
+ V8DOMWrapper::convertDOMWrapperToNative<CanvasRenderingContext3D>(args.Holder());
+ bool ok;
+ int location = toInt32(args[0], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ bool transpose = args[1]->BooleanValue();
+ if (V8CanvasFloatArray::HasInstance(args[2])) {
+ CanvasFloatArray* array =
+ V8DOMWrapper::convertToNativeObject<CanvasFloatArray>(V8ClassIndex::CANVASFLOATARRAY, args[2]->ToObject());
+ ASSERT(array != NULL);
+ switch (matrixSize) {
+ case 2: context->uniformMatrix2fv(location, transpose, array); break;
+ case 3: context->uniformMatrix3fv(location, transpose, array); break;
+ case 4: context->uniformMatrix4fv(location, transpose, array); break;
+ default: ASSERT_NOT_REACHED(); break;
+ }
+ return v8::Undefined();
+ }
+
+ v8::Handle<v8::Array> array =
+ v8::Local<v8::Array>::Cast(args[2]);
+ if (array.IsEmpty()) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ uint32_t len = array->Length();
+ float* data = jsArrayToFloatArray(array, len);
+ if (!data) {
+ // FIXME: consider different / better exception type.
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ switch (matrixSize) {
+ case 2: context->uniformMatrix2fv(location, transpose, data, len); break;
+ case 3: context->uniformMatrix3fv(location, transpose, data, len); break;
+ case 4: context->uniformMatrix4fv(location, transpose, data, len); break;
+ default: ASSERT_NOT_REACHED(); break;
+ }
+ fastFree(data);
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniformMatrix2fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniformMatrix2fv()");
+ return uniformMatrixHelper(args, 2);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniformMatrix3fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniformMatrix3fv()");
+ return uniformMatrixHelper(args, 3);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DUniformMatrix4fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.uniformMatrix4fv()");
+ return uniformMatrixHelper(args, 4);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DVertexAttrib1fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.vertexAttrib1fv()");
+ return vertexAttribAndUniformHelperf(args, kVertexAttrib1v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DVertexAttrib2fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.vertexAttrib2fv()");
+ return vertexAttribAndUniformHelperf(args, kVertexAttrib2v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DVertexAttrib3fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.vertexAttrib3fv()");
+ return vertexAttribAndUniformHelperf(args, kVertexAttrib3v);
+}
+
+CALLBACK_FUNC_DECL(CanvasRenderingContext3DVertexAttrib4fv)
+{
+ INC_STATS("DOM.CanvasRenderingContext3D.vertexAttrib4fv()");
+ return vertexAttribAndUniformHelperf(args, kVertexAttrib4v);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasShortArrayCustom.cpp
new file mode 100644
index 0000000..8b83022
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasShortArrayCustom.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasShortArray.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CanvasArrayCustom.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(CanvasShortArrayConstructor)
+{
+ INC_STATS("DOM.CanvasShortArray.Contructor");
+
+ return constructCanvasArray<CanvasShortArray>(args, V8ClassIndex::ToInt(V8ClassIndex::CANVASSHORTARRAY));
+}
+
+// Get the specified value from the array and return it wrapped as a JavaScript Number object to V8. Accesses outside the valid array range return "undefined".
+INDEXED_PROPERTY_GETTER(CanvasShortArray)
+{
+ INC_STATS("DOM.CanvasShortArray.IndexedPropertyGetter");
+ CanvasShortArray* array = V8DOMWrapper::convertToNativeObject<CanvasShortArray>(V8ClassIndex::CANVASSHORTARRAY, info.Holder());
+
+ if ((index < 0) || (index >= array->length()))
+ return v8::Undefined();
+ short result;
+ if (!array->get(index, result))
+ return v8::Undefined();
+ return v8::Number::New(result);
+}
+
+// Set the specified value in the array. Accesses outside the valid array range are silently ignored.
+INDEXED_PROPERTY_SETTER(CanvasShortArray)
+{
+ INC_STATS("DOM.CanvasShortArray.IndexedPropertySetter");
+ CanvasShortArray* array = V8DOMWrapper::convertToNativeObject<CanvasShortArray>(V8ClassIndex::CANVASSHORTARRAY, info.Holder());
+
+ if ((index >= 0) && (index < array->length())) {
+ if (!value->IsNumber())
+ return throwError("Could not convert value argument to a number");
+ array->set(index, value->NumberValue());
+ }
+ return value;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasUnsignedByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasUnsignedByteArrayCustom.cpp
new file mode 100644
index 0000000..62ab880
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasUnsignedByteArrayCustom.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasUnsignedByteArray.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CanvasArrayCustom.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(CanvasUnsignedByteArrayConstructor)
+{
+ INC_STATS("DOM.CanvasUnsignedByteArray.Contructor");
+
+ return constructCanvasArray<CanvasUnsignedByteArray>(args, V8ClassIndex::ToInt(V8ClassIndex::CANVASUNSIGNEDBYTEARRAY));
+}
+
+// Get the specified value from the array and return it wrapped as a JavaScript Number object to V8. Accesses outside the valid array range return "undefined".
+INDEXED_PROPERTY_GETTER(CanvasUnsignedByteArray)
+{
+ INC_STATS("DOM.CanvasUnsignedByteArray.IndexedPropertyGetter");
+ CanvasUnsignedByteArray* array = V8DOMWrapper::convertToNativeObject<CanvasUnsignedByteArray>(V8ClassIndex::CANVASUNSIGNEDBYTEARRAY, info.Holder());
+
+ if ((index < 0) || (index >= array->length()))
+ return v8::Undefined();
+ unsigned char result;
+ if (!array->get(index, result))
+ return v8::Undefined();
+ return v8::Number::New(result);
+}
+
+// Set the specified value in the array. Accesses outside the valid array range are silently ignored.
+INDEXED_PROPERTY_SETTER(CanvasUnsignedByteArray)
+{
+ INC_STATS("DOM.CanvasUnsignedByteArray.IndexedPropertySetter");
+ CanvasUnsignedByteArray* array = V8DOMWrapper::convertToNativeObject<CanvasUnsignedByteArray>(V8ClassIndex::CANVASUNSIGNEDBYTEARRAY, info.Holder());
+
+ if ((index >= 0) && (index < array->length())) {
+ if (!value->IsNumber())
+ return throwError("Could not convert value argument to a number");
+ array->set(index, value->NumberValue());
+ }
+ return value;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasUnsignedIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasUnsignedIntArrayCustom.cpp
new file mode 100644
index 0000000..94ec7d0
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasUnsignedIntArrayCustom.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasUnsignedIntArray.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CanvasArrayCustom.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(CanvasUnsignedIntArrayConstructor)
+{
+ INC_STATS("DOM.CanvasUnsignedIntArray.Contructor");
+
+ return constructCanvasArray<CanvasUnsignedIntArray>(args, V8ClassIndex::ToInt(V8ClassIndex::CANVASUNSIGNEDINTARRAY));
+}
+
+// Get the specified value from the integer array and return it wrapped as a JavaScript Number object to V8. Accesses outside the valid pixel buffer range return "undefined".
+INDEXED_PROPERTY_GETTER(CanvasUnsignedIntArray)
+{
+ INC_STATS("DOM.CanvasUnsignedIntArray.IndexedPropertyGetter");
+ CanvasUnsignedIntArray* array = V8DOMWrapper::convertToNativeObject<CanvasUnsignedIntArray>(V8ClassIndex::CANVASUNSIGNEDINTARRAY, info.Holder());
+
+ if ((index < 0) || (index >= array->length()))
+ return v8::Undefined();
+ unsigned int result;
+ if (!array->get(index, result))
+ return v8::Undefined();
+ return v8::Number::New(result);
+}
+
+// Set the specified value in the integer array. Accesses outside the valid integer array range are silently ignored.
+INDEXED_PROPERTY_SETTER(CanvasUnsignedIntArray)
+{
+ INC_STATS("DOM.CanvasUnsignedIntArray.IndexedPropertySetter");
+ CanvasUnsignedIntArray* array = V8DOMWrapper::convertToNativeObject<CanvasUnsignedIntArray>(V8ClassIndex::CANVASUNSIGNEDINTARRAY, info.Holder());
+
+ if ((index >= 0) && (index < array->length())) {
+ if (!value->IsNumber())
+ return throwError("Could not convert value argument to a number");
+ array->set(index, value->NumberValue());
+ }
+ return value;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CanvasUnsignedShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasUnsignedShortArrayCustom.cpp
new file mode 100644
index 0000000..eeef82c
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8CanvasUnsignedShortArrayCustom.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "CanvasArrayBuffer.h"
+#include "CanvasUnsignedShortArray.h"
+
+#include "V8Binding.h"
+#include "V8CanvasArrayBuffer.h"
+#include "V8CanvasArrayCustom.h"
+#include "V8CustomBinding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(CanvasUnsignedShortArrayConstructor)
+{
+ INC_STATS("DOM.CanvasUnsignedShortArray.Contructor");
+
+ return constructCanvasArray<CanvasUnsignedShortArray>(args, V8ClassIndex::ToInt(V8ClassIndex::CANVASUNSIGNEDSHORTARRAY));
+}
+
+// Get the specified value from the array and return it wrapped as a JavaScript Number object to V8. Accesses outside the valid array range return "undefined".
+INDEXED_PROPERTY_GETTER(CanvasUnsignedShortArray)
+{
+ INC_STATS("DOM.CanvasUnsignedShortArray.IndexedPropertyGetter");
+ CanvasUnsignedShortArray* array = V8DOMWrapper::convertToNativeObject<CanvasUnsignedShortArray>(V8ClassIndex::CANVASUNSIGNEDSHORTARRAY, info.Holder());
+
+ if ((index < 0) || (index >= array->length()))
+ return v8::Undefined();
+ unsigned short result;
+ if (!array->get(index, result))
+ return v8::Undefined();
+ return v8::Number::New(result);
+}
+
+// Set the specified value in the array. Accesses outside the valid array range are silently ignored.
+INDEXED_PROPERTY_SETTER(CanvasUnsignedShortArray)
+{
+ INC_STATS("DOM.CanvasUnsignedShortArray.IndexedPropertySetter");
+ CanvasUnsignedShortArray* array = V8DOMWrapper::convertToNativeObject<CanvasUnsignedShortArray>(V8ClassIndex::CANVASUNSIGNEDSHORTARRAY, info.Holder());
+
+ if ((index >= 0) && (index < array->length())) {
+ if (!value->IsNumber())
+ return throwError("Could not convert value argument to a number");
+ array->set(index, value->NumberValue());
+ }
+ return value;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h
index dd8571b..2814121 100644
--- a/WebCore/bindings/v8/custom/V8CustomBinding.h
+++ b/WebCore/bindings/v8/custom/V8CustomBinding.h
@@ -328,6 +328,38 @@ namespace WebCore {
DECLARE_CALLBACK(CanvasRenderingContext2DStrokeText);
DECLARE_CALLBACK(CanvasRenderingContext2DPutImageData);
+#if ENABLE(3D_CANVAS)
+ DECLARE_CALLBACK(CanvasRenderingContext3DBufferData);
+ DECLARE_CALLBACK(CanvasRenderingContext3DBufferSubData);
+ DECLARE_CALLBACK(CanvasRenderingContext3DSizeof);
+ DECLARE_CALLBACK(CanvasRenderingContext3DTexImage2D);
+ DECLARE_CALLBACK(CanvasRenderingContext3DTexSubImage2D);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniform1fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniform1iv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniform2fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniform2iv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniform3fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniform3iv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniform4fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniform4iv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniformMatrix2fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniformMatrix3fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DUniformMatrix4fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DVertexAttrib1fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DVertexAttrib2fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DVertexAttrib3fv);
+ DECLARE_CALLBACK(CanvasRenderingContext3DVertexAttrib4fv);
+
+ DECLARE_CALLBACK(CanvasArrayBufferConstructor);
+ DECLARE_CALLBACK(CanvasByteArrayConstructor);
+ DECLARE_CALLBACK(CanvasFloatArrayConstructor);
+ DECLARE_CALLBACK(CanvasIntArrayConstructor);
+ DECLARE_CALLBACK(CanvasShortArrayConstructor);
+ DECLARE_CALLBACK(CanvasUnsignedByteArrayConstructor);
+ DECLARE_CALLBACK(CanvasUnsignedIntArrayConstructor);
+ DECLARE_CALLBACK(CanvasUnsignedShortArrayConstructor);
+#endif
+
DECLARE_PROPERTY_ACCESSOR_GETTER(ClipboardTypes);
DECLARE_CALLBACK(ClipboardClearData);
DECLARE_CALLBACK(ClipboardGetData);
@@ -462,9 +494,34 @@ namespace WebCore {
DECLARE_INDEXED_PROPERTY_SETTER(HTMLSelectElementCollection);
DECLARE_NAMED_PROPERTY_GETTER(HTMLCollection);
+#if ENABLE(3D_CANVAS)
+ DECLARE_INDEXED_PROPERTY_GETTER(CanvasByteArray);
+ DECLARE_INDEXED_PROPERTY_SETTER(CanvasByteArray);
+
+ DECLARE_INDEXED_PROPERTY_GETTER(CanvasFloatArray);
+ DECLARE_INDEXED_PROPERTY_SETTER(CanvasFloatArray);
+
+ DECLARE_INDEXED_PROPERTY_GETTER(CanvasIntArray);
+ DECLARE_INDEXED_PROPERTY_SETTER(CanvasIntArray);
+#endif
+
DECLARE_INDEXED_PROPERTY_GETTER(CanvasPixelArray);
DECLARE_INDEXED_PROPERTY_SETTER(CanvasPixelArray);
+#if ENABLE(3D_CANVAS)
+ DECLARE_INDEXED_PROPERTY_GETTER(CanvasShortArray);
+ DECLARE_INDEXED_PROPERTY_SETTER(CanvasShortArray);
+
+ DECLARE_INDEXED_PROPERTY_GETTER(CanvasUnsignedByteArray);
+ DECLARE_INDEXED_PROPERTY_SETTER(CanvasUnsignedByteArray);
+
+ DECLARE_INDEXED_PROPERTY_GETTER(CanvasUnsignedIntArray);
+ DECLARE_INDEXED_PROPERTY_SETTER(CanvasUnsignedIntArray);
+
+ DECLARE_INDEXED_PROPERTY_GETTER(CanvasUnsignedShortArray);
+ DECLARE_INDEXED_PROPERTY_SETTER(CanvasUnsignedShortArray);
+#endif
+
DECLARE_PROPERTY_ACCESSOR_GETTER(MessageEventPorts);
DECLARE_CALLBACK(MessageEventInitMessageEvent);
diff --git a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
index ef199a9..1bd518c 100644
--- a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
@@ -36,6 +36,7 @@
#include "Node.h"
#include "XPathNSResolver.h"
#include "XPathResult.h"
+#include "CanvasRenderingContext.h"
#include "V8Binding.h"
#include "V8CustomBinding.h"
@@ -94,13 +95,16 @@ CALLBACK_FUNC_DECL(DocumentGetCSSCanvasContext)
int width = toInt32(args[2]);
int height = toInt32(args[3]);
CanvasRenderingContext* result = imp->getCSSCanvasContext(contextId, name, width, height);
+ if (!result)
+ return v8::Undefined();
if (result->is2d())
return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
- else {
- // FIXME: Add the conversion to CanvasRenderingContext3D when it is hooked up.
- ASSERT_NOT_REACHED();
- return v8::Handle<v8::Value>();
- }
+#if ENABLE(3D_CANVAS)
+ else if (result->is3d())
+ return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT3D, result);
+#endif // ENABLE(3D_CANVAS)
+ ASSERT_NOT_REACHED();
+ return v8::Undefined();
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
index ea00f92..4116673 100644
--- a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp
@@ -30,6 +30,7 @@
#include "config.h"
#include "HTMLCanvasElement.h"
+#include "CanvasRenderingContext.h"
#include "CanvasRenderingContext.h"
#include "V8Binding.h"
@@ -46,12 +47,16 @@ CALLBACK_FUNC_DECL(HTMLCanvasElementGetContext)
HTMLCanvasElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLCanvasElement>(holder);
String contextId = toWebCoreString(args[0]);
CanvasRenderingContext* result = imp->getContext(contextId);
- if (result && result->is2d())
+ if (!result)
+ return v8::Undefined();
+ if (result->is2d())
return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result);
- else {
- // FIXME: Add the conversion to CanvasRenderingContext3D when it is hooked up.
- return v8::Handle<v8::Value>();
- }
+#if ENABLE(3D_CANVAS)
+ else if (result->is3d())
+ return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT3D, result);
+#endif
+ ASSERT_NOT_REACHED();
+ return v8::Undefined();
}
} // namespace WebCore
diff --git a/WebCore/platform/graphics/GraphicsContext3D.h b/WebCore/platform/graphics/GraphicsContext3D.h
index cbbf2b4..edda215 100644
--- a/WebCore/platform/graphics/GraphicsContext3D.h
+++ b/WebCore/platform/graphics/GraphicsContext3D.h
@@ -62,6 +62,11 @@ namespace WebCore {
class ImageData;
class WebKitCSSMatrix;
+ // FIXME: ideally this would be used on all platforms.
+#if PLATFORM(SKIA)
+ class GraphicsContext3DInternal;
+#endif
+
class GraphicsContext3D : Noncopyable {
public:
enum ShaderType { FRAGMENT_SHADER, VERTEX_SHADER };
@@ -308,10 +313,6 @@ namespace WebCore {
private:
int m_currentWidth, m_currentHeight;
-#if PLATFORM(SKIA)
-#include "GraphicsContext3DSkia.h"
-#endif
-
#if PLATFORM(MAC)
Vector<Vector<float> > m_vertexArray;
@@ -320,6 +321,12 @@ namespace WebCore {
GLuint m_fbo;
GLuint m_depthBuffer;
#endif
+
+ // FIXME: ideally this would be used on all platforms.
+#if PLATFORM(SKIA)
+ friend class GraphicsContext3DInternal;
+ OwnPtr<GraphicsContext3DInternal> m_internal;
+#endif
};
} // namespace WebCore
diff --git a/WebKit/chromium/features.gypi b/WebKit/chromium/features.gypi
index 3bef07e..cf5420f 100644
--- a/WebKit/chromium/features.gypi
+++ b/WebKit/chromium/features.gypi
@@ -32,6 +32,7 @@
# The following defines turn webkit features on or off.
'variables': {
'feature_defines': [
+ 'ENABLE_3D_CANVAS=0',
'ENABLE_CHANNEL_MESSAGING=1',
'ENABLE_DATABASE=1',
'ENABLE_DATAGRID=0',
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list