[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

simon.fraser at apple.com simon.fraser at apple.com
Sun Feb 20 23:34:01 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 9574a22e7bd6597dd784722d099f17e9addef515
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 21 19:33:41 2011 +0000

    2011-01-21  Simon Fraser  <simon.fraser at apple.com>
    
            Reviewed by Sam Weinig.
    
            Report the sized used by canvases and types arrays
            https://bugs.webkit.org/show_bug.cgi?id=52856
    
            Report the memory cost associated with canvas elements,
            and typed arrays to JavaScript as extraCost, so that it
            can figure this into its GC behavior.
    
            * bindings/js/JSArrayBufferViewHelper.h:
            (WebCore::toJSArrayBufferView): New templatized function, similar
            to getDOMObjectWrapper() but calls reportExtraMemoryCost() with
            the byteLength of the array.
    
            * bindings/js/JSFloat32ArrayCustom.cpp:
            (WebCore::toJS): Use toJSArrayBufferView.
            * bindings/js/JSInt16ArrayCustom.cpp:
            (WebCore::toJS): Use toJSArrayBufferView.
            * bindings/js/JSInt32ArrayCustom.cpp:
            (WebCore::toJS): Use toJSArrayBufferView.
            * bindings/js/JSInt8ArrayCustom.cpp:
            (WebCore::toJS): Use toJSArrayBufferView.
            * bindings/js/JSUint16ArrayCustom.cpp:
            (WebCore::toJS): Use toJSArrayBufferView.
            * bindings/js/JSUint32ArrayCustom.cpp:
            (WebCore::toJS): Use toJSArrayBufferView.
            * bindings/js/JSUint8ArrayCustom.cpp:
            (WebCore::toJS): Use toJSArrayBufferView.
    
            * html/HTMLCanvasElement.cpp:
            (WebCore::HTMLCanvasElement::createImageBuffer): Call heap.reportExtraMemoryCost()
            with the size of the canvas backing store.
    
            * html/canvas/TypedArrayBase.h:
            (WebCore::TypedArrayBase::byteLength): byteLength needs to
            be public.
    
            * platform/graphics/ImageBuffer.h: Add dataSize() method.
    
            * platform/graphics/cairo/ImageBufferCairo.cpp:
            (WebCore::ImageBuffer::dataSize): Implement dataSize().
            * platform/graphics/cg/ImageBufferCG.cpp:
            (WebCore::ImageBuffer::dataSize): Implement dataSize().
            * platform/graphics/haiku/ImageBufferHaiku.cpp:
            (WebCore::ImageBuffer::dataSize): Implement dataSize().
            * platform/graphics/qt/ImageBufferQt.cpp:
            (WebCore::ImageBuffer::dataSize): Implement dataSize().
            * platform/graphics/skia/ImageBufferSkia.cpp:
            (WebCore::ImageBuffer::dataSize): Implement dataSize().
            * platform/graphics/wince/ImageBufferWinCE.cpp:
            (WebCore::ImageBuffer::dataSize): Implement dataSize().
            * platform/graphics/wx/ImageBufferWx.cpp:
            (WebCore::ImageBuffer::dataSize): Implement dataSize().
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76371 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 2a366e3..2669043 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,59 @@
+2011-01-21  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Report the sized used by canvases and types arrays
+        https://bugs.webkit.org/show_bug.cgi?id=52856
+
+        Report the memory cost associated with canvas elements,
+        and typed arrays to JavaScript as extraCost, so that it
+        can figure this into its GC behavior.
+
+        * bindings/js/JSArrayBufferViewHelper.h:
+        (WebCore::toJSArrayBufferView): New templatized function, similar
+        to getDOMObjectWrapper() but calls reportExtraMemoryCost() with
+        the byteLength of the array.
+        
+        * bindings/js/JSFloat32ArrayCustom.cpp:
+        (WebCore::toJS): Use toJSArrayBufferView.
+        * bindings/js/JSInt16ArrayCustom.cpp:
+        (WebCore::toJS): Use toJSArrayBufferView.
+        * bindings/js/JSInt32ArrayCustom.cpp:
+        (WebCore::toJS): Use toJSArrayBufferView.
+        * bindings/js/JSInt8ArrayCustom.cpp:
+        (WebCore::toJS): Use toJSArrayBufferView.
+        * bindings/js/JSUint16ArrayCustom.cpp:
+        (WebCore::toJS): Use toJSArrayBufferView.
+        * bindings/js/JSUint32ArrayCustom.cpp:
+        (WebCore::toJS): Use toJSArrayBufferView.
+        * bindings/js/JSUint8ArrayCustom.cpp:
+        (WebCore::toJS): Use toJSArrayBufferView.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::createImageBuffer): Call heap.reportExtraMemoryCost()
+        with the size of the canvas backing store.
+        
+        * html/canvas/TypedArrayBase.h:
+        (WebCore::TypedArrayBase::byteLength): byteLength needs to
+        be public.
+        
+        * platform/graphics/ImageBuffer.h: Add dataSize() method.
+        
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::dataSize): Implement dataSize().
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::dataSize): Implement dataSize().
+        * platform/graphics/haiku/ImageBufferHaiku.cpp:
+        (WebCore::ImageBuffer::dataSize): Implement dataSize().
+        * platform/graphics/qt/ImageBufferQt.cpp:
+        (WebCore::ImageBuffer::dataSize): Implement dataSize().
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::ImageBuffer::dataSize): Implement dataSize().
+        * platform/graphics/wince/ImageBufferWinCE.cpp:
+        (WebCore::ImageBuffer::dataSize): Implement dataSize().
+        * platform/graphics/wx/ImageBufferWx.cpp:
+        (WebCore::ImageBuffer::dataSize): Implement dataSize().
+
 2011-01-21  Adam Roben  <aroben at apple.com>
 
         Rename WKCACFLayerRenderer[Client] to CACFLayerTreeHost[Client]
diff --git a/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h b/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h
index e010406..73229da 100644
--- a/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h
+++ b/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h
@@ -181,6 +181,19 @@ PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec)
     return result;
 }
 
+template <typename JSType, typename WebCoreType>
+static JSC::JSValue toJSArrayBufferView(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebCoreType* object)
+{
+    if (!object)
+        return JSC::jsNull();
+
+    if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec, object))
+        return wrapper;
+
+    exec->heap()->reportExtraMemoryCost(object->byteLength());
+    return createDOMObjectWrapper<JSType>(exec, globalObject, object);
+}
+
 } // namespace WebCore
 
 #endif // JSArrayBufferViewHelper_h
diff --git a/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp
index 880d68c..eb4608c 100644
--- a/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp
+++ b/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp
@@ -43,7 +43,7 @@ void JSFloat32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVa
 
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float32Array* object)
 {
-    return getDOMObjectWrapper<JSFloat32Array>(exec, globalObject, object);
+    return toJSArrayBufferView<JSFloat32Array>(exec, globalObject, object);
 }
 
 JSC::JSValue JSFloat32Array::set(JSC::ExecState* exec)
diff --git a/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp
index e08da8a..2e56d0b 100644
--- a/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp
+++ b/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp
@@ -43,7 +43,7 @@ void JSInt16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu
 
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int16Array* object)
 {
-    return getDOMObjectWrapper<JSInt16Array>(exec, globalObject, object);
+    return toJSArrayBufferView<JSInt16Array>(exec, globalObject, object);
 }
 
 JSC::JSValue JSInt16Array::set(JSC::ExecState* exec)
diff --git a/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp
index 5aa64bb..eaf474a 100644
--- a/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp
+++ b/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp
@@ -43,7 +43,7 @@ void JSInt32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu
 
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int32Array* object)
 {
-    return getDOMObjectWrapper<JSInt32Array>(exec, globalObject, object);
+    return toJSArrayBufferView<JSInt32Array>(exec, globalObject, object);
 }
 
 JSC::JSValue JSInt32Array::set(JSC::ExecState* exec)
diff --git a/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp
index b63de54..c4bd007 100644
--- a/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp
+++ b/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp
@@ -44,7 +44,7 @@ void JSInt8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue
 
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int8Array* object)
 {
-    return getDOMObjectWrapper<JSInt8Array>(exec, globalObject, object);
+    return toJSArrayBufferView<JSInt8Array>(exec, globalObject, object);
 }
 
 JSC::JSValue JSInt8Array::set(JSC::ExecState* exec)
diff --git a/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp
index 6a024ee..9e476f2 100644
--- a/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp
+++ b/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp
@@ -43,7 +43,7 @@ void JSUint16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVal
 
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint16Array* object)
 {
-    return getDOMObjectWrapper<JSUint16Array>(exec, globalObject, object);
+    return toJSArrayBufferView<JSUint16Array>(exec, globalObject, object);
 }
 
 JSC::JSValue JSUint16Array::set(JSC::ExecState* exec)
diff --git a/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp
index 34eb8de..d221c2a 100644
--- a/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp
+++ b/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp
@@ -43,7 +43,7 @@ void JSUint32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSVal
 
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint32Array* object)
 {
-    return getDOMObjectWrapper<JSUint32Array>(exec, globalObject, object);
+    return toJSArrayBufferView<JSUint32Array>(exec, globalObject, object);
 }
 
 JSC::JSValue JSUint32Array::set(JSC::ExecState* exec)
diff --git a/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp
index a9ed73f..b37eea8 100644
--- a/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp
+++ b/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp
@@ -43,7 +43,7 @@ void JSUint8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValu
 
 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint8Array* object)
 {
-    return getDOMObjectWrapper<JSUint8Array>(exec, globalObject, object);
+    return toJSArrayBufferView<JSUint8Array>(exec, globalObject, object);
 }
 
 JSC::JSValue JSUint8Array::set(JSC::ExecState* exec)
diff --git a/Source/WebCore/html/HTMLCanvasElement.cpp b/Source/WebCore/html/HTMLCanvasElement.cpp
index 9d15e46..0fdb7b2 100644
--- a/Source/WebCore/html/HTMLCanvasElement.cpp
+++ b/Source/WebCore/html/HTMLCanvasElement.cpp
@@ -406,6 +406,11 @@ void HTMLCanvasElement::createImageBuffer() const
     m_imageBuffer->context()->scale(FloatSize(size.width() / unscaledSize.width(), size.height() / unscaledSize.height()));
     m_imageBuffer->context()->setShadowsIgnoreTransforms(true);
     m_imageBuffer->context()->setImageInterpolationQuality(DefaultInterpolationQuality);
+
+#if USE(JSC)
+    if (hasCachedDOMNodeWrapperUnchecked(document(), const_cast<HTMLCanvasElement*>(this)))
+        scriptExecutionContext()->globalData()->heap.reportExtraMemoryCost(m_imageBuffer->dataSize());
+#endif
 }
 
 GraphicsContext* HTMLCanvasElement::drawingContext() const
diff --git a/Source/WebCore/html/canvas/TypedArrayBase.h b/Source/WebCore/html/canvas/TypedArrayBase.h
index 2bef6f0..a828620 100644
--- a/Source/WebCore/html/canvas/TypedArrayBase.h
+++ b/Source/WebCore/html/canvas/TypedArrayBase.h
@@ -60,7 +60,12 @@ class TypedArrayBase : public ArrayBufferView {
         return m_length;
     }
 
- protected:
+    virtual unsigned byteLength() const
+    {
+        return m_length * sizeof(T);
+    }
+
+protected:
     TypedArrayBase(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
         : ArrayBufferView(buffer, byteOffset)
         , m_length(length)
@@ -110,13 +115,6 @@ class TypedArrayBase : public ArrayBufferView {
     // We do not want to have to access this via a virtual function in subclasses,
     // which is why it is protected rather than private.
     unsigned m_length;
-
-  private:
-    // Overridden from ArrayBufferView.
-    virtual unsigned byteLength() const
-    {
-        return m_length * sizeof(T);
-    }
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h
index a6cc0d6..48878da 100644
--- a/Source/WebCore/platform/graphics/ImageBuffer.h
+++ b/Source/WebCore/platform/graphics/ImageBuffer.h
@@ -82,6 +82,8 @@ namespace WebCore {
         int width() const { return m_size.width(); }
         int height() const { return m_size.height(); }
         
+        size_t dataSize() const;
+        
         GraphicsContext* context() const;
 
         bool drawsUsingCopy() const; // If the image buffer has to render using a copied image, it will return true.
diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
index ac5da3d..51b5ee6 100644
--- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
@@ -91,6 +91,11 @@ ImageBuffer::~ImageBuffer()
     cairo_surface_destroy(m_data.m_surface);
 }
 
+size_t ImageBuffer::dataSize() const
+{
+    return m_size.width() * m_size.height() * 4;
+}
+
 GraphicsContext* ImageBuffer::context() const
 {
     return m_context.get();
diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
index 023d098..295f632 100644
--- a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
@@ -173,6 +173,11 @@ ImageBuffer::~ImageBuffer()
 {
 }
 
+size_t ImageBuffer::dataSize() const
+{
+    return m_size.height() * m_data.m_bytesPerRow;
+}
+
 GraphicsContext* ImageBuffer::context() const
 {
     return m_context.get();
diff --git a/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp b/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp
index bdad6a0..7a7c88b 100644
--- a/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp
+++ b/Source/WebCore/platform/graphics/haiku/ImageBufferHaiku.cpp
@@ -78,6 +78,11 @@ ImageBuffer::~ImageBuffer()
 {
 }
 
+size_t ImageBuffer::dataSize() const
+{
+    return m_size.width() * m_size.height() * 4;
+}
+
 GraphicsContext* ImageBuffer::context() const
 {
     ASSERT(m_data.m_view.Window());
diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index f56603d..d1567ec 100644
--- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -95,6 +95,11 @@ ImageBuffer::~ImageBuffer()
 {
 }
 
+size_t ImageBuffer::dataSize() const
+{
+    return m_size.width() * m_size.height() * 4;
+}
+
 GraphicsContext* ImageBuffer::context() const
 {
     ASSERT(m_data.m_painter->isActive());
diff --git a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
index b65b5bd..2c489ef 100644
--- a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
+++ b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
@@ -91,6 +91,11 @@ GraphicsContext* ImageBuffer::context() const
     return m_context.get();
 }
 
+size_t ImageBuffer::dataSize() const
+{
+    return m_size.width() * m_size.height() * 4;
+}
+
 bool ImageBuffer::drawsUsingCopy() const
 {
     return false;
diff --git a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
index 537d27d..b5118f6 100644
--- a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
+++ b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
@@ -88,6 +88,11 @@ ImageBuffer::~ImageBuffer()
 {
 }
 
+size_t ImageBuffer::dataSize() const
+{
+    return m_size.width() * m_size.height() * 4;
+}
+
 GraphicsContext* ImageBuffer::context() const
 {
     return m_context.get();
diff --git a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp
index ba33287..b603a60 100644
--- a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp
+++ b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp
@@ -48,6 +48,12 @@ ImageBuffer::~ImageBuffer()
 {
 }
 
+size_t ImageBuffer::dataSize() const
+{
+    notImplemented();
+    return 0;
+}
+
 GraphicsContext* ImageBuffer::context() const
 {
     notImplemented();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list