[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
cmarrin at apple.com
cmarrin at apple.com
Wed Apr 7 23:44:09 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit a4ae3281bafda750abe790a2237485d8e5029d04
Author: cmarrin at apple.com <cmarrin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Nov 16 21:30:15 2009 +0000
Update API of WebGLArray and friends
https://bugs.webkit.org/show_bug.cgi?id=31175
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51049 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 786b4c0..f7cafdd 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2009-11-16 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Oliver Hunt.
+
+ Update API of WebGLArray and friends
+ https://bugs.webkit.org/show_bug.cgi?id=31175
+
+ * fast/canvas/webgl/array-unit-tests-expected.txt:
+ * fast/canvas/webgl/array-unit-tests.html:
+
2009-11-16 Alexey Proskuryakov <ap at apple.com>
Re-enabling WebSocket tests on Tiger and Windows, now that SSL is disabled.
diff --git a/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt b/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt
index c2100d7..5cb4e79 100644
--- a/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/array-unit-tests-expected.txt
@@ -3,25 +3,81 @@ Verifies the functionality of the new array-like objects in the WebGL spec
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS test WebGLByteArray SetAndGetPos10ToNeg10
+PASS test WebGLByteArray SetAndGetMethodsPos10ToNeg10
PASS test WebGLByteArray ConstructWithArrayOfSignedValues
+PASS test WebGLByteArray ConstructWithWebGLArrayOfSignedValues
+PASS test WebGLByteArray OffsetsAndSizes
+PASS test WebGLByteArray SetFromWebGLArray
+PASS negativeTest WebGLByteArray SetFromWebGLArray
+PASS test WebGLByteArray SetFromArray
+PASS test WebGLByteArray Slice
+PASS negativeTest WebGLByteArray Slice
PASS test WebGLByteArray BoundaryConditions(-128, -128, 127, 127)
PASS test WebGLFloatArray SetAndGetPos10ToNeg10
+PASS test WebGLFloatArray SetAndGetMethodsPos10ToNeg10
PASS test WebGLFloatArray ConstructWithArrayOfSignedValues
+PASS test WebGLFloatArray ConstructWithWebGLArrayOfSignedValues
+PASS test WebGLFloatArray OffsetsAndSizes
+PASS test WebGLFloatArray SetFromWebGLArray
+PASS negativeTest WebGLFloatArray SetFromWebGLArray
+PASS test WebGLFloatArray SetFromArray
+PASS test WebGLFloatArray Slice
+PASS negativeTest WebGLFloatArray Slice
PASS test WebGLFloatArray BoundaryConditions(-500, -500, 500, 500)
PASS test WebGLIntArray SetAndGetPos10ToNeg10
+PASS test WebGLIntArray SetAndGetMethodsPos10ToNeg10
PASS test WebGLIntArray ConstructWithArrayOfSignedValues
+PASS test WebGLIntArray ConstructWithWebGLArrayOfSignedValues
+PASS test WebGLIntArray OffsetsAndSizes
+PASS test WebGLIntArray SetFromWebGLArray
+PASS negativeTest WebGLIntArray SetFromWebGLArray
+PASS test WebGLIntArray SetFromArray
+PASS test WebGLIntArray Slice
+PASS negativeTest WebGLIntArray Slice
PASS test WebGLIntArray BoundaryConditions(-2147483648, -2147483648, 2147483647, 2147483647)
PASS test WebGLShortArray SetAndGetPos10ToNeg10
+PASS test WebGLShortArray SetAndGetMethodsPos10ToNeg10
PASS test WebGLShortArray ConstructWithArrayOfSignedValues
+PASS test WebGLShortArray ConstructWithWebGLArrayOfSignedValues
+PASS test WebGLShortArray OffsetsAndSizes
+PASS test WebGLShortArray SetFromWebGLArray
+PASS negativeTest WebGLShortArray SetFromWebGLArray
+PASS test WebGLShortArray SetFromArray
+PASS test WebGLShortArray Slice
+PASS negativeTest WebGLShortArray Slice
PASS test WebGLShortArray BoundaryConditions(-32768, -32768, 32767, 32767)
PASS test WebGLUnsignedByteArray SetAndGet10To1
+PASS test WebGLUnsignedByteArray SetAndGetMethods10To1
PASS test WebGLUnsignedByteArray ConstructWithArrayOfUnsignedValues
+PASS test WebGLUnsignedByteArray ConstructWithWebGLArrayOfUnsignedValues
+PASS test WebGLUnsignedByteArray OffsetsAndSizes
+PASS test WebGLUnsignedByteArray SetFromWebGLArray
+PASS negativeTest WebGLUnsignedByteArray SetFromWebGLArray
+PASS test WebGLUnsignedByteArray SetFromArray
+PASS test WebGLUnsignedByteArray Slice
+PASS negativeTest WebGLUnsignedByteArray Slice
PASS test WebGLUnsignedByteArray BoundaryConditions(0, 0, 255, 255)
PASS test WebGLUnsignedIntArray SetAndGet10To1
+PASS test WebGLUnsignedIntArray SetAndGetMethods10To1
PASS test WebGLUnsignedIntArray ConstructWithArrayOfUnsignedValues
+PASS test WebGLUnsignedIntArray ConstructWithWebGLArrayOfUnsignedValues
+PASS test WebGLUnsignedIntArray OffsetsAndSizes
+PASS test WebGLUnsignedIntArray SetFromWebGLArray
+PASS negativeTest WebGLUnsignedIntArray SetFromWebGLArray
+PASS test WebGLUnsignedIntArray SetFromArray
+PASS test WebGLUnsignedIntArray Slice
+PASS negativeTest WebGLUnsignedIntArray Slice
PASS test WebGLUnsignedIntArray BoundaryConditions(0, 0, 4294967295, 4294967295)
PASS test WebGLUnsignedShortArray SetAndGet10To1
+PASS test WebGLUnsignedShortArray SetAndGetMethods10To1
PASS test WebGLUnsignedShortArray ConstructWithArrayOfUnsignedValues
+PASS test WebGLUnsignedShortArray ConstructWithWebGLArrayOfUnsignedValues
+PASS test WebGLUnsignedShortArray OffsetsAndSizes
+PASS test WebGLUnsignedShortArray SetFromWebGLArray
+PASS negativeTest WebGLUnsignedShortArray SetFromWebGLArray
+PASS test WebGLUnsignedShortArray SetFromArray
+PASS test WebGLUnsignedShortArray Slice
+PASS negativeTest WebGLUnsignedShortArray Slice
PASS test WebGLUnsignedShortArray BoundaryConditions(0, 0, 65535, 65535)
Test passed.
PASS successfullyParsed is true
diff --git a/LayoutTests/fast/canvas/webgl/array-unit-tests.html b/LayoutTests/fast/canvas/webgl/array-unit-tests.html
index 1d028d0..ecfa076 100644
--- a/LayoutTests/fast/canvas/webgl/array-unit-tests.html
+++ b/LayoutTests/fast/canvas/webgl/array-unit-tests.html
@@ -27,13 +27,26 @@ function pass() {
}
function fail(str) {
- var exc = 'FAILED: ' + currentlyRunning + ': ' + str;
- testFailed(str);
+ allPassed = false;
+ var exc;
+ if (str)
+ exc = currentlyRunning + ': ' + str;
+ else
+ exc = str;
+ testFailed(exc);
}
function assertEq(prefix, expected, val) {
if (expected != val) {
- fail(prefix + ': expected ' + expected + ', got ' + val);
+ var str = prefix + ': expected ' + expected + ', got ' + val;
+ throw str;
+ }
+}
+
+function assert(prefix, expected) {
+ if (!expected) {
+ var str = prefix + ': expected value / true';
+ throw str;
}
}
@@ -65,6 +78,22 @@ function testSetAndGet10To1(type, name) {
}
}
+function testSetAndGetMethods10To1(type, name) {
+ running('test ' + name + ' SetAndGetMethods10To1');
+ try {
+ var array = new type(10);
+ for (var i = 0; i < 10; i++) {
+ array.set(i, 10 - i);
+ }
+ for (var i = 0; i < 10; i++) {
+ assertEq('Element ' + i, 10 - i, array.get(i));
+ }
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
function testConstructWithArrayOfUnsignedValues(type, name) {
running('test ' + name + ' ConstructWithArrayOfUnsignedValues');
try {
@@ -79,6 +108,21 @@ function testConstructWithArrayOfUnsignedValues(type, name) {
}
}
+function testConstructWithWebGLArrayOfUnsignedValues(type, name) {
+ running('test ' + name + ' ConstructWithWebGLArrayOfUnsignedValues');
+ try {
+ var tmp = new type([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]);
+ var array = new type(tmp);
+ assertEq('Array length', 10, array.length);
+ for (var i = 0; i < 10; i++) {
+ assertEq('Element ' + i, 10 - i, array[i]);
+ }
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
//
// Tests for signed array variants
//
@@ -99,6 +143,22 @@ function testSetAndGetPos10ToNeg10(type, name) {
}
}
+function testSetAndGetMethodsPos10ToNeg10(type, name) {
+ running('test ' + name + ' SetAndGetMethodsPos10ToNeg10');
+ try {
+ var array = new type(21);
+ for (var i = 0; i < 21; i++) {
+ array.set(i, 10 - i);
+ }
+ for (var i = 0; i < 21; i++) {
+ assertEq('Element ' + i, 10 - i, array.get(i));
+ }
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
function testConstructWithArrayOfSignedValues(type, name) {
running('test ' + name + ' ConstructWithArrayOfSignedValues');
try {
@@ -113,10 +173,157 @@ function testConstructWithArrayOfSignedValues(type, name) {
}
}
+function testConstructWithWebGLArrayOfSignedValues(type, name) {
+ running('test ' + name + ' ConstructWithWebGLArrayOfSignedValues');
+ try {
+ var tmp = new type([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]);
+ var array = new type(tmp);
+ assertEq('Array length', 21, array.length);
+ for (var i = 0; i < 21; i++) {
+ assertEq('Element ' + i, 10 - i, array[i]);
+ }
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
//
// Test cases for both signed and unsigned types
//
+function testOffsetsAndSizes(type, name, elementSizeInBytes) {
+ running('test ' + name + ' OffsetsAndSizes');
+ try {
+ var len = 10;
+ var array = new type(len);
+ assert('array.buffer', array.buffer);
+ assertEq('array.byteOffset', array.byteOffset, 0);
+ assertEq('array.length', array.length, len);
+ assertEq('array.byteLength', array.byteLength, len * elementSizeInBytes);
+ array = new type(array.buffer, elementSizeInBytes, len - 1);
+ assert('array.buffer', array.buffer);
+ assertEq('array.byteOffset', array.byteOffset, elementSizeInBytes);
+ assertEq('array.length', array.length, len - 1);
+ assertEq('array.byteLength', array.byteLength, (len - 1) * elementSizeInBytes);
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
+function testSetFromWebGLArray(type, name) {
+ running('test ' + name + ' SetFromWebGLArray');
+ try {
+ var array = new type(10);
+ var array2 = new type(5);
+ for (var i = 0; i < 10; i++) {
+ assertEq('Element ' + i, 0, array[i]);
+ }
+ for (var i = 0; i < array2.length; i++) {
+ array2[i] = i;
+ }
+ array.set(array2);
+ for (var i = 0; i < array2.length; i++) {
+ assertEq('Element ' + i, i, array[i]);
+ }
+ array.set(array2, 5);
+ for (var i = 0; i < array2.length; i++) {
+ assertEq('Element ' + i, i, array[5 + i]);
+ }
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
+function negativeTestSetFromWebGLArray(type, name) {
+ running('negativeTest ' + name + ' SetFromWebGLArray');
+ try {
+ var array = new type(5);
+ var array2 = new type(6);
+ for (var i = 0; i < 5; i++) {
+ assertEq('Element ' + i, 0, array[i]);
+ }
+ for (var i = 0; i < array2.length; i++) {
+ array2[i] = i;
+ }
+ try {
+ array.set(array2);
+ fail('Expected exception from array.set(array2)');
+ return;
+ } catch (e) {
+ }
+ try {
+ array2.set(array, 2);
+ fail('Expected exception from array2.set(array, 2)');
+ return;
+ } catch (e) {
+ }
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
+function testSetFromArray(type, name) {
+ running('test ' + name + ' SetFromArray');
+ try {
+ var array = new type(10);
+ var array2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
+ for (var i = 0; i < 10; i++) {
+ assertEq('Element ' + i, 0, array[i]);
+ }
+ array.set(array2, 0);
+ for (var i = 0; i < array2.length; i++) {
+ assertEq('Element ' + i, 10 - i, array[i]);
+ }
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
+function testSlice(type, name) {
+ running('test ' + name + ' Slice');
+ try {
+ var array = new type([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ var slice = array.slice(0, 5);
+ assertEq('slice.length', 5, slice.length);
+ for (var i = 0; i < 5; i++) {
+ assertEq('Element ' + i, i, slice[i]);
+ }
+ slice = array.slice(4, 6);
+ assertEq('slice.length', 6, slice.length);
+ for (var i = 0; i < 6; i++) {
+ assertEq('Element ' + i, 4 + i, slice[i]);
+ }
+ pass();
+ } catch (e) {
+ fail(e);
+ }
+}
+
+function negativeTestSlice(type, name) {
+ running('negativeTest ' + name + ' Slice');
+ try {
+ var array = new type([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ slice = array.slice(5, 6);
+ if (slice) {
+ fail();
+ return;
+ }
+ slice = array.slice(10, 0);
+ if (slice) {
+ fail();
+ return;
+ }
+ pass();
+ } catch (e) {
+ pass();
+ }
+}
+
function testBoundaryConditions(type, name, lowValue, expectedLowValue, highValue, expectedHighValue) {
running('test ' + name + ' BoundaryConditions(' +
lowValue + ', ' + expectedLowValue + ', ' +
@@ -146,42 +353,49 @@ function runTests() {
var testCases =
[ {name: "WebGLByteArray",
unsigned: false,
+ elementSizeInBytes: 1,
low: -128,
expectedLow: -128,
high: 127,
expectedHigh: 127},
{name: "WebGLFloatArray",
unsigned: false,
+ elementSizeInBytes: 4,
low: -500,
expectedLow: -500,
high: 500,
expectedHigh: 500},
{name: "WebGLIntArray",
unsigned: false,
+ elementSizeInBytes: 4,
low: -2147483648,
expectedLow: -2147483648,
high: 2147483647,
expectedHigh: 2147483647},
{name: "WebGLShortArray",
unsigned: false,
+ elementSizeInBytes: 2,
low: -32768,
expectedLow: -32768,
high: 32767,
expectedHigh: 32767},
{name: "WebGLUnsignedByteArray",
unsigned: true,
+ elementSizeInBytes: 1,
low: 0,
expectedLow: 0,
high: 255,
expectedHigh: 255},
{name: "WebGLUnsignedIntArray",
unsigned: true,
+ elementSizeInBytes: 4,
low: 0,
expectedLow: 0,
high: 4294967295,
expectedHigh: 4294967295},
{name: "WebGLUnsignedShortArray",
unsigned: true,
+ elementSizeInBytes: 2,
low: 0,
expectedLow: 0,
high: 65535,
@@ -198,11 +412,21 @@ function runTests() {
var name = testCase.name;
if (testCase.unsigned) {
testSetAndGet10To1(type, name);
+ testSetAndGetMethods10To1(type, name);
testConstructWithArrayOfUnsignedValues(type, name);
+ testConstructWithWebGLArrayOfUnsignedValues(type, name);
} else {
testSetAndGetPos10ToNeg10(type, name);
+ testSetAndGetMethodsPos10ToNeg10(type, name);
testConstructWithArrayOfSignedValues(type, name);
+ testConstructWithWebGLArrayOfSignedValues(type, name);
}
+ testOffsetsAndSizes(type, name, testCase.elementSizeInBytes);
+ testSetFromWebGLArray(type, name);
+ negativeTestSetFromWebGLArray(type, name);
+ testSetFromArray(type, name);
+ testSlice(type, name);
+ negativeTestSlice(type, name);
testBoundaryConditions(type,
name,
testCase.low,
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 60c868a..7e1272b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,176 @@
+2009-11-16 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Oliver Hunt.
+
+ Update API of WebGLArray and friends
+ https://bugs.webkit.org/show_bug.cgi?id=31175
+
+ * bindings/js/JSWebGLArrayCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSWebGLArrayHelper.h: Added.
+ (WebCore::setWebGLArrayFromArray):
+ * bindings/js/JSWebGLByteArrayCustom.cpp:
+ (WebCore::JSWebGLByteArray::set):
+ * bindings/js/JSWebGLFloatArrayCustom.cpp:
+ (WebCore::JSWebGLFloatArray::set):
+ * bindings/js/JSWebGLIntArrayCustom.cpp:
+ (WebCore::JSWebGLIntArray::set):
+ * bindings/js/JSWebGLShortArrayCustom.cpp:
+ (WebCore::JSWebGLShortArray::set):
+ * bindings/js/JSWebGLUnsignedByteArrayCustom.cpp:
+ (WebCore::JSWebGLUnsignedByteArray::set):
+ * bindings/js/JSWebGLUnsignedIntArrayCustom.cpp:
+ (WebCore::JSWebGLUnsignedIntArray::set):
+ * bindings/js/JSWebGLUnsignedShortArrayCustom.cpp:
+ (WebCore::JSWebGLUnsignedShortArray::set):
+ * bindings/scripts/CodeGeneratorV8.pm:
+ * bindings/v8/V8DOMWrapper.cpp:
+ (WebCore::V8DOMWrapper::convertToV8Object):
+ * bindings/v8/custom/V8CustomBinding.h:
+ * bindings/v8/custom/V8WebGLArrayBufferCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8WebGLArrayCustom.h:
+ (WebCore::constructWebGLArray):
+ (WebCore::getWebGLArrayElement):
+ (WebCore::setWebGLArrayFromArray):
+ (WebCore::setWebGLArray):
+ * bindings/v8/custom/V8WebGLByteArrayCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8WebGLFloatArrayCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8WebGLIntArrayCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8WebGLShortArrayCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp:
+ (WebCore::CALLBACK_FUNC_DECL):
+ * html/canvas/WebGLArray.cpp:
+ (WebCore::WebGLArray::WebGLArray):
+ (WebCore::WebGLArray::~WebGLArray):
+ (WebCore::WebGLArray::setImpl):
+ * html/canvas/WebGLArray.h:
+ (WebCore::WebGLArray::isByteArray):
+ (WebCore::WebGLArray::isUnsignedByteArray):
+ (WebCore::WebGLArray::isShortArray):
+ (WebCore::WebGLArray::isUnsignedShortArray):
+ (WebCore::WebGLArray::isIntArray):
+ (WebCore::WebGLArray::isUnsignedIntArray):
+ (WebCore::WebGLArray::isFloatArray):
+ (WebCore::WebGLArray::buffer):
+ (WebCore::WebGLArray::baseAddress):
+ (WebCore::WebGLArray::byteOffset):
+ * html/canvas/WebGLArray.idl:
+ * html/canvas/WebGLArrayBuffer.cpp:
+ (WebCore::WebGLArrayBuffer::create):
+ (WebCore::WebGLArrayBuffer::WebGLArrayBuffer):
+ (WebCore::WebGLArrayBuffer::data):
+ (WebCore::WebGLArrayBuffer::byteLength):
+ (WebCore::WebGLArrayBuffer::~WebGLArrayBuffer):
+ * html/canvas/WebGLArrayBuffer.h:
+ * html/canvas/WebGLByteArray.cpp:
+ (WebCore::WebGLByteArray::create):
+ (WebCore::WebGLByteArray::byteLength):
+ (WebCore::WebGLByteArray::slice):
+ (WebCore::WebGLByteArray::set):
+ * html/canvas/WebGLByteArray.h:
+ (WebCore::WebGLByteArray::isByteArray):
+ (WebCore::WebGLByteArray::data):
+ (WebCore::WebGLByteArray::set):
+ (WebCore::WebGLByteArray::get):
+ (WebCore::WebGLByteArray::item):
+ * html/canvas/WebGLByteArray.idl:
+ * html/canvas/WebGLFloatArray.cpp:
+ (WebCore::WebGLFloatArray::create):
+ (WebCore::WebGLFloatArray::WebGLFloatArray):
+ (WebCore::WebGLFloatArray::length):
+ (WebCore::WebGLFloatArray::byteLength):
+ (WebCore::WebGLFloatArray::slice):
+ (WebCore::WebGLFloatArray::set):
+ * html/canvas/WebGLFloatArray.h:
+ (WebCore::WebGLFloatArray::isFloatArray):
+ (WebCore::WebGLFloatArray::data):
+ (WebCore::WebGLFloatArray::set):
+ (WebCore::WebGLFloatArray::get):
+ (WebCore::WebGLFloatArray::item):
+ * html/canvas/WebGLFloatArray.idl:
+ * html/canvas/WebGLIntArray.cpp:
+ (WebCore::WebGLIntArray::create):
+ (WebCore::WebGLIntArray::WebGLIntArray):
+ (WebCore::WebGLIntArray::length):
+ (WebCore::WebGLIntArray::byteLength):
+ (WebCore::WebGLIntArray::slice):
+ (WebCore::WebGLIntArray::set):
+ * html/canvas/WebGLIntArray.h:
+ (WebCore::WebGLIntArray::isIntArray):
+ (WebCore::WebGLIntArray::data):
+ (WebCore::WebGLIntArray::set):
+ (WebCore::WebGLIntArray::get):
+ (WebCore::WebGLIntArray::item):
+ * html/canvas/WebGLIntArray.idl:
+ * html/canvas/WebGLShortArray.cpp:
+ (WebCore::WebGLShortArray::create):
+ (WebCore::WebGLShortArray::WebGLShortArray):
+ (WebCore::WebGLShortArray::length):
+ (WebCore::WebGLShortArray::byteLength):
+ (WebCore::WebGLShortArray::slice):
+ (WebCore::WebGLShortArray::set):
+ * html/canvas/WebGLShortArray.h:
+ (WebCore::WebGLShortArray::isShortArray):
+ (WebCore::WebGLShortArray::data):
+ (WebCore::WebGLShortArray::set):
+ (WebCore::WebGLShortArray::get):
+ (WebCore::WebGLShortArray::item):
+ * html/canvas/WebGLShortArray.idl:
+ * html/canvas/WebGLUnsignedByteArray.cpp:
+ (WebCore::WebGLUnsignedByteArray::create):
+ (WebCore::WebGLUnsignedByteArray::WebGLUnsignedByteArray):
+ (WebCore::WebGLUnsignedByteArray::length):
+ (WebCore::WebGLUnsignedByteArray::byteLength):
+ (WebCore::WebGLUnsignedByteArray::slice):
+ (WebCore::WebGLUnsignedByteArray::set):
+ * html/canvas/WebGLUnsignedByteArray.h:
+ (WebCore::WebGLUnsignedByteArray::isUnsignedByteArray):
+ (WebCore::WebGLUnsignedByteArray::data):
+ (WebCore::WebGLUnsignedByteArray::set):
+ (WebCore::WebGLUnsignedByteArray::get):
+ (WebCore::WebGLUnsignedByteArray::item):
+ * html/canvas/WebGLUnsignedByteArray.idl:
+ * html/canvas/WebGLUnsignedIntArray.cpp:
+ (WebCore::WebGLUnsignedIntArray::create):
+ (WebCore::WebGLUnsignedIntArray::WebGLUnsignedIntArray):
+ (WebCore::WebGLUnsignedIntArray::length):
+ (WebCore::WebGLUnsignedIntArray::byteLength):
+ (WebCore::WebGLUnsignedIntArray::slice):
+ (WebCore::WebGLUnsignedIntArray::set):
+ * html/canvas/WebGLUnsignedIntArray.h:
+ (WebCore::WebGLUnsignedIntArray::isUnsignedIntArray):
+ (WebCore::WebGLUnsignedIntArray::data):
+ (WebCore::WebGLUnsignedIntArray::set):
+ (WebCore::WebGLUnsignedIntArray::get):
+ (WebCore::WebGLUnsignedIntArray::item):
+ * html/canvas/WebGLUnsignedIntArray.idl:
+ * html/canvas/WebGLUnsignedShortArray.cpp:
+ (WebCore::WebGLUnsignedShortArray::create):
+ (WebCore::WebGLUnsignedShortArray::WebGLUnsignedShortArray):
+ (WebCore::WebGLUnsignedShortArray::length):
+ (WebCore::WebGLUnsignedShortArray::byteLength):
+ (WebCore::WebGLUnsignedShortArray::slice):
+ (WebCore::WebGLUnsignedShortArray::set):
+ * html/canvas/WebGLUnsignedShortArray.h:
+ (WebCore::WebGLUnsignedShortArray::isUnsignedShortArray):
+ (WebCore::WebGLUnsignedShortArray::data):
+ (WebCore::WebGLUnsignedShortArray::set):
+ (WebCore::WebGLUnsignedShortArray::get):
+ (WebCore::WebGLUnsignedShortArray::item):
+ * html/canvas/WebGLUnsignedShortArray.idl:
+ * platform/graphics/mac/GraphicsContext3DMac.cpp:
+ (WebCore::GraphicsContext3D::bufferData):
+ (WebCore::GraphicsContext3D::bufferSubData):
+
2009-11-16 Alexey Proskuryakov <ap at apple.com>
Windows build fix.
diff --git a/WebCore/bindings/js/JSWebGLArrayCustom.cpp b/WebCore/bindings/js/JSWebGLArrayCustom.cpp
index bebbc7c..4348054 100644
--- a/WebCore/bindings/js/JSWebGLArrayCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLArrayCustom.cpp
@@ -45,20 +45,22 @@ namespace WebCore {
JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLArray* object)
{
- if (object->isFloatArray())
- return getDOMObjectWrapper<JSWebGLFloatArray>(exec, globalObject, static_cast<WebGLFloatArray*>(object));
- if (object->isUnsignedByteArray())
- return getDOMObjectWrapper<JSWebGLUnsignedByteArray>(exec, globalObject, static_cast<WebGLUnsignedByteArray*>(object));
- if (object->isByteArray())
- return getDOMObjectWrapper<JSWebGLByteArray>(exec, globalObject, static_cast<WebGLByteArray*>(object));
- if (object->isIntArray())
- return getDOMObjectWrapper<JSWebGLIntArray>(exec, globalObject, static_cast<WebGLIntArray*>(object));
- if (object->isUnsignedIntArray())
- return getDOMObjectWrapper<JSWebGLUnsignedIntArray>(exec, globalObject, static_cast<WebGLUnsignedIntArray*>(object));
- if (object->isShortArray())
- return getDOMObjectWrapper<JSWebGLShortArray>(exec, globalObject, static_cast<WebGLShortArray*>(object));
- if (object->isUnsignedShortArray())
- return getDOMObjectWrapper<JSWebGLUnsignedShortArray>(exec, globalObject, static_cast<WebGLUnsignedShortArray*>(object));
+ if (object) {
+ if (object->isFloatArray())
+ return getDOMObjectWrapper<JSWebGLFloatArray>(exec, globalObject, static_cast<WebGLFloatArray*>(object));
+ if (object->isUnsignedByteArray())
+ return getDOMObjectWrapper<JSWebGLUnsignedByteArray>(exec, globalObject, static_cast<WebGLUnsignedByteArray*>(object));
+ if (object->isByteArray())
+ return getDOMObjectWrapper<JSWebGLByteArray>(exec, globalObject, static_cast<WebGLByteArray*>(object));
+ if (object->isIntArray())
+ return getDOMObjectWrapper<JSWebGLIntArray>(exec, globalObject, static_cast<WebGLIntArray*>(object));
+ if (object->isUnsignedIntArray())
+ return getDOMObjectWrapper<JSWebGLUnsignedIntArray>(exec, globalObject, static_cast<WebGLUnsignedIntArray*>(object));
+ if (object->isShortArray())
+ return getDOMObjectWrapper<JSWebGLShortArray>(exec, globalObject, static_cast<WebGLShortArray*>(object));
+ if (object->isUnsignedShortArray())
+ return getDOMObjectWrapper<JSWebGLUnsignedShortArray>(exec, globalObject, static_cast<WebGLUnsignedShortArray*>(object));
+ }
return jsUndefined();
}
diff --git a/WebCore/bindings/js/JSWebGLByteArrayCustom.cpp b/WebCore/bindings/js/JSWebGLByteArrayCustom.cpp
index 60e7973..f7872a8 100644
--- a/WebCore/bindings/js/JSWebGLByteArrayCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLByteArrayCustom.cpp
@@ -27,10 +27,13 @@
#if ENABLE(3D_CANVAS)
+#include "JSWebGLArrayHelper.h"
#include "JSWebGLByteArray.h"
#include "WebGLByteArray.h"
+#include <runtime/Error.h>
+
using namespace JSC;
namespace WebCore {
@@ -45,6 +48,33 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLBy
return getDOMObjectWrapper<JSWebGLByteArray>(exec, globalObject, object);
}
+JSC::JSValue JSWebGLByteArray::set(JSC::ExecState* exec, JSC::ArgList const& args)
+{
+ if (args.size() < 1 || args.size() > 2)
+ return throwError(exec, SyntaxError);
+
+ if (args.size() == 2 && args.at(0).isInt32()) {
+ // void set(in unsigned long index, in long value);
+ unsigned index = args.at(0).toUInt32(exec);
+ impl()->set(index, static_cast<signed char>(args.at(1).toInt32(exec)));
+ return jsUndefined();
+ }
+
+ WebGLByteArray* array = toWebGLByteArray(args.at(0));
+ if (array) {
+ // void set(in WebGLByteArray array, [Optional] in unsigned long offset);
+ unsigned offset = 0;
+ if (args.size() == 2)
+ offset = args.at(1).toInt32(exec);
+ ExceptionCode ec = 0;
+ impl()->set(array, offset, ec);
+ setDOMException(exec, ec);
+ return jsUndefined();
+ }
+
+ return setWebGLArrayFromArray(exec, impl(), args);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/js/JSWebGLFloatArrayCustom.cpp b/WebCore/bindings/js/JSWebGLFloatArrayCustom.cpp
index 683e9d3..5f5b24f 100644
--- a/WebCore/bindings/js/JSWebGLFloatArrayCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLFloatArrayCustom.cpp
@@ -27,6 +27,7 @@
#if ENABLE(3D_CANVAS)
+#include "JSWebGLArrayHelper.h"
#include "JSWebGLFloatArray.h"
#include "WebGLFloatArray.h"
@@ -45,6 +46,33 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLFl
return getDOMObjectWrapper<JSWebGLFloatArray>(exec, globalObject, object);
}
+JSC::JSValue JSWebGLFloatArray::set(JSC::ExecState* exec, JSC::ArgList const& args)
+{
+ if (args.size() > 2)
+ return throwError(exec, SyntaxError);
+
+ if (args.size() == 2 && args.at(0).isInt32()) {
+ // void set(in unsigned long index, in long value);
+ unsigned index = args.at(0).toUInt32(exec);
+ impl()->set(index, static_cast<signed char>(args.at(1).toInt32(exec)));
+ return jsUndefined();
+ }
+
+ WebGLFloatArray* array = toWebGLFloatArray(args.at(0));
+ if (array) {
+ // void set(in WebGLFloatArray array, [Optional] in unsigned long offset);
+ unsigned offset = 0;
+ if (args.size() == 2)
+ offset = args.at(1).toInt32(exec);
+ ExceptionCode ec = 0;
+ impl()->set(array, offset, ec);
+ setDOMException(exec, ec);
+ return jsUndefined();
+ }
+
+ return setWebGLArrayFromArray(exec, impl(), args);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/js/JSWebGLIntArrayCustom.cpp b/WebCore/bindings/js/JSWebGLIntArrayCustom.cpp
index 89320f6..9c384d8 100644
--- a/WebCore/bindings/js/JSWebGLIntArrayCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLIntArrayCustom.cpp
@@ -27,6 +27,7 @@
#if ENABLE(3D_CANVAS)
+#include "JSWebGLArrayHelper.h"
#include "JSWebGLIntArray.h"
#include "WebGLIntArray.h"
@@ -45,6 +46,33 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLIn
return getDOMObjectWrapper<JSWebGLIntArray>(exec, globalObject, object);
}
+JSC::JSValue JSWebGLIntArray::set(JSC::ExecState* exec, JSC::ArgList const& args)
+{
+ if (args.size() > 2)
+ return throwError(exec, SyntaxError);
+
+ if (args.size() == 2 && args.at(0).isInt32()) {
+ // void set(in unsigned long index, in long value);
+ unsigned index = args.at(0).toUInt32(exec);
+ impl()->set(index, static_cast<signed char>(args.at(1).toInt32(exec)));
+ return jsUndefined();
+ }
+
+ WebGLIntArray* array = toWebGLIntArray(args.at(0));
+ if (array) {
+ // void set(in WebGLIntArray array, [Optional] in unsigned long offset);
+ unsigned offset = 0;
+ if (args.size() == 2)
+ offset = args.at(1).toInt32(exec);
+ ExceptionCode ec = 0;
+ impl()->set(array, offset, ec);
+ setDOMException(exec, ec);
+ return jsUndefined();
+ }
+
+ return setWebGLArrayFromArray(exec, impl(), args);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/js/JSWebGLShortArrayCustom.cpp b/WebCore/bindings/js/JSWebGLShortArrayCustom.cpp
index 1f4f96b..462b09a 100644
--- a/WebCore/bindings/js/JSWebGLShortArrayCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLShortArrayCustom.cpp
@@ -27,6 +27,7 @@
#if ENABLE(3D_CANVAS)
+#include "JSWebGLArrayHelper.h"
#include "JSWebGLShortArray.h"
#include "WebGLShortArray.h"
@@ -45,6 +46,33 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLSh
return getDOMObjectWrapper<JSWebGLShortArray>(exec, globalObject, object);
}
+JSC::JSValue JSWebGLShortArray::set(JSC::ExecState* exec, JSC::ArgList const& args)
+{
+ if (args.size() > 2)
+ return throwError(exec, SyntaxError);
+
+ if (args.size() == 2 && args.at(0).isInt32()) {
+ // void set(in unsigned long index, in long value);
+ unsigned index = args.at(0).toUInt32(exec);
+ impl()->set(index, static_cast<signed char>(args.at(1).toInt32(exec)));
+ return jsUndefined();
+ }
+
+ WebGLShortArray* shortArray = toWebGLShortArray(args.at(0));
+ if (shortArray) {
+ // void set(in WebGLShortArray array, [Optional] in unsigned long offset);
+ unsigned offset = 0;
+ if (args.size() == 2)
+ offset = args.at(1).toInt32(exec);
+ ExceptionCode ec = 0;
+ impl()->set(shortArray, offset, ec);
+ setDOMException(exec, ec);
+ return jsUndefined();
+ }
+
+ return setWebGLArrayFromArray(exec, impl(), args);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/js/JSWebGLUnsignedByteArrayCustom.cpp b/WebCore/bindings/js/JSWebGLUnsignedByteArrayCustom.cpp
index c54a01c..35a545d 100644
--- a/WebCore/bindings/js/JSWebGLUnsignedByteArrayCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLUnsignedByteArrayCustom.cpp
@@ -27,6 +27,7 @@
#if ENABLE(3D_CANVAS)
+#include "JSWebGLArrayHelper.h"
#include "JSWebGLUnsignedByteArray.h"
#include "WebGLUnsignedByteArray.h"
@@ -45,6 +46,33 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLUn
return getDOMObjectWrapper<JSWebGLUnsignedByteArray>(exec, globalObject, object);
}
+JSC::JSValue JSWebGLUnsignedByteArray::set(JSC::ExecState* exec, JSC::ArgList const& args)
+{
+ if (args.size() > 2)
+ return throwError(exec, SyntaxError);
+
+ if (args.size() == 2 && args.at(0).isInt32()) {
+ // void set(in unsigned long index, in long value);
+ unsigned index = args.at(0).toUInt32(exec);
+ impl()->set(index, static_cast<signed char>(args.at(1).toInt32(exec)));
+ return jsUndefined();
+ }
+
+ WebGLUnsignedByteArray* array = toWebGLUnsignedByteArray(args.at(0));
+ if (array) {
+ // void set(in WebGLUnsignedByteArray array, [Optional] in unsigned long offset);
+ unsigned offset = 0;
+ if (args.size() == 2)
+ offset = args.at(1).toInt32(exec);
+ ExceptionCode ec = 0;
+ impl()->set(array, offset, ec);
+ setDOMException(exec, ec);
+ return jsUndefined();
+ }
+
+ return setWebGLArrayFromArray(exec, impl(), args);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/js/JSWebGLUnsignedIntArrayCustom.cpp b/WebCore/bindings/js/JSWebGLUnsignedIntArrayCustom.cpp
index f606abe..ea28111 100644
--- a/WebCore/bindings/js/JSWebGLUnsignedIntArrayCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLUnsignedIntArrayCustom.cpp
@@ -27,6 +27,7 @@
#if ENABLE(3D_CANVAS)
+#include "JSWebGLArrayHelper.h"
#include "JSWebGLUnsignedIntArray.h"
#include "WebGLUnsignedIntArray.h"
@@ -45,6 +46,33 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLUn
return getDOMObjectWrapper<JSWebGLUnsignedIntArray>(exec, globalObject, object);
}
+JSC::JSValue JSWebGLUnsignedIntArray::set(JSC::ExecState* exec, JSC::ArgList const& args)
+{
+ if (args.size() > 2)
+ return throwError(exec, SyntaxError);
+
+ if (args.size() == 2 && args.at(0).isInt32()) {
+ // void set(in unsigned long index, in long value);
+ unsigned index = args.at(0).toUInt32(exec);
+ impl()->set(index, static_cast<signed char>(args.at(1).toInt32(exec)));
+ return jsUndefined();
+ }
+
+ WebGLUnsignedIntArray* array = toWebGLUnsignedIntArray(args.at(0));
+ if (array) {
+ // void set(in WebGLUnsignedIntArray array, [Optional] in unsigned long offset);
+ unsigned offset = 0;
+ if (args.size() == 2)
+ offset = args.at(1).toInt32(exec);
+ ExceptionCode ec = 0;
+ impl()->set(array, offset, ec);
+ setDOMException(exec, ec);
+ return jsUndefined();
+ }
+
+ return setWebGLArrayFromArray(exec, impl(), args);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/js/JSWebGLUnsignedShortArrayCustom.cpp b/WebCore/bindings/js/JSWebGLUnsignedShortArrayCustom.cpp
index e58dd89..898cc06 100644
--- a/WebCore/bindings/js/JSWebGLUnsignedShortArrayCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLUnsignedShortArrayCustom.cpp
@@ -27,6 +27,7 @@
#if ENABLE(3D_CANVAS)
+#include "JSWebGLArrayHelper.h"
#include "JSWebGLUnsignedShortArray.h"
#include "WebGLUnsignedShortArray.h"
@@ -45,6 +46,33 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLUn
return getDOMObjectWrapper<JSWebGLUnsignedShortArray>(exec, globalObject, object);
}
+JSC::JSValue JSWebGLUnsignedShortArray::set(JSC::ExecState* exec, JSC::ArgList const& args)
+{
+ if (args.size() > 2)
+ return throwError(exec, SyntaxError);
+
+ if (args.size() == 2 && args.at(0).isInt32()) {
+ // void set(in unsigned long index, in long value);
+ unsigned index = args.at(0).toUInt32(exec);
+ impl()->set(index, static_cast<signed char>(args.at(1).toInt32(exec)));
+ return jsUndefined();
+ }
+
+ WebGLUnsignedShortArray* array = toWebGLUnsignedShortArray(args.at(0));
+ if (array) {
+ // void set(in WebGLUnsignedShortArray array, [Optional] in unsigned long offset);
+ unsigned offset = 0;
+ if (args.size() == 2)
+ offset = args.at(1).toInt32(exec);
+ ExceptionCode ec = 0;
+ impl()->set(array, offset, ec);
+ setDOMException(exec, ec);
+ return jsUndefined();
+ }
+
+ return setWebGLArrayFromArray(exec, impl(), args);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 2a5879a..1fef83e 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -1746,25 +1746,9 @@ sub IsRefPtrType
{
my $type = shift;
return 1 if $type eq "Attr";
- return 1 if $type eq "WebGLActiveInfo";
- return 1 if $type eq "WebGLArray";
- return 1 if $type eq "WebGLArrayBuffer";
return 1 if $type eq "CanvasBooleanArray";
- return 1 if $type eq "WebGLByteArray";
- return 1 if $type eq "WebGLBuffer";
- return 1 if $type eq "WebGLFloatArray";
- return 1 if $type eq "WebGLFramebuffer";
return 1 if $type eq "CanvasGradient";
- return 1 if $type eq "WebGLIntArray";
return 1 if $type eq "CanvasObject";
- return 1 if $type eq "WebGLProgram";
- return 1 if $type eq "WebGLRenderbuffer";
- return 1 if $type eq "WebGLShader";
- return 1 if $type eq "WebGLShortArray";
- return 1 if $type eq "WebGLTexture";
- return 1 if $type eq "WebGLUnsignedByteArray";
- return 1 if $type eq "WebGLUnsignedIntArray";
- return 1 if $type eq "WebGLUnsignedShortArray";
return 1 if $type eq "ClientRect";
return 1 if $type eq "ClientRectList";
return 1 if $type eq "CDATASection";
@@ -1812,6 +1796,22 @@ sub IsRefPtrType
return 1 if $type eq "TextMetrics";
return 1 if $type eq "TimeRanges";
return 1 if $type eq "TreeWalker";
+ return 1 if $type eq "WebGLActiveInfo";
+ return 1 if $type eq "WebGLArray";
+ return 1 if $type eq "WebGLArrayBuffer";
+ return 1 if $type eq "WebGLByteArray";
+ return 1 if $type eq "WebGLBuffer";
+ return 1 if $type eq "WebGLFloatArray";
+ return 1 if $type eq "WebGLFramebuffer";
+ return 1 if $type eq "WebGLIntArray";
+ return 1 if $type eq "WebGLProgram";
+ return 1 if $type eq "WebGLRenderbuffer";
+ return 1 if $type eq "WebGLShader";
+ return 1 if $type eq "WebGLShortArray";
+ return 1 if $type eq "WebGLTexture";
+ return 1 if $type eq "WebGLUnsignedByteArray";
+ return 1 if $type eq "WebGLUnsignedIntArray";
+ return 1 if $type eq "WebGLUnsignedShortArray";
return 1 if $type eq "WebKitCSSMatrix";
return 1 if $type eq "WebKitPoint";
return 1 if $type eq "XPathExpression";
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index ddf8946..15f966e 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -31,7 +31,6 @@
#include "config.h"
#include "V8DOMWrapper.h"
-#include "WebGLArray.h"
#include "CSSMutableStyleDeclaration.h"
#include "ChromiumBridge.h"
#include "DOMObjectsInclude.h"
@@ -51,6 +50,7 @@
#include "V8Index.h"
#include "V8IsolatedWorld.h"
#include "V8Proxy.h"
+#include "WebGLArray.h"
#include "WorkerContextExecutionProxy.h"
#include <algorithm>
@@ -720,6 +720,27 @@ v8::Handle<v8::Value> V8DOMWrapper::convertToV8Object(V8ClassIndex::V8WrapperTyp
// Non DOM node
v8::Persistent<v8::Object> result = isActiveDomObject ? getActiveDOMObjectMap().get(impl) : getDOMObjectMap().get(impl);
if (result.IsEmpty()) {
+#if ENABLE(3D_CANVAS)
+ if (type == V8ClassIndex::WEBGLARRAY && impl) {
+ // Determine which subclass we are wrapping.
+ WebGLArray* array = reinterpret_cast<WebGLArray*>(impl);
+ if (array->isByteArray())
+ type = V8ClassIndex::WEBGLBYTEARRAY;
+ else if (array->isFloatArray())
+ type = V8ClassIndex::WEBGLFLOATARRAY;
+ else if (array->isIntArray())
+ type = V8ClassIndex::WEBGLINTARRAY;
+ else if (array->isShortArray())
+ type = V8ClassIndex::WEBGLSHORTARRAY;
+ else if (array->isUnsignedByteArray())
+ type = V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY;
+ else if (array->isUnsignedIntArray())
+ type = V8ClassIndex::WEBGLUNSIGNEDINTARRAY;
+ else if (array->isUnsignedShortArray())
+ type = V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY;
+ }
+#endif
+
v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, impl);
if (!v8Object.IsEmpty()) {
// Go through big switch statement, it has some duplications
diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h
index c29f491..2dc02b7 100644
--- a/WebCore/bindings/v8/custom/V8CustomBinding.h
+++ b/WebCore/bindings/v8/custom/V8CustomBinding.h
@@ -531,30 +531,42 @@ namespace WebCore {
DECLARE_NAMED_PROPERTY_GETTER(HTMLAllCollection);
DECLARE_NAMED_PROPERTY_GETTER(HTMLCollection);
+ DECLARE_INDEXED_PROPERTY_GETTER(CanvasPixelArray);
+ DECLARE_INDEXED_PROPERTY_SETTER(CanvasPixelArray);
+
#if ENABLE(3D_CANVAS)
+ DECLARE_CALLBACK(WebGLByteArrayGet);
+ DECLARE_CALLBACK(WebGLByteArraySet);
DECLARE_INDEXED_PROPERTY_GETTER(WebGLByteArray);
DECLARE_INDEXED_PROPERTY_SETTER(WebGLByteArray);
+ DECLARE_CALLBACK(WebGLFloatArrayGet);
+ DECLARE_CALLBACK(WebGLFloatArraySet);
DECLARE_INDEXED_PROPERTY_GETTER(WebGLFloatArray);
DECLARE_INDEXED_PROPERTY_SETTER(WebGLFloatArray);
+ DECLARE_CALLBACK(WebGLIntArrayGet);
+ DECLARE_CALLBACK(WebGLIntArraySet);
DECLARE_INDEXED_PROPERTY_GETTER(WebGLIntArray);
DECLARE_INDEXED_PROPERTY_SETTER(WebGLIntArray);
-#endif
- DECLARE_INDEXED_PROPERTY_GETTER(CanvasPixelArray);
- DECLARE_INDEXED_PROPERTY_SETTER(CanvasPixelArray);
-
-#if ENABLE(3D_CANVAS)
+ DECLARE_CALLBACK(WebGLShortArrayGet);
+ DECLARE_CALLBACK(WebGLShortArraySet);
DECLARE_INDEXED_PROPERTY_GETTER(WebGLShortArray);
DECLARE_INDEXED_PROPERTY_SETTER(WebGLShortArray);
+ DECLARE_CALLBACK(WebGLUnsignedByteArrayGet);
+ DECLARE_CALLBACK(WebGLUnsignedByteArraySet);
DECLARE_INDEXED_PROPERTY_GETTER(WebGLUnsignedByteArray);
DECLARE_INDEXED_PROPERTY_SETTER(WebGLUnsignedByteArray);
+ DECLARE_CALLBACK(WebGLUnsignedIntArrayGet);
+ DECLARE_CALLBACK(WebGLUnsignedIntArraySet);
DECLARE_INDEXED_PROPERTY_GETTER(WebGLUnsignedIntArray);
DECLARE_INDEXED_PROPERTY_SETTER(WebGLUnsignedIntArray);
+ DECLARE_CALLBACK(WebGLUnsignedShortArrayGet);
+ DECLARE_CALLBACK(WebGLUnsignedShortArraySet);
DECLARE_INDEXED_PROPERTY_GETTER(WebGLUnsignedShortArray);
DECLARE_INDEXED_PROPERTY_SETTER(WebGLUnsignedShortArray);
#endif
diff --git a/WebCore/bindings/v8/custom/V8WebGLArrayBufferCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLArrayBufferCustom.cpp
index 6aa404e..699667e 100644
--- a/WebCore/bindings/v8/custom/V8WebGLArrayBufferCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLArrayBufferCustom.cpp
@@ -43,12 +43,22 @@ namespace WebCore {
CALLBACK_FUNC_DECL(WebGLArrayBufferConstructor)
{
- INC_STATS("DOM.WebGLArrayBuffer.Contructor");
+ INC_STATS("DOM.WebGLArrayBuffer.Constructor");
if (!args.IsConstructCall())
return throwError("DOM object constructor cannot be called as a function.");
int argLen = args.Length();
+ if (argLen == 0) {
+ // This happens when we return a previously constructed
+ // WebGLArrayBuffer, e.g. from the call to WebGLArray.buffer.
+ // The V8DOMWrapper will set the internal pointer in the
+ // created object. Unfortunately it doesn't look like it's
+ // possible to distinguish between this case and that where
+ // the user calls "new WebGLArrayBuffer()" from JavaScript.
+ return args.Holder();
+ }
+
// Supported constructors:
// WebGLArrayBuffer(n) where n is an integer:
// -- create an empty buffer of n bytes
diff --git a/WebCore/bindings/v8/custom/V8WebGLArrayCustom.h b/WebCore/bindings/v8/custom/V8WebGLArrayCustom.h
index 4c1259d..1a4b6a4 100644
--- a/WebCore/bindings/v8/custom/V8WebGLArrayCustom.h
+++ b/WebCore/bindings/v8/custom/V8WebGLArrayCustom.h
@@ -41,95 +41,64 @@
namespace WebCore {
- // Template function used by the WebGLArray*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 WebGLArrayBuffer
- // "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 WebGLArrayBuffer.
- if (V8WebGLArrayBuffer::HasInstance(args[0])) {
- if (argLen > 3)
- return throwError("Wrong number of arguments to new Canvas<T>Array(WebGLArrayBuffer, int, int)");
-
- WebGLArrayBuffer* buf =
+// Template function used by the WebGLArray*Constructor callbacks.
+template<class ArrayClass>
+v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args,
+ int classIndex)
+{
+ if (!args.IsConstructCall())
+ return throwError("DOM object constructor cannot be called as a function.");
+
+ int argLen = args.Length();
+ if (argLen == 0) {
+ // This happens when we return a previously constructed
+ // WebGLArray, e.g. from the call to WebGL<T>Array.slice().
+ // The V8DOMWrapper will set the internal pointer in the
+ // created object. Unfortunately it doesn't look like it's
+ // possible to distinguish between this case and that where
+ // the user calls "new WebGL<T>Array()" from JavaScript.
+ return args.Holder();
+ }
+
+ // Supported constructors:
+ // WebGL<T>Array(n) where n is an integer:
+ // -- create an empty array of n elements
+ // WebGL<T>Array(arr) where arr is an array:
+ // -- create a WebGL<T>Array containing the contents of "arr"
+ // WebGL<T>Array(buf, offset, length)
+ // -- create a WebGL<T>Array pointing to the WebGLArrayBuffer
+ // "buf", starting at the specified offset, for the given
+ // length
+
+ // See whether the first argument is a WebGLArrayBuffer.
+ if (V8WebGLArrayBuffer::HasInstance(args[0])) {
+ if (argLen > 3)
+ return throwError("Wrong number of arguments to new WebGL<T>Array(WebGLArrayBuffer, int, int)");
+
+ WebGLArrayBuffer* buf =
V8DOMWrapper::convertToNativeObject<WebGLArrayBuffer>(V8ClassIndex::WEBGLARRAYBUFFER,
- args[0]->ToObject());
- if (buf == NULL)
- return throwError("Could not convert argument 0 to a WebGLArrayBuffer");
- 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(WebGLArrayBuffer, int, int)");
- // Transform the holder into a wrapper object for the array.
- V8DOMWrapper::setDOMWrapper(args.Holder(), classIndex, array.get());
- V8DOMWrapper::setIndexedPropertiesToExternalArray(args.Holder(),
- classIndex,
- array.get()->baseAddress(),
- array.get()->length());
- return toV8(array.release(), args.Holder());
+ args[0]->ToObject());
+ if (buf == NULL)
+ return throwError("Could not convert argument 0 to a WebGLArrayBuffer");
+ 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 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 WebGLArray.
- 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());
- }
+ 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 WebGL<T>Array(WebGLArrayBuffer, int, int)");
// Transform the holder into a wrapper object for the array.
V8DOMWrapper::setDOMWrapper(args.Holder(), classIndex, array.get());
V8DOMWrapper::setIndexedPropertiesToExternalArray(args.Holder(),
@@ -139,6 +108,113 @@ namespace WebCore {
return toV8(array.release(), args.Holder());
}
+ int len = 0;
+ v8::Handle<v8::Object> srcArray;
+ if (argLen != 1)
+ return throwError("Wrong number of arguments to new WebGL<T>Array(int / array)");
+
+ if (args[0]->IsInt32()) {
+ len = toInt32(args[0]);
+ } else if (args[0]->IsObject()) {
+ srcArray = args[0]->ToObject();
+ if (srcArray.IsEmpty())
+ return throwError("Could not convert argument 0 to an object");
+ len = toInt32(srcArray->Get(v8::String::New("length")));
+ } else
+ return throwError("Could not convert argument 0 to either an int32 or an object");
+
+ RefPtr<ArrayClass> array = ArrayClass::create(len);
+ if (!srcArray.IsEmpty()) {
+ // Need to copy the incoming array into the newly created WebGLArray.
+ for (int i = 0; i < len; i++) {
+ v8::Local<v8::Value> val = srcArray->Get(v8::Integer::New(i));
+ array->set(i, val->NumberValue());
+ }
+ }
+
+ // Transform the holder into a wrapper object for the array.
+ V8DOMWrapper::setDOMWrapper(args.Holder(), classIndex, array.get());
+ V8DOMWrapper::setIndexedPropertiesToExternalArray(args.Holder(),
+ classIndex,
+ array.get()->baseAddress(),
+ array.get()->length());
+ return toV8(array.release(), args.Holder());
+}
+
+template <class T, typename ElementType>
+v8::Handle<v8::Value> getWebGLArrayElement(const v8::Arguments& args,
+ V8ClassIndex::V8WrapperType wrapperType)
+{
+ if (args.Length() != 1) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ bool ok;
+ uint32_t index = toInt32(args[0], ok);
+ if (!ok) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+ T* array = V8DOMWrapper::convertToNativeObject<T>(wrapperType, args.Holder());
+ if (index >= array->length())
+ return v8::Undefined();
+ ElementType result;
+ if (!array->get(index, result))
+ return v8::Undefined();
+ return v8::Number::New(result);
+}
+
+template <class T>
+v8::Handle<v8::Value> setWebGLArrayFromArray(T* webGLArray, const v8::Arguments& args)
+{
+ if (args[0]->IsObject()) {
+ // void set(in sequence<long> array, [Optional] in unsigned long offset);
+ v8::Local<v8::Object> array = args[0]->ToObject();
+ uint32_t offset = 0;
+ if (args.Length() == 2)
+ offset = toInt32(args[1]);
+ uint32_t length = toInt32(array->Get(v8::String::New("length")));
+ for (uint32_t i = 0; i < length; i++) {
+ webGLArray->set(offset + i, array->Get(v8::Integer::New(i))->NumberValue());
+ }
+ }
+
+ return v8::Undefined();
+}
+
+template <class CPlusPlusArrayType, class JavaScriptWrapperArrayType>
+v8::Handle<v8::Value> setWebGLArray(const v8::Arguments& args,
+ V8ClassIndex::V8WrapperType wrapperType)
+{
+ if (args.Length() < 1 || args.Length() > 2) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ CPlusPlusArrayType* array = V8DOMWrapper::convertToNativeObject<CPlusPlusArrayType>(wrapperType, args.Holder());
+
+ if (args.Length() == 2 && args[0]->IsInt32()) {
+ // void set(in unsigned long index, in long value);
+ uint32_t index = toInt32(args[0]);
+ array->set(index, args[1]->NumberValue());
+ return v8::Undefined();
+ }
+
+ if (JavaScriptWrapperArrayType::HasInstance(args[0])) {
+ // void set(in WebGL<T>Array array, [Optional] in unsigned long offset);
+ CPlusPlusArrayType* src = V8DOMWrapper::convertToNativeObject<CPlusPlusArrayType>(wrapperType, args[0]->ToObject());
+ uint32_t offset = 0;
+ if (args.Length() == 2)
+ offset = toInt32(args[1]);
+ ExceptionCode ec = 0;
+ array->set(src, offset, ec);
+ V8Proxy::setDOMException(ec);
+ return v8::Undefined();
+ }
+
+ return setWebGLArrayFromArray(array, args);
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
index 2a85e14..5719c8a 100644
--- a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8WebGLArrayBuffer.h"
#include "V8WebGLArrayCustom.h"
+#include "V8WebGLByteArray.h"
#include "V8CustomBinding.h"
#include "V8Proxy.h"
@@ -47,7 +48,7 @@ CALLBACK_FUNC_DECL(WebGLByteArrayConstructor)
{
INC_STATS("DOM.WebGLByteArray.Contructor");
- return constructCanvasArray<WebGLByteArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLBYTEARRAY));
+ return constructWebGLArray<WebGLByteArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLBYTEARRAY));
}
// 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".
@@ -78,6 +79,18 @@ INDEXED_PROPERTY_SETTER(WebGLByteArray)
return value;
}
+CALLBACK_FUNC_DECL(WebGLByteArrayGet)
+{
+ INC_STATS("DOM.WebGLByteArray.get()");
+ return getWebGLArrayElement<WebGLByteArray, signed char>(args, V8ClassIndex::WEBGLBYTEARRAY);
+}
+
+CALLBACK_FUNC_DECL(WebGLByteArraySet)
+{
+ INC_STATS("DOM.WebGLByteArray.set()");
+ return setWebGLArray<WebGLByteArray, V8WebGLByteArray>(args, V8ClassIndex::WEBGLBYTEARRAY);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
index 7d66a84..6e56760 100644
--- a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8WebGLArrayBuffer.h"
#include "V8WebGLArrayCustom.h"
+#include "V8WebGLFloatArray.h"
#include "V8CustomBinding.h"
#include "V8Proxy.h"
@@ -47,7 +48,7 @@ CALLBACK_FUNC_DECL(WebGLFloatArrayConstructor)
{
INC_STATS("DOM.WebGLFloatArray.Contructor");
- return constructCanvasArray<WebGLFloatArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLFLOATARRAY));
+ return constructWebGLArray<WebGLFloatArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLFLOATARRAY));
}
// 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".
@@ -75,6 +76,18 @@ INDEXED_PROPERTY_SETTER(WebGLFloatArray)
return value;
}
+CALLBACK_FUNC_DECL(WebGLFloatArrayGet)
+{
+ INC_STATS("DOM.WebGLFloatArray.get()");
+ return getWebGLArrayElement<WebGLFloatArray, float>(args, V8ClassIndex::WEBGLFLOATARRAY);
+}
+
+CALLBACK_FUNC_DECL(WebGLFloatArraySet)
+{
+ INC_STATS("DOM.WebGLFloatArray.set()");
+ return setWebGLArray<WebGLFloatArray, V8WebGLFloatArray>(args, V8ClassIndex::WEBGLFLOATARRAY);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
index 31c90cd..1bd30b2 100644
--- a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8WebGLArrayBuffer.h"
#include "V8WebGLArrayCustom.h"
+#include "V8WebGLIntArray.h"
#include "V8CustomBinding.h"
#include "V8Proxy.h"
@@ -47,7 +48,7 @@ CALLBACK_FUNC_DECL(WebGLIntArrayConstructor)
{
INC_STATS("DOM.WebGLIntArray.Contructor");
- return constructCanvasArray<WebGLIntArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLINTARRAY));
+ return constructWebGLArray<WebGLIntArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLINTARRAY));
}
// 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".
@@ -78,6 +79,18 @@ INDEXED_PROPERTY_SETTER(WebGLIntArray)
return value;
}
+CALLBACK_FUNC_DECL(WebGLIntArrayGet)
+{
+ INC_STATS("DOM.WebGLIntArray.get()");
+ return getWebGLArrayElement<WebGLIntArray, int>(args, V8ClassIndex::WEBGLINTARRAY);
+}
+
+CALLBACK_FUNC_DECL(WebGLIntArraySet)
+{
+ INC_STATS("DOM.WebGLIntArray.set()");
+ return setWebGLArray<WebGLIntArray, V8WebGLIntArray>(args, V8ClassIndex::WEBGLINTARRAY);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
index 7234d75..f8a26c3 100644
--- a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8WebGLArrayBuffer.h"
#include "V8WebGLArrayCustom.h"
+#include "V8WebGLShortArray.h"
#include "V8CustomBinding.h"
#include "V8Proxy.h"
@@ -47,7 +48,7 @@ CALLBACK_FUNC_DECL(WebGLShortArrayConstructor)
{
INC_STATS("DOM.WebGLShortArray.Contructor");
- return constructCanvasArray<WebGLShortArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLSHORTARRAY));
+ return constructWebGLArray<WebGLShortArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLSHORTARRAY));
}
// 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".
@@ -78,6 +79,18 @@ INDEXED_PROPERTY_SETTER(WebGLShortArray)
return value;
}
+CALLBACK_FUNC_DECL(WebGLShortArrayGet)
+{
+ INC_STATS("DOM.WebGLShortArray.get()");
+ return getWebGLArrayElement<WebGLShortArray, short>(args, V8ClassIndex::WEBGLSHORTARRAY);
+}
+
+CALLBACK_FUNC_DECL(WebGLShortArraySet)
+{
+ INC_STATS("DOM.WebGLShortArray.set()");
+ return setWebGLArray<WebGLShortArray, V8WebGLShortArray>(args, V8ClassIndex::WEBGLSHORTARRAY);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
index 124f09f..391f213 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8WebGLArrayBuffer.h"
#include "V8WebGLArrayCustom.h"
+#include "V8WebGLUnsignedByteArray.h"
#include "V8CustomBinding.h"
#include "V8Proxy.h"
@@ -47,7 +48,7 @@ CALLBACK_FUNC_DECL(WebGLUnsignedByteArrayConstructor)
{
INC_STATS("DOM.WebGLUnsignedByteArray.Contructor");
- return constructCanvasArray<WebGLUnsignedByteArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY));
+ return constructWebGLArray<WebGLUnsignedByteArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY));
}
// 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".
@@ -78,6 +79,18 @@ INDEXED_PROPERTY_SETTER(WebGLUnsignedByteArray)
return value;
}
+CALLBACK_FUNC_DECL(WebGLUnsignedByteArrayGet)
+{
+ INC_STATS("DOM.WebGLUnsignedByteArray.get()");
+ return getWebGLArrayElement<WebGLUnsignedByteArray, unsigned char>(args, V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY);
+}
+
+CALLBACK_FUNC_DECL(WebGLUnsignedByteArraySet)
+{
+ INC_STATS("DOM.WebGLUnsignedByteArray.set()");
+ return setWebGLArray<WebGLUnsignedByteArray, V8WebGLUnsignedByteArray>(args, V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
index c1f7f9d..92b9fe0 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8WebGLArrayBuffer.h"
#include "V8WebGLArrayCustom.h"
+#include "V8WebGLUnsignedIntArray.h"
#include "V8CustomBinding.h"
#include "V8Proxy.h"
@@ -47,7 +48,7 @@ CALLBACK_FUNC_DECL(WebGLUnsignedIntArrayConstructor)
{
INC_STATS("DOM.WebGLUnsignedIntArray.Contructor");
- return constructCanvasArray<WebGLUnsignedIntArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLUNSIGNEDINTARRAY));
+ return constructWebGLArray<WebGLUnsignedIntArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLUNSIGNEDINTARRAY));
}
// 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".
@@ -78,6 +79,18 @@ INDEXED_PROPERTY_SETTER(WebGLUnsignedIntArray)
return value;
}
+CALLBACK_FUNC_DECL(WebGLUnsignedIntArrayGet)
+{
+ INC_STATS("DOM.WebGLUnsignedIntArray.get()");
+ return getWebGLArrayElement<WebGLUnsignedIntArray, unsigned int>(args, V8ClassIndex::WEBGLUNSIGNEDINTARRAY);
+}
+
+CALLBACK_FUNC_DECL(WebGLUnsignedIntArraySet)
+{
+ INC_STATS("DOM.WebGLUnsignedIntArray.set()");
+ return setWebGLArray<WebGLUnsignedIntArray, V8WebGLUnsignedIntArray>(args, V8ClassIndex::WEBGLUNSIGNEDINTARRAY);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
index 394edf2..ce261e9 100644
--- a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8WebGLArrayBuffer.h"
#include "V8WebGLArrayCustom.h"
+#include "V8WebGLUnsignedShortArray.h"
#include "V8CustomBinding.h"
#include "V8Proxy.h"
@@ -47,7 +48,7 @@ CALLBACK_FUNC_DECL(WebGLUnsignedShortArrayConstructor)
{
INC_STATS("DOM.WebGLUnsignedShortArray.Contructor");
- return constructCanvasArray<WebGLUnsignedShortArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY));
+ return constructWebGLArray<WebGLUnsignedShortArray>(args, V8ClassIndex::ToInt(V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY));
}
// 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".
@@ -78,6 +79,18 @@ INDEXED_PROPERTY_SETTER(WebGLUnsignedShortArray)
return value;
}
+CALLBACK_FUNC_DECL(WebGLUnsignedShortArrayGet)
+{
+ INC_STATS("DOM.WebGLUnsignedShortArray.get()");
+ return getWebGLArrayElement<WebGLUnsignedShortArray, unsigned short>(args, V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY);
+}
+
+CALLBACK_FUNC_DECL(WebGLUnsignedShortArraySet)
+{
+ INC_STATS("DOM.WebGLUnsignedShortArray.set()");
+ return setWebGLArray<WebGLUnsignedShortArray, V8WebGLUnsignedShortArray>(args, V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLArray.cpp b/WebCore/html/canvas/WebGLArray.cpp
index 4530411..c5a712d 100644
--- a/WebCore/html/canvas/WebGLArray.cpp
+++ b/WebCore/html/canvas/WebGLArray.cpp
@@ -31,22 +31,30 @@
#include "WebGLArrayBuffer.h"
namespace WebCore {
- WebGLArray::WebGLArray(PassRefPtr<WebGLArrayBuffer> buffer,
- unsigned offset)
- : m_offset(offset)
+
+WebGLArray::WebGLArray(PassRefPtr<WebGLArrayBuffer> buffer,
+ unsigned byteOffset)
+ : m_byteOffset(byteOffset)
, m_buffer(buffer)
- {
- m_baseAddress = m_buffer ? (static_cast<char*>(m_buffer->data()) + m_offset) : 0;
- }
+{
+ m_baseAddress = m_buffer ? (static_cast<char*>(m_buffer->data()) + m_byteOffset) : 0;
+}
- WebGLArray::~WebGLArray()
- {
- }
+WebGLArray::~WebGLArray()
+{
+}
- unsigned WebGLArray::alignedSizeInBytes() const {
- // Assume we only need to round up to 4-byte boundaries for alignment.
- return ((sizeInBytes() + 3) / 4) * 4;
+void WebGLArray::setImpl(WebGLArray* array, unsigned byteOffset, ExceptionCode& ec)
+{
+ if (byteOffset + array->byteLength() > byteLength()) {
+ ec = INDEX_SIZE_ERR;
+ return;
}
+
+ char* base = static_cast<char*>(baseAddress());
+ memcpy(base + byteOffset, array->baseAddress(), array->byteLength());
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLArray.h b/WebCore/html/canvas/WebGLArray.h
index 70ed64d..11065cc 100644
--- a/WebCore/html/canvas/WebGLArray.h
+++ b/WebCore/html/canvas/WebGLArray.h
@@ -26,50 +26,56 @@
#ifndef WebGLArray_h
#define WebGLArray_h
+#include "ExceptionCode.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include "WebGLArrayBuffer.h"
namespace WebCore {
- class WebGLArray : public RefCounted<WebGLArray> {
- public:
- virtual bool isByteArray() const { return false; }
- virtual bool isUnsignedByteArray() const { return false; }
- virtual bool isShortArray() const { return false; }
- virtual bool isUnsignedShortArray() const { return false; }
- virtual bool isIntArray() const { return false; }
- virtual bool isUnsignedIntArray() const { return false; }
- virtual bool isFloatArray() const { return false; }
-
- PassRefPtr<WebGLArrayBuffer> buffer() {
- return m_buffer;
- }
-
- void* baseAddress() {
- return m_baseAddress;
- }
-
- unsigned offset() const {
- return m_offset;
- }
-
- virtual unsigned length() const = 0;
- virtual unsigned sizeInBytes() const = 0;
- virtual unsigned alignedSizeInBytes() const;
- virtual ~WebGLArray();
-
- protected:
- WebGLArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned offset);
-
- // This is the address of the WebGLArrayBuffer's storage, plus the offset.
- void* m_baseAddress;
- unsigned m_offset;
-
- private:
- RefPtr<WebGLArrayBuffer> m_buffer;
- };
-
+
+class WebGLArray : public RefCounted<WebGLArray> {
+ public:
+ virtual bool isByteArray() const { return false; }
+ virtual bool isUnsignedByteArray() const { return false; }
+ virtual bool isShortArray() const { return false; }
+ virtual bool isUnsignedShortArray() const { return false; }
+ virtual bool isIntArray() const { return false; }
+ virtual bool isUnsignedIntArray() const { return false; }
+ virtual bool isFloatArray() const { return false; }
+
+ PassRefPtr<WebGLArrayBuffer> buffer() {
+ return m_buffer;
+ }
+
+ void* baseAddress() {
+ return m_baseAddress;
+ }
+
+ unsigned byteOffset() const {
+ return m_byteOffset;
+ }
+
+ virtual unsigned length() const = 0;
+ virtual unsigned byteLength() const = 0;
+ virtual PassRefPtr<WebGLArray> slice(unsigned offset, unsigned length) = 0;
+
+ virtual ~WebGLArray();
+
+ protected:
+ WebGLArray(PassRefPtr<WebGLArrayBuffer> buffer, unsigned byteOffset);
+
+ void setImpl(WebGLArray* array, unsigned byteOffset, ExceptionCode& ec);
+
+ // This is the address of the WebGLArrayBuffer's storage, plus the byte offset.
+ void* m_baseAddress;
+
+ unsigned m_byteOffset;
+
+ private:
+ RefPtr<WebGLArrayBuffer> m_buffer;
+};
+
} // namespace WebCore
#endif // WebGLArray_h
diff --git a/WebCore/html/canvas/WebGLArray.idl b/WebCore/html/canvas/WebGLArray.idl
index de46d89..156ca5b 100644
--- a/WebCore/html/canvas/WebGLArray.idl
+++ b/WebCore/html/canvas/WebGLArray.idl
@@ -25,8 +25,11 @@
module html {
interface [Conditional=3D_CANVAS, CustomToJS] WebGLArray {
- readonly attribute long length;
- int sizeInBytes();
- int alignedSizeInBytes();
+ readonly attribute WebGLArrayBuffer buffer;
+ readonly attribute unsigned long byteOffset;
+ readonly attribute unsigned long byteLength;
+ readonly attribute unsigned long length;
+
+ WebGLArray slice(in unsigned long offset, in unsigned long length);
};
}
diff --git a/WebCore/html/canvas/WebGLArrayBuffer.cpp b/WebCore/html/canvas/WebGLArrayBuffer.cpp
index 3605849..8a7da01 100644
--- a/WebCore/html/canvas/WebGLArrayBuffer.cpp
+++ b/WebCore/html/canvas/WebGLArrayBuffer.cpp
@@ -30,28 +30,29 @@
#include "WebGLArrayBuffer.h"
namespace WebCore {
-
- PassRefPtr<WebGLArrayBuffer> WebGLArrayBuffer::create(unsigned sizeInBytes)
- {
- return adoptRef(new WebGLArrayBuffer(sizeInBytes));
- }
-
- WebGLArrayBuffer::WebGLArrayBuffer(unsigned sizeInBytes) {
- m_sizeInBytes = sizeInBytes;
- m_data = WTF::fastZeroedMalloc(sizeInBytes);
- }
-
- void* WebGLArrayBuffer::data() {
- return m_data;
- }
-
- unsigned WebGLArrayBuffer::byteLength() const {
- return m_sizeInBytes;
- }
-
- WebGLArrayBuffer::~WebGLArrayBuffer() {
- WTF::fastFree(m_data);
- }
+
+PassRefPtr<WebGLArrayBuffer> WebGLArrayBuffer::create(unsigned sizeInBytes)
+{
+ return adoptRef(new WebGLArrayBuffer(sizeInBytes));
+}
+
+WebGLArrayBuffer::WebGLArrayBuffer(unsigned sizeInBytes) {
+ m_sizeInBytes = sizeInBytes;
+ m_data = WTF::fastZeroedMalloc(sizeInBytes);
+}
+
+void* WebGLArrayBuffer::data() {
+ return m_data;
+}
+
+unsigned WebGLArrayBuffer::byteLength() const {
+ return m_sizeInBytes;
+}
+
+WebGLArrayBuffer::~WebGLArrayBuffer() {
+ WTF::fastFree(m_data);
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLArrayBuffer.h b/WebCore/html/canvas/WebGLArrayBuffer.h
index 4c0abde..ffbbef1 100644
--- a/WebCore/html/canvas/WebGLArrayBuffer.h
+++ b/WebCore/html/canvas/WebGLArrayBuffer.h
@@ -30,22 +30,22 @@
#include <wtf/RefCounted.h>
namespace WebCore {
-
- class WebGLArrayBuffer : public RefCounted<WebGLArrayBuffer> {
- public:
- static PassRefPtr<WebGLArrayBuffer> create(unsigned sizeInBytes);
-
- void* data();
- unsigned byteLength() const;
-
- ~WebGLArrayBuffer();
-
- private:
- WebGLArrayBuffer(unsigned sizeInBytes);
- unsigned m_sizeInBytes;
- void* m_data;
- };
-
+
+class WebGLArrayBuffer : public RefCounted<WebGLArrayBuffer> {
+ public:
+ static PassRefPtr<WebGLArrayBuffer> create(unsigned sizeInBytes);
+
+ void* data();
+ unsigned byteLength() const;
+
+ ~WebGLArrayBuffer();
+
+ private:
+ WebGLArrayBuffer(unsigned sizeInBytes);
+ unsigned m_sizeInBytes;
+ void* m_data;
+};
+
} // namespace WebCore
#endif // WebGLArrayBuffer_h
diff --git a/WebCore/html/canvas/WebGLByteArray.cpp b/WebCore/html/canvas/WebGLByteArray.cpp
index 1b1c7bd..1c2849b 100644
--- a/WebCore/html/canvas/WebGLByteArray.cpp
+++ b/WebCore/html/canvas/WebGLByteArray.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -31,7 +32,7 @@
#include "WebGLByteArray.h"
namespace WebCore {
-
+
PassRefPtr<WebGLByteArray> WebGLByteArray::create(unsigned length)
{
RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(signed char));
@@ -46,16 +47,16 @@ PassRefPtr<WebGLByteArray> WebGLByteArray::create(signed char* array, unsigned l
return a;
}
-PassRefPtr<WebGLByteArray> WebGLByteArray::create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length)
+PassRefPtr<WebGLByteArray> WebGLByteArray::create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length)
{
if (buffer) {
// Check to make sure we are talking about a valid region of
// the given WebGLArrayBuffer's storage.
- if ((offset + (length * sizeof(signed char))) > buffer->byteLength())
+ if ((byteOffset + (length * sizeof(signed char))) > buffer->byteLength())
return NULL;
}
-
- return adoptRef(new WebGLByteArray(buffer, offset, length));
+
+ return adoptRef(new WebGLByteArray(buffer, byteOffset, length));
}
WebGLByteArray::WebGLByteArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length)
@@ -67,9 +68,24 @@ WebGLByteArray::WebGLByteArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset,
unsigned WebGLByteArray::length() const {
return m_size;
}
-
-unsigned WebGLByteArray::sizeInBytes() const {
- return length() * sizeof(signed char);
+
+unsigned WebGLByteArray::byteLength() const {
+ return m_size * sizeof(signed char);
+}
+
+PassRefPtr<WebGLArray> WebGLByteArray::slice(unsigned offset, unsigned length) {
+ // Check to make sure the specified region is within the bounds of
+ // the WebGLArrayBuffer.
+ unsigned startByte = m_byteOffset + offset * sizeof(signed char);
+ unsigned limitByte = startByte + length * sizeof(signed char);
+ unsigned bufferLength = buffer()->byteLength();
+ if (startByte >= bufferLength || limitByte > bufferLength)
+ return 0;
+ return create(buffer(), startByte, length);
+}
+
+void WebGLByteArray::set(WebGLByteArray* array, unsigned offset, ExceptionCode& ec) {
+ setImpl(array, offset * sizeof(signed char), ec);
}
}
diff --git a/WebCore/html/canvas/WebGLByteArray.h b/WebCore/html/canvas/WebGLByteArray.h
index 9146299..c517c03 100644
--- a/WebCore/html/canvas/WebGLByteArray.h
+++ b/WebCore/html/canvas/WebGLByteArray.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -33,58 +34,67 @@
#include <wtf/RefCounted.h>
namespace WebCore {
-
- class WebGLArrayBuffer;
-
- class WebGLByteArray : public WebGLArray {
- public:
- virtual bool isByteArray() const { return true; }
-
- static PassRefPtr<WebGLByteArray> create(unsigned length);
- static PassRefPtr<WebGLByteArray> create(signed char* array, unsigned length);
- static PassRefPtr<WebGLByteArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
-
- char* data() { return static_cast<char*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned sizeInBytes() const;
-
- void set(unsigned index, double value)
- {
- if (index >= m_size)
- return;
- if (isnan(value)) // Clamp NaN to 0
- value = 0;
- if (value < std::numeric_limits<signed char>::min())
- value = std::numeric_limits<signed char>::min();
- else if (value > std::numeric_limits<signed char>::max())
- value = std::numeric_limits<signed char>::max();
- signed char* storage = static_cast<signed char*>(m_baseAddress);
- storage[index] = static_cast<signed char>(value);
- }
-
- bool get(unsigned index, signed char& result) const
- {
- if (index >= m_size)
- return false;
- signed char* storage = static_cast<signed char*>(m_baseAddress);
- result = storage[index];
- return true;
- }
-
- signed char item(unsigned index) const
- {
- ASSERT(index < m_size);
- signed char* storage = static_cast<signed char*>(m_baseAddress);
- return storage[index];
- }
- private:
- WebGLByteArray(PassRefPtr<WebGLArrayBuffer> buffer,
- int offset,
- unsigned length);
- unsigned m_size;
- };
-
+
+class WebGLArrayBuffer;
+
+class WebGLByteArray : public WebGLArray {
+ public:
+ virtual bool isByteArray() const { return true; }
+
+ static PassRefPtr<WebGLByteArray> create(unsigned length);
+ static PassRefPtr<WebGLByteArray> create(signed char* array, unsigned length);
+ static PassRefPtr<WebGLByteArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
+
+ char* data() { return static_cast<char*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned byteLength() const;
+ virtual PassRefPtr<WebGLArray> slice(unsigned offset, unsigned length);
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<signed char>::min())
+ value = std::numeric_limits<signed char>::min();
+ else if (value > std::numeric_limits<signed char>::max())
+ value = std::numeric_limits<signed char>::max();
+ signed char* storage = static_cast<signed char*>(m_baseAddress);
+ storage[index] = static_cast<signed char>(value);
+ }
+
+ bool get(unsigned index, signed char& result) const
+ {
+ if (index >= m_size)
+ return false;
+ signed char* storage = static_cast<signed char*>(m_baseAddress);
+ result = storage[index];
+ return true;
+ }
+
+ signed char get(unsigned index) const
+ {
+ return item(index);
+ }
+
+ signed char item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ signed char* storage = static_cast<signed char*>(m_baseAddress);
+ return storage[index];
+ }
+
+ void set(WebGLByteArray* array, unsigned offset, ExceptionCode& ec);
+
+ private:
+ WebGLByteArray(PassRefPtr<WebGLArrayBuffer> buffer,
+ int offset,
+ unsigned length);
+ unsigned m_size;
+};
+
} // namespace WebCore
#endif // WebGLByteArray_h
diff --git a/WebCore/html/canvas/WebGLByteArray.idl b/WebCore/html/canvas/WebGLByteArray.idl
index 0df7c4e..054a912 100644
--- a/WebCore/html/canvas/WebGLByteArray.idl
+++ b/WebCore/html/canvas/WebGLByteArray.idl
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -32,5 +33,10 @@ module html {
GenerateCustomConstructor,
CustomToJS
] WebGLByteArray : WebGLArray {
+ long get(in unsigned long index);
+ // void set(in unsigned long index, in long value);
+ // void set(in WebGLByteArray 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/WebGLFloatArray.cpp b/WebCore/html/canvas/WebGLFloatArray.cpp
index dd47c8a..6192898 100644
--- a/WebCore/html/canvas/WebGLFloatArray.cpp
+++ b/WebCore/html/canvas/WebGLFloatArray.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -30,49 +31,65 @@
#include "WebGLFloatArray.h"
namespace WebCore {
-
- PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(unsigned length)
- {
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(float));
- return create(buffer, 0, length);
- }
- PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(float* array, unsigned length)
- {
- RefPtr<WebGLFloatArray> a = WebGLFloatArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
- }
+PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(unsigned length)
+{
+ RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(float));
+ return create(buffer, 0, length);
+}
- PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length)
- {
- // Make sure the offset results in valid alignment.
- if ((offset % sizeof(float)) != 0)
- return NULL;
+PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(float* array, unsigned length)
+{
+ RefPtr<WebGLFloatArray> a = WebGLFloatArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+}
+
+PassRefPtr<WebGLFloatArray> WebGLFloatArray::create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length)
+{
+ // Make sure the offset results in valid alignment.
+ if ((byteOffset % sizeof(float)) != 0)
+ return NULL;
- if (buffer) {
- // Check to make sure we are talking about a valid region of
- // the given WebGLArrayBuffer's storage.
- if ((offset + (length * sizeof(float))) > buffer->byteLength())
- return NULL;
- }
- return adoptRef(new WebGLFloatArray(buffer, offset, length));
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given WebGLArrayBuffer's storage.
+ if ((byteOffset + (length * sizeof(float))) > buffer->byteLength())
+ return NULL;
}
-
- WebGLFloatArray::WebGLFloatArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length)
- : WebGLArray(buffer, offset)
+ return adoptRef(new WebGLFloatArray(buffer, byteOffset, length));
+}
+
+WebGLFloatArray::WebGLFloatArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length)
+ : WebGLArray(buffer, byteOffset)
, m_size(length)
- {
- }
-
- unsigned WebGLFloatArray::length() const {
- return m_size;
- }
-
- unsigned WebGLFloatArray::sizeInBytes() const {
- return length() * sizeof(float);
- }
+{
+}
+
+unsigned WebGLFloatArray::length() const {
+ return m_size;
+}
+
+unsigned WebGLFloatArray::byteLength() const {
+ return m_size * sizeof(float);
+}
+
+PassRefPtr<WebGLArray> WebGLFloatArray::slice(unsigned offset, unsigned length) {
+ // Check to make sure the specified region is within the bounds of
+ // the WebGLArrayBuffer.
+ unsigned startByte = m_byteOffset + offset * sizeof(float);
+ unsigned limitByte = startByte + length * sizeof(float);
+ unsigned bufferLength = buffer()->byteLength();
+ if (startByte >= bufferLength || limitByte > bufferLength)
+ return 0;
+ return create(buffer(), startByte, length);
+}
+
+void WebGLFloatArray::set(WebGLFloatArray* array, unsigned offset, ExceptionCode& ec) {
+ setImpl(array, offset * sizeof(float), ec);
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLFloatArray.h b/WebCore/html/canvas/WebGLFloatArray.h
index 00a6c13..4607962 100644
--- a/WebCore/html/canvas/WebGLFloatArray.h
+++ b/WebCore/html/canvas/WebGLFloatArray.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -32,55 +33,63 @@
#include <wtf/RefCounted.h>
namespace WebCore {
-
- class WebGLFloatArray : public WebGLArray {
- public:
- virtual bool isFloatArray() const { return true; }
- static PassRefPtr<WebGLFloatArray> create(unsigned length);
- static PassRefPtr<WebGLFloatArray> create(float* array, unsigned length);
- static PassRefPtr<WebGLFloatArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
+class WebGLFloatArray : public WebGLArray {
+ public:
+ virtual bool isFloatArray() const { return true; }
- float* data() { return static_cast<float*>(baseAddress()); }
+ static PassRefPtr<WebGLFloatArray> create(unsigned length);
+ static PassRefPtr<WebGLFloatArray> create(float* array, unsigned length);
+ static PassRefPtr<WebGLFloatArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
- virtual unsigned length() const;
-
- virtual unsigned sizeInBytes() const;
+ float* data() { return static_cast<float*>(baseAddress()); }
- void set(unsigned index, double value)
- {
- if (index >= m_size)
- return;
- if (isnan(value)) // Clamp NaN to 0
- value = 0;
- float* storage = static_cast<float*>(m_baseAddress);
- storage[index] = static_cast<float>(value);
- }
-
- bool get(unsigned index, float& result) const
- {
- if (index >= m_size)
- return false;
- result = item(index);
- return true;
- }
-
- float item(unsigned index) const
- {
- ASSERT(index < m_size);
- float* storage = static_cast<float*>(m_baseAddress);
- float result = storage[index];
- if (isnan(result)) {
- // Clamp NaN to 0
- result = 0;
- }
- return result;
+ virtual unsigned length() const;
+ virtual unsigned byteLength() const;
+ virtual PassRefPtr<WebGLArray> slice(unsigned offset, unsigned length);
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ float* storage = static_cast<float*>(m_baseAddress);
+ storage[index] = static_cast<float>(value);
+ }
+
+ bool get(unsigned index, float& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ float get(unsigned index) const
+ {
+ return item(index);
+ }
+
+ float item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ float* storage = static_cast<float*>(m_baseAddress);
+ float result = storage[index];
+ if (isnan(result)) {
+ // Clamp NaN to 0
+ result = 0;
}
- private:
- WebGLFloatArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
- unsigned m_size;
- };
-
+ return result;
+ }
+
+ void set(WebGLFloatArray* array, unsigned offset, ExceptionCode& ec);
+
+ private:
+ WebGLFloatArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
+ unsigned m_size;
+};
+
} // namespace WebCore
#endif // WebGLFloatArray_h
diff --git a/WebCore/html/canvas/WebGLFloatArray.idl b/WebCore/html/canvas/WebGLFloatArray.idl
index bc8f57b..83479b3 100644
--- a/WebCore/html/canvas/WebGLFloatArray.idl
+++ b/WebCore/html/canvas/WebGLFloatArray.idl
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * 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
@@ -32,5 +33,10 @@ module html {
GenerateCustomConstructor,
CustomToJS
] WebGLFloatArray : WebGLArray {
+ long get(in unsigned long index);
+ // void set(in unsigned long index, in long value);
+ // void set(in WebGLFloatArray 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/WebGLIntArray.cpp b/WebCore/html/canvas/WebGLIntArray.cpp
index 0992d2c..4617010 100644
--- a/WebCore/html/canvas/WebGLIntArray.cpp
+++ b/WebCore/html/canvas/WebGLIntArray.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -31,52 +32,68 @@
#include "WebGLIntArray.h"
namespace WebCore {
-
- PassRefPtr<WebGLIntArray> WebGLIntArray::create(unsigned length)
- {
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(int));
- return create(buffer, 0, length);
- }
- PassRefPtr<WebGLIntArray> WebGLIntArray::create(int* array, unsigned length)
- {
- RefPtr<WebGLIntArray> a = WebGLIntArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
- }
+PassRefPtr<WebGLIntArray> WebGLIntArray::create(unsigned length)
+{
+ RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(int));
+ return create(buffer, 0, length);
+}
- PassRefPtr<WebGLIntArray> WebGLIntArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- int offset,
- unsigned length)
- {
- // Make sure the offset results in valid alignment.
- if ((offset % sizeof(int)) != 0)
- return NULL;
+PassRefPtr<WebGLIntArray> WebGLIntArray::create(int* array, unsigned length)
+{
+ RefPtr<WebGLIntArray> a = WebGLIntArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+}
+
+PassRefPtr<WebGLIntArray> WebGLIntArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
+ int byteOffset,
+ unsigned length)
+{
+ // Make sure the offset results in valid alignment.
+ if ((byteOffset % sizeof(int)) != 0)
+ return NULL;
- if (buffer) {
- // Check to make sure we are talking about a valid region of
- // the given WebGLArrayBuffer's storage.
- if ((offset + (length * sizeof(int))) > buffer->byteLength())
- return NULL;
- }
-
- return adoptRef(new WebGLIntArray(buffer, offset, length));
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given WebGLArrayBuffer's storage.
+ if ((byteOffset + (length * sizeof(int))) > buffer->byteLength())
+ return NULL;
}
-
- WebGLIntArray::WebGLIntArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length)
- : WebGLArray(buffer, offset)
+
+ return adoptRef(new WebGLIntArray(buffer, byteOffset, length));
+}
+
+WebGLIntArray::WebGLIntArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length)
+ : WebGLArray(buffer, byteOffset)
, m_size(length)
- {
- }
-
- unsigned WebGLIntArray::length() const {
- return m_size;
- }
-
- unsigned WebGLIntArray::sizeInBytes() const {
- return length() * sizeof(int);
- }
+{
+}
+
+unsigned WebGLIntArray::length() const {
+ return m_size;
+}
+
+unsigned WebGLIntArray::byteLength() const {
+ return m_size * sizeof(int);
+}
+
+PassRefPtr<WebGLArray> WebGLIntArray::slice(unsigned offset, unsigned length) {
+ // Check to make sure the specified region is within the bounds of
+ // the WebGLArrayBuffer.
+ unsigned startByte = m_byteOffset + offset * sizeof(int);
+ unsigned limitByte = startByte + length * sizeof(int);
+ unsigned bufferLength = buffer()->byteLength();
+ if (startByte >= bufferLength || limitByte > bufferLength)
+ return 0;
+ return create(buffer(), startByte, length);
+}
+
+void WebGLIntArray::set(WebGLIntArray* array, unsigned offset, ExceptionCode& ec) {
+ setImpl(array, offset * sizeof(int), ec);
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLIntArray.h b/WebCore/html/canvas/WebGLIntArray.h
index 48fe661..25108ac 100644
--- a/WebCore/html/canvas/WebGLIntArray.h
+++ b/WebCore/html/canvas/WebGLIntArray.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -33,56 +34,64 @@
#include <wtf/RefCounted.h>
namespace WebCore {
-
- class WebGLIntArray : public WebGLArray {
- public:
- virtual bool isIntArray() const { return true; }
- static PassRefPtr<WebGLIntArray> create(unsigned length);
- static PassRefPtr<WebGLIntArray> create(int* array, unsigned length);
- static PassRefPtr<WebGLIntArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
+class WebGLIntArray : public WebGLArray {
+ public:
+ virtual bool isIntArray() const { return true; }
- int* data() { return static_cast<int*>(baseAddress()); }
+ static PassRefPtr<WebGLIntArray> create(unsigned length);
+ static PassRefPtr<WebGLIntArray> create(int* array, unsigned length);
+ static PassRefPtr<WebGLIntArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
- virtual unsigned length() const;
- virtual unsigned sizeInBytes() const;
+ int* data() { return static_cast<int*>(baseAddress()); }
- void set(unsigned index, double value)
- {
- if (index >= m_size)
- return;
- if (isnan(value)) // Clamp NaN to 0
- value = 0;
- if (value < std::numeric_limits<int>::min())
- value = std::numeric_limits<int>::min();
- else if (value > std::numeric_limits<int>::max())
- value = std::numeric_limits<int>::max();
- int* storage = static_cast<int*>(m_baseAddress);
- storage[index] = static_cast<int>(value);
- }
-
- bool get(unsigned index, int& result) const
- {
- if (index >= m_size)
- return false;
- result = item(index);
- return true;
- }
-
- int item(unsigned index) const
- {
- ASSERT(index < m_size);
- int* storage = static_cast<int*>(m_baseAddress);
- return storage[index];
- }
+ virtual unsigned length() const;
+ virtual unsigned byteLength() const;
+ virtual PassRefPtr<WebGLArray> slice(unsigned offset, unsigned length);
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<int>::min())
+ value = std::numeric_limits<int>::min();
+ else if (value > std::numeric_limits<int>::max())
+ value = std::numeric_limits<int>::max();
+ int* storage = static_cast<int*>(m_baseAddress);
+ storage[index] = static_cast<int>(value);
+ }
+
+ bool get(unsigned index, int& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ int get(unsigned index) const
+ {
+ return item(index);
+ }
+
+ int item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ int* storage = static_cast<int*>(m_baseAddress);
+ return storage[index];
+ }
+
+ void set(WebGLIntArray* array, unsigned offset, ExceptionCode& ec);
+
+ private:
+ WebGLIntArray(PassRefPtr<WebGLArrayBuffer> buffer,
+ int byteOffset,
+ unsigned length);
+ unsigned m_size;
+};
- private:
- WebGLIntArray(PassRefPtr<WebGLArrayBuffer> buffer,
- int offset,
- unsigned length);
- unsigned m_size;
- };
-
} // namespace WebCore
#endif // WebGLIntArray_h
diff --git a/WebCore/html/canvas/WebGLIntArray.idl b/WebCore/html/canvas/WebGLIntArray.idl
index a953efc..3bc037c 100644
--- a/WebCore/html/canvas/WebGLIntArray.idl
+++ b/WebCore/html/canvas/WebGLIntArray.idl
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -32,5 +33,10 @@ module html {
GenerateCustomConstructor,
CustomToJS
] WebGLIntArray : WebGLArray {
+ long get(in unsigned long index);
+ // void set(in unsigned long index, in long value);
+ // void set(in WebGLIntArray 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/WebGLShortArray.cpp b/WebCore/html/canvas/WebGLShortArray.cpp
index d5f1571..f96a290 100644
--- a/WebCore/html/canvas/WebGLShortArray.cpp
+++ b/WebCore/html/canvas/WebGLShortArray.cpp
@@ -31,52 +31,68 @@
#include "WebGLShortArray.h"
namespace WebCore {
-
- PassRefPtr<WebGLShortArray> WebGLShortArray::create(unsigned length)
- {
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(short));
- return create(buffer, 0, length);
- }
- PassRefPtr<WebGLShortArray> WebGLShortArray::create(short* array, unsigned length)
- {
- RefPtr<WebGLShortArray> a = WebGLShortArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
- }
+PassRefPtr<WebGLShortArray> WebGLShortArray::create(unsigned length)
+{
+ RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(short));
+ return create(buffer, 0, length);
+}
- PassRefPtr<WebGLShortArray> WebGLShortArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- int offset,
- unsigned length)
- {
- // Make sure the offset results in valid alignment.
- if ((offset % sizeof(short)) != 0)
- return NULL;
+PassRefPtr<WebGLShortArray> WebGLShortArray::create(short* array, unsigned length)
+{
+ RefPtr<WebGLShortArray> a = WebGLShortArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+}
- if (buffer) {
- // Check to make sure we are talking about a valid region of
- // the given WebGLArrayBuffer's storage.
- if ((offset + (length * sizeof(short))) > buffer->byteLength())
- return NULL;
- }
+PassRefPtr<WebGLShortArray> WebGLShortArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
+ int byteOffset,
+ unsigned length)
+{
+ // Make sure the offset results in valid alignment.
+ if ((byteOffset % sizeof(short)) != 0)
+ return NULL;
- return adoptRef(new WebGLShortArray(buffer, offset, length));
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given WebGLArrayBuffer's storage.
+ if ((byteOffset + (length * sizeof(short))) > buffer->byteLength())
+ return NULL;
}
-
- WebGLShortArray::WebGLShortArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length)
- : WebGLArray(buffer, offset)
+
+ return adoptRef(new WebGLShortArray(buffer, byteOffset, length));
+}
+
+WebGLShortArray::WebGLShortArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length)
+ : WebGLArray(buffer, byteOffset)
, m_size(length)
- {
- }
-
- unsigned WebGLShortArray::length() const {
- return m_size;
- }
-
- unsigned WebGLShortArray::sizeInBytes() const {
- return length() * sizeof(short);
- }
+{
+}
+
+unsigned WebGLShortArray::length() const {
+ return m_size;
+}
+
+unsigned WebGLShortArray::byteLength() const {
+ return m_size * sizeof(short);
+}
+
+PassRefPtr<WebGLArray> WebGLShortArray::slice(unsigned offset, unsigned length) {
+ // Check to make sure the specified region is within the bounds of
+ // the WebGLArrayBuffer.
+ unsigned startByte = m_byteOffset + offset * sizeof(short);
+ unsigned limitByte = startByte + length * sizeof(short);
+ unsigned bufferLength = buffer()->byteLength();
+ if (startByte >= bufferLength || limitByte > bufferLength)
+ return 0;
+ return create(buffer(), startByte, length);
+}
+
+void WebGLShortArray::set(WebGLShortArray* array, unsigned offset, ExceptionCode& ec) {
+ setImpl(array, offset * sizeof(short), ec);
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLShortArray.h b/WebCore/html/canvas/WebGLShortArray.h
index 452bf42..70c66ca 100644
--- a/WebCore/html/canvas/WebGLShortArray.h
+++ b/WebCore/html/canvas/WebGLShortArray.h
@@ -33,54 +33,62 @@
#include <wtf/RefCounted.h>
namespace WebCore {
-
- class WebGLShortArray : public WebGLArray {
- public:
- virtual bool isShortArray() const { return true; }
- static PassRefPtr<WebGLShortArray> create(unsigned length);
- static PassRefPtr<WebGLShortArray> create(short* array, unsigned length);
- static PassRefPtr<WebGLShortArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
+class WebGLShortArray : public WebGLArray {
+ public:
+ virtual bool isShortArray() const { return true; }
- short* data() { return static_cast<short*>(baseAddress()); }
+ static PassRefPtr<WebGLShortArray> create(unsigned length);
+ static PassRefPtr<WebGLShortArray> create(short* array, unsigned length);
+ static PassRefPtr<WebGLShortArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
- virtual unsigned length() const;
- virtual unsigned sizeInBytes() const;
+ short* data() { return static_cast<short*>(baseAddress()); }
- void set(unsigned index, double value)
- {
- if (index >= m_size)
- return;
- if (isnan(value)) // Clamp NaN to 0
- value = 0;
- if (value < std::numeric_limits<short>::min())
- value = std::numeric_limits<short>::min();
- else if (value > std::numeric_limits<short>::max())
- value = std::numeric_limits<short>::max();
- short* storage = static_cast<short*>(m_baseAddress);
- storage[index] = static_cast<short>(value);
- }
-
- bool get(unsigned index, short& result) const
- {
- if (index >= m_size)
- return false;
- result = item(index);
- return true;
- }
-
- short item(unsigned index) const
- {
- ASSERT(index < m_size);
- short* storage = static_cast<short*>(m_baseAddress);
- return storage[index];
- }
+ virtual unsigned length() const;
+ virtual unsigned byteLength() const;
+ virtual PassRefPtr<WebGLArray> slice(unsigned offset, unsigned length);
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<short>::min())
+ value = std::numeric_limits<short>::min();
+ else if (value > std::numeric_limits<short>::max())
+ value = std::numeric_limits<short>::max();
+ short* storage = static_cast<short*>(m_baseAddress);
+ storage[index] = static_cast<short>(value);
+ }
+
+ bool get(unsigned index, short& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ short get(unsigned index) const
+ {
+ return item(index);
+ }
+
+ short item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ short* storage = static_cast<short*>(m_baseAddress);
+ return storage[index];
+ }
+
+ void set(WebGLShortArray* array, unsigned offset, ExceptionCode& ec);
+
+ private:
+ WebGLShortArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
+ unsigned m_size;
+};
- private:
- WebGLShortArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
- unsigned m_size;
- };
-
} // namespace WebCore
#endif // WebGLShortArray_h
diff --git a/WebCore/html/canvas/WebGLShortArray.idl b/WebCore/html/canvas/WebGLShortArray.idl
index 9c0b2fd..bd8380f 100644
--- a/WebCore/html/canvas/WebGLShortArray.idl
+++ b/WebCore/html/canvas/WebGLShortArray.idl
@@ -32,5 +32,10 @@ module html {
GenerateCustomConstructor,
CustomToJS
] WebGLShortArray : WebGLArray {
+ long get(in unsigned long index);
+ // void set(in unsigned long index, in long value);
+ // void set(in WebGLShortArray 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/WebGLUnsignedByteArray.cpp b/WebCore/html/canvas/WebGLUnsignedByteArray.cpp
index f81881e..3fd1b50 100644
--- a/WebCore/html/canvas/WebGLUnsignedByteArray.cpp
+++ b/WebCore/html/canvas/WebGLUnsignedByteArray.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -31,48 +32,64 @@
#include "WebGLUnsignedByteArray.h"
namespace WebCore {
-
- PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(unsigned length)
- {
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(unsigned char));
- return create(buffer, 0, length);
- }
- PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(unsigned char* array, unsigned length)
- {
- RefPtr<WebGLUnsignedByteArray> a = WebGLUnsignedByteArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
- }
+PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(unsigned length)
+{
+ RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(unsigned char));
+ return create(buffer, 0, length);
+}
- PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- int offset,
- unsigned length)
- {
- if (buffer) {
- // Check to make sure we are talking about a valid region of
- // the given WebGLArrayBuffer's storage.
- if ((offset + (length * sizeof(unsigned char))) > buffer->byteLength())
- return NULL;
- }
+PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(unsigned char* array, unsigned length)
+{
+ RefPtr<WebGLUnsignedByteArray> a = WebGLUnsignedByteArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+}
- return adoptRef(new WebGLUnsignedByteArray(buffer, offset, length));
+PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
+ int byteOffset,
+ unsigned length)
+{
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given WebGLArrayBuffer's storage.
+ if ((byteOffset + (length * sizeof(unsigned char))) > buffer->byteLength())
+ return NULL;
}
-
- WebGLUnsignedByteArray::WebGLUnsignedByteArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length)
- : WebGLArray(buffer, offset)
+
+ return adoptRef(new WebGLUnsignedByteArray(buffer, byteOffset, length));
+}
+
+WebGLUnsignedByteArray::WebGLUnsignedByteArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length)
+ : WebGLArray(buffer, byteOffset)
, m_size(length)
- {
- }
-
- unsigned WebGLUnsignedByteArray::length() const {
- return m_size;
- }
-
- unsigned WebGLUnsignedByteArray::sizeInBytes() const {
- return length() * sizeof(unsigned char);
- }
+{
+}
+
+unsigned WebGLUnsignedByteArray::length() const {
+ return m_size;
+}
+
+unsigned WebGLUnsignedByteArray::byteLength() const {
+ return m_size * sizeof(unsigned char);
+}
+
+PassRefPtr<WebGLArray> WebGLUnsignedByteArray::slice(unsigned offset, unsigned length) {
+ // Check to make sure the specified region is within the bounds of
+ // the WebGLArrayBuffer.
+ unsigned startByte = m_byteOffset + offset * sizeof(unsigned char);
+ unsigned limitByte = startByte + length * sizeof(unsigned char);
+ unsigned bufferLength = buffer()->byteLength();
+ if (startByte >= bufferLength || limitByte > bufferLength)
+ return 0;
+ return create(buffer(), startByte, length);
+}
+
+void WebGLUnsignedByteArray::set(WebGLUnsignedByteArray* array, unsigned offset, ExceptionCode& ec) {
+ setImpl(array, offset * sizeof(unsigned char), ec);
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLUnsignedByteArray.h b/WebCore/html/canvas/WebGLUnsignedByteArray.h
index b8980a7..6909de5 100644
--- a/WebCore/html/canvas/WebGLUnsignedByteArray.h
+++ b/WebCore/html/canvas/WebGLUnsignedByteArray.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -33,54 +34,62 @@
#include <wtf/RefCounted.h>
namespace WebCore {
-
- class WebGLUnsignedByteArray : public WebGLArray {
- public:
- virtual bool isUnsignedByteArray() const { return true; }
- static PassRefPtr<WebGLUnsignedByteArray> create(unsigned length);
- static PassRefPtr<WebGLUnsignedByteArray> create(unsigned char* array, unsigned length);
- static PassRefPtr<WebGLUnsignedByteArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
+class WebGLUnsignedByteArray : public WebGLArray {
+ public:
+ virtual bool isUnsignedByteArray() const { return true; }
- unsigned char* data() { return static_cast<unsigned char*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned sizeInBytes() const;
+ static PassRefPtr<WebGLUnsignedByteArray> create(unsigned length);
+ static PassRefPtr<WebGLUnsignedByteArray> create(unsigned char* array, unsigned length);
+ static PassRefPtr<WebGLUnsignedByteArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
- void set(unsigned index, double value)
- {
- if (index >= m_size)
- return;
- if (isnan(value)) // Clamp NaN to 0
- value = 0;
- if (value < std::numeric_limits<unsigned char>::min())
- value = std::numeric_limits<unsigned char>::min();
- else if (value > std::numeric_limits<unsigned char>::max())
- value = std::numeric_limits<unsigned char>::max();
- unsigned char* storage = static_cast<unsigned char*>(m_baseAddress);
- storage[index] = static_cast<unsigned char>(value);
- }
-
- bool get(unsigned index, unsigned char& result) const
- {
- if (index >= m_size)
- return false;
- result = item(index);
- return true;
- }
-
- unsigned char item(unsigned index) const
- {
- ASSERT(index < m_size);
- unsigned char* storage = static_cast<unsigned char*>(m_baseAddress);
- return storage[index];
- }
+ unsigned char* data() { return static_cast<unsigned char*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned byteLength() const;
+ virtual PassRefPtr<WebGLArray> slice(unsigned offset, unsigned length);
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<unsigned char>::min())
+ value = std::numeric_limits<unsigned char>::min();
+ else if (value > std::numeric_limits<unsigned char>::max())
+ value = std::numeric_limits<unsigned char>::max();
+ unsigned char* storage = static_cast<unsigned char*>(m_baseAddress);
+ storage[index] = static_cast<unsigned char>(value);
+ }
+
+ bool get(unsigned index, unsigned char& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ unsigned char get(unsigned index) const
+ {
+ return item(index);
+ }
+
+ unsigned char item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ unsigned char* storage = static_cast<unsigned char*>(m_baseAddress);
+ return storage[index];
+ }
+
+ void set(WebGLUnsignedByteArray* array, unsigned offset, ExceptionCode& ec);
+
+ private:
+ WebGLUnsignedByteArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
+ unsigned m_size;
+};
- private:
- WebGLUnsignedByteArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
- unsigned m_size;
- };
-
} // namespace WebCore
#endif // WebGLUnsignedByteArray_h
diff --git a/WebCore/html/canvas/WebGLUnsignedByteArray.idl b/WebCore/html/canvas/WebGLUnsignedByteArray.idl
index b8eb21a..57aa4ff 100644
--- a/WebCore/html/canvas/WebGLUnsignedByteArray.idl
+++ b/WebCore/html/canvas/WebGLUnsignedByteArray.idl
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -32,5 +33,10 @@ module html {
GenerateCustomConstructor,
CustomToJS
] WebGLUnsignedByteArray : WebGLArray {
+ long get(in unsigned long index);
+ // void set(in unsigned long index, in long value);
+ // void set(in WebGLUnsignedByteArray 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/WebGLUnsignedIntArray.cpp b/WebCore/html/canvas/WebGLUnsignedIntArray.cpp
index a35eb62..97910f9 100644
--- a/WebCore/html/canvas/WebGLUnsignedIntArray.cpp
+++ b/WebCore/html/canvas/WebGLUnsignedIntArray.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -31,53 +32,69 @@
#include "WebGLUnsignedIntArray.h"
namespace WebCore {
-
- PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(unsigned length)
- {
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(unsigned int));
- return create(buffer, 0, length);
- }
- PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(unsigned int* array, unsigned length)
- {
- RefPtr<WebGLUnsignedIntArray> a = WebGLUnsignedIntArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
+PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(unsigned length)
+{
+ RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(unsigned int));
+ return create(buffer, 0, length);
+}
+
+PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(unsigned int* array, unsigned length)
+{
+ RefPtr<WebGLUnsignedIntArray> a = WebGLUnsignedIntArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+}
+
+PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
+ int byteOffset,
+ unsigned length)
+{
+ // Make sure the offset results in valid alignment.
+ if ((byteOffset % sizeof(unsigned int)) != 0) {
+ return NULL;
}
- PassRefPtr<WebGLUnsignedIntArray> WebGLUnsignedIntArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- int offset,
- unsigned length)
- {
- // Make sure the offset results in valid alignment.
- if ((offset % sizeof(unsigned int)) != 0) {
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given WebGLArrayBuffer's storage.
+ if ((byteOffset + (length * sizeof(unsigned int))) > buffer->byteLength())
return NULL;
- }
+ }
- if (buffer) {
- // Check to make sure we are talking about a valid region of
- // the given WebGLArrayBuffer's storage.
- if ((offset + (length * sizeof(unsigned int))) > buffer->byteLength())
- return NULL;
- }
+ return adoptRef(new WebGLUnsignedIntArray(buffer, byteOffset, length));
+}
- return adoptRef(new WebGLUnsignedIntArray(buffer, offset, length));
- }
-
- WebGLUnsignedIntArray::WebGLUnsignedIntArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length)
- : WebGLArray(buffer, offset)
+WebGLUnsignedIntArray::WebGLUnsignedIntArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length)
+ : WebGLArray(buffer, byteOffset)
, m_size(length)
- {
- }
-
- unsigned WebGLUnsignedIntArray::length() const {
- return m_size;
- }
-
- unsigned WebGLUnsignedIntArray::sizeInBytes() const {
- return length() * sizeof(unsigned int);
- }
+{
+}
+
+unsigned WebGLUnsignedIntArray::length() const {
+ return m_size;
+}
+
+unsigned WebGLUnsignedIntArray::byteLength() const {
+ return m_size * sizeof(unsigned int);
+}
+
+PassRefPtr<WebGLArray> WebGLUnsignedIntArray::slice(unsigned offset, unsigned length) {
+ // Check to make sure the specified region is within the bounds of
+ // the WebGLArrayBuffer.
+ unsigned startByte = m_byteOffset + offset * sizeof(unsigned int);
+ unsigned limitByte = startByte + length * sizeof(unsigned int);
+ unsigned bufferLength = buffer()->byteLength();
+ if (startByte >= bufferLength || limitByte > bufferLength)
+ return 0;
+ return create(buffer(), startByte, length);
+}
+
+void WebGLUnsignedIntArray::set(WebGLUnsignedIntArray* array, unsigned offset, ExceptionCode& ec) {
+ setImpl(array, offset * sizeof(unsigned int), ec);
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLUnsignedIntArray.h b/WebCore/html/canvas/WebGLUnsignedIntArray.h
index cd548f2..b0d9b65 100644
--- a/WebCore/html/canvas/WebGLUnsignedIntArray.h
+++ b/WebCore/html/canvas/WebGLUnsignedIntArray.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -33,54 +34,62 @@
#include <wtf/RefCounted.h>
namespace WebCore {
-
- class WebGLUnsignedIntArray : public WebGLArray {
- public:
- virtual bool isUnsignedIntArray() const { return true; }
- static PassRefPtr<WebGLUnsignedIntArray> create(unsigned length);
- static PassRefPtr<WebGLUnsignedIntArray> create(unsigned int* array, unsigned length);
- static PassRefPtr<WebGLUnsignedIntArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
+class WebGLUnsignedIntArray : public WebGLArray {
+ public:
+ virtual bool isUnsignedIntArray() const { return true; }
- unsigned int* data() { return static_cast<unsigned int*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned sizeInBytes() const;
+ static PassRefPtr<WebGLUnsignedIntArray> create(unsigned length);
+ static PassRefPtr<WebGLUnsignedIntArray> create(unsigned int* array, unsigned length);
+ static PassRefPtr<WebGLUnsignedIntArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
- void set(unsigned index, double value)
- {
- if (index >= m_size)
- return;
- if (isnan(value)) // Clamp NaN to 0
- value = 0;
- if (value < std::numeric_limits<unsigned int>::min())
- value = std::numeric_limits<unsigned int>::min();
- else if (value > std::numeric_limits<unsigned int>::max())
- value = std::numeric_limits<unsigned int>::max();
- unsigned int* storage = static_cast<unsigned int*>(m_baseAddress);
- storage[index] = static_cast<unsigned int>(value);
- }
-
- bool get(unsigned index, unsigned int& result) const
- {
- if (index >= m_size)
- return false;
- result = item(index);
- return true;
- }
-
- unsigned int item(unsigned index) const
- {
- ASSERT(index < m_size);
- unsigned int* storage = static_cast<unsigned int*>(m_baseAddress);
- return storage[index];
- }
+ unsigned int* data() { return static_cast<unsigned int*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned byteLength() const;
+ virtual PassRefPtr<WebGLArray> slice(unsigned offset, unsigned length);
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<unsigned int>::min())
+ value = std::numeric_limits<unsigned int>::min();
+ else if (value > std::numeric_limits<unsigned int>::max())
+ value = std::numeric_limits<unsigned int>::max();
+ unsigned int* storage = static_cast<unsigned int*>(m_baseAddress);
+ storage[index] = static_cast<unsigned int>(value);
+ }
+
+ bool get(unsigned index, unsigned int& result) const
+ {
+ if (index >= m_size)
+ return false;
+ result = item(index);
+ return true;
+ }
+
+ unsigned int get(unsigned index) const
+ {
+ return item(index);
+ }
+
+ unsigned int item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ unsigned int* storage = static_cast<unsigned int*>(m_baseAddress);
+ return storage[index];
+ }
+
+ void set(WebGLUnsignedIntArray* array, unsigned offset, ExceptionCode& ec);
+
+ private:
+ WebGLUnsignedIntArray(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
+ unsigned m_size;
+};
- private:
- WebGLUnsignedIntArray(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
- unsigned m_size;
- };
-
} // namespace WebCore
#endif // WebGLUnsignedIntArray_h
diff --git a/WebCore/html/canvas/WebGLUnsignedIntArray.idl b/WebCore/html/canvas/WebGLUnsignedIntArray.idl
index 17cfb58..8697e70 100644
--- a/WebCore/html/canvas/WebGLUnsignedIntArray.idl
+++ b/WebCore/html/canvas/WebGLUnsignedIntArray.idl
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -32,5 +33,10 @@ module html {
GenerateCustomConstructor,
CustomToJS
] WebGLUnsignedIntArray : WebGLArray {
+ long get(in unsigned long index);
+ // void set(in unsigned long index, in long value);
+ // void set(in WebGLUnsignedIntArray 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/WebGLUnsignedShortArray.cpp b/WebCore/html/canvas/WebGLUnsignedShortArray.cpp
index 54b9228..86fae8c 100644
--- a/WebCore/html/canvas/WebGLUnsignedShortArray.cpp
+++ b/WebCore/html/canvas/WebGLUnsignedShortArray.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -31,55 +32,71 @@
#include "WebGLUnsignedShortArray.h"
namespace WebCore {
-
- PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(unsigned length)
- {
- RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(unsigned short));
- return create(buffer, 0, length);
- }
- PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(unsigned short* array, unsigned length)
- {
- RefPtr<WebGLUnsignedShortArray> a = WebGLUnsignedShortArray::create(length);
- for (unsigned i = 0; i < length; ++i)
- a->set(i, array[i]);
- return a;
+PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(unsigned length)
+{
+ RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(length * sizeof(unsigned short));
+ return create(buffer, 0, length);
+}
+
+PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(unsigned short* array, unsigned length)
+{
+ RefPtr<WebGLUnsignedShortArray> a = WebGLUnsignedShortArray::create(length);
+ for (unsigned i = 0; i < length; ++i)
+ a->set(i, array[i]);
+ return a;
+}
+
+PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
+ int byteOffset,
+ unsigned length)
+{
+ // Make sure the offset results in valid alignment.
+ if ((byteOffset % sizeof(unsigned short)) != 0) {
+ return NULL;
}
- PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(PassRefPtr<WebGLArrayBuffer> buffer,
- int offset,
- unsigned length)
- {
- // Make sure the offset results in valid alignment.
- if ((offset % sizeof(unsigned short)) != 0) {
+ if (buffer) {
+ // Check to make sure we are talking about a valid region of
+ // the given WebGLArrayBuffer's storage.
+ if ((byteOffset + (length * sizeof(unsigned short))) > buffer->byteLength())
return NULL;
- }
+ }
- if (buffer) {
- // Check to make sure we are talking about a valid region of
- // the given WebGLArrayBuffer's storage.
- if ((offset + (length * sizeof(unsigned short))) > buffer->byteLength())
- return NULL;
- }
+ return adoptRef(new WebGLUnsignedShortArray(buffer, byteOffset, length));
+}
- return adoptRef(new WebGLUnsignedShortArray(buffer, offset, length));
- }
-
- WebGLUnsignedShortArray::WebGLUnsignedShortArray(PassRefPtr<WebGLArrayBuffer> buffer,
- int offset,
- unsigned length)
- : WebGLArray(buffer, offset)
+WebGLUnsignedShortArray::WebGLUnsignedShortArray(PassRefPtr<WebGLArrayBuffer> buffer,
+ int byteOffset,
+ unsigned length)
+ : WebGLArray(buffer, byteOffset)
, m_size(length)
- {
- }
-
- unsigned WebGLUnsignedShortArray::length() const {
- return m_size;
- }
-
- unsigned WebGLUnsignedShortArray::sizeInBytes() const {
- return length() * sizeof(unsigned short);
- }
+{
+}
+
+unsigned WebGLUnsignedShortArray::length() const {
+ return m_size;
+}
+
+unsigned WebGLUnsignedShortArray::byteLength() const {
+ return m_size * sizeof(unsigned short);
+}
+
+PassRefPtr<WebGLArray> WebGLUnsignedShortArray::slice(unsigned offset, unsigned length) {
+ // Check to make sure the specified region is within the bounds of
+ // the WebGLArrayBuffer.
+ unsigned startByte = m_byteOffset + offset * sizeof(unsigned short);
+ unsigned limitByte = startByte + length * sizeof(unsigned short);
+ unsigned bufferLength = buffer()->byteLength();
+ if (startByte >= bufferLength || limitByte > bufferLength)
+ return 0;
+ return create(buffer(), startByte, length);
+}
+
+void WebGLUnsignedShortArray::set(WebGLUnsignedShortArray* array, unsigned offset, ExceptionCode& ec) {
+ setImpl(array, offset * sizeof(unsigned short), ec);
+}
+
}
#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebGLUnsignedShortArray.h b/WebCore/html/canvas/WebGLUnsignedShortArray.h
index a94a6a9..3bad1b6 100644
--- a/WebCore/html/canvas/WebGLUnsignedShortArray.h
+++ b/WebCore/html/canvas/WebGLUnsignedShortArray.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -33,55 +34,63 @@
#include <wtf/RefCounted.h>
namespace WebCore {
-
- class WebGLUnsignedShortArray : public WebGLArray {
- public:
- virtual bool isUnsignedShortArray() const { return true; }
- static PassRefPtr<WebGLUnsignedShortArray> create(unsigned length);
- static PassRefPtr<WebGLUnsignedShortArray> create(unsigned short* array, unsigned length);
- static PassRefPtr<WebGLUnsignedShortArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int offset, unsigned length);
+class WebGLUnsignedShortArray : public WebGLArray {
+ public:
+ virtual bool isUnsignedShortArray() const { return true; }
- unsigned short* data() { return static_cast<unsigned short*>(baseAddress()); }
-
- virtual unsigned length() const;
- virtual unsigned sizeInBytes() const;
+ static PassRefPtr<WebGLUnsignedShortArray> create(unsigned length);
+ static PassRefPtr<WebGLUnsignedShortArray> create(unsigned short* array, unsigned length);
+ static PassRefPtr<WebGLUnsignedShortArray> create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length);
- void set(unsigned index, double value)
- {
- if (index >= m_size)
- return;
- if (isnan(value)) // Clamp NaN to 0
- value = 0;
- if (value < std::numeric_limits<unsigned short>::min())
- value = std::numeric_limits<unsigned short>::min();
- else if (value > std::numeric_limits<unsigned short>::max())
- value = std::numeric_limits<unsigned short>::max();
- unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
- storage[index] = static_cast<unsigned short>(value);
- }
-
- bool get(unsigned index, unsigned short& result) const
- {
- if (index >= m_size)
- return false;
- unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
- result = storage[index];
- return true;
- }
-
- unsigned short item(unsigned index) const
- {
- ASSERT(index < m_size);
- unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
- return storage[index];
- }
+ unsigned short* data() { return static_cast<unsigned short*>(baseAddress()); }
+
+ virtual unsigned length() const;
+ virtual unsigned byteLength() const;
+ virtual PassRefPtr<WebGLArray> slice(unsigned offset, unsigned length);
+
+ void set(unsigned index, double value)
+ {
+ if (index >= m_size)
+ return;
+ if (isnan(value)) // Clamp NaN to 0
+ value = 0;
+ if (value < std::numeric_limits<unsigned short>::min())
+ value = std::numeric_limits<unsigned short>::min();
+ else if (value > std::numeric_limits<unsigned short>::max())
+ value = std::numeric_limits<unsigned short>::max();
+ unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
+ storage[index] = static_cast<unsigned short>(value);
+ }
+
+ bool get(unsigned index, unsigned short& result) const
+ {
+ if (index >= m_size)
+ return false;
+ unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
+ result = storage[index];
+ return true;
+ }
+
+ unsigned short get(unsigned index) const
+ {
+ return item(index);
+ }
+
+ unsigned short item(unsigned index) const
+ {
+ ASSERT(index < m_size);
+ unsigned short* storage = static_cast<unsigned short*>(m_baseAddress);
+ return storage[index];
+ }
+
+ void set(WebGLUnsignedShortArray* array, unsigned offset, ExceptionCode& ec);
+
+ private:
+ WebGLUnsignedShortArray(PassRefPtr<WebGLArrayBuffer> buffer,int byteOffset,unsigned length);
+ unsigned m_size;
+};
- private:
- WebGLUnsignedShortArray(PassRefPtr<WebGLArrayBuffer> buffer,int offset,unsigned length);
- unsigned m_size;
- };
-
} // namespace WebCore
#endif // WebGLUnsignedShortArray_h
diff --git a/WebCore/html/canvas/WebGLUnsignedShortArray.idl b/WebCore/html/canvas/WebGLUnsignedShortArray.idl
index e558e23..d546444 100644
--- a/WebCore/html/canvas/WebGLUnsignedShortArray.idl
+++ b/WebCore/html/canvas/WebGLUnsignedShortArray.idl
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
+ * 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
@@ -32,5 +33,10 @@ module html {
GenerateCustomConstructor,
CustomToJS
] WebGLUnsignedShortArray : WebGLArray {
+ long get(in unsigned long index);
+ // void set(in unsigned long index, in long value);
+ // void set(in WebGLUnsignedShortArray array, [Optional] in unsigned long offset);
+ // void set(in sequence<long> array, [Optional] in unsigned long offset);
+ [Custom] void set();
};
}
diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
index 6296dc1..30daabf 100644
--- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
+++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
@@ -329,7 +329,7 @@ void GraphicsContext3D::bufferData(unsigned long target, WebGLArray* array, unsi
return;
ensureContext(m_contextObj);
- ::glBufferData(target, array->sizeInBytes(), array->baseAddress(), usage);
+ ::glBufferData(target, array->byteLength(), array->baseAddress(), usage);
}
void GraphicsContext3D::bufferSubData(unsigned long target, long offset, WebGLArray* array)
@@ -338,7 +338,7 @@ void GraphicsContext3D::bufferSubData(unsigned long target, long offset, WebGLAr
return;
ensureContext(m_contextObj);
- ::glBufferSubData(target, offset, array->sizeInBytes(), array->baseAddress());
+ ::glBufferSubData(target, offset, array->byteLength(), array->baseAddress());
}
unsigned long GraphicsContext3D::checkFramebufferStatus(unsigned long target)
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index cba89be..46a17f8 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,14 @@
+2009-11-16 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Oliver Hunt.
+
+ Update API of WebGLArray and friends
+ https://bugs.webkit.org/show_bug.cgi?id=31175
+
+ * src/GraphicsContext3D.cpp:
+ (WebCore::GraphicsContext3D::bufferData):
+ (WebCore::GraphicsContext3D::bufferSubData):
+
2009-11-15 Dimitri Glazkov <dglazkov at chromium.org>
Unreviewed, build fix.
diff --git a/WebKit/chromium/src/GraphicsContext3D.cpp b/WebKit/chromium/src/GraphicsContext3D.cpp
index 465656a..7bb057a 100644
--- a/WebKit/chromium/src/GraphicsContext3D.cpp
+++ b/WebKit/chromium/src/GraphicsContext3D.cpp
@@ -1227,7 +1227,7 @@ void GraphicsContext3D::bufferData(unsigned long target, int size, unsigned long
void GraphicsContext3D::bufferData(unsigned long target, WebGLArray* array, unsigned long usage)
{
- m_internal->bufferDataImpl(target, array->sizeInBytes(), array->baseAddress(), usage);
+ m_internal->bufferDataImpl(target, array->byteLength(), array->baseAddress(), usage);
}
void GraphicsContext3D::bufferSubData(unsigned long target, long offset, WebGLArray* array)
@@ -1247,7 +1247,7 @@ void GraphicsContext3D::bufferSubData(unsigned long target, long offset, WebGLAr
// LogMessagef(("bufferSubData: no buffer bound"));
return;
}
- glBufferSubData(target, offset, array->sizeInBytes(), array->baseAddress());
+ glBufferSubData(target, offset, array->byteLength(), array->baseAddress());
}
unsigned long GraphicsContext3D::checkFramebufferStatus(unsigned long target)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list