Reviewed by Sam Weinig.
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Jul 2009 23:41:26 +0000 (23:41 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Jul 2009 23:41:26 +0000 (23:41 +0000)
        - Image cleanup

        * platform/graphics/BitmapImage.cpp:
        (WebCore::BitmapImage::destroyDecodedData): Use the data() accessor
        instead of the m_data member.
        (WebCore::BitmapImage::dataChanged): Ditto.
        * platform/graphics/Image.h: Re-ordered #includes and class
        declarations. Removed the drawPatternCallback() declaration. Made member
        variables private.
        * platform/graphics/cg/ImageCG.cpp:
        (WebCore::drawPatternCallback): Changed this from a member function to a
        static function.
        * platform/graphics/cg/PDFDocumentImage.cpp:
        (WebCore::PDFDocumentImage::dataChanged): Use the data() accessor
        instead of the m_data member.
        * svg/graphics/SVGImage.cpp:
        (WebCore::SVGImage::dataChanged): Ditto.

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

WebCore/ChangeLog
WebCore/platform/graphics/BitmapImage.cpp
WebCore/platform/graphics/Image.h
WebCore/platform/graphics/cg/ImageCG.cpp
WebCore/platform/graphics/cg/PDFDocumentImage.cpp
WebCore/svg/graphics/SVGImage.cpp

index 612089b..24709b9 100644 (file)
@@ -1,3 +1,25 @@
+2009-07-12  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        - Image cleanup
+
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::destroyDecodedData): Use the data() accessor
+        instead of the m_data member.
+        (WebCore::BitmapImage::dataChanged): Ditto.
+        * platform/graphics/Image.h: Re-ordered #includes and class
+        declarations. Removed the drawPatternCallback() declaration. Made member
+        variables private.
+        * platform/graphics/cg/ImageCG.cpp:
+        (WebCore::drawPatternCallback): Changed this from a member function to a
+        static function.
+        * platform/graphics/cg/PDFDocumentImage.cpp:
+        (WebCore::PDFDocumentImage::dataChanged): Use the data() accessor
+        instead of the m_data member.
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::dataChanged): Ditto.
+
 2009-07-12  Daniel Bates  <dbates@intudata.com>
 
         Reviewed by Darin Adler.
index 8933d7b..32aefc9 100644 (file)
@@ -86,7 +86,7 @@ void BitmapImage::destroyDecodedData(bool destroyAll)
 
     destroyMetadataAndNotify(framesCleared);
 
-    m_source.clear(destroyAll, clearBeforeFrame, m_data.get(), m_allDataReceived);
+    m_source.clear(destroyAll, clearBeforeFrame, data(), m_allDataReceived);
     return;
 }
 
@@ -163,7 +163,7 @@ bool BitmapImage::dataChanged(bool allDataReceived)
     
     // Feed all the data we've seen so far to the image decoder.
     m_allDataReceived = allDataReceived;
-    m_source.setData(m_data.get(), allDataReceived);
+    m_source.setData(data(), allDataReceived);
     
     // Clear the frame count.
     m_haveFrameCount = false;
index bb61043..c0d07c9 100644 (file)
@@ -31,9 +31,9 @@
 #include "GraphicsTypes.h"
 #include "ImageSource.h"
 #include "IntRect.h"
-#include <wtf/RefPtr.h>
-#include <wtf/PassRefPtr.h>
 #include "SharedBuffer.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
 
 #if PLATFORM(MAC)
 #ifdef __OBJC__
@@ -67,13 +67,13 @@ typedef struct _GdkPixbuf GdkPixbuf;
 
 namespace WebCore {
 
-class TransformationMatrix;
 class FloatPoint;
 class FloatRect;
 class FloatSize;
 class GraphicsContext;
 class SharedBuffer;
 class String;
+class TransformationMatrix;
 
 // This class gets notified when an image creates or destroys decoded frames and when it advances animation frames.
 class ImageObserver;
@@ -81,6 +81,7 @@ class ImageObserver;
 class Image : public RefCounted<Image> {
     friend class GeneratedImage;
     friend class GraphicsContext;
+
 public:
     virtual ~Image();
     
@@ -168,13 +169,8 @@ protected:
     
     virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform,
                              const FloatPoint& phase, CompositeOperator, const FloatRect& destRect);
-#if PLATFORM(CG)
-    // These are private to CG.  Ideally they would be only in the .cpp file, but the callback requires access
-    // to the private function nativeImageForCurrentFrame()
-    static void drawPatternCallback(void* info, CGContext*);
-#endif
-    
-protected:
+
+private:
     RefPtr<SharedBuffer> m_data; // The encoded raw data for the image. 
     ImageObserver* m_imageObserver;
 };
index dbf1d85..2bb0e53 100644 (file)
@@ -205,7 +205,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const F
         imageObserver()->didDraw(this);
 }
 
-void Image::drawPatternCallback(void* info, CGContextRef context)
+static void drawPatternCallback(void* info, CGContextRef context)
 {
     CGImageRef image = (CGImageRef)info;
     CGContextDrawImage(context, GraphicsContext(context).roundToDevicePixels(FloatRect(0, 0, CGImageGetWidth(image), CGImageGetHeight(image))), image);
index 2578f08..257b991 100644 (file)
@@ -68,11 +68,11 @@ bool PDFDocumentImage::dataChanged(bool allDataReceived)
 #if PLATFORM(MAC)
         // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.  We use SharedBuffer's ability
         // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
-        CFDataRef data = m_data->createCFData();
+        CFDataRef data = this->data()->createCFData();
 #else
         // If no NSData is available, then we know SharedBuffer will always just be a vector.  That means no secret changes can occur to it behind the
         // scenes.  We use CFDataCreateWithBytesNoCopy in that case.
-        CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(m_data->data()), m_data->size(), kCFAllocatorNull);
+        CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data()->data()), data()->size(), kCFAllocatorNull);
 #endif
         CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(data);
         CFRelease(data);
index 227b570..4efcf2e 100644 (file)
@@ -222,7 +222,7 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame()
 bool SVGImage::dataChanged(bool allDataReceived)
 {
     // Don't do anything if is an empty image.
-    if (!m_data->size())
+    if (!data()->size())
         return true;
 
     if (allDataReceived) {
@@ -251,7 +251,7 @@ bool SVGImage::dataChanged(bool allDataReceived)
         loader->commitProvisionalLoad(0);
         loader->setResponseMIMEType("image/svg+xml");
         loader->begin(KURL()); // create the empty document
-        loader->write(m_data->data(), m_data->size());
+        loader->write(data()->data(), data()->size());
         loader->end();
         frame->view()->setTransparent(true); // SVG Images are transparent.
     }