Web Inspector: NMI: Instrument WebCore part of the Image class hierarchy
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 09:28:48 +0000 (09:28 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 09:28:48 +0000 (09:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94959

Drive by fix: remove unused GeneratedImage.cpp

Reviewed by Yury Semikhatsky.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::reportMemoryUsage):
(WebCore):
* html/HTMLImageElement.h:
(HTMLImageElement):
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::reportMemoryUsage):
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::reportMemoryUsage):
(WebCore):
* platform/graphics/BitmapImage.h:
(FrameData):
(BitmapImage):
* platform/graphics/CrossfadeGeneratedImage.cpp:
(WebCore::CrossfadeGeneratedImage::reportMemoryUsage):
(WebCore):
* platform/graphics/CrossfadeGeneratedImage.h:
(WebCore):
(CrossfadeGeneratedImage):
* platform/graphics/GeneratedImage.cpp: Removed.
* platform/graphics/GeneratedImage.h:
(GeneratedImage):
* platform/graphics/GeneratorGeneratedImage.cpp:
(WebCore::GeneratedImage::reportMemoryUsage):
(WebCore):
(WebCore::GeneratorGeneratedImage::reportMemoryUsage):
* platform/graphics/GeneratorGeneratedImage.h:
(GeneratorGeneratedImage):
* platform/graphics/Image.cpp:
(WebCore::Image::reportMemoryUsage):
(WebCore):
* platform/graphics/Image.h:
(WebCore):
(Image):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::reportMemoryUsage):
(WebCore):
* svg/graphics/SVGImage.h:
(SVGImage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126974 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLImageElement.h
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp
Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h
Source/WebCore/platform/graphics/GeneratedImage.cpp [deleted file]
Source/WebCore/platform/graphics/GeneratedImage.h
Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp
Source/WebCore/platform/graphics/GeneratorGeneratedImage.h
Source/WebCore/platform/graphics/Image.cpp
Source/WebCore/platform/graphics/Image.h
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/svg/graphics/SVGImage.h

index 40421c0..f997834 100644 (file)
@@ -1,3 +1,52 @@
+2012-08-24  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: NMI: Instrument WebCore part of the Image class hierarchy
+        https://bugs.webkit.org/show_bug.cgi?id=94959
+
+        Drive by fix: remove unused GeneratedImage.cpp
+
+        Reviewed by Yury Semikhatsky.
+
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::reportMemoryUsage):
+        (WebCore):
+        * html/HTMLImageElement.h:
+        (HTMLImageElement):
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::reportMemoryUsage):
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::reportMemoryUsage):
+        (WebCore):
+        * platform/graphics/BitmapImage.h:
+        (FrameData):
+        (BitmapImage):
+        * platform/graphics/CrossfadeGeneratedImage.cpp:
+        (WebCore::CrossfadeGeneratedImage::reportMemoryUsage):
+        (WebCore):
+        * platform/graphics/CrossfadeGeneratedImage.h:
+        (WebCore):
+        (CrossfadeGeneratedImage):
+        * platform/graphics/GeneratedImage.cpp: Removed.
+        * platform/graphics/GeneratedImage.h:
+        (GeneratedImage):
+        * platform/graphics/GeneratorGeneratedImage.cpp:
+        (WebCore::GeneratedImage::reportMemoryUsage):
+        (WebCore):
+        (WebCore::GeneratorGeneratedImage::reportMemoryUsage):
+        * platform/graphics/GeneratorGeneratedImage.h:
+        (GeneratorGeneratedImage):
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::reportMemoryUsage):
+        (WebCore):
+        * platform/graphics/Image.h:
+        (WebCore):
+        (Image):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::reportMemoryUsage):
+        (WebCore):
+        * svg/graphics/SVGImage.h:
+        (SVGImage):
+
 2012-08-29  Dominic Mazzoni  <dmazzoni@google.com>
 
         AX: Canvas should have a distinct role
index ba0fd99..5d1cd07 100644 (file)
@@ -421,4 +421,12 @@ inline ImageInnerElement* HTMLImageElement::innerElement() const
     return toImageInnerElement(userAgentShadowRoot()->firstChild());
 }
 
+void HTMLImageElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+    HTMLElement::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_imageLoader);
+    info.addInstrumentedMember(m_form);
+}
+
 }
index ae8e7cb..4657d7c 100644 (file)
@@ -89,6 +89,8 @@ public:
 
     virtual bool canContainRangeEndPoint() const { return false; }
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 protected:
     HTMLImageElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
 
index 11588a0..be4cea5 100644 (file)
@@ -478,11 +478,7 @@ void CachedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CachedResourceImage);
     CachedResource::reportMemoryUsage(memoryObjectInfo);
-    if (m_image) {
-        if (m_image->data())
-            info.addRawBuffer(m_image->data(), m_image->data()->size());
-        info.addRawBuffer(m_image.get(), decodedSize());
-    }
+    info.addInstrumentedMember(m_image);
 #if ENABLE(SVG)
     info.addMember(m_svgImageCache);
 #endif
index 440628b..77fa2f3 100644 (file)
@@ -31,6 +31,7 @@
 #include "ImageObserver.h"
 #include "IntRect.h"
 #include "MIMETypeRegistry.h"
+#include "MemoryInstrumentation.h"
 #include "PlatformString.h"
 #include "Timer.h"
 #include <wtf/CurrentTime.h>
@@ -571,4 +572,16 @@ Color BitmapImage::solidColor() const
     return m_solidColor;
 }
 
+void BitmapImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CachedResourceImage);
+    Image::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_source);
+    info.addMember(m_frameTimer);
+    info.addVector(m_frames);
+    int size = frameBytes(m_size);
+    for (unsigned i = 0; i < m_frameCount; ++i)
+        info.addRawBuffer(m_frames[i].m_frame, size);
+}
+
 }
index 90b335a..10b3729 100644 (file)
@@ -87,6 +87,7 @@ public:
     // Clear the cached image data on the frame, and (optionally) the metadata.
     // Returns whether there was cached image data to clear.
     bool clear(bool clearMetadata);
+    void reportMemoryUsage(MemoryObjectInfo*) const;
 
     NativeImagePtr m_frame;
     ImageOrientation m_orientation;
@@ -180,6 +181,8 @@ public:
     virtual bool notSolidColor();
 #endif
 
+    void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 private:
     void updateSize() const;
 
index 708dcd0..e675001 100644 (file)
@@ -29,6 +29,7 @@
 #include "FloatRect.h"
 #include "GraphicsContext.h"
 #include "ImageBuffer.h"
+#include "MemoryInstrumentation.h"
 
 using namespace std;
 
@@ -107,4 +108,12 @@ void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatR
     imageBuffer->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, compositeOp, dstRect);
 }
 
+void CrossfadeGeneratedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+    GeneratedImage::reportMemoryUsage(memoryObjectInfo);
+    info.addInstrumentedMember(m_fromImage);
+    info.addInstrumentedMember(m_toImage);
+}
+
 }
index eb06b6d..b73a239 100644 (file)
@@ -35,6 +35,7 @@
 namespace WebCore {
 
 class CSSCrossfadeValue;
+class MemoryObjectInfo;
 
 class CrossfadeGeneratedImage : public GeneratedImage {
 public:
@@ -50,6 +51,8 @@ public:
 
     virtual IntSize size() const { return m_crossfadeSize; }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 protected:
     virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
     virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& dstRect);
diff --git a/Source/WebCore/platform/graphics/GeneratedImage.cpp b/Source/WebCore/platform/graphics/GeneratedImage.cpp
deleted file mode 100644 (file)
index 5e06dfd..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2008, 2009, 2010 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "GeneratedImage.h"
-
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "ImageBuffer.h"
-#include "Length.h"
-
-namespace WebCore {
-
-void GeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
-{
-    GraphicsContextStateSaver stateSaver(*context);
-    context->setCompositeOperation(compositeOp);
-    context->clip(dstRect);
-    context->translate(dstRect.x(), dstRect.y());
-    if (dstRect.size() != srcRect.size())
-        context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
-    context->translate(-srcRect.x(), -srcRect.y());
-    context->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
-}
-
-void GeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
-                                 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
-{
-    // Allow the generator to provide visually-equivalent tiling parameters for better performance.
-    IntSize adjustedSize = m_size;
-    FloatRect adjustedSrcRect = srcRect;
-    m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
-
-    // Create a BitmapImage and call drawPattern on it.
-    OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(adjustedSize);
-    if (!imageBuffer)
-        return;
-
-    // Fill with the gradient.
-    GraphicsContext* graphicsContext = imageBuffer->context();
-    graphicsContext->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator.get());
-
-    // Tile the image buffer into the context.
-    imageBuffer->drawPattern(context, adjustedSrcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
-}
-
-void GeneratedImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
-{
-    Image::computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
-    intrinsicRatio = FloatSize();
-}
-
-}
index bec343c..d294af7 100644 (file)
@@ -50,6 +50,8 @@ public:
     virtual void destroyDecodedData(bool /*destroyAll*/ = true) { }
     virtual unsigned decodedSize() const { return 0; }
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 protected:
     virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator) = 0;
     virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
index c98603a..30ac346 100644 (file)
@@ -85,10 +85,25 @@ void GeneratedImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length&
     intrinsicRatio = FloatSize();
 }
 
+void GeneratedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CachedResourceImage);
+    Image::reportMemoryUsage(memoryObjectInfo);
+}
+
 void GeneratorGeneratedImage::invalidateCacheTimerFired(DeferrableOneShotTimer<GeneratorGeneratedImage>*)
 {
     m_cachedImageBuffer.clear();
     m_cachedAdjustedSize = IntSize();
 }
 
+void GeneratorGeneratedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+    GeneratedImage::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_generator);
+    info.addMember(m_cachedImageBuffer);
+    info.addMember(m_cacheTimer);
+}
+
 }
index 071c2c0..b803129 100644 (file)
@@ -31,6 +31,7 @@
 #include "Image.h"
 #include "ImageBuffer.h"
 #include "IntSize.h"
+#include "MemoryInstrumentation.h"
 #include "Timer.h"
 #include <wtf/RefPtr.h>
 
@@ -50,6 +51,8 @@ public:
         m_cacheTimer.stop();
     }
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 protected:
     virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
     virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
index 655b6d1..0255603 100644 (file)
 #include "AffineTransform.h"
 #include "BitmapImage.h"
 #include "GraphicsContext.h"
+#include "ImageObserver.h"
 #include "IntRect.h"
 #include "Length.h"
 #include "MIMETypeRegistry.h"
+#include "MemoryInstrumentation.h"
 #include "SharedBuffer.h"
 #include <math.h>
 #include <wtf/MainThread.h>
@@ -196,4 +198,11 @@ void Image::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsic
     intrinsicHeight = Length(intrinsicRatio.height(), Fixed);
 }
 
+void Image::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CachedResourceImage);
+    info.addInstrumentedMember(m_data);
+    info.addMember(m_imageObserver);
+}
+
 }
index 7c7ba9b..a52af3e 100644 (file)
@@ -64,6 +64,7 @@ class FloatPoint;
 class FloatRect;
 class FloatSize;
 class GraphicsContext;
+class MemoryObjectInfo;
 class SharedBuffer;
 struct Length;
 
@@ -168,6 +169,8 @@ public:
     virtual bool notSolidColor() { return true; }
 #endif
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     Image(ImageObserver* = 0);
 
index 3527913..f36f9a8 100644 (file)
@@ -355,6 +355,15 @@ String SVGImage::filenameExtension() const
     return "svg";
 }
 
+void SVGImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CachedResourceImage);
+    Image::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_chromeClient);
+    info.addMember(m_page);
+    info.addInstrumentedMember(m_frameCache);
+}
+
 }
 
 #endif // ENABLE(SVG)
index b3631bf..36b32ba 100644 (file)
@@ -61,6 +61,8 @@ public:
     virtual bool hasRelativeWidth() const;
     virtual bool hasRelativeHeight() const;
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 private:
     friend class SVGImageChromeClient;
     virtual ~SVGImage();