Regression(r142765) Broke Custom SVG cursors and SVG canvas drawing for Chromium
authorch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2013 12:05:27 +0000 (12:05 +0000)
committerch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2013 12:05:27 +0000 (12:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=113420

Reviewed by Stephen White.

Source/WebCore:

Introduce a PassNativeImagePtr typedef that is used in place of NativeImagePtr
for method arguments and return values. This is needed as Skia now maps
NativeImagePtr to RefPtr<NativeImageSkia> and PassNativeImagePtr to
PassRefPtr<NativeImageSkia>. We move towards ref counted smart pointers so that
SVGImage::nativeImageForCurrentFrame() can transfer ownership of the native
image to the caller if needed (e.g. for SVGImage).

Provide nativeImageForCurrentFrame() implementation for SVGImage. SVGImage no
longer holds the native image internally, to save memory. It is therefore created
when nativeImageForCurrentFrame() is called and ownership is passed to the
caller. For now, this implementation is only enabled for Skia as others are using
raw pointers for PassNativeImagePtr.

Test: svg/canvas/canvas-pattern-svg.html

* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::synchronousNativeIconForPageURL):
Return a PassNativeImagePtr instead of NativeImagePtr.

* loader/icon/IconDatabase.h:
(IconDatabase):
* loader/icon/IconDatabaseBase.h:
(WebCore::IconDatabaseBase::synchronousNativeIconForPageURL):
Return a PassNativeImagePtr instead of NativeImagePtr.

* platform/chromium/DragImageChromiumSkia.cpp:
(WebCore::createDragImageFromImage):
Store return value of nativeImageForCurrentFrame() in a RefPtr instead of a raw
one.

* platform/chromium/PasteboardChromium.cpp:
(WebCore::Pasteboard::writeImage):
Store return value of nativeImageForCurrentFrame() in a RefPtr<NativeImageSkia>
instead of a NativeImagePtr. While these are equivalent, the former is more
readable in Skia-specific code.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::frameAtIndex):
Return a PassNativeImagePtr instead of a NativeImagePtr.

(WebCore::BitmapImage::nativeImageForCurrentFrame):
Return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/graphics/BitmapImage.h:
(WebCore::BitmapImage::create):
Take a PassNativeImagePtr in argument instead of a NativeImagePtr.

(BitmapImage): Ditto.

* platform/graphics/GraphicsContext.h:
(GraphicsContext): Ditto.

* platform/graphics/GraphicsContext3D.h:
(ImageExtractor):
Keep NativeImageSkia in a RefPtr instead of OwnPtr, now that it is refcounted.

* platform/graphics/Image.h:
(WebCore::Image::nativeImageForCurrentFrame):
Return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/graphics/ImageBuffer.h:
(ImageBuffer):
Have copyNativeImage() return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::createFrameAtIndex):
Return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/graphics/ImageSource.h:
Have createFrameAtIndex() return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/graphics/NativeImagePtr.h:
Map NativeImagePtr to a RefPtr<NativeImageSkia> instead of NativeImageSkia* for Skia.
Introduce new PassNativeImagePtr that maps to PassRefPtr<NativeImageSkia> for Skia
and is equivalent to NativeImagePtr for other ports. We now use smart pointers for
the native image so that SVGImage::nativeImageForCurrentFrame() can pass ownership
of the native image to the caller, unlike BitmapImage::nativeImageForCurrentFrame().

* platform/graphics/blackberry/ImageBlackBerry.cpp:
(WebCore::ImageFrame::asNewNativeImage):
Return a PassNativeImagePtr instead of a NativeImagePtr.

(WebCore::BitmapImage::BitmapImage):
Take a PassNativeImagePtr instead of a NativeImagePtr in argument.

* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::drawNativeImage): Ditto.

* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::copyNativeImage):
Take a PassNativeImagePtr instead of a NativeImagePtr in argument.

* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::setContentsToImage):
Store return value of nativeImageForCurrentFrame() in a RefPtr instead of a raw one.

* platform/graphics/filters/skia/FEBlendSkia.cpp:
(WebCore::FEBlend::platformApplySkia): Ditto.

* platform/graphics/filters/skia/FEColorMatrixSkia.cpp:
(WebCore::FEColorMatrix::platformApplySkia): Ditto.

* platform/graphics/filters/skia/FEComponentTransferSkia.cpp:
(WebCore::FEComponentTransfer::platformApplySkia): Ditto.

* platform/graphics/filters/skia/FEDisplacementMapSkia.cpp:
(WebCore::FEDisplacementMap::platformApplySkia): Ditto.

* platform/graphics/filters/skia/FELightingSkia.cpp:
(WebCore::FELighting::platformApplySkia): Ditto.

* platform/graphics/qt/ImageDecoderQt.cpp:
(WebCore::ImageFrame::asNewNativeImage):
Return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/graphics/qt/StillImageQt.cpp:
(WebCore::StillImage::nativeImageForCurrentFrame):
Return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/graphics/qt/StillImageQt.h:
(StillImage): Ditto.

* platform/graphics/skia/GraphicsContext3DSkia.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage):
No longer need to adopt the return value of asNewNativeImage() now
that it returns a PassRefPtr instead of a raw one.

* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::ImageBuffer::copyImage):
(WebCore::ImageBuffer::draw):
(WebCore::ImageBuffer::drawPattern):
Call NativeImageSkia::create() factory method now that the constructor
is private.

* platform/graphics/skia/ImageSkia.cpp:
(WebCore::FrameData::clear):
Just call clear() on m_frame instead of explicitely deleting it now
that it is a RefPtr.

(WebCore::Image::drawPattern):
Store return value of nativeImageForCurrentFrame() in a RefPtr instead
of a raw one.

(WebCore::BitmapImage::BitmapImage):
(WebCore::BitmapImage::checkForSolidColor):
Store return value of frameAtIndex() in a RefPtr instead of a raw one.

(WebCore::BitmapImage::draw):
Store return value of nativeImageForCurrentFrame() in a RefPtr instead
of a raw one.

* platform/graphics/skia/NativeImageSkia.cpp:
Add new constructor taking all members in argument. This is used for
cloning a NativeImageSkia object.

(WebCore::NativeImageSkia::NativeImageSkia):
(WebCore::NativeImageSkia::deepSkBitmapCopy):
Add convenience function to make a deep copy of a SkBitmap.

* platform/graphics/skia/NativeImageSkia.h:
(WebCore):
(WebCore::NativeImageSkia::create):
(NativeImageSkia):
Make NativeImageSkia subclass RefCounted. Make the constructor private
and add a factory method instead that returns a PassRefPtr.

(WebCore::NativeImageSkia::clone):
Add a clone() method now that NativeImageSkia is refcounted and is no
longer copyable.

* platform/graphics/skia/PatternSkia.cpp:
(WebCore::Pattern::platformPattern):
Store return value of nativeImageForCurrentFrame() in a RefPtr instead
of a raw one.

* platform/graphics/wince/ImageWinCE.cpp:
(WebCore::ImageFrame::asNewNativeImage):
Return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/image-decoders/ImageDecoder.h:
(ImageFrame):
Have asNewNativeImage() return a PassNativeImagePtr instead of a
NativeImagePtr.

(WebCore::ImageFrame::getAddr):
(WebCore::ImageFrame::setSkBitmap):
(WebCore::ImageFrame::getSkBitmap):
(WebCore::ImageFrame::width):
(WebCore::ImageFrame::height):
Update use of m_bitmap now that it is a pointer type and call
NativeImageSkia::create() to construct a NativeImageSkia object now
that the constructor is private.

* platform/image-decoders/cairo/ImageDecoderCairo.cpp:
(WebCore::ImageFrame::asNewNativeImage):
Return a PassNativeImagePtr instead of a NativeImagePtr.

* platform/image-decoders/openvg/ImageDecoderOpenVG.cpp:
(WebCore::ImageFrame::asNewNativeImage): Ditto.

* platform/image-decoders/skia/ImageDecoderSkia.cpp:
(WebCore::ImageFrame::ImageFrame):
Initialize m_bitmap in the constructor now that it is a pointer
type and we need NativeImageSkia's default constructor to be
called.

(WebCore::ImageFrame::operator=):
Call NativeImageSkia's new clone() method to copy m_bitmap as
NativeImageSkia is now RefCounted and no longer copyable.

(WebCore::ImageFrame::clearPixelData):
(WebCore::ImageFrame::zeroFillPixelData):
(WebCore::ImageFrame::copyBitmapData):
(WebCore::ImageFrame::setSize):
Update use of m_bitmap now that it is a pointer type.

(WebCore::ImageFrame::asNewNativeImage):
Return a PassNativeImagePtr instead of a NativeImagePtr.
Call NativeImageSkia's clone method now that it is no longer
copyable.

(WebCore::ImageFrame::setHasAlpha):
(WebCore::ImageFrame::setStatus):
Update use of m_bitmap now that it is a pointer type.

* platform/image-decoders/wx/ImageDecoderWx.cpp:
(WebCore::ImageFrame::asNewNativeImage):
Return a PassNativeImagePtr instead of a NativeImagePtr.

* svg/graphics/SVGImage.cpp:
(WebCore):
(WebCore::SVGImage::nativeImageForCurrentFrame):
Add implementation of nativeImageForCurrentFrame() for SVGImage as
it is needed for SVG custom cursor support and Canvas drawing of
patterns containing SVG images. As SVGImage no longer keep the
native image internally to save memory, the implementation creates
the native image when nativeImageForCurrentFrame() and passes
its ownership to the caller.

* svg/graphics/SVGImage.h:
Override Image::nativeImageForCurrentFrame() and remove dummy
implementation of frameAtIndex() as it is not needed / used.

* svg/graphics/SVGImageForContainer.cpp:
(WebCore::SVGImageForContainer::nativeImageForCurrentFrame):
Add implementation of nativeImageForCurrentFrame() which merely
forwards the call to the Image being contained.

* svg/graphics/SVGImageForContainer.h:
Override Image::nativeImageForCurrentFrame().

Source/WebKit/chromium:

Update code now that Image::nativeImageForCurrentFrame() and
ImageFrame::asNewNativeImage() return a smart pointer instead
of a raw one.

* src/WebImageDecoder.cpp:
(WebKit::WebImageDecoder::getFrameAtIndex):
* src/WebImageSkia.cpp:
(WebKit::WebImage::fromData):
(WebKit::WebImage::framesFromData):
(WebKit::WebImage::operator=):
* tests/DeferredImageDecoderTest.cpp:
(WebCore::TEST_F):
* tests/DragImageTest.cpp:
(WebCore::TestImage::TestImage):
(WebCore::TestImage::nativeImageForCurrentFrame):
(TestImage):
* tests/ImageLayerChromiumTest.cpp:
(WebCore::TestImage::TestImage):
(WebCore::TestImage::nativeImageForCurrentFrame):
(TestImage):
* tests/PlatformContextSkiaTest.cpp:
(WebCore::TEST):

LayoutTests:

Add layout test to check that drawing canvas patterns containing SVG images works.

* platform/chromium-linux/svg/canvas/canvas-pattern-svg-expected.png: Added.
* svg/canvas/canvas-pattern-svg-expected.txt: Added.
* svg/canvas/canvas-pattern-svg.html: Added.

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

54 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium-linux/svg/canvas/canvas-pattern-svg-expected.png [new file with mode: 0644]
LayoutTests/svg/canvas/canvas-pattern-svg-expected.txt [new file with mode: 0644]
LayoutTests/svg/canvas/canvas-pattern-svg.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/icon/IconDatabase.cpp
Source/WebCore/loader/icon/IconDatabase.h
Source/WebCore/loader/icon/IconDatabaseBase.h
Source/WebCore/platform/chromium/DragImageChromiumSkia.cpp
Source/WebCore/platform/chromium/PasteboardChromium.cpp
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/GraphicsContext.h
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/Image.h
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/ImageSource.cpp
Source/WebCore/platform/graphics/ImageSource.h
Source/WebCore/platform/graphics/NativeImagePtr.h
Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp
Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp
Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp
Source/WebCore/platform/graphics/filters/skia/FEDisplacementMapSkia.cpp
Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp
Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
Source/WebCore/platform/graphics/qt/StillImageQt.cpp
Source/WebCore/platform/graphics/qt/StillImageQt.h
Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp
Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
Source/WebCore/platform/graphics/skia/ImageSkia.cpp
Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp
Source/WebCore/platform/graphics/skia/NativeImageSkia.h
Source/WebCore/platform/graphics/skia/PatternSkia.cpp
Source/WebCore/platform/graphics/wince/ImageWinCE.cpp
Source/WebCore/platform/image-decoders/ImageDecoder.h
Source/WebCore/platform/image-decoders/cairo/ImageDecoderCairo.cpp
Source/WebCore/platform/image-decoders/openvg/ImageDecoderOpenVG.cpp
Source/WebCore/platform/image-decoders/skia/ImageDecoderSkia.cpp
Source/WebCore/platform/image-decoders/wx/ImageDecoderWx.cpp
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/svg/graphics/SVGImage.h
Source/WebCore/svg/graphics/SVGImageForContainer.cpp
Source/WebCore/svg/graphics/SVGImageForContainer.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebImageDecoder.cpp
Source/WebKit/chromium/src/WebImageSkia.cpp
Source/WebKit/chromium/tests/DeferredImageDecoderTest.cpp
Source/WebKit/chromium/tests/DragImageTest.cpp
Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp
Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp

index 1ebc843..c48c2a0 100644 (file)
@@ -1,3 +1,16 @@
+2013-04-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
+
+        Regression(r142765) Broke Custom SVG cursors and SVG canvas drawing for Chromium
+        https://bugs.webkit.org/show_bug.cgi?id=113420
+
+        Reviewed by Stephen White.
+
+        Add layout test to check that drawing canvas patterns containing SVG images works.
+
+        * platform/chromium-linux/svg/canvas/canvas-pattern-svg-expected.png: Added.
+        * svg/canvas/canvas-pattern-svg-expected.txt: Added.
+        * svg/canvas/canvas-pattern-svg.html: Added.
+
 2013-04-04  Seokju Kwon  <seokju.kwon@gmail.com>
 
         [SOUP] inspector/timeline/timeline-receive-response-event.html fails
diff --git a/LayoutTests/platform/chromium-linux/svg/canvas/canvas-pattern-svg-expected.png b/LayoutTests/platform/chromium-linux/svg/canvas/canvas-pattern-svg-expected.png
new file mode 100644 (file)
index 0000000..2811c59
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/svg/canvas/canvas-pattern-svg-expected.png differ
diff --git a/LayoutTests/svg/canvas/canvas-pattern-svg-expected.txt b/LayoutTests/svg/canvas/canvas-pattern-svg-expected.txt
new file mode 100644 (file)
index 0000000..8878d48
--- /dev/null
@@ -0,0 +1,3 @@
+There should be one big square below containing four squares. Top left square should be filled with 3 rows of 3 circles. Top right square should have one column of 3 circles. The bottom left square should have one row with three circles. The bottom right square should have one circle in the top-left corner.
+
+
diff --git a/LayoutTests/svg/canvas/canvas-pattern-svg.html b/LayoutTests/svg/canvas/canvas-pattern-svg.html
new file mode 100644 (file)
index 0000000..0a6333f
--- /dev/null
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+  <title>Test for WK113420: SVG-based patterns should be drawn correctly</title>
+  <style> canvas { border:solid #000 } </style>
+  <script>
+   if (window.testRunner) {
+     testRunner.dumpAsText(true);
+     testRunner.waitUntilDone();
+   }
+   window.onload = function(){
+    var i = new Image();
+    i.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50'><circle cx='10' cy='10' r='10' fill='green' /></svg>";
+    i.onload = function() {
+      var ctx = document.getElementsByTagName('canvas')[0].getContext('2d');
+
+      var pattern = ctx.createPattern(i, "repeat");
+      ctx.fillStyle = pattern;
+      ctx.translate(10, 10);
+      ctx.strokeRect(0, 0, 150, 150);
+      ctx.fillRect(0, 0, 150, 150);
+
+      var patternX = ctx.createPattern(i, "repeat-x");
+      ctx.fillStyle = patternX;
+      ctx.translate(0, 160);
+      ctx.strokeRect(0, 0, 150, 150);
+      ctx.fillRect(0, 0, 150, 150);
+
+      var patternN = ctx.createPattern(i, "no-repeat");
+      ctx.fillStyle = patternN;
+      ctx.translate(160, 0);
+      ctx.strokeRect(0, 0, 150, 150);
+      ctx.fillRect(0, 0, 150, 150);
+
+      var patternY = ctx.createPattern(i, "repeat-y");
+      ctx.fillStyle = patternY;
+      ctx.translate(0, -160);
+      ctx.strokeRect(0, 0, 150, 150);
+      ctx.fillRect(0, 0, 150, 150);
+
+      if (window.testRunner)
+          testRunner.notifyDone();
+    }
+   }
+  </script>
+ </head>
+ <body>
+  <p>There should be one big square below containing four squares. Top left square should be filled with 3 rows of 3 circles. Top right square should have one column of 3 circles. The bottom left square should have one row with three circles. The bottom right square should have one circle in the top-left corner.</p>
+  <p><canvas height="330" width="330"></canvas></p>
+ </body>
+</html>
index 8ed6fa1..60a4457 100644 (file)
@@ -1,3 +1,261 @@
+2013-04-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
+
+        Regression(r142765) Broke Custom SVG cursors and SVG canvas drawing for Chromium
+        https://bugs.webkit.org/show_bug.cgi?id=113420
+
+        Reviewed by Stephen White.
+
+        Introduce a PassNativeImagePtr typedef that is used in place of NativeImagePtr
+        for method arguments and return values. This is needed as Skia now maps
+        NativeImagePtr to RefPtr<NativeImageSkia> and PassNativeImagePtr to
+        PassRefPtr<NativeImageSkia>. We move towards ref counted smart pointers so that
+        SVGImage::nativeImageForCurrentFrame() can transfer ownership of the native
+        image to the caller if needed (e.g. for SVGImage).
+
+        Provide nativeImageForCurrentFrame() implementation for SVGImage. SVGImage no
+        longer holds the native image internally, to save memory. It is therefore created
+        when nativeImageForCurrentFrame() is called and ownership is passed to the
+        caller. For now, this implementation is only enabled for Skia as others are using
+        raw pointers for PassNativeImagePtr.
+
+        Test: svg/canvas/canvas-pattern-svg.html
+
+        * loader/icon/IconDatabase.cpp:
+        (WebCore::IconDatabase::synchronousNativeIconForPageURL):
+        Return a PassNativeImagePtr instead of NativeImagePtr.
+
+        * loader/icon/IconDatabase.h:
+        (IconDatabase):
+        * loader/icon/IconDatabaseBase.h:
+        (WebCore::IconDatabaseBase::synchronousNativeIconForPageURL):
+        Return a PassNativeImagePtr instead of NativeImagePtr.
+
+        * platform/chromium/DragImageChromiumSkia.cpp:
+        (WebCore::createDragImageFromImage):
+        Store return value of nativeImageForCurrentFrame() in a RefPtr instead of a raw
+        one.
+
+        * platform/chromium/PasteboardChromium.cpp:
+        (WebCore::Pasteboard::writeImage):
+        Store return value of nativeImageForCurrentFrame() in a RefPtr<NativeImageSkia>
+        instead of a NativeImagePtr. While these are equivalent, the former is more
+        readable in Skia-specific code.
+
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::frameAtIndex):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        (WebCore::BitmapImage::nativeImageForCurrentFrame):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/graphics/BitmapImage.h:
+        (WebCore::BitmapImage::create):
+        Take a PassNativeImagePtr in argument instead of a NativeImagePtr.
+
+        (BitmapImage): Ditto.
+
+        * platform/graphics/GraphicsContext.h:
+        (GraphicsContext): Ditto.
+
+        * platform/graphics/GraphicsContext3D.h:
+        (ImageExtractor):
+        Keep NativeImageSkia in a RefPtr instead of OwnPtr, now that it is refcounted.
+
+        * platform/graphics/Image.h:
+        (WebCore::Image::nativeImageForCurrentFrame):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/graphics/ImageBuffer.h:
+        (ImageBuffer):
+        Have copyNativeImage() return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/graphics/ImageSource.cpp:
+        (WebCore::ImageSource::createFrameAtIndex):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/graphics/ImageSource.h:
+        Have createFrameAtIndex() return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/graphics/NativeImagePtr.h:
+        Map NativeImagePtr to a RefPtr<NativeImageSkia> instead of NativeImageSkia* for Skia.
+        Introduce new PassNativeImagePtr that maps to PassRefPtr<NativeImageSkia> for Skia
+        and is equivalent to NativeImagePtr for other ports. We now use smart pointers for
+        the native image so that SVGImage::nativeImageForCurrentFrame() can pass ownership
+        of the native image to the caller, unlike BitmapImage::nativeImageForCurrentFrame().
+
+        * platform/graphics/blackberry/ImageBlackBerry.cpp:
+        (WebCore::ImageFrame::asNewNativeImage):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        (WebCore::BitmapImage::BitmapImage):
+        Take a PassNativeImagePtr instead of a NativeImagePtr in argument.
+
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::drawNativeImage): Ditto.
+
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::copyNativeImage):
+        Take a PassNativeImagePtr instead of a NativeImagePtr in argument.
+
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::setContentsToImage):
+        Store return value of nativeImageForCurrentFrame() in a RefPtr instead of a raw one.
+
+        * platform/graphics/filters/skia/FEBlendSkia.cpp:
+        (WebCore::FEBlend::platformApplySkia): Ditto.
+
+        * platform/graphics/filters/skia/FEColorMatrixSkia.cpp:
+        (WebCore::FEColorMatrix::platformApplySkia): Ditto.
+
+        * platform/graphics/filters/skia/FEComponentTransferSkia.cpp:
+        (WebCore::FEComponentTransfer::platformApplySkia): Ditto.
+
+        * platform/graphics/filters/skia/FEDisplacementMapSkia.cpp:
+        (WebCore::FEDisplacementMap::platformApplySkia): Ditto.
+
+        * platform/graphics/filters/skia/FELightingSkia.cpp:
+        (WebCore::FELighting::platformApplySkia): Ditto.
+
+        * platform/graphics/qt/ImageDecoderQt.cpp:
+        (WebCore::ImageFrame::asNewNativeImage):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/graphics/qt/StillImageQt.cpp:
+        (WebCore::StillImage::nativeImageForCurrentFrame):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/graphics/qt/StillImageQt.h:
+        (StillImage): Ditto.
+
+        * platform/graphics/skia/GraphicsContext3DSkia.cpp:
+        (WebCore::GraphicsContext3D::ImageExtractor::extractImage):
+        No longer need to adopt the return value of asNewNativeImage() now
+        that it returns a PassRefPtr instead of a raw one.
+
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::ImageBuffer::copyImage):
+        (WebCore::ImageBuffer::draw):
+        (WebCore::ImageBuffer::drawPattern):
+        Call NativeImageSkia::create() factory method now that the constructor
+        is private.
+
+        * platform/graphics/skia/ImageSkia.cpp:
+        (WebCore::FrameData::clear):
+        Just call clear() on m_frame instead of explicitely deleting it now
+        that it is a RefPtr.
+
+        (WebCore::Image::drawPattern):
+        Store return value of nativeImageForCurrentFrame() in a RefPtr instead
+        of a raw one.
+
+        (WebCore::BitmapImage::BitmapImage):
+        (WebCore::BitmapImage::checkForSolidColor):
+        Store return value of frameAtIndex() in a RefPtr instead of a raw one.
+
+        (WebCore::BitmapImage::draw):
+        Store return value of nativeImageForCurrentFrame() in a RefPtr instead
+        of a raw one.
+
+        * platform/graphics/skia/NativeImageSkia.cpp:
+        Add new constructor taking all members in argument. This is used for
+        cloning a NativeImageSkia object.
+
+        (WebCore::NativeImageSkia::NativeImageSkia):
+        (WebCore::NativeImageSkia::deepSkBitmapCopy):
+        Add convenience function to make a deep copy of a SkBitmap.
+
+        * platform/graphics/skia/NativeImageSkia.h:
+        (WebCore):
+        (WebCore::NativeImageSkia::create):
+        (NativeImageSkia):
+        Make NativeImageSkia subclass RefCounted. Make the constructor private
+        and add a factory method instead that returns a PassRefPtr.
+
+        (WebCore::NativeImageSkia::clone):
+        Add a clone() method now that NativeImageSkia is refcounted and is no
+        longer copyable.
+
+        * platform/graphics/skia/PatternSkia.cpp:
+        (WebCore::Pattern::platformPattern):
+        Store return value of nativeImageForCurrentFrame() in a RefPtr instead
+        of a raw one.
+
+        * platform/graphics/wince/ImageWinCE.cpp:
+        (WebCore::ImageFrame::asNewNativeImage):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/image-decoders/ImageDecoder.h:
+        (ImageFrame):
+        Have asNewNativeImage() return a PassNativeImagePtr instead of a
+        NativeImagePtr.
+
+        (WebCore::ImageFrame::getAddr):
+        (WebCore::ImageFrame::setSkBitmap):
+        (WebCore::ImageFrame::getSkBitmap):
+        (WebCore::ImageFrame::width):
+        (WebCore::ImageFrame::height):
+        Update use of m_bitmap now that it is a pointer type and call
+        NativeImageSkia::create() to construct a NativeImageSkia object now
+        that the constructor is private.
+
+        * platform/image-decoders/cairo/ImageDecoderCairo.cpp:
+        (WebCore::ImageFrame::asNewNativeImage):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * platform/image-decoders/openvg/ImageDecoderOpenVG.cpp:
+        (WebCore::ImageFrame::asNewNativeImage): Ditto.
+
+        * platform/image-decoders/skia/ImageDecoderSkia.cpp:
+        (WebCore::ImageFrame::ImageFrame):
+        Initialize m_bitmap in the constructor now that it is a pointer
+        type and we need NativeImageSkia's default constructor to be
+        called.
+
+        (WebCore::ImageFrame::operator=):
+        Call NativeImageSkia's new clone() method to copy m_bitmap as
+        NativeImageSkia is now RefCounted and no longer copyable.
+
+        (WebCore::ImageFrame::clearPixelData):
+        (WebCore::ImageFrame::zeroFillPixelData):
+        (WebCore::ImageFrame::copyBitmapData):
+        (WebCore::ImageFrame::setSize):
+        Update use of m_bitmap now that it is a pointer type.
+
+        (WebCore::ImageFrame::asNewNativeImage):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+        Call NativeImageSkia's clone method now that it is no longer
+        copyable.
+
+        (WebCore::ImageFrame::setHasAlpha):
+        (WebCore::ImageFrame::setStatus):
+        Update use of m_bitmap now that it is a pointer type.
+
+        * platform/image-decoders/wx/ImageDecoderWx.cpp:
+        (WebCore::ImageFrame::asNewNativeImage):
+        Return a PassNativeImagePtr instead of a NativeImagePtr.
+
+        * svg/graphics/SVGImage.cpp:
+        (WebCore):
+        (WebCore::SVGImage::nativeImageForCurrentFrame):
+        Add implementation of nativeImageForCurrentFrame() for SVGImage as
+        it is needed for SVG custom cursor support and Canvas drawing of
+        patterns containing SVG images. As SVGImage no longer keep the
+        native image internally to save memory, the implementation creates
+        the native image when nativeImageForCurrentFrame() and passes
+        its ownership to the caller.
+
+        * svg/graphics/SVGImage.h:
+        Override Image::nativeImageForCurrentFrame() and remove dummy
+        implementation of frameAtIndex() as it is not needed / used.
+
+        * svg/graphics/SVGImageForContainer.cpp:
+        (WebCore::SVGImageForContainer::nativeImageForCurrentFrame):
+        Add implementation of nativeImageForCurrentFrame() which merely
+        forwards the call to the Image being contained.
+
+        * svg/graphics/SVGImageForContainer.h:
+        Override Image::nativeImageForCurrentFrame().
+
 2013-04-04  Andrei Bucur  <abucur@adobe.com>
 
         [CSSRegions] RenderFlowThread::renderRegionForLine should use a faster search method
index 3cb1396..691c77b 100644 (file)
@@ -299,7 +299,7 @@ Image* IconDatabase::synchronousIconForPageURL(const String& pageURLOriginal, co
     return iconRecord->image(size);
 }
 
-NativeImagePtr IconDatabase::synchronousNativeIconForPageURL(const String& pageURLOriginal, const IntSize& size)
+PassNativeImagePtr IconDatabase::synchronousNativeIconForPageURL(const String& pageURLOriginal, const IntSize& size)
 {
     Image* icon = synchronousIconForPageURL(pageURLOriginal, size);
     if (!icon)
index 0a72422..a6226dd 100644 (file)
@@ -97,7 +97,7 @@ public:
     virtual void setIconURLForPageURL(const String& iconURL, const String& pageURL);
 
     virtual Image* synchronousIconForPageURL(const String&, const IntSize&);
-    virtual NativeImagePtr synchronousNativeIconForPageURL(const String& pageURLOriginal, const IntSize&);
+    virtual PassNativeImagePtr synchronousNativeIconForPageURL(const String& pageURLOriginal, const IntSize&);
     virtual String synchronousIconURLForPageURL(const String&);
     virtual bool synchronousIconDataKnownForIconURL(const String&);
     virtual IconLoadDecision synchronousLoadDecisionForIconURL(const String&, DocumentLoader*);    
index 040fc47..e1f63af 100644 (file)
@@ -179,7 +179,7 @@ public:
     virtual bool synchronousIconDataKnownForIconURL(const String&) { return false; }
     virtual IconLoadDecision synchronousLoadDecisionForIconURL(const String&, DocumentLoader*) { return IconLoadNo; }
     virtual Image* synchronousIconForPageURL(const String&, const IntSize&) { return 0; }
-    virtual NativeImagePtr synchronousNativeIconForPageURL(const String&, const IntSize&) { return 0; }
+    virtual PassNativeImagePtr synchronousNativeIconForPageURL(const String&, const IntSize&) { return 0; }
 
     // Asynchronous calls we should use to replace the above when supported.
     virtual bool supportsAsynchronousMode() { return false; }
index 1b0d92a..b68d44b 100644 (file)
@@ -105,7 +105,7 @@ DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum
     if (!image)
         return 0;
 
-    NativeImageSkia* bitmap = image->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> bitmap = image->nativeImageForCurrentFrame();
     if (!bitmap)
         return 0;
 
index 07fa9a9..133fbb7 100644 (file)
@@ -138,7 +138,7 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String& title)
     Image* image = cachedImage->imageForRenderer(renderer);
     ASSERT(image);
 
-    NativeImagePtr bitmap = image->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> bitmap = image->nativeImageForCurrentFrame();
     if (!bitmap)
         return;
 
index cf43073..cb80a8d 100644 (file)
@@ -299,7 +299,7 @@ bool BitmapImage::ensureFrameIsCached(size_t index)
     return true;
 }
 
-NativeImagePtr BitmapImage::frameAtIndex(size_t index)
+PassNativeImagePtr BitmapImage::frameAtIndex(size_t index)
 {
     if (!ensureFrameIsCached(index))
         return 0;
@@ -320,7 +320,7 @@ float BitmapImage::frameDurationAtIndex(size_t index)
     return m_frames[index].m_duration;
 }
 
-NativeImagePtr BitmapImage::nativeImageForCurrentFrame()
+PassNativeImagePtr BitmapImage::nativeImageForCurrentFrame()
 {
     return frameAtIndex(currentFrame());
 }
index a87cd58..31c9058 100644 (file)
@@ -109,7 +109,7 @@ class BitmapImage : public Image {
     friend class GeneratorGeneratedImage;
     friend class GraphicsContext;
 public:
-    static PassRefPtr<BitmapImage> create(NativeImagePtr nativeImage, ImageObserver* observer = 0)
+    static PassRefPtr<BitmapImage> create(PassNativeImagePtr nativeImage, ImageObserver* observer = 0)
     {
         return adoptRef(new BitmapImage(nativeImage, observer));
     }
@@ -177,7 +177,8 @@ public:
     virtual Evas_Object* getEvasObject(Evas*);
 #endif
 
-    virtual NativeImagePtr nativeImageForCurrentFrame();
+    virtual PassNativeImagePtr nativeImageForCurrentFrame() OVERRIDE;
+
     virtual bool currentFrameKnownToBeOpaque() OVERRIDE;
 
     ImageOrientation currentFrameOrientation();
@@ -198,7 +199,7 @@ protected:
       Certain     // The repetition count is known to be correct.
     };
 
-    BitmapImage(NativeImagePtr, ImageObserver* = 0);
+    BitmapImage(PassNativeImagePtr, ImageObserver* = 0);
     BitmapImage(ImageObserver* = 0);
 #if PLATFORM(WX)
     BitmapImage(const wxBitmap&);
@@ -219,7 +220,7 @@ protected:
 
     size_t currentFrame() const { return m_currentFrame; }
     virtual size_t frameCount();
-    NativeImagePtr frameAtIndex(size_t);
+    PassNativeImagePtr frameAtIndex(size_t);
     bool frameIsCompleteAtIndex(size_t);
     float frameDurationAtIndex(size_t);
     bool frameHasAlphaAtIndex(size_t);
index 5bc8881..d6f6f5b 100644 (file)
@@ -273,7 +273,7 @@ namespace WebCore {
         void applyFillPattern();
         void drawPath(const Path&);
 
-        void drawNativeImage(NativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
+        void drawNativeImage(PassNativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
 
         // Allow font smoothing (LCD antialiasing). Not part of the graphics state.
         void setAllowsFontSmoothing(bool);
index ea3a728..5da2964 100644 (file)
@@ -923,8 +923,8 @@ public:
         bool extractImage(bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
 
 #if USE(SKIA)
-        OwnPtr<NativeImageSkia> m_nativeImage;
-        NativeImageSkia* m_skiaImage;
+        RefPtr<NativeImageSkia> m_nativeImage;
+        RefPtr<NativeImageSkia> m_skiaImage;
 #elif USE(CAIRO)
         ImageSource* m_decoder;
         RefPtr<cairo_surface_t> m_imageSurface;
index 637643d..9f545de 100644 (file)
@@ -142,7 +142,7 @@ public:
 
     enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
 
-    virtual NativeImagePtr nativeImageForCurrentFrame() { return 0; }
+    virtual PassNativeImagePtr nativeImageForCurrentFrame() { return 0; }
     
 #if PLATFORM(MAC)
     // Accessors for native image formats.
index 1e4e5d4..9d0b3e8 100644 (file)
@@ -132,7 +132,7 @@ namespace WebCore {
 
     private:
 #if USE(CG)
-        NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const;
+        PassNativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const;
 #endif
         void clip(GraphicsContext*, const FloatRect&) const;
 
index 917400e..c066ce7 100644 (file)
@@ -141,7 +141,7 @@ size_t ImageSource::frameCount() const
     return m_decoder ? m_decoder->frameCount() : 0;
 }
 
-NativeImagePtr ImageSource::createFrameAtIndex(size_t index)
+PassNativeImagePtr ImageSource::createFrameAtIndex(size_t index)
 {
     if (!m_decoder)
         return 0;
index 66a8a0a..ca99770 100644 (file)
@@ -149,7 +149,7 @@ public:
 
     // Callers should not call this after calling clear() with a higher index;
     // see comments on clear() above.
-    NativeImagePtr createFrameAtIndex(size_t);
+    PassNativeImagePtr createFrameAtIndex(size_t);
 
     float frameDurationAtIndex(size_t);
     bool frameHasAlphaAtIndex(size_t); // Whether or not the frame actually used any alpha.
index 1ad5be9..7353141 100644 (file)
@@ -56,6 +56,8 @@ class MemoryObjectInfo;
 
 namespace WebCore {
 
+// FIXME: NativeImagePtr and PassNativeImagePtr should be smart
+// pointers (see SVGImage::nativeImageForCurrentFrame()).
 #if USE(CG)
 typedef CGImageRef NativeImagePtr;
 #elif PLATFORM(QT)
@@ -72,7 +74,8 @@ typedef wxBitmap* NativeImagePtr;
 #elif USE(CAIRO)
 typedef WebCore::NativeImageCairo* NativeImagePtr;
 #elif USE(SKIA)
-typedef WebCore::NativeImageSkia* NativeImagePtr;
+typedef RefPtr<NativeImageSkia> NativeImagePtr;
+typedef PassRefPtr<NativeImageSkia> PassNativeImagePtr;
 void reportMemoryUsage(const NativeImageSkia*, WTF::MemoryObjectInfo*);
 #elif OS(WINCE)
 typedef RefPtr<SharedBitmap> NativeImagePtr;
@@ -80,6 +83,10 @@ typedef RefPtr<SharedBitmap> NativeImagePtr;
 typedef void* NativeImagePtr;
 #endif
 
+#if !USE(SKIA)
+typedef NativeImagePtr PassNativeImagePtr;
+#endif
+
 }
 
 #endif
index 55d3ec3..247f76a 100644 (file)
@@ -55,7 +55,7 @@ PassRefPtr<Image> Image::loadPlatformResource(const char *name)
     return img.release();
 }
 
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
 {
     return new BlackBerry::Platform::Graphics::TiledImage(m_size, m_bytes);
 }
@@ -73,7 +73,7 @@ bool FrameData::clear(bool clearMetadata)
     return false;
 }
 
-BitmapImage::BitmapImage(NativeImagePtr nativeImage, ImageObserver* observer)
+BitmapImage::BitmapImage(PassNativeImagePtr nativeImage, ImageObserver* observer)
     : Image(observer)
     , m_currentFrame(0)
     , m_frames(0)
index a374850..9e18891 100644 (file)
@@ -157,7 +157,7 @@ void GraphicsContext::restorePlatformState()
     m_data->m_userToDeviceTransformKnownToBeIdentity = false;
 }
 
-void GraphicsContext::drawNativeImage(NativeImagePtr imagePtr, const FloatSize& imageSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
+void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSize& imageSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
 {
     RetainPtr<CGImageRef> image(imagePtr);
 
index e573732..0681578 100644 (file)
@@ -235,7 +235,7 @@ BackingStoreCopy ImageBuffer::fastCopyImageMode()
     return DontCopyBackingStore;
 }
 
-NativeImagePtr ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const
+PassNativeImagePtr ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const
 {
     CGImageRef image = 0;
     if (!m_context->isAcceleratedContext()) {
index 794ec73..f624f96 100644 (file)
@@ -487,7 +487,7 @@ void GraphicsLayerChromium::setContentsRect(const IntRect& rect)
 void GraphicsLayerChromium::setContentsToImage(Image* image)
 {
     bool childrenChanged = false;
-    NativeImageSkia* nativeImage = image ? image->nativeImageForCurrentFrame() : 0;
+    RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFrame() : 0;
     if (nativeImage) {
         if (m_contentsLayerPurpose != ContentsLayerForImage) {
             m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->createImageLayer());
index 64e5358..2e9d828 100644 (file)
@@ -72,8 +72,8 @@ bool FEBlend::platformApplySkia()
     RefPtr<Image> foreground = in->asImageBuffer()->copyImage(DontCopyBackingStore);
     RefPtr<Image> background = in2->asImageBuffer()->copyImage(DontCopyBackingStore);
 
-    NativeImageSkia* foregroundNativeImage = foreground->nativeImageForCurrentFrame();
-    NativeImageSkia* backgroundNativeImage = background->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> foregroundNativeImage = foreground->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> backgroundNativeImage = background->nativeImageForCurrentFrame();
 
     if (!foregroundNativeImage || !backgroundNativeImage)
         return false;
index 3228cd8..2919d0c 100644 (file)
@@ -123,7 +123,7 @@ bool FEColorMatrix::platformApplySkia()
     SkAutoTUnref<SkColorFilter> filter(createColorFilter(m_type, m_values.data()));
 
     RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
-    NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
     if (!nativeImage)
         return false;
 
index b0f80ce..4a40bf8 100644 (file)
@@ -43,7 +43,7 @@ bool FEComponentTransfer::platformApplySkia()
         return false;
 
     RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
-    NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
     if (!nativeImage)
         return false;
 
index 22f1b73..1be4551 100644 (file)
@@ -71,8 +71,8 @@ bool FEDisplacementMap::platformApplySkia()
     RefPtr<Image> color = in->asImageBuffer()->copyImage(DontCopyBackingStore);
     RefPtr<Image> displ = in2->asImageBuffer()->copyImage(DontCopyBackingStore);
 
-    NativeImageSkia* colorNativeImage = color->nativeImageForCurrentFrame();
-    NativeImageSkia* displNativeImage = displ->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> colorNativeImage = color->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> displNativeImage = displ->nativeImageForCurrentFrame();
 
     if (!colorNativeImage || !displNativeImage)
         return false;
index d7087d4..3a0b779 100644 (file)
@@ -97,7 +97,7 @@ bool FELighting::platformApplySkia()
     setIsAlphaImage(in->isAlphaImage());
 
     RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
-    NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> nativeImage = image->nativeImageForCurrentFrame();
     if (!nativeImage)
         return false;
 
index a7d9f75..a3f4465 100644 (file)
@@ -264,7 +264,7 @@ void ImageDecoderQt::clearPointers()
     m_buffer.clear();
 }
 
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
 {
     QImage::Format format;
     if (m_hasAlpha)
index 0f407c1..3e5387b 100644 (file)
@@ -62,9 +62,9 @@ IntSize StillImage::size() const
     return IntSize(m_pixmap->width(), m_pixmap->height());
 }
 
-NativeImagePtr StillImage::nativeImageForCurrentFrame()
+PassNativeImagePtr StillImage::nativeImageForCurrentFrame()
 {
-    return const_cast<NativeImagePtr>(m_pixmap);
+    return const_cast<PassNativeImagePtr>(m_pixmap);
 }
 
 void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
index 505b190..1e9e219 100644 (file)
@@ -52,7 +52,7 @@ namespace WebCore {
         virtual unsigned decodedSize() const { return 0; }
 
         virtual IntSize size() const;
-        virtual NativeImagePtr nativeImageForCurrentFrame();
+        virtual PassNativeImagePtr nativeImageForCurrentFrame();
         virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
 
     private:
index 3b1c8f2..8ac6d06 100644 (file)
@@ -69,7 +69,7 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
         if (!frame || frame->status() != ImageFrame::FrameComplete)
             return false;
         hasAlpha = frame->hasAlpha();
-        m_nativeImage = adoptPtr(frame->asNewNativeImage());
+        m_nativeImage = frame->asNewNativeImage();
         if (!m_nativeImage.get() || !m_nativeImage->isDataComplete() || !m_nativeImage->bitmap().width() || !m_nativeImage->bitmap().height())
             return false;
         SkBitmap::Config skiaConfig = m_nativeImage->bitmap().config();
index f61decb..c64d8db 100644 (file)
@@ -202,10 +202,20 @@ GraphicsContext* ImageBuffer::context() const
     return m_context.get();
 }
 
+static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap)
+{
+    SkBitmap tmp;
+    if (!bitmap.deepCopyTo(&tmp, bitmap.config()))
+        bitmap.copyTo(&tmp, bitmap.config());
+
+    return tmp;
+}
+
 PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior) const
 {
+    const SkBitmap& bitmap = *m_data.m_platformContext.bitmap();
     // FIXME: Start honoring ScaleBehavior to scale 2x buffers down to 1x.
-    return BitmapImage::create(new NativeImageSkia(*m_data.m_platformContext.bitmap(), copyBehavior == CopyBackingStore ? NativeImageSkia::CopyPixels : NativeImageSkia::DoNotCopyPixels, m_resolutionScale));
+    return BitmapImage::create(NativeImageSkia::create(copyBehavior == CopyBackingStore ? deepSkBitmapCopy(bitmap) : bitmap, m_resolutionScale));
 }
 
 BackingStoreCopy ImageBuffer::fastCopyImageMode()
@@ -251,22 +261,24 @@ void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
     context->platformContext()->beginLayerClippedToImage(rect, this);
 }
 
-static NativeImageSkia::CopyBehavior drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst)
+static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst)
 {
-    return (dst->platformContext()->isDeferred() || src == dst) ? NativeImageSkia::CopyPixels : NativeImageSkia::DoNotCopyPixels;
+    return (dst->platformContext()->isDeferred() || src == dst);
 }
 
 void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
     CompositeOperator op, BlendMode, bool useLowQualityScale)
 {
-    RefPtr<Image> image = BitmapImage::create(new NativeImageSkia(*m_data.m_platformContext.bitmap(), drawNeedsCopy(m_context.get(), context)));
+    const SkBitmap& bitmap = *m_data.m_platformContext.bitmap();
+    RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsCopy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap));
     context->drawImage(image.get(), styleColorSpace, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
 }
 
 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
                               const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
 {
-    RefPtr<Image> image = BitmapImage::create(new NativeImageSkia(*m_data.m_platformContext.bitmap(), drawNeedsCopy(m_context.get(), context)));
+    const SkBitmap& bitmap = *m_data.m_platformContext.bitmap();
+    RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsCopy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap));
     image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
 }
 
index cb92392..13ccf11 100644 (file)
@@ -449,10 +449,8 @@ bool FrameData::clear(bool clearMetadata)
     m_orientation = DefaultImageOrientation;
 
     if (m_frame) {
-        // ImageSource::createFrameAtIndex() allocated |m_frame| and passed
-        // ownership to BitmapImage; we must delete it here.
-        delete m_frame;
-        m_frame = 0;
+        m_frame.clear();
+
         return true;
     }
     return false;
@@ -470,7 +468,7 @@ void Image::drawPattern(GraphicsContext* context,
 #if PLATFORM(CHROMIUM)
     TRACE_EVENT0("skia", "Image::drawPattern");
 #endif
-    NativeImageSkia* bitmap = nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> bitmap = nativeImageForCurrentFrame();
     if (!bitmap)
         return;
 
@@ -559,7 +557,7 @@ void Image::drawPattern(GraphicsContext* context,
 
 // FIXME: These should go to BitmapImageSkia.cpp
 
-BitmapImage::BitmapImage(NativeImageSkia* nativeImage, ImageObserver* observer)
+BitmapImage::BitmapImage(PassRefPtr<NativeImageSkia> nativeImage, ImageObserver* observer)
     : Image(observer)
     , m_size(nativeImage->bitmap().width(), nativeImage->bitmap().height())
     , m_currentFrame(0)
@@ -584,8 +582,8 @@ BitmapImage::BitmapImage(NativeImageSkia* nativeImage, ImageObserver* observer)
     m_sizeRespectingOrientation = m_size;
 
     m_frames.grow(1);
-    m_frames[0].m_frame = nativeImage;
     m_frames[0].m_hasAlpha = !nativeImage->bitmap().isOpaque();
+    m_frames[0].m_frame = nativeImage;
     m_frames[0].m_haveMetadata = true;
 
     checkForSolidColor();
@@ -603,7 +601,7 @@ void BitmapImage::checkForSolidColor()
     if (frameCount() > 1)
         return;
 
-    WebCore::NativeImageSkia* frame = frameAtIndex(0);
+    RefPtr<NativeImageSkia> frame = frameAtIndex(0);
 
     if (frame && size().width() == 1 && size().height() == 1) {
         SkAutoLockPixels lock(frame->bitmap());
@@ -627,7 +625,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const Fl
     // causing flicker and wasting CPU.
     startAnimation();
 
-    NativeImageSkia* bm = nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> bm = nativeImageForCurrentFrame();
     if (!bm)
         return; // It's too early and we don't have an image yet.
 
index 21ebf5b..e689d07 100644 (file)
 namespace WebCore {
 
 NativeImageSkia::NativeImageSkia()
-    : m_resolutionScale(1),
-      m_resizeRequests(0)
+    : m_resolutionScale(1)
+    , m_resizeRequests(0)
 {
 }
 
-NativeImageSkia::NativeImageSkia(const SkBitmap& other, CopyBehavior copyBehavior, float resolutionScale)
-    : m_resolutionScale(resolutionScale),
-      m_resizeRequests(0)
+NativeImageSkia::NativeImageSkia(const SkBitmap& other, float resolutionScale)
+    : m_image(other)
+    , m_resolutionScale(resolutionScale)
+    , m_resizeRequests(0)
+{
+}
+
+NativeImageSkia::NativeImageSkia(const SkBitmap& image, float resolutionScale, const SkBitmap& resizedImage, const CachedImageInfo& cachedImageInfo, int resizeRequests)
+    : m_image(image)
+    , m_resolutionScale(resolutionScale)
+    , m_resizedImage(resizedImage)
+    , m_cachedImageInfo(cachedImageInfo)
+    , m_resizeRequests(resizeRequests)
 {
-    if (copyBehavior == CopyPixels) {
-        if (!other.deepCopyTo(&m_image, other.config()))
-            other.copyTo(&m_image, other.config());
-    } else
-        m_image = other;
 }
 
 NativeImageSkia::~NativeImageSkia()
index 89e326a..1faeb5a 100644 (file)
 #include "SkRect.h"
 #include "SkSize.h"
 #include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
 // This object is used as the "native image" in our port. When WebKit uses
-// "NativeImagePtr", it is a pointer to this type. It has an SkBitmap, and also
-// stores a cached resized image.
-class NativeImageSkia {
+// PassNativeImagePtr / NativeImagePtr, it is a smart pointer to this type.
+// It has an SkBitmap, and also stores a cached resized image.
+class NativeImageSkia : public RefCounted<NativeImageSkia> {
 public:
-    enum CopyBehavior { CopyPixels, DoNotCopyPixels };
+    static PassRefPtr<NativeImageSkia> create()
+    {
+        return adoptRef(new NativeImageSkia());
+    }
+
+    // This factory method does a shallow copy of the passed-in SkBitmap
+    // (ie., it references the same pixel data and bumps the refcount). Use
+    // only when you want sharing semantics.
+    static PassRefPtr<NativeImageSkia> create(const SkBitmap& bitmap, float resolutionScale = 1)
+    {
+        return adoptRef(new NativeImageSkia(bitmap, resolutionScale));
+    }
+
+    // This method does a shallow copy of the internal SkBitmap (ie., it
+    // references the same pixel data and bumps the refcount). Use only when
+    // you want sharing semantics.
+    PassRefPtr<NativeImageSkia> clone() const
+    {
+        return adoptRef(new NativeImageSkia(m_image, m_resolutionScale, m_resizedImage, m_cachedImageInfo, m_resizeRequests));
+    }
 
-    NativeImageSkia();
     ~NativeImageSkia();
 
-    NativeImageSkia(const SkBitmap&, CopyBehavior, float resolutionScale = 1);
-
     // Returns the number of bytes of image data. This includes the cached
     // resized version if there is one.
     int decodedSize() const;
@@ -87,6 +105,10 @@ public:
     void reportMemoryUsage(MemoryObjectInfo*) const;
 
 private:
+    NativeImageSkia();
+
+    NativeImageSkia(const SkBitmap&, float resolutionScale);
+
     // CachedImageInfo is used to uniquely identify cached or requested image
     // resizes.
     // Image resize is identified by the scaled image size and scaled image subset.
@@ -101,6 +123,8 @@ private:
         SkIRect rectInSubset(const SkIRect& otherScaledImageRect);
     };
 
+    NativeImageSkia(const SkBitmap& image, float resolutionScale, const SkBitmap& resizedImage, const CachedImageInfo&, int resizeRequests);
+
     // Returns true if the given resize operation should either resize the whole
     // image and cache it, or resize just the part it needs and throw the result
     // away.
index 2ae4dd6..fa0aa86 100644 (file)
@@ -71,7 +71,7 @@ PlatformPatternPtr Pattern::platformPattern(const AffineTransform& patternTransf
     // and expanded scale and skew in:
     // LayoutTests/svg/W3C-SVG-1.1/pservers-grad-06-b.svg
 
-    const NativeImageSkia* image = m_tileImage->nativeImageForCurrentFrame();
+    RefPtr<NativeImageSkia> image = m_tileImage->nativeImageForCurrentFrame();
     // If we don't have a bitmap, return a transparent shader.
     if (!image)
         m_pattern = new SkColorShader(SkColorSetARGB(0, 0, 0, 0));
index a28d149..3d1ca26 100644 (file)
@@ -41,7 +41,7 @@
 
 namespace WebCore {
 
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
 {
     return SharedBitmap::create(m_backingStore, m_size, hasAlpha());
 }
index 291167b..a4e7066 100644 (file)
@@ -115,7 +115,7 @@ namespace WebCore {
         // Returns a caller-owned pointer to the underlying native image data.
         // (Actual use: This pointer will be owned by BitmapImage and freed in
         // FrameData::clear()).
-        NativeImagePtr asNewNativeImage() const;
+        PassNativeImagePtr asNewNativeImage() const;
 
         bool hasAlpha() const;
         const IntRect& originalFrameRect() const { return m_originalFrameRect; }
@@ -141,7 +141,7 @@ namespace WebCore {
         inline PixelData* getAddr(int x, int y)
         {
 #if USE(SKIA)
-            return m_bitmap.bitmap().getAddr32(x, y);
+            return m_bitmap->bitmap().getAddr32(x, y);
 #else
             return m_bytes + (y * width()) + x;
 #endif
@@ -150,12 +150,12 @@ namespace WebCore {
 #if PLATFORM(CHROMIUM)
         void setSkBitmap(const SkBitmap& bitmap)
         {
-            m_bitmap = NativeImageSkia(bitmap, NativeImageSkia::DoNotCopyPixels);
+            m_bitmap = NativeImageSkia::create(bitmap);
         }
 
         const SkBitmap& getSkBitmap() const
         {
-            return m_bitmap.bitmap();
+            return m_bitmap->bitmap();
         }
 
         void setMemoryAllocator(SkBitmap::Allocator* allocator)
@@ -202,7 +202,7 @@ namespace WebCore {
         int width() const
         {
 #if USE(SKIA)
-            return m_bitmap.bitmap().width();
+            return m_bitmap->bitmap().width();
 #else
             return m_size.width();
 #endif
@@ -211,14 +211,14 @@ namespace WebCore {
         int height() const
         {
 #if USE(SKIA)
-            return m_bitmap.bitmap().height();
+            return m_bitmap->bitmap().height();
 #else
             return m_size.height();
 #endif
         }
 
 #if USE(SKIA)
-        NativeImageSkia m_bitmap;
+        RefPtr<NativeImageSkia> m_bitmap;
         SkBitmap::Allocator* m_allocator;
 #else
         Vector<PixelData> m_backingStore;
index 417628d..5cbdc56 100644 (file)
@@ -30,7 +30,7 @@
 
 namespace WebCore {
 
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
 {
     return new NativeImageCairo(cairo_image_surface_create_for_data(
         reinterpret_cast<unsigned char*>(const_cast<PixelData*>(m_bytes)),
index d29317a..833e527 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
 {
     static const VGImageFormat bufferFormat = VG_sARGB_8888_PRE;
     // Save memory by using 16-bit images for fully opaque images.
index 6243b86..c25412b 100644 (file)
 #include "config.h"
 #include "ImageDecoder.h"
 
+#include "NativeImageSkia.h"
 #include "PlatformMemoryInstrumentation.h"
 
 namespace WebCore {
 
 ImageFrame::ImageFrame()
-    : m_allocator(0)
+    : m_bitmap(NativeImageSkia::create())
+    , m_allocator(0)
     , m_hasAlpha(false)
     , m_status(FrameEmpty)
     , m_duration(0)
@@ -46,10 +48,10 @@ ImageFrame& ImageFrame::operator=(const ImageFrame& other)
     if (this == &other)
         return *this;
 
-    m_bitmap = other.m_bitmap;
+    m_bitmap = other.m_bitmap->clone();
     // Keep the pixels locked since we will be writing directly into the
     // bitmap throughout this object's lifetime.
-    m_bitmap.bitmap().lockPixels();
+    m_bitmap->bitmap().lockPixels();
     setMemoryAllocator(other.allocator());
     setOriginalFrameRect(other.originalFrameRect());
     setStatus(other.status());
@@ -64,7 +66,7 @@ ImageFrame& ImageFrame::operator=(const ImageFrame& other)
 
 void ImageFrame::clearPixelData()
 {
-    m_bitmap.bitmap().reset();
+    m_bitmap->bitmap().reset();
     m_status = FrameEmpty;
     // NOTE: Do not reset other members here; clearFrameBufferCache()
     // calls this to free the bitmap data, but other functions like
@@ -74,7 +76,7 @@ void ImageFrame::clearPixelData()
 
 void ImageFrame::zeroFillPixelData()
 {
-    m_bitmap.bitmap().eraseARGB(0, 0, 0, 0);
+    m_bitmap->bitmap().eraseARGB(0, 0, 0, 0);
     m_hasAlpha = true;
 }
 
@@ -84,9 +86,9 @@ bool ImageFrame::copyBitmapData(const ImageFrame& other)
         return true;
 
     m_hasAlpha = other.m_hasAlpha;
-    m_bitmap.bitmap().reset();
-    const NativeImageSkia& otherBitmap = other.m_bitmap;
-    return otherBitmap.bitmap().copyTo(&m_bitmap.bitmap(), otherBitmap.bitmap().config());
+    m_bitmap->bitmap().reset();
+    const NativeImageSkia* otherBitmap = other.m_bitmap.get();
+    return otherBitmap->bitmap().copyTo(&m_bitmap->bitmap(), otherBitmap->bitmap().config());
 }
 
 bool ImageFrame::setSize(int newWidth, int newHeight)
@@ -94,17 +96,17 @@ bool ImageFrame::setSize(int newWidth, int newHeight)
     // setSize() should only be called once, it leaks memory otherwise.
     ASSERT(!width() && !height());
 
-    m_bitmap.bitmap().setConfig(SkBitmap::kARGB_8888_Config, newWidth, newHeight);
-    if (!m_bitmap.bitmap().allocPixels(m_allocator, 0))
+    m_bitmap->bitmap().setConfig(SkBitmap::kARGB_8888_Config, newWidth, newHeight);
+    if (!m_bitmap->bitmap().allocPixels(m_allocator, 0))
         return false;
 
     zeroFillPixelData();
     return true;
 }
 
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
 {
-    return new NativeImageSkia(m_bitmap);
+    return m_bitmap->clone();
 }
 
 bool ImageFrame::hasAlpha() const
@@ -122,7 +124,7 @@ void ImageFrame::setHasAlpha(bool alpha)
     bool isOpaque = !m_hasAlpha;
     if (m_status != FrameComplete)
         isOpaque = false;
-    m_bitmap.bitmap().setIsOpaque(isOpaque);
+    m_bitmap->bitmap().setIsOpaque(isOpaque);
 }
 
 void ImageFrame::setColorProfile(const ColorProfile& colorProfile)
@@ -135,8 +137,8 @@ void ImageFrame::setStatus(FrameStatus status)
 {
     m_status = status;
     if (m_status == FrameComplete) {
-        m_bitmap.bitmap().setIsOpaque(!m_hasAlpha);
-        m_bitmap.setDataComplete();  // Tell the bitmap it's done.
+        m_bitmap->bitmap().setIsOpaque(!m_hasAlpha);
+        m_bitmap->setDataComplete(); // Tell the bitmap it's done.
     }
 }
 
index 0e0479e..9eeb74d 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace WebCore {
 
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
 {
     wxBitmap* bmp = new wxBitmap(width(), height(), 32);
 
index 296c34d..8635a63 100644 (file)
@@ -141,6 +141,25 @@ void SVGImage::drawForContainer(GraphicsContext* context, const FloatSize contai
     setImageObserver(observer);
 }
 
+#if USE(SKIA)
+// Passes ownership of the native image to the caller so PassNativeImagePtr needs
+// to be a smart pointer type.
+PassNativeImagePtr SVGImage::nativeImageForCurrentFrame()
+{
+    if (!m_page)
+        return 0;
+
+    OwnPtr<ImageBuffer> buffer = ImageBuffer::create(size(), 1);
+    if (!buffer) // failed to allocate image
+        return 0;
+
+    draw(buffer->context(), rect(), rect(), ColorSpaceDeviceRGB, CompositeSourceOver, BlendModeNormal);
+
+    // FIXME: WK(Bug 113657): We should use DontCopyBackingStore here.
+    return buffer->copyImage(CopyBackingStore)->nativeImageForCurrentFrame();
+}
+#endif
+
 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect,
     const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect)
 {
index f09a2b1..5dd0e7b 100644 (file)
@@ -62,6 +62,10 @@ public:
 
     virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
 
+#if USE(SKIA)
+    virtual PassNativeImagePtr nativeImageForCurrentFrame() OVERRIDE;
+#endif
+
 private:
     friend class SVGImageChromeClient;
     friend class SVGImageForContainer;
@@ -82,8 +86,6 @@ private:
     virtual void destroyDecodedData(bool) { }
     virtual unsigned decodedSize() const { return 0; }
 
-    virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
-
     // FIXME: Implement this to be less conservative.
     virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
 
index d076fea..e9e2728 100644 (file)
@@ -48,6 +48,11 @@ void SVGImageForContainer::drawPattern(GraphicsContext* context, const FloatRect
     m_image->drawPatternForContainer(context, m_containerSize, m_zoom, srcRect, patternTransform, phase, colorSpace, compositeOp, dstRect);
 }
 
+PassNativeImagePtr SVGImageForContainer::nativeImageForCurrentFrame()
+{
+    return m_image->nativeImageForCurrentFrame();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SVG)
index b3228e5..a2f15e4 100644 (file)
@@ -62,6 +62,8 @@ public:
     // FIXME: Implement this to be less conservative.
     virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
 
+    virtual PassNativeImagePtr nativeImageForCurrentFrame() OVERRIDE;
+
 private:
     SVGImageForContainer(SVGImage* image, const FloatSize& containerSize, float zoom)
         : m_image(image)
index e77a0e7..6ccb4c3 100644 (file)
@@ -1,3 +1,33 @@
+2013-04-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
+
+        Regression(r142765) Broke Custom SVG cursors and SVG canvas drawing for Chromium
+        https://bugs.webkit.org/show_bug.cgi?id=113420
+
+        Reviewed by Stephen White.
+
+        Update code now that Image::nativeImageForCurrentFrame() and
+        ImageFrame::asNewNativeImage() return a smart pointer instead
+        of a raw one.
+
+        * src/WebImageDecoder.cpp:
+        (WebKit::WebImageDecoder::getFrameAtIndex):
+        * src/WebImageSkia.cpp:
+        (WebKit::WebImage::fromData):
+        (WebKit::WebImage::framesFromData):
+        (WebKit::WebImage::operator=):
+        * tests/DeferredImageDecoderTest.cpp:
+        (WebCore::TEST_F):
+        * tests/DragImageTest.cpp:
+        (WebCore::TestImage::TestImage):
+        (WebCore::TestImage::nativeImageForCurrentFrame):
+        (TestImage):
+        * tests/ImageLayerChromiumTest.cpp:
+        (WebCore::TestImage::TestImage):
+        (WebCore::TestImage::nativeImageForCurrentFrame):
+        (TestImage):
+        * tests/PlatformContextSkiaTest.cpp:
+        (WebCore::TEST):
+
 2013-04-03  Christophe Dumez  <ch.dumez@sisa.samsung.com>
 
         [Chromium] Bad cast from BitmapImageSingleFrameSkia to BitmapImage
index 104ab13..2651347 100644 (file)
@@ -107,7 +107,7 @@ WebImage WebImageDecoder::getFrameAtIndex(int index = 0) const
     ImageFrame* const frameBuffer = m_private->frameBufferAtIndex(index);
     if (!frameBuffer)
         return WebImage();
-    OwnPtr<NativeImageSkia> image = adoptPtr(frameBuffer->asNewNativeImage());
+    RefPtr<NativeImageSkia> image = frameBuffer->asNewNativeImage();
     return WebImage(image->bitmap());
 }
 
index 6d55555..2b760a9 100644 (file)
@@ -85,7 +85,7 @@ WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize)
     if (!frame)
         return WebImage();
 
-    OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage());
+    RefPtr<NativeImageSkia> image = frame->asNewNativeImage();
     if (!image)
         return WebImage();
 
@@ -122,8 +122,8 @@ WebVector<WebImage> WebImage::framesFromData(const WebData& data)
         if (!frame)
             continue;
 
-        OwnPtr<NativeImageSkia> image = adoptPtr(frame->asNewNativeImage());
-        if (image.get() && image->isDataComplete())
+        RefPtr<NativeImageSkia> image = frame->asNewNativeImage();
+        if (image && image->isDataComplete())
             frames.append(WebImage(image->bitmap()));
     }
 
@@ -157,8 +157,8 @@ WebImage::WebImage(const PassRefPtr<Image>& image)
 
 WebImage& WebImage::operator=(const PassRefPtr<Image>& image)
 {
-    NativeImagePtr p;
-    if (image.get() && (p = image->nativeImageForCurrentFrame()))
+    RefPtr<NativeImageSkia> p;
+    if (image && (p = image->nativeImageForCurrentFrame()))
         assign(p->bitmap());
     else
         reset();
index 7f1900b..64f8e57 100644 (file)
@@ -117,7 +117,7 @@ protected:
 
 TEST_F(DeferredImageDecoderTest, drawIntoSkPicture)
 {
-    OwnPtr<NativeImageSkia> image(adoptPtr(m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage()));
+    RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage();
     EXPECT_EQ(1, image->bitmap().width());
     EXPECT_EQ(1, image->bitmap().height());
     EXPECT_FALSE(image->bitmap().isNull());
@@ -140,7 +140,7 @@ TEST_F(DeferredImageDecoderTest, drawIntoSkPicture)
 
 TEST_F(DeferredImageDecoderTest, drawScaledIntoSkPicture)
 {
-    OwnPtr<NativeImageSkia> image(adoptPtr(m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage()));
+    RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage();
     SkBitmap scaledBitmap = image->resizedBitmap(SkISize::Make(50, 51), SkIRect::MakeWH(50, 51));
     EXPECT_FALSE(scaledBitmap.isNull());
     EXPECT_TRUE(scaledBitmap.isImmutable());
@@ -174,7 +174,7 @@ TEST_F(DeferredImageDecoderTest, decodeOnOtherThread)
 {
     WTF::initializeThreading();
 
-    OwnPtr<NativeImageSkia> image(adoptPtr(m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage()));
+    RefPtr<NativeImageSkia> image = m_lazyDecoder->frameBufferAtIndex(0)->asNewNativeImage();
     EXPECT_EQ(1, image->bitmap().width());
     EXPECT_EQ(1, image->bitmap().height());
     EXPECT_FALSE(image->bitmap().isNull());
index a9465e6..6bf1834 100644 (file)
@@ -53,7 +53,7 @@ public:
         : Image(0)
         , m_size(size)
     {
-        m_nativeImage = adoptPtr(new NativeImageSkia());
+        m_nativeImage = NativeImageSkia::create();
         m_nativeImage->bitmap().setConfig(SkBitmap::kARGB_8888_Config,
                                           size.width(), size.height(), 0);
         m_nativeImage->bitmap().allocPixels();
@@ -64,12 +64,12 @@ public:
         return m_size;
     }
 
-    virtual NativeImagePtr nativeImageForCurrentFrame()
+    virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame()
     {
         if (m_size.isZero())
             return 0;
 
-        return m_nativeImage.get();
+        return m_nativeImage;
     }
 
     // Stub implementations of pure virtual Image functions.
@@ -97,7 +97,7 @@ private:
 
     IntSize m_size;
 
-    OwnPtr<NativeImagePtr> m_nativeImage;
+    RefPtr<NativeImageSkia> m_nativeImage;
 };
 
 TEST(DragImageTest, NullHandling)
index 4db428c..648dbe7 100644 (file)
@@ -55,7 +55,7 @@ public:
         : Image(0)
         , m_size(size)
     {
-        m_nativeImage = adoptPtr(new NativeImageSkia());
+        m_nativeImage = NativeImageSkia::create();
         m_nativeImage->bitmap().setConfig(SkBitmap::kARGB_8888_Config,
                                           size.width(), size.height(), 0);
         m_nativeImage->bitmap().allocPixels();
@@ -77,12 +77,12 @@ public:
         return m_size;
     }
 
-    virtual NativeImagePtr nativeImageForCurrentFrame()
+    virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame()
     {
         if (m_size.isZero())
             return 0;
 
-        return m_nativeImage.get();
+        return m_nativeImage;
     }
 
     // Stub implementations of pure virtual Image functions.
@@ -105,7 +105,7 @@ private:
 
     IntSize m_size;
 
-    OwnPtr<NativeImagePtr> m_nativeImage;
+    RefPtr<NativeImageSkia> m_nativeImage;
 };
 
 TEST(ImageLayerChromiumTest, opaqueImages)
index 374328b..760144c 100644 (file)
@@ -541,22 +541,26 @@ TEST(PlatformContextSkiaTest, trackOpaqueImageTest)
     Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
     Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
 
-    SkBitmap drawBitmap;
-    drawBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
-    drawBitmap.allocPixels();
-
-    drawBitmap.setIsOpaque(true);
-    for (int y = 0; y < drawBitmap.height(); ++y)
-        for (int x = 0; x < drawBitmap.width(); ++x)
-            *drawBitmap.getAddr32(x, y) = 0xFFFFFFFF;
-    RefPtr<BitmapImage> opaqueImage = BitmapImage::create(new NativeImageSkia(drawBitmap, NativeImageSkia::CopyPixels));
+    SkBitmap opaqueBitmap;
+    opaqueBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    opaqueBitmap.allocPixels();
+
+    opaqueBitmap.setIsOpaque(true);
+    for (int y = 0; y < opaqueBitmap.height(); ++y)
+        for (int x = 0; x < opaqueBitmap.width(); ++x)
+            *opaqueBitmap.getAddr32(x, y) = 0xFFFFFFFF;
+    RefPtr<BitmapImage> opaqueImage = BitmapImage::create(NativeImageSkia::create(opaqueBitmap));
     EXPECT_TRUE(opaqueImage->currentFrameKnownToBeOpaque());
 
-    drawBitmap.setIsOpaque(false);
-    for (int y = 0; y < drawBitmap.height(); ++y)
-        for (int x = 0; x < drawBitmap.width(); ++x)
-            *drawBitmap.getAddr32(x, y) = 0x00000000;
-    RefPtr<BitmapImage> alphaImage = BitmapImage::create(new NativeImageSkia(drawBitmap, NativeImageSkia::CopyPixels));
+    SkBitmap alphaBitmap;
+    alphaBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
+    alphaBitmap.allocPixels();
+
+    alphaBitmap.setIsOpaque(false);
+    for (int y = 0; y < alphaBitmap.height(); ++y)
+        for (int x = 0; x < alphaBitmap.width(); ++x)
+            *alphaBitmap.getAddr32(x, y) = 0x00000000;
+    RefPtr<BitmapImage> alphaImage = BitmapImage::create(NativeImageSkia::create(alphaBitmap));
     EXPECT_FALSE(alphaImage->currentFrameKnownToBeOpaque());
 
     context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);