[Cairo] Fix canvas drawing of SVG-based patterns and remove NativeImageCairo

https://bugs.webkit.org/show_bug.cgi?id=113929

Reviewed by Martin Robinson.

Source/WebCore:

Make (Pass)NativeImagePtr typedefs to (Pass)RefPtr<cairo_surface_t> instead
of NativeImageCairo*. Now that we switch to using smart pointers,
NativeImageCairo is removed as it made no sense to make it ref counted when
it merely held a single ref counted member.

Now that Cairo is using smart pointers for (Pass)NativeImagePtr, this patch
also enables the implementation of SVGImage::nativeImageForCurrentFrame()
for USE(CAIRO) as well. This effectively fixes canvas drawing of SVG-based
patterns for Cairo-based ports.

No new tests, covered by svg/canvas/canvas-pattern-svg.html.

* GNUmakefile.list.am: Remove NativeImageCairo.* for GTK.

* PlatformEfl.cmake: Remove NativeImageCairo.* for EFL.

* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
Remove NativeImageCairo.* for Win.

* platform/graphics/BitmapImage.cpp:
(WebCore::FrameData::reportMemoryUsage):
Update MemoryClassInfo::addRawBuffer() call now that m_frame is a RefPtr
for USE(CAIRO).

* platform/graphics/BitmapImage.h:
(BitmapImage):
Remove factory method taking a cairo_surface_t* in argument. This is useless
now that PassNativeImagePtr is a typedef to PassRefPtr<cairo_surface_t> and
there is already a factory method taking a PassNativeImagePtr in argument.

* platform/graphics/NativeImagePtr.h:
(WebCore):
Make PassNativeImagePtr a typedef to PassRefPtr<cairo_surface_t> and
NativeImagePtr a typedef to RefPtr<cairo_surface_t>, instead of
NativeImageCairo*. Moving to smart pointers is needed to enable implementation
of SVGImage::nativeImageForCurrentFrame() for Cairo.

* platform/graphics/cairo/BitmapImageCairo.cpp:
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::checkForSolidColor):
(WebCore::FrameData::clear):
* platform/graphics/cairo/GraphicsContext3DCairo.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage):
* platform/graphics/cairo/ImageCairo.cpp:
(WebCore::Image::drawPattern):
Update Cairo graphics code to reflect the (Pass)NativeImagePtr type changes.

* platform/graphics/cairo/NativeImageCairo.cpp: Removed.
* platform/graphics/cairo/NativeImageCairo.h: Removed.

* platform/graphics/cairo/PatternCairo.cpp:
(WebCore::Pattern::createPlatformPattern):
* platform/graphics/efl/GraphicsContext3DEfl.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage):
* platform/graphics/efl/ImageEfl.cpp:
(WebCore::BitmapImage::getEvasObject):
* platform/graphics/gtk/ImageGtk.cpp:
(WebCore::BitmapImage::getGdkPixbuf):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::BitmapTextureGL::updateContents):
* platform/graphics/win/ImageCairoWin.cpp:
(WebCore::BitmapImage::create):
(WebCore::BitmapImage::drawFrameMatchingSourceSize):
* platform/gtk/DragImageGtk.cpp:
(WebCore::createDragImageFromImage):
* platform/image-decoders/cairo/ImageDecoderCairo.cpp:
(WebCore::ImageFrame::asNewNativeImage):
* platform/win/DragImageCairoWin.cpp:
(WebCore::createDragImageFromImage):
Update code to reflect the (Pass)NativeImagePtr type changes.

* svg/graphics/SVGImage.cpp:
(WebCore):
* svg/graphics/SVGImage.h:
Enable SVGImage::nativeImageForCurrentFrame() for USE(CAIRO).

Source/WebKit:

Remove outdated symbols now that NativeImageCairo was removed.

* WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:

Source/WebKit/efl:

Update code now that PassNativeImagePtr is now a typedef to PassRefPtr<cairo_surface_t>
instead of NativeImageCairo*.

* ewk/ewk_history.cpp:
(ewk_history_item_icon_surface_get):
(ewk_history_item_icon_object_add):
* ewk/ewk_settings.cpp:
(ewk_settings_icon_database_icon_surface_get):
(ewk_settings_icon_database_icon_object_get):

Source/WebKit/gtk:

Update code now that PassNativeImagePtr is now a typedef to PassRefPtr<cairo_surface_t>
instead of NativeImageCairo*.

* webkit/webkitfavicondatabase.cpp:
(getIconPixbufSynchronously):

Source/WebKit/win:

Remove outdated symbols now that NativeImageCairo was removed.

* WebKit.vcproj/WebKitExports.def.in:

Source/WebKit2:

Update code now that PassNativeImagePtr is now a typedef to PassRefPtr<cairo_surface_t>
instead of NativeImageCairo*.

* Shared/gtk/ArgumentCodersGtk.cpp:
(CoreIPC::decodeImage):
* UIProcess/API/C/cairo/WKIconDatabaseCairo.cpp:
(WKIconDatabaseTryGetCairoSurfaceForURL):
* UIProcess/API/gtk/WebKitFaviconDatabase.cpp:
(getIconSurfaceSynchronously):

LayoutTests:

Add EFL / GTK pixels results for svg/canvas/canvas-pattern-svg.html now that
the test passes for cairo-based ports.

* platform/efl/svg/canvas/canvas-pattern-svg-expected.png: Added.
* platform/gtk/svg/canvas/canvas-pattern-svg-expected.png: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147643 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1256d826
2013-04-04 Christophe Dumez <ch.dumez@sisa.samsung.com>
[Cairo] Fix canvas drawing of SVG-based patterns and remove NativeImageCairo
https://bugs.webkit.org/show_bug.cgi?id=113929
Reviewed by Martin Robinson.
Add EFL / GTK pixels results for svg/canvas/canvas-pattern-svg.html now that
the test passes for cairo-based ports.
* platform/efl/svg/canvas/canvas-pattern-svg-expected.png: Added.
* platform/gtk/svg/canvas/canvas-pattern-svg-expected.png: Added.
2013-04-04 Xidorn Quan <quanxunzhen@gmail.com>
REGRESSION (r145870): Can't get insertion point to appear in some input and textareas on wordpress
2013-04-04 Christophe Dumez <ch.dumez@sisa.samsung.com>
[Cairo] Fix canvas drawing of SVG-based patterns and remove NativeImageCairo
https://bugs.webkit.org/show_bug.cgi?id=113929
Reviewed by Martin Robinson.
Make (Pass)NativeImagePtr typedefs to (Pass)RefPtr<cairo_surface_t> instead
of NativeImageCairo*. Now that we switch to using smart pointers,
NativeImageCairo is removed as it made no sense to make it ref counted when
it merely held a single ref counted member.
Now that Cairo is using smart pointers for (Pass)NativeImagePtr, this patch
also enables the implementation of SVGImage::nativeImageForCurrentFrame()
for USE(CAIRO) as well. This effectively fixes canvas drawing of SVG-based
patterns for Cairo-based ports.
No new tests, covered by svg/canvas/canvas-pattern-svg.html.
* GNUmakefile.list.am: Remove NativeImageCairo.* for GTK.
* PlatformEfl.cmake: Remove NativeImageCairo.* for EFL.
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
Remove NativeImageCairo.* for Win.
* platform/graphics/BitmapImage.cpp:
(WebCore::FrameData::reportMemoryUsage):
Update MemoryClassInfo::addRawBuffer() call now that m_frame is a RefPtr
for USE(CAIRO).
* platform/graphics/BitmapImage.h:
(BitmapImage):
Remove factory method taking a cairo_surface_t* in argument. This is useless
now that PassNativeImagePtr is a typedef to PassRefPtr<cairo_surface_t> and
there is already a factory method taking a PassNativeImagePtr in argument.
* platform/graphics/NativeImagePtr.h:
(WebCore):
Make PassNativeImagePtr a typedef to PassRefPtr<cairo_surface_t> and
NativeImagePtr a typedef to RefPtr<cairo_surface_t>, instead of
NativeImageCairo*. Moving to smart pointers is needed to enable implementation
of SVGImage::nativeImageForCurrentFrame() for Cairo.
* platform/graphics/cairo/BitmapImageCairo.cpp:
(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::checkForSolidColor):
(WebCore::FrameData::clear):
* platform/graphics/cairo/GraphicsContext3DCairo.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage):
* platform/graphics/cairo/ImageCairo.cpp:
(WebCore::Image::drawPattern):
Update Cairo graphics code to reflect the (Pass)NativeImagePtr type changes.
* platform/graphics/cairo/NativeImageCairo.cpp: Removed.
* platform/graphics/cairo/NativeImageCairo.h: Removed.
* platform/graphics/cairo/PatternCairo.cpp:
(WebCore::Pattern::createPlatformPattern):
* platform/graphics/efl/GraphicsContext3DEfl.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage):
* platform/graphics/efl/ImageEfl.cpp:
(WebCore::BitmapImage::getEvasObject):
* platform/graphics/gtk/ImageGtk.cpp:
(WebCore::BitmapImage::getGdkPixbuf):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::BitmapTextureGL::updateContents):
* platform/graphics/win/ImageCairoWin.cpp:
(WebCore::BitmapImage::create):
(WebCore::BitmapImage::drawFrameMatchingSourceSize):
* platform/gtk/DragImageGtk.cpp:
(WebCore::createDragImageFromImage):
* platform/image-decoders/cairo/ImageDecoderCairo.cpp:
(WebCore::ImageFrame::asNewNativeImage):
* platform/win/DragImageCairoWin.cpp:
(WebCore::createDragImageFromImage):
Update code to reflect the (Pass)NativeImagePtr type changes.
* svg/graphics/SVGImage.cpp:
(WebCore):
* svg/graphics/SVGImage.h:
Enable SVGImage::nativeImageForCurrentFrame() for USE(CAIRO).
2013-04-04 Ed Bartosh <bartosh@gmail.com>
[EFL] --minimal build fails with 'error: unused variable'
......@@ -5521,8 +5521,6 @@ webcore_platform_sources += \
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 \
......
......@@ -96,7 +96,6 @@ list(APPEND WebCore_SOURCES
platform/graphics/cairo/ImageBufferCairo.cpp
platform/graphics/cairo/ImageCairo.cpp
platform/graphics/cairo/IntRectCairo.cpp
platform/graphics/cairo/NativeImageCairo.cpp
platform/graphics/cairo/OwnPtrCairo.cpp
platform/graphics/cairo/PathCairo.cpp
platform/graphics/cairo/PatternCairo.cpp
......
......@@ -31976,42 +31976,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\platform\graphics\cairo\NativeImageCairo.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_All|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Production|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\platform\graphics\cairo\OwnPtrCairo.cpp"
>
......@@ -4511,12 +4511,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\platform\graphics\cairo\NativeImageCairo.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\platform\graphics\cairo\OwnPtrCairo.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
......@@ -13629,4 +13623,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
</Project>
......@@ -3036,9 +3036,6 @@
<ClCompile Include="..\platform\graphics\cairo\IntRectCairo.cpp">
<Filter>platform\graphics\cairo</Filter>
</ClCompile>
<ClCompile Include="..\platform\graphics\cairo\NativeImageCairo.cpp">
<Filter>platform\graphics\cairo</Filter>
</ClCompile>
<ClCompile Include="..\platform\graphics\cairo\OwnPtrCairo.cpp">
<Filter>platform\graphics\cairo</Filter>
</ClCompile>
......@@ -15348,4 +15345,4 @@
<Filter>rendering</Filter>
</CustomBuildStep>
</ItemGroup>
</Project>
\ No newline at end of file
</Project>
......@@ -588,7 +588,7 @@ void FrameData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
memoryObjectInfo->setClassName("FrameData");
#if OS(WINCE) && !PLATFORM(QT)
#if (OS(WINCE) && !PLATFORM(QT)) || USE(CAIRO)
info.addRawBuffer(m_frame.get(), m_frameBytes, "NativeImage", "frame");
#elif USE(SKIA)
info.addMember(m_frame, "frame", WTF::RetainingPointer);
......
......@@ -165,10 +165,6 @@ public:
virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE);
#endif
#if USE(CAIRO)
static PassRefPtr<BitmapImage> create(cairo_surface_t*);
#endif
#if PLATFORM(GTK)
virtual GdkPixbuf* getGdkPixbuf();
#endif
......
......@@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE
class QPixmap;
QT_END_NAMESPACE
#elif USE(CAIRO)
#include "NativeImageCairo.h"
#include "RefPtrCairo.h"
#elif USE(SKIA)
#include "NativeImageSkia.h"
namespace WebCore {
......@@ -72,7 +72,8 @@ typedef wxGraphicsBitmap* NativeImagePtr;
typedef wxBitmap* NativeImagePtr;
#endif
#elif USE(CAIRO)
typedef WebCore::NativeImageCairo* NativeImagePtr;
typedef RefPtr<cairo_surface_t> NativeImagePtr;
typedef PassRefPtr<cairo_surface_t> PassNativeImagePtr;
#elif USE(SKIA)
typedef RefPtr<NativeImageSkia> NativeImagePtr;
typedef PassRefPtr<NativeImageSkia> PassNativeImagePtr;
......@@ -83,7 +84,7 @@ typedef RefPtr<SharedBitmap> NativeImagePtr;
typedef void* NativeImagePtr;
#endif
#if !USE(SKIA)
#if !USE(SKIA) && !USE(CAIRO)
typedef NativeImagePtr PassNativeImagePtr;
#endif
......
......@@ -29,18 +29,12 @@
#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)
BitmapImage::BitmapImage(PassRefPtr<cairo_surface_t> nativeImage, ImageObserver* observer)
: Image(observer)
, m_currentFrame(0)
, m_frames(0)
......@@ -58,15 +52,14 @@ BitmapImage::BitmapImage(NativeImageCairo* nativeImage, ImageObserver* observer)
, m_sizeAvailable(true)
, m_haveFrameCount(true)
{
cairo_surface_t* surface = nativeImage->surface();
int width = cairo_image_surface_get_width(surface);
int height = cairo_image_surface_get_height(surface);
int width = cairo_image_surface_get_width(nativeImage.get());
int height = cairo_image_surface_get_height(nativeImage.get());
m_decodedSize = width * height * 4;
m_size = IntSize(width, height);
m_frames.grow(1);
m_frames[0].m_hasAlpha = cairo_surface_get_content(nativeImage.get()) != CAIRO_CONTENT_COLOR;
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();
}
......@@ -84,8 +77,8 @@ void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo
startAnimation();
NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame);
if (!nativeImage) // If it's too early we won't have an image yet.
RefPtr<cairo_surface_t> surface = frameAtIndex(m_currentFrame);
if (!surface) // If it's too early we won't have an image yet.
return;
if (mayFillWithSolidColor()) {
......@@ -102,8 +95,7 @@ void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo
context->setCompositeOperation(op, blendMode);
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
cairo_surface_t* surface = nativeImage->surface();
IntSize scaledSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
IntSize scaledSize(cairo_image_surface_get_width(surface.get()), cairo_image_surface_get_height(surface.get()));
FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(src, scaledSize);
#else
FloatRect adjustedSrcRect(src);
......@@ -127,7 +119,7 @@ void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo
}
}
context->platformContext()->drawSurfaceToContext(nativeImage->surface(), dstRect, adjustedSrcRect, context);
context->platformContext()->drawSurfaceToContext(surface.get(), dstRect, adjustedSrcRect, context);
context->restore();
......@@ -143,20 +135,19 @@ void BitmapImage::checkForSolidColor()
if (frameCount() > 1)
return;
NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame);
if (!nativeImage) // If it's too early we won't have an image yet.
RefPtr<cairo_surface_t> surface = frameAtIndex(m_currentFrame);
if (!surface) // 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);
ASSERT(cairo_surface_get_type(surface.get()) == CAIRO_SURFACE_TYPE_IMAGE);
int width = cairo_image_surface_get_width(surface);
int height = cairo_image_surface_get_height(surface);
int width = cairo_image_surface_get_width(surface.get());
int height = cairo_image_surface_get_height(surface.get());
if (width != 1 || height != 1)
return;
unsigned* pixelColor = reinterpret_cast<unsigned*>(cairo_image_surface_get_data(surface));
unsigned* pixelColor = reinterpret_cast<unsigned*>(cairo_image_surface_get_data(surface.get()));
m_solidColor = colorFromPremultipliedARGB(*pixelColor);
m_isSolidColor = true;
......@@ -168,8 +159,7 @@ bool FrameData::clear(bool clearMetadata)
m_haveMetadata = false;
if (m_frame) {
delete m_frame;
m_frame = 0;
m_frame.clear();
return true;
}
return false;
......
......@@ -186,11 +186,9 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
decoder.setData(m_image->data(), true);
if (!decoder.frameCount() || !decoder.frameIsCompleteAtIndex(0))
return false;
OwnPtr<NativeImageCairo> nativeImage = adoptPtr(decoder.createFrameAtIndex(0));
m_imageSurface = nativeImage->surface();
m_imageSurface = decoder.createFrameAtIndex(0);
} else {
NativeImageCairo* nativeImage = m_image->nativeImageForCurrentFrame();
m_imageSurface = (nativeImage) ? nativeImage->surface() : 0;
m_imageSurface = m_image->nativeImageForCurrentFrame();
// 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAlpha had been applied and the alpha value is 0xFF for each pixel,
// which is true at present and may be changed in the future and needs adjustment accordingly.
// 2. For texImage2D with HTMLCanvasElement input in which Alpha is already Premultiplied in this port,
......
......@@ -35,7 +35,6 @@
#include "Color.h"
#include "GraphicsContext.h"
#include "ImageObserver.h"
#include "NativeImageCairo.h"
#include "PlatformContextCairo.h"
#include <cairo.h>
#include <math.h>
......@@ -45,12 +44,12 @@ namespace WebCore {
void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode)
{
NativeImageCairo* image = nativeImageForCurrentFrame();
if (!image) // If it's too early we won't have an image yet.
RefPtr<cairo_surface_t> surface = nativeImageForCurrentFrame();
if (!surface) // If it's too early we won't have an image yet.
return;
cairo_t* cr = context->platformContext()->cr();
drawPatternToCairoContext(cr, image->surface(), size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
drawPatternToCairoContext(cr, surface.get(), size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
if (imageObserver())
imageObserver()->didDraw(this);
......
/*
* 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
/*
* 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
......@@ -34,11 +34,11 @@ namespace WebCore {
cairo_pattern_t* Pattern::createPlatformPattern(const AffineTransform&) const
{
NativeImageCairo* image = tileImage()->nativeImageForCurrentFrame();
if (!image)
RefPtr<cairo_surface_t> surface = tileImage()->nativeImageForCurrentFrame();
if (!surface)
return 0;
cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image->surface());
cairo_pattern_t* pattern = cairo_pattern_create_for_surface(surface.get());
// cairo merges patter space and user space itself
cairo_matrix_t matrix = m_patternSpaceTransformation;
......
......@@ -263,11 +263,9 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
if (!decoder.frameCount() || !decoder.frameIsCompleteAtIndex(0))
return false;
OwnPtr<NativeImageCairo> nativeImage = adoptPtr(decoder.createFrameAtIndex(0));
m_imageSurface = nativeImage->surface();
m_imageSurface = decoder.createFrameAtIndex(0);
} else {
NativeImageCairo* nativeImage = m_image->nativeImageForCurrentFrame();
m_imageSurface = (nativeImage) ? nativeImage->surface() : 0;
m_imageSurface = m_image->nativeImageForCurrentFrame();
// 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAlpha had been applied and the alpha value is 0xFF for each pixel,
// which is true at present and may be changed in the future and needs adjustment accordingly.
// 2. For texImage2D with HTMLCanvasElement input in which Alpha is already Premultiplied in this port,
......
......@@ -65,8 +65,8 @@ PassRefPtr<Image> Image::loadPlatformResource(const char* name)
Evas_Object* BitmapImage::getEvasObject(Evas* evas)
{
NativeImageCairo* image = nativeImageForCurrentFrame();
return image ? evasObjectFromCairoImageSurface(evas, image->surface()).leakRef() : 0;
RefPtr<cairo_surface_t> surface = nativeImageForCurrentFrame();
return surface ? evasObjectFromCairoImageSurface(evas, surface.get()).leakRef() : 0;
}
}
......@@ -108,8 +108,8 @@ PassRefPtr<Image> Image::loadPlatformThemeIcon(const char* name, int size)
GdkPixbuf* BitmapImage::getGdkPixbuf()
{
NativeImageCairo* image = nativeImageForCurrentFrame();
return image ? cairoImageSurfaceToGdkPixbuf(image->surface()) : 0;
RefPtr<cairo_surface_t> surface = nativeImageForCurrentFrame();
return surface ? cairoImageSurfaceToGdkPixbuf(surface.get()) : 0;
}
}
......@@ -729,7 +729,7 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
imageData = reinterpret_cast<const char*>(qImage.constBits());
bytesPerLine = qImage.bytesPerLine();
#elif USE(CAIRO)
cairo_surface_t* surface = frameImage->surface();
cairo_surface_t* surface = frameImage.get();
imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
bytesPerLine = cairo_image_surface_get_stride(surface);
#endif
......
......@@ -27,6 +27,7 @@
#include "Image.h"
#include "BitmapImage.h"
#include "GraphicsContext.h"
#include "RefPtrCairo.h"
#include <cairo.h>
#include <cairo-win32.h>
......@@ -49,9 +50,9 @@ PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
if (!dibSection.dsBm.bmBits)
return 0;
cairo_surface_t* surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight);
RefPtr<cairo_surface_t> surface = adoptRef(cairo_win32_surface_create_with_dib(CAIRO_FORMAT_ARGB32, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight));
return BitmapImage::create(new NativeImageCairo(surface));
return BitmapImage::create(surface.release());
}
bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
......@@ -95,14 +96,11 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const Float
{
size_t frames = frameCount();
for (size_t i = 0; i < frames; ++i) {
NativeImageCairo* nativeImage = frameAtIndex(i);
if (!nativeImage)
continue;
cairo_surface_t* image = nativeImage->surface();
if (!image)
RefPtr<cairo_surface_t> surface = frameAtIndex(i);
if (!surface)
continue;
if (cairo_image_surface_get_height(image) == static_cast<size_t>(srcSize.height()) && cairo_image_surface_get_width(image) == static_cast<size_t>(srcSize.width())) {
if (cairo_image_surface_get_height(surface.get()) == static_cast<size_t>(srcSize.height()) && cairo_image_surface_get_width(surface.get()) == static_cast<size_t>(srcSize.width())) {
size_t currentFrame = m_currentFrame;
m_currentFrame = i;
draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), ColorSpaceDeviceRGB, compositeOp, BlendModeNormal);
......
......@@ -79,8 +79,7 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum)
{
NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame();