Diff
Modified: trunk/Source/WebCore/ChangeLog (115384 => 115385)
--- trunk/Source/WebCore/ChangeLog 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/ChangeLog 2012-04-26 23:03:06 UTC (rev 115385)
@@ -1,3 +1,33 @@
+2012-04-26 Martin Robinson <[email protected]>
+
+ [Cairo] Wrap cairo surfaces in a class when storing native images
+ https://bugs.webkit.org/show_bug.cgi?id=83611
+
+ Reviewed by Alejandro G. Castro.
+
+ No new tests. This is just a refactoring. This shouldn't change
+ functionality.
+
+ Added class that wraps Cairo images surfaces to serve as the "native image"
+ type for the Cairo platform. This will allow the addition of caching resampled
+ images as well as versions of the image for non-image Cairo backends. Also
+ split out BitmapImageCairo.cpp from ImageCairo.cpp since these classes are
+ defined in two headers.
+
+ * GNUmakefile.list.am: Added new files.
+ * platform/graphics/BitmapImage.h: Added a factory method that takes an image surface to
+ reduce code churn.
+ * platform/graphics/ImageSource.h: NativeImagePtr is now NativeImageCairo*.
+ (WebCore):
+ * platform/graphics/cairo/BitmapImageCairo.cpp: Copied from Source/WebCore/platform/graphics/cairo/ImageCairo.cpp.
+ * platform/graphics/cairo/GraphicsContext3DCairo.cpp: Updated to reflect use of NativeImageCairo.
+ * platform/graphics/cairo/ImageCairo.cpp: Ditto.
+ * platform/graphics/cairo/NativeImageCairo.cpp: Added.
+ * platform/graphics/cairo/NativeImageCairo.h: Added.
+ * platform/graphics/cairo/PatternCairo.cpp: Updated to reflect use of NativeImageCairo.
+ * platform/graphics/gtk/ImageGtk.cpp: Ditto.
+ * platform/image-decoders/cairo/ImageDecoderCairo.cpp: Ditto.
+
2012-04-26 Mark Hahnenberg <[email protected]>
[GTK] Massive media tests failures since r115288
Modified: trunk/Source/WebCore/GNUmakefile.list.am (115384 => 115385)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-04-26 23:03:06 UTC (rev 115385)
@@ -3108,6 +3108,7 @@
Source/WebCore/platform/graphics/ColorSpace.h \
Source/WebCore/platform/graphics/DashArray.h \
Source/WebCore/platform/graphics/Extensions3D.h \
+ Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp \
Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp \
Source/WebCore/platform/graphics/cairo/CairoUtilities.h \
Source/WebCore/platform/graphics/cairo/FloatRectCairo.cpp \
@@ -3118,6 +3119,8 @@
Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h \
Source/WebCore/platform/graphics/cairo/ImageCairo.cpp \
Source/WebCore/platform/graphics/cairo/IntRectCairo.cpp \
+ Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp \
+ Source/WebCore/platform/graphics/cairo/NativeImageCairo.h \
Source/WebCore/platform/graphics/cairo/OwnPtrCairo.cpp \
Source/WebCore/platform/graphics/cairo/OwnPtrCairo.h \
Source/WebCore/platform/graphics/cairo/PathCairo.cpp \
Modified: trunk/Source/WebCore/PlatformEfl.cmake (115384 => 115385)
--- trunk/Source/WebCore/PlatformEfl.cmake 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/PlatformEfl.cmake 2012-04-26 23:03:06 UTC (rev 115385)
@@ -119,12 +119,14 @@
)
LIST(APPEND WebCore_SOURCES
platform/cairo/WidgetBackingStoreCairo.cpp
+ platform/graphics/cairo/BitmapImageCairo.cpp
platform/graphics/cairo/CairoUtilities.cpp
platform/graphics/cairo/FontCairo.cpp
platform/graphics/cairo/GradientCairo.cpp
platform/graphics/cairo/GraphicsContextCairo.cpp
platform/graphics/cairo/ImageBufferCairo.cpp
platform/graphics/cairo/ImageCairo.cpp
+ platform/graphics/cairo/NativeImageCairo.cpp
platform/graphics/cairo/OwnPtrCairo.cpp
platform/graphics/cairo/PathCairo.cpp
platform/graphics/cairo/PatternCairo.cpp
Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (115384 => 115385)
--- trunk/Source/WebCore/platform/graphics/BitmapImage.h 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h 2012-04-26 23:03:06 UTC (rev 115385)
@@ -160,6 +160,10 @@
virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE);
#endif
+#if USE(CAIRO)
+ static PassRefPtr<BitmapImage> create(cairo_surface_t*);
+#endif
+
#if PLATFORM(GTK)
virtual GdkPixbuf* getGdkPixbuf();
#endif
Modified: trunk/Source/WebCore/platform/graphics/ImageSource.h (115384 => 115385)
--- trunk/Source/WebCore/platform/graphics/ImageSource.h 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/graphics/ImageSource.h 2012-04-26 23:03:06 UTC (rev 115385)
@@ -46,8 +46,7 @@
class QPixmap;
QT_END_NAMESPACE
#elif USE(CAIRO)
-struct _cairo_surface;
-typedef struct _cairo_surface cairo_surface_t;
+#include "NativeImageCairo.h"
#elif USE(SKIA)
namespace WebCore {
class NativeImageSkia;
@@ -90,7 +89,7 @@
typedef wxBitmap* NativeImagePtr;
#endif
#elif USE(CAIRO)
-typedef cairo_surface_t* NativeImagePtr;
+typedef WebCore::NativeImageCairo* NativeImagePtr;
#elif USE(SKIA)
typedef WebCore::NativeImageSkia* NativeImagePtr;
#elif OS(WINCE)
Copied: trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp (from rev 115383, trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp) (0 => 115385)
--- trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2007 Alp Toker <[email protected]>
+ * Copyright (C) 2009 Dirk Schulze <[email protected]>
+ *
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "BitmapImage.h"
+
+#include "ImageObserver.h"
+#include "NativeImageCairo.h"
+#include "PlatformContextCairo.h"
+#include <cairo.h>
+
+namespace WebCore {
+
+PassRefPtr<BitmapImage> BitmapImage::create(cairo_surface_t* surface)
+{
+ return BitmapImage::create(new NativeImageCairo(surface));
+}
+
+BitmapImage::BitmapImage(NativeImageCairo* nativeImage, ImageObserver* observer)
+ : Image(observer)
+ , m_currentFrame(0)
+ , m_frames(0)
+ , m_frameTimer(0)
+ , m_repetitionCount(cAnimationNone)
+ , m_repetitionCountStatus(Unknown)
+ , m_repetitionsComplete(0)
+ , m_decodedSize(0)
+ , m_frameCount(1)
+ , m_isSolidColor(false)
+ , m_checkedForSolidColor(false)
+ , m_animationFinished(true)
+ , m_allDataReceived(true)
+ , m_haveSize(true)
+ , m_sizeAvailable(true)
+ , m_haveFrameCount(true)
+{
+ initPlatformData();
+
+ cairo_surface_t* surface = nativeImage->surface();
+ int width = cairo_image_surface_get_width(surface);
+ int height = cairo_image_surface_get_height(surface);
+ m_decodedSize = width * height * 4;
+ m_size = IntSize(width, height);
+
+ m_frames.grow(1);
+ m_frames[0].m_frame = nativeImage;
+ m_frames[0].m_hasAlpha = cairo_surface_get_content(surface) != CAIRO_CONTENT_COLOR;
+ m_frames[0].m_haveMetadata = true;
+ checkForSolidColor();
+}
+
+void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
+{
+ FloatRect srcRect(src);
+ FloatRect dstRect(dst);
+
+ if (!dstRect.width() || !dstRect.height() || !srcRect.width() || !srcRect.height())
+ return;
+
+ startAnimation();
+
+ NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame);
+ if (!nativeImage) // If it's too early we won't have an image yet.
+ return;
+
+ if (mayFillWithSolidColor()) {
+ fillWithSolidColor(context, dstRect, solidColor(), styleColorSpace, op);
+ return;
+ }
+
+ context->save();
+
+ // Set the compositing operation.
+ if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame))
+ context->setCompositeOperation(CompositeCopy);
+ else
+ context->setCompositeOperation(op);
+ context->platformContext()->drawSurfaceToContext(nativeImage->surface(), dstRect, srcRect, context);
+
+ context->restore();
+
+ if (imageObserver())
+ imageObserver()->didDraw(this);
+}
+
+void BitmapImage::checkForSolidColor()
+{
+ m_isSolidColor = false;
+ m_checkedForSolidColor = true;
+
+ if (frameCount() > 1)
+ return;
+
+ NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame);
+ if (!nativeImage) // If it's too early we won't have an image yet.
+ return;
+
+ cairo_surface_t* surface = nativeImage->surface();
+ ASSERT(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE);
+
+ int width = cairo_image_surface_get_width(surface);
+ int height = cairo_image_surface_get_height(surface);
+
+ if (width != 1 || height != 1)
+ return;
+
+ unsigned* pixelColor = reinterpret_cast<unsigned*>(cairo_image_surface_get_data(surface));
+ m_solidColor = colorFromPremultipliedARGB(*pixelColor);
+
+ m_isSolidColor = true;
+}
+
+bool FrameData::clear(bool clearMetadata)
+{
+ if (clearMetadata)
+ m_haveMetadata = false;
+
+ if (m_frame) {
+ delete m_frame;
+ m_frame = 0;
+ return true;
+ }
+ return false;
+}
+
+} // namespace WebCore
+
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (115384 => 115385)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -157,9 +157,9 @@
decoder.setData(image->data(), true);
if (!decoder.frameCount() || !decoder.frameIsCompleteAtIndex(0))
return false;
- imageSurface = decoder.createFrameAtIndex(0);
+ imageSurface = decoder.createFrameAtIndex(0)->surface();
} else {
- imageSurface = image->nativeImageForCurrentFrame();
+ imageSurface = image->nativeImageForCurrentFrame()->surface();
if (!premultiplyAlpha)
alphaOp = AlphaDoUnmultiply;
}
Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp (115384 => 115385)
--- trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -26,147 +26,36 @@
*/
#include "config.h"
-#include "BitmapImage.h"
+#include "Image.h"
#if USE(CAIRO)
#include "AffineTransform.h"
#include "CairoUtilities.h"
#include "Color.h"
-#include "FloatRect.h"
#include "GraphicsContext.h"
-#include "PlatformContextCairo.h"
-#include "ImageBuffer.h"
#include "ImageObserver.h"
-#include "RefPtrCairo.h"
+#include "NativeImageCairo.h"
+#include "PlatformContextCairo.h"
#include <cairo.h>
#include <math.h>
-#include <wtf/OwnPtr.h>
namespace WebCore {
-bool FrameData::clear(bool clearMetadata)
-{
- if (clearMetadata)
- m_haveMetadata = false;
-
- if (m_frame) {
- cairo_surface_destroy(m_frame);
- m_frame = 0;
- return true;
- }
- return false;
-}
-
-BitmapImage::BitmapImage(cairo_surface_t* surface, ImageObserver* observer)
- : Image(observer)
- , m_currentFrame(0)
- , m_frames(0)
- , m_frameTimer(0)
- , m_repetitionCount(cAnimationNone)
- , m_repetitionCountStatus(Unknown)
- , m_repetitionsComplete(0)
- , m_decodedSize(0)
- , m_frameCount(1)
- , m_isSolidColor(false)
- , m_checkedForSolidColor(false)
- , m_animationFinished(true)
- , m_allDataReceived(true)
- , m_haveSize(true)
- , m_sizeAvailable(true)
- , m_haveFrameCount(true)
-{
- initPlatformData();
-
- // TODO: check to be sure this is an image surface
-
- int width = cairo_image_surface_get_width(surface);
- int height = cairo_image_surface_get_height(surface);
- m_decodedSize = width * height * 4;
- m_size = IntSize(width, height);
-
- m_frames.grow(1);
- m_frames[0].m_frame = surface;
- m_frames[0].m_hasAlpha = cairo_surface_get_content(surface) != CAIRO_CONTENT_COLOR;
- m_frames[0].m_haveMetadata = true;
- checkForSolidColor();
-}
-
-void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
-{
- FloatRect srcRect(src);
- FloatRect dstRect(dst);
-
- if (dstRect.width() == 0.0f || dstRect.height() == 0.0f ||
- srcRect.width() == 0.0f || srcRect.height() == 0.0f)
- return;
-
- startAnimation();
-
- 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(), styleColorSpace, op);
- return;
- }
-
- context->save();
-
- // Set the compositing operation.
- if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame))
- context->setCompositeOperation(CompositeCopy);
- else
- context->setCompositeOperation(op);
- context->platformContext()->drawSurfaceToContext(image, dstRect, srcRect, context);
-
- context->restore();
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator op, const FloatRect& destRect)
{
- cairo_surface_t* image = nativeImageForCurrentFrame();
+ NativeImageCairo* image = nativeImageForCurrentFrame();
if (!image) // If it's too early we won't have an image yet.
return;
cairo_t* cr = context->platformContext()->cr();
- drawPatternToCairoContext(cr, image, size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
+ drawPatternToCairoContext(cr, image->surface(), size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
if (imageObserver())
imageObserver()->didDraw(this);
}
-void BitmapImage::checkForSolidColor()
-{
- m_isSolidColor = false;
- m_checkedForSolidColor = true;
-
- if (frameCount() > 1)
- return;
-
- cairo_surface_t* frameSurface = frameAtIndex(0);
- if (!frameSurface)
- return;
-
- ASSERT(cairo_surface_get_type(frameSurface) == CAIRO_SURFACE_TYPE_IMAGE);
-
- int width = cairo_image_surface_get_width(frameSurface);
- int height = cairo_image_surface_get_height(frameSurface);
-
- if (width != 1 || height != 1)
- return;
-
- unsigned* pixelColor = reinterpret_cast<unsigned*>(cairo_image_surface_get_data(frameSurface));
- m_solidColor = colorFromPremultipliedARGB(*pixelColor);
-
- m_isSolidColor = true;
}
-}
-
#endif // USE(CAIRO)
Added: trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp (0 => 115385)
--- trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2008, Google Inc. All rights reserved.
+ * Copyright (c) 2012, Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "NativeImageCairo.h"
+
+namespace WebCore {
+
+NativeImageCairo::NativeImageCairo()
+{
+}
+
+NativeImageCairo::NativeImageCairo(cairo_surface_t* surface)
+ : m_surface(adoptRef(surface))
+{
+}
+
+NativeImageCairo::~NativeImageCairo()
+{
+}
+
+} // namespace WebCore
Property changes on: trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.h (0 => 115385)
--- trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.h 2012-04-26 23:03:06 UTC (rev 115385)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2008, Google Inc. All rights reserved.
+ * Copyright (c) 2012, Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef NativeImageCairo_h
+#define NativeImageCairo_h
+
+#include "RefPtrCairo.h"
+
+namespace WebCore {
+
+class NativeImageCairo {
+public:
+ NativeImageCairo();
+ ~NativeImageCairo();
+ explicit NativeImageCairo(cairo_surface_t*);
+ cairo_surface_t* surface () { return m_surface.get(); }
+
+private:
+ RefPtr<cairo_surface_t> m_surface;
+};
+
+}
+#endif // NativeImageCairo_h
+
Property changes on: trunk/Source/WebCore/platform/graphics/cairo/NativeImageCairo.h
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/platform/graphics/cairo/PatternCairo.cpp (115384 => 115385)
--- trunk/Source/WebCore/platform/graphics/cairo/PatternCairo.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/graphics/cairo/PatternCairo.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -28,18 +28,17 @@
#include "AffineTransform.h"
#include "GraphicsContext.h"
-
#include <cairo.h>
namespace WebCore {
cairo_pattern_t* Pattern::createPlatformPattern(const AffineTransform&) const
{
- cairo_surface_t* surface = tileImage()->nativeImageForCurrentFrame();
- if (!surface)
+ NativeImageCairo* image = tileImage()->nativeImageForCurrentFrame();
+ if (!image)
return 0;
- cairo_pattern_t* pattern = cairo_pattern_create_for_surface(surface);
+ cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image->surface());
// cairo merges patter space and user space itself
cairo_matrix_t matrix = m_patternSpaceTransformation;
Modified: trunk/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp (115384 => 115385)
--- trunk/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -112,10 +112,8 @@
GdkPixbuf* BitmapImage::getGdkPixbuf()
{
- cairo_surface_t* frame = frameAtIndex(currentFrame());
- if (!frame)
- return 0;
- return cairoImageSurfaceToGdkPixbuf(frame);
+ NativeImageCairo* image = nativeImageForCurrentFrame();
+ return image ? cairoImageSurfaceToGdkPixbuf(image->surface()) : 0;
}
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (115384 => 115385)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -489,8 +489,9 @@
imageData = reinterpret_cast<const char*>(qtImage.constBits());
bytesPerLine = qtImage.bytesPerLine();
#elif USE(CAIRO)
- imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(frameImage));
- bytesPerLine = cairo_image_surface_get_stride(frameImage);
+ cairo_surface_t* surface = frameImage->surface();
+ imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
+ bytesPerLine = cairo_image_surface_get_stride(surface);
#endif
updateContents(imageData, targetRect, offset, bytesPerLine);
Modified: trunk/Source/WebCore/platform/gtk/DragImageGtk.cpp (115384 => 115385)
--- trunk/Source/WebCore/platform/gtk/DragImageGtk.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/gtk/DragImageGtk.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -75,7 +75,8 @@
DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum)
{
- return cairo_surface_reference(image->nativeImageForCurrentFrame());
+ NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame();
+ return nativeImage ? cairo_surface_reference(nativeImage->surface()) : 0;
}
DragImageRef createDragImageIconForCachedImage(CachedImage*)
Modified: trunk/Source/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp (115384 => 115385)
--- trunk/Source/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -32,10 +32,9 @@
NativeImagePtr ImageFrame::asNewNativeImage() const
{
- return cairo_image_surface_create_for_data(
- reinterpret_cast<unsigned char*>(const_cast<PixelData*>(
- m_bytes)), CAIRO_FORMAT_ARGB32, width(), height(),
- width() * sizeof(PixelData));
+ return new NativeImageCairo(cairo_image_surface_create_for_data(
+ reinterpret_cast<unsigned char*>(const_cast<PixelData*>(m_bytes)),
+ CAIRO_FORMAT_ARGB32, width(), height(), width() * sizeof(PixelData)));
}
} // namespace WebCore
Modified: trunk/Source/WebKit/efl/ChangeLog (115384 => 115385)
--- trunk/Source/WebKit/efl/ChangeLog 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebKit/efl/ChangeLog 2012-04-26 23:03:06 UTC (rev 115385)
@@ -1,3 +1,13 @@
+2012-04-26 Martin Robinson <[email protected]>
+
+ [Cairo] Wrap cairo surfaces in a class when storing native images
+ https://bugs.webkit.org/show_bug.cgi?id=83611
+
+ Reviewed by Alejandro G. Castro.
+
+ * ewk/ewk_history.cpp: Updated to reflect addition of NativeImageCario.
+ * ewk/ewk_settings.cpp: Ditto.
+
2012-04-26 Christophe Dumez <[email protected]>
[EFL] Enable VIDEO_TRACK feature
Modified: trunk/Source/WebKit/efl/ewk/ewk_history.cpp (115384 => 115385)
--- trunk/Source/WebKit/efl/ewk/ewk_history.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebKit/efl/ewk/ewk_history.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -341,7 +341,9 @@
ERR("icon is NULL.");
return 0;
}
- return icon->nativeImageForCurrentFrame();
+
+ WebCore::NativeImageCairo* nativeImage = icon->nativeImageForCurrentFrame();
+ return nativeImage ? nativeImage->surface() : 0;
}
Evas_Object* ewk_history_item_icon_object_add(const Ewk_History_Item* item, Evas* canvas)
@@ -349,15 +351,14 @@
EWK_HISTORY_ITEM_CORE_GET_OR_RETURN(item, core, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
WebCore::Image* icon = WebCore::iconDatabase().synchronousIconForPageURL(core->url(), WebCore::IntSize(16, 16));
- cairo_surface_t* surface;
if (!icon) {
ERR("icon is NULL.");
return 0;
}
- surface = icon->nativeImageForCurrentFrame();
- return ewk_util_image_from_cairo_surface_add(canvas, surface);
+ WebCore::NativeImageCairo* nativeImage = icon->nativeImageForCurrentFrame();
+ return nativeImage ? ewk_util_image_from_cairo_surface_add(canvas, nativeImage->surface()) : 0;
}
Eina_Bool ewk_history_item_page_cache_exists(const Ewk_History_Item* item)
Modified: trunk/Source/WebKit/efl/ewk/ewk_settings.cpp (115384 => 115385)
--- trunk/Source/WebKit/efl/ewk/ewk_settings.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebKit/efl/ewk/ewk_settings.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -225,7 +225,8 @@
return 0;
}
- return icon->nativeImageForCurrentFrame();
+ WebCore::NativeImageCairo* nativeImage = icon->nativeImageForCurrentFrame();
+ return nativeImage ? nativeImage->surface() : 0;
}
Evas_Object* ewk_settings_icon_database_icon_object_get(const char* url, Evas* canvas)
@@ -235,15 +236,14 @@
WebCore::KURL kurl(WebCore::KURL(), WTF::String::fromUTF8(url));
WebCore::Image* icon = WebCore::iconDatabase().synchronousIconForPageURL(kurl.string(), WebCore::IntSize(16, 16));
- cairo_surface_t* surface;
if (!icon) {
ERR("no icon for url %s", url);
return 0;
}
- surface = icon->nativeImageForCurrentFrame();
- return ewk_util_image_from_cairo_surface_add(canvas, surface);
+ WebCore::NativeImageCairo* nativeImage = icon->nativeImageForCurrentFrame();
+ return nativeImage ? ewk_util_image_from_cairo_surface_add(canvas, nativeImage->surface()) : 0;
}
void ewk_settings_object_cache_capacity_set(unsigned minDeadCapacity, unsigned maxDeadCapacity, unsigned totalCapacity)
Modified: trunk/Source/WebKit2/ChangeLog (115384 => 115385)
--- trunk/Source/WebKit2/ChangeLog 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebKit2/ChangeLog 2012-04-26 23:03:06 UTC (rev 115385)
@@ -1,3 +1,12 @@
+2012-04-26 Martin Robinson <[email protected]>
+
+ [Cairo] Wrap cairo surfaces in a class when storing native images
+ https://bugs.webkit.org/show_bug.cgi?id=83611
+
+ Reviewed by Alejandro G. Castro.
+
+ * Shared/gtk/ArgumentCodersGtk.cpp: Updated to reflect the addition of NativeImageCairo.
+
2012-04-26 Jon Lee <[email protected]>
[WK2] AlternativeTextClient leaks when the page is destroyed
Modified: trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp (115384 => 115385)
--- trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp 2012-04-26 22:57:54 UTC (rev 115384)
+++ trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp 2012-04-26 23:03:06 UTC (rev 115385)
@@ -71,10 +71,11 @@
if (!image)
return false;
- cairo_surface_t* surface = image->nativeImageForCurrentFrame();
- if (!surface)
+ NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame();
+ if (!nativeImage)
return false;
+ cairo_surface_t* surface = nativeImage->surface();
pixbuf = adoptGRef(gdk_pixbuf_get_from_surface(surface, 0, 0,
cairo_image_surface_get_width(surface),
cairo_image_surface_get_height(surface)));