Changeset 73119 in webkit


Ignore:
Timestamp:
Dec 2, 2010 2:40:07 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2010-12-02 Yuqiang Xian <yuqiang.xian@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:
Location:
trunk/WebCore
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r73118 r73119  
     12010-12-02  Yuqiang Xian  <yuqiang.xian@intel.com>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        [V8] Speed up data property access for ImageData.
     6        https://bugs.webkit.org/show_bug.cgi?id=49999
     7
     8        We create a normal V8 object which has a PixelArray as the backing storage,
     9        and set the "data" property of the ImageData object to it.
     10        This way "data" becomes a pure JS property and we don't need to call through
     11        the C++ bindings for ImageData "data" access.
     12        This eliminates big overhead in switching between JavaScript and native
     13        contexts and performing object bindings.
     14
     15        No new tests. Relying on existing Canvas tests.
     16
     17        * WebCore.gypi:
     18        * bindings/scripts/CodeGeneratorV8.pm:
     19        * bindings/v8/custom/V8CanvasPixelArrayCustom.cpp:
     20        (WebCore::toV8):
     21        * bindings/v8/custom/V8ImageDataCustom.cpp: Added.
     22        (WebCore::toV8):
     23        * html/ImageData.idl:
     24        * html/canvas/CanvasPixelArray.idl:
     25
    1262010-12-02  Kent Tamura  <tkent@chromium.org>
    227
  • trunk/WebCore/WebCore.gypi

    r73011 r73119  
    748748            'bindings/v8/OptionsObject.cpp',
    749749            'bindings/v8/OptionsObject.h',
     750            'bindings/v8/custom/V8ImageDataCustom.cpp',
    750751            'bindings/v8/custom/V8CanvasPixelArrayCustom.cpp',
    751752            'bindings/v8/custom/V8ArrayBufferViewCustom.h',
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r73011 r73119  
    25292529    return 0 if $interfaceName eq "AbstractWorker";
    25302530    return 0 if $interfaceName eq "CanvasRenderingContext";
    2531     return 0 if $interfaceName eq "ImageData";
    25322531    return 0 if $interfaceName eq "SVGElementInstance";
    25332532
  • trunk/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp

    r54153 r73119  
    3939        return v8::Null();
    4040    v8::Handle<v8::Object> wrapper = V8CanvasPixelArray::wrap(impl);
    41     if (!wrapper.IsEmpty())
     41    if (!wrapper.IsEmpty()) {
    4242        wrapper->SetIndexedPropertiesToPixelData(impl->data()->data(), impl->length());
     43        wrapper->Set(v8::String::NewSymbol("length"),
     44                     v8::Integer::New(impl->length()),
     45                     v8::ReadOnly);
     46    }
    4347    return wrapper;
    4448}
  • trunk/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp

    r73118 r73119  
    3030
    3131#include "config.h"
     32#include "V8ImageData.h"
     33
    3234#include "V8CanvasPixelArray.h"
    3335
    3436namespace WebCore {
    3537
    36 v8::Handle<v8::Value> toV8(CanvasPixelArray* impl)
     38v8::Handle<v8::Value> toV8(ImageData* impl)
    3739{
    3840    if (!impl)
    3941        return v8::Null();
    40     v8::Handle<v8::Object> wrapper = V8CanvasPixelArray::wrap(impl);
    41     if (!wrapper.IsEmpty())
    42         wrapper->SetIndexedPropertiesToPixelData(impl->data()->data(), impl->length());
     42    v8::Handle<v8::Object> wrapper = V8ImageData::wrap(impl);
     43    if (!wrapper.IsEmpty()) {
     44        // Create a V8 CanvasPixelArray object.
     45        v8::Handle<v8::Value> pixelArray = toV8(impl->data());
     46        // Set the "data" property of the ImageData object to
     47        // the created v8 object, eliminating the C++ callback
     48        // when accessing the "data" property.
     49        if (!pixelArray.IsEmpty()) {
     50            wrapper->Set(v8::String::NewSymbol("data"),
     51                         pixelArray,
     52                         v8::ReadOnly);
     53        }
     54    }
     55
    4356    return wrapper;
    4457}
  • trunk/WebCore/html/ImageData.idl

    r52537 r73119  
    3434        readonly attribute long width;
    3535        readonly attribute long height;
    36 #if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT || defined(V8_BINDING) && V8_BINDING
     36#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT
    3737        readonly attribute CanvasPixelArray data;
    3838#endif
  • trunk/WebCore/html/canvas/CanvasPixelArray.idl

    r52534 r73119  
    3535        HasCustomIndexSetter
    3636    ] CanvasPixelArray {
     37#if !defined(V8_BINDING) || !V8_BINDING
    3738        readonly attribute long length;
     39#endif
    3840    };
    3941#endif
Note: See TracChangeset for help on using the changeset viewer.