2007-12-03 Alp Toker <alp@atoker.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2007 12:57:14 +0000 (12:57 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2007 12:57:14 +0000 (12:57 +0000)
        Reviewed by Mark Rowe.

        Don't delete the decoder if it's already been created. The one we have
        is fine.

        Cairo image cleanups. Nothing substantial.

        Notify ImageObservers where appropriate.

        * platform/graphics/cairo/ImageCairo.cpp:
        (WebCore::BitmapImage::draw):
        (WebCore::Image::drawPattern):
        * platform/graphics/cairo/ImageSourceCairo.cpp:
        (WebCore::ImageSource::setData):
        * platform/graphics/gtk/ImageGtk.cpp:

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

WebCore/ChangeLog
WebCore/platform/graphics/cairo/ImageCairo.cpp
WebCore/platform/graphics/cairo/ImageSourceCairo.cpp
WebCore/platform/graphics/gtk/ImageGtk.cpp

index cd1afa1aeb3b5114cf647eaaff2051fbdfff468e..26bdaf07cbf1adbd93fdcff8839e4b3de5a431fe 100644 (file)
@@ -1,3 +1,21 @@
+2007-12-03  Alp Toker  <alp@atoker.com>
+
+        Reviewed by Mark Rowe.
+
+        Don't delete the decoder if it's already been created. The one we have
+        is fine.
+
+        Cairo image cleanups. Nothing substantial.
+
+        Notify ImageObservers where appropriate.
+
+        * platform/graphics/cairo/ImageCairo.cpp:
+        (WebCore::BitmapImage::draw):
+        (WebCore::Image::drawPattern):
+        * platform/graphics/cairo/ImageSourceCairo.cpp:
+        (WebCore::ImageSource::setData):
+        * platform/graphics/gtk/ImageGtk.cpp:
+
 2007-12-03  Simon Hausmann  <hausmann@webkit.org>
 
         Reviewed by Lars.
index 5b23f72a65532c1670de4447bd5f5c00fdc386b1..143d528f809733b8ab48ce0399d4e9c07a945172 100644 (file)
@@ -32,6 +32,7 @@
 #include "AffineTransform.h"
 #include "FloatRect.h"
 #include "GraphicsContext.h"
+#include "ImageObserver.h"
 #include <cairo.h>
 #include <math.h>
 
@@ -47,27 +48,26 @@ void FrameData::clear()
     }
 }
 
-// ================================================
-// Image Class
-// ================================================
-
-// Drawing Routines
-
 void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, CompositeOperator op)
 {
-    cairo_t* cr = context->platformContext();
-
     if (!m_source.initialized())
         return;
 
+    FloatRect srcRect(src);
+    FloatRect dstRect(dst);
+
     cairo_surface_t* image = frameAtIndex(m_currentFrame);
     if (!image) // If it's too early we won't have an image yet.
         return;
 
+    if (mayFillWithSolidColor()) {
+        fillWithSolidColor(context, dstRect, solidColor(), op);
+        return;
+    }
+
     IntSize selfSize = size();
-    FloatRect srcRect(src);
-    FloatRect dstRect(dst);
 
+    cairo_t* cr = context->platformContext();
     cairo_save(cr);
 
     // Set the compositing operation.
@@ -89,19 +89,22 @@ void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo
 
     float scaleX = srcRect.width() / dstRect.width();
     float scaleY = srcRect.height() / dstRect.height();
-    cairo_matrix_t matrix = { scaleX,  0, 0 , scaleY, srcRect.x(), srcRect.y() };
+    cairo_matrix_t matrix = { scaleX, 0, 0, scaleY, srcRect.x(), srcRect.y() };
     cairo_pattern_set_matrix(pattern, &matrix);
 
     // Draw the image.
     cairo_translate(cr, dstRect.x(), dstRect.y());
     cairo_set_source(cr, pattern);
+    cairo_pattern_destroy(pattern);
     cairo_rectangle(cr, 0, 0, dstRect.width(), dstRect.height());
     cairo_fill(cr);
 
-    cairo_pattern_destroy(pattern);
     cairo_restore(cr);
 
     startAnimation();
+
+    if (imageObserver())
+        imageObserver()->didDraw(this);
 }
 
 void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform,
@@ -131,11 +134,14 @@ void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, con
 
     context->setCompositeOperation(op);
     cairo_set_source(cr, pattern);
+    cairo_pattern_destroy(pattern);
     cairo_rectangle(cr, destRect.x(), destRect.y(), destRect.width(), destRect.height());
     cairo_fill(cr);
 
-    cairo_pattern_destroy(pattern);
     context->restore();
+
+    if (imageObserver())
+        imageObserver()->didDraw(this);
 }
 
 void BitmapImage::checkForSolidColor()
index 7d0b4bedf7baba319ae56b58f23ec6f1f44bdb49..84c1c12096e8c9a5fd0e8ad528694896b2e6e3af 100644 (file)
@@ -112,10 +112,12 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
     // This method will examine the data and instantiate an instance of the appropriate decoder plugin.
     // If insufficient bytes are available to determine the image type, no decoder plugin will be
     // made.
-    delete m_decoder;
-    m_decoder = createDecoder(data->buffer());
+    if (!m_decoder)
+        m_decoder = createDecoder(data->buffer());
+
     if (!m_decoder)
         return;
+
     m_decoder->setData(data, allDataReceived);
 }
 
index 3e1f123537762b97603b7acfbc83c0d278f8ef43..c27ce5d47248f29ba55b4f4365d72d19f8ce5fe6 100644 (file)
  */
 
 #include "config.h"
-#include "Image.h"
 
 #include "BitmapImage.h"
+#include "Image.h"
 #include "NotImplemented.h"
-#include <cairo.h>
+
 // This function loads resources from WebKit
 Vector<char> loadResourceIntoArray(const char*);