All pastes #804376 Raw Edit

Something

public text v1 · immutable
·published 2007-12-03 12:46 UTC
rendered paste body
Index: WebCore/ChangeLog
===================================================================
--- WebCore/ChangeLog	(revision 28344)
+++ WebCore/ChangeLog	(working copy)
@@ -1,3 +1,18 @@
+2007-12-03  Alp Toker  <alp@atoker.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        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: WebCore/platform/graphics/cairo/ImageCairo.cpp
===================================================================
--- WebCore/platform/graphics/cairo/ImageCairo.cpp	(revision 28344)
+++ WebCore/platform/graphics/cairo/ImageCairo.cpp	(working copy)
@@ -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* 
 
     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->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: WebCore/platform/graphics/cairo/ImageSourceCairo.cpp
===================================================================
--- WebCore/platform/graphics/cairo/ImageSourceCairo.cpp	(revision 28344)
+++ WebCore/platform/graphics/cairo/ImageSourceCairo.cpp	(working copy)
@@ -112,10 +112,12 @@ void ImageSource::setData(SharedBuffer* 
     // 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: WebCore/platform/graphics/gtk/ImageGtk.cpp
===================================================================
--- WebCore/platform/graphics/gtk/ImageGtk.cpp	(revision 28344)
+++ WebCore/platform/graphics/gtk/ImageGtk.cpp	(working copy)
@@ -24,12 +24,11 @@
  */
 
 #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*);