Commit 9c946b82 authored by jamesr@google.com's avatar jamesr@google.com

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):

git-svn-id: svn://svn.chromium.org/blink/trunk@93441 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 18068794
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment