Skip to content
Permalink
Browse files
REGRESSION(r91628): 3 canvas tests crash on Chromium Linux and one te…
…st fail on Chromium Mac

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

Reviewed by Darin Fisher.

Fixes crashes due to a bad cast from Image to BitmapImage on skia ports
that use BitmapImageSingleFrameSkia. In the skia port
Image::isBitmapImage() returning true does not necessarily mean that
Image is of type BitmapImage.

Covered by fast/canvas/canvas-as-image.html and many other canvas
tests.

Patch originally by Tom Hudson.

* platform/graphics/BitmapImage.h:
(WebCore::BitmapImage::currentFrameHasAlpha):
(WebCore::BitmapImage::notSolidColor):
* platform/graphics/Image.cpp:
(WebCore::Image::drawTiled):
* platform/graphics/Image.h:
(WebCore::Image::currentFrameHasAlpha):
(WebCore::Image::notSolidColor):
* platform/graphics/skia/BitmapImageSingleFrameSkia.h:
(WebCore::BitmapImageSingleFrameSkia::currentFrameHasAlpha):
(WebCore::BitmapImageSingleFrameSkia::notSolidColor):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::backgroundIsObscured):

Canonical link: https://commits.webkit.org/82431@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93441 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jamesr committed Aug 19, 2011
1 parent 3d0d52d commit 111ad9a1046c11590aef5c5e0e10b795e6edd26f
Showing 6 changed files with 49 additions and 8 deletions.
@@ -1,3 +1,34 @@
2011-08-19 James Robinson <jamesr@chromium.org>

REGRESSION(r91628): 3 canvas tests crash on Chromium Linux and one test fail on Chromium Mac
https://bugs.webkit.org/show_bug.cgi?id=65063

Reviewed by Darin Fisher.

Fixes crashes due to a bad cast from Image to BitmapImage on skia ports
that use BitmapImageSingleFrameSkia. In the skia port
Image::isBitmapImage() returning true does not necessarily mean that
Image is of type BitmapImage.

Covered by fast/canvas/canvas-as-image.html and many other canvas
tests.

Patch originally by Tom Hudson.

* platform/graphics/BitmapImage.h:
(WebCore::BitmapImage::currentFrameHasAlpha):
(WebCore::BitmapImage::notSolidColor):
* platform/graphics/Image.cpp:
(WebCore::Image::drawTiled):
* platform/graphics/Image.h:
(WebCore::Image::currentFrameHasAlpha):
(WebCore::Image::notSolidColor):
* platform/graphics/skia/BitmapImageSingleFrameSkia.h:
(WebCore::BitmapImageSingleFrameSkia::currentFrameHasAlpha):
(WebCore::BitmapImageSingleFrameSkia::notSolidColor):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::backgroundIsObscured):

2011-08-19 Emil A Eklund <eae@chromium.org>

Switch clipping for svg to to new layout types
@@ -159,10 +159,10 @@ class BitmapImage : public Image {

virtual NativeImagePtr nativeImageForCurrentFrame() { return frameAtIndex(currentFrame()); }
bool frameHasAlphaAtIndex(size_t);
bool currentFrameHasAlpha() { return frameHasAlphaAtIndex(currentFrame()); }
virtual bool currentFrameHasAlpha() { return frameHasAlphaAtIndex(currentFrame()); }

#if !ASSERT_DISABLED
bool notSolidColor()
virtual bool notSolidColor()
{
return size().width() != 1 || size().height() != 1 || frameCount() > 1;
}
@@ -115,7 +115,7 @@ void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const Fl

// See <https://webkit.org/b/59043>.
#if !PLATFORM(WX)
ASSERT(!isBitmapImage() || static_cast<BitmapImage*>(this)->notSolidColor());
ASSERT(!isBitmapImage() || notSolidColor());
#endif

FloatSize intrinsicTileSize = size();
@@ -88,6 +88,7 @@ class Image : public RefCounted<Image> {
static bool supportsType(const String&);

virtual bool isBitmapImage() const { return false; }
virtual bool currentFrameHasAlpha() { return false; }

// Derived classes should override this if they can assure that
// the image contains only resources from its own security origin.
@@ -157,6 +158,10 @@ class Image : public RefCounted<Image> {
virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);

#if !ASSERT_DISABLED
virtual bool notSolidColor() { return true; }
#endif

protected:
Image(ImageObserver* = 0);

@@ -53,6 +53,8 @@ class BitmapImageSingleFrameSkia : public Image {

virtual bool isBitmapImage() const { return true; }

virtual bool currentFrameHasAlpha() { return !m_nativeImage.isOpaque(); }

virtual IntSize size() const
{
return IntSize(m_nativeImage.width(), m_nativeImage.height());
@@ -72,6 +74,13 @@ class BitmapImageSingleFrameSkia : public Image {
return &m_nativeImage;
}

#if !ASSERT_DISABLED
virtual bool notSolidColor()
{
return m_nativeImage.width() != 1 || m_nativeImage.height() != 1;
}
#endif

protected:
virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);

@@ -408,13 +408,9 @@ bool RenderImage::backgroundIsObscured() const

// Check for bitmap image with alpha.
Image* image = m_imageResource->image().get();
if (!image || !image->isBitmapImage())
if (!image || !image->isBitmapImage() || image->currentFrameHasAlpha())
return false;

BitmapImage* bitmapImage = static_cast<BitmapImage*>(image);
if (bitmapImage->currentFrameHasAlpha())
return false;

return true;
}

0 comments on commit 111ad9a

Please sign in to comment.