[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 17:54:06 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 21d2b8501eb5846fa19f03ea50f461f1107bf2df
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 2 10:40:07 2010 +0000

    2010-12-02  Yuqiang Xian  <yuqiang.xian at intel.com>
    
            Reviewed by Pavel Feldman.
    
            [V8] Speed up data property access for ImageData.
            https://bugs.webkit.org/show_bug.cgi?id=49999
    
            We create a normal V8 object which has a PixelArray as the backing storage,
            and set the "data" property of the ImageData object to it.
            This way "data" becomes a pure JS property and we don't need to call through
            the C++ bindings for ImageData "data" access.
            This eliminates big overhead in switching between JavaScript and native
            contexts and performing object bindings.
    
            No new tests. Relying on existing Canvas tests.
    
            * WebCore.gypi:
            * bindings/scripts/CodeGeneratorV8.pm:
            * bindings/v8/custom/V8CanvasPixelArrayCustom.cpp:
            (WebCore::toV8):
            * bindings/v8/custom/V8ImageDataCustom.cpp: Added.
            (WebCore::toV8):
            * html/ImageData.idl:
            * html/canvas/CanvasPixelArray.idl:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73119 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e0a9c3d..7472771 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-12-02  Yuqiang Xian  <yuqiang.xian at intel.com>
+
+        Reviewed by Pavel Feldman.
+
+        [V8] Speed up data property access for ImageData.
+        https://bugs.webkit.org/show_bug.cgi?id=49999
+
+        We create a normal V8 object which has a PixelArray as the backing storage,
+        and set the "data" property of the ImageData object to it. 
+        This way "data" becomes a pure JS property and we don't need to call through
+        the C++ bindings for ImageData "data" access. 
+        This eliminates big overhead in switching between JavaScript and native
+        contexts and performing object bindings.
+
+        No new tests. Relying on existing Canvas tests.
+
+        * WebCore.gypi:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/v8/custom/V8CanvasPixelArrayCustom.cpp:
+        (WebCore::toV8):
+        * bindings/v8/custom/V8ImageDataCustom.cpp: Added.
+        (WebCore::toV8):
+        * html/ImageData.idl:
+        * html/canvas/CanvasPixelArray.idl:
+
 2010-12-02  Kent Tamura  <tkent at chromium.org>
 
         Unreviewed. Run sort-Xcode-project-file.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 64cad8e..2b5a0f6 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -747,6 +747,7 @@
             'bindings/v8/IDBBindingUtilities.h',
             'bindings/v8/OptionsObject.cpp',
             'bindings/v8/OptionsObject.h',
+            'bindings/v8/custom/V8ImageDataCustom.cpp',
             'bindings/v8/custom/V8CanvasPixelArrayCustom.cpp',
             'bindings/v8/custom/V8ArrayBufferViewCustom.h',
             'bindings/v8/custom/V8ArrayBufferCustom.cpp',
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 7488d50..5ec3827 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -2528,7 +2528,6 @@ sub HasCustomToV8Implementation {
     # We don't generate a custom converter (but JSC does) for the following:
     return 0 if $interfaceName eq "AbstractWorker";
     return 0 if $interfaceName eq "CanvasRenderingContext";
-    return 0 if $interfaceName eq "ImageData";
     return 0 if $interfaceName eq "SVGElementInstance";
 
     # For everything else, do what JSC does.
diff --git a/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp
index cd638ce..91e39b7 100644
--- a/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp
@@ -38,8 +38,12 @@ v8::Handle<v8::Value> toV8(CanvasPixelArray* impl)
     if (!impl)
         return v8::Null();
     v8::Handle<v8::Object> wrapper = V8CanvasPixelArray::wrap(impl);
-    if (!wrapper.IsEmpty())
+    if (!wrapper.IsEmpty()) {
         wrapper->SetIndexedPropertiesToPixelData(impl->data()->data(), impl->length());
+        wrapper->Set(v8::String::NewSymbol("length"),
+                     v8::Integer::New(impl->length()),
+                     v8::ReadOnly);
+    }
     return wrapper;
 }
 
diff --git a/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp b/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp
new file mode 100644
index 0000000..b4549e4
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8ImageData.h"
+
+#include "V8CanvasPixelArray.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(ImageData* impl)
+{
+    if (!impl)
+        return v8::Null();
+    v8::Handle<v8::Object> wrapper = V8ImageData::wrap(impl);
+    if (!wrapper.IsEmpty()) {
+        // Create a V8 CanvasPixelArray object.
+        v8::Handle<v8::Value> pixelArray = toV8(impl->data());
+        // Set the "data" property of the ImageData object to
+        // the created v8 object, eliminating the C++ callback
+        // when accessing the "data" property.
+        if (!pixelArray.IsEmpty()) {
+            wrapper->Set(v8::String::NewSymbol("data"),
+                         pixelArray,
+                         v8::ReadOnly);
+        }
+    }
+
+    return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/html/ImageData.idl b/WebCore/html/ImageData.idl
index a5e2467..6050205 100644
--- a/WebCore/html/ImageData.idl
+++ b/WebCore/html/ImageData.idl
@@ -33,7 +33,7 @@ module html {
     ] ImageData {
         readonly attribute long width;
         readonly attribute long height;
-#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT || defined(V8_BINDING) && V8_BINDING
+#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT
         readonly attribute CanvasPixelArray data;
 #endif
     };
diff --git a/WebCore/html/canvas/CanvasPixelArray.idl b/WebCore/html/canvas/CanvasPixelArray.idl
index 60726cd..8b7edbd 100644
--- a/WebCore/html/canvas/CanvasPixelArray.idl
+++ b/WebCore/html/canvas/CanvasPixelArray.idl
@@ -34,7 +34,9 @@ module html {
         HasNumericIndexGetter,
         HasCustomIndexSetter
     ] CanvasPixelArray {
+#if !defined(V8_BINDING) || !V8_BINDING
         readonly attribute long length;
+#endif
     };
 #endif
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list