Chromium Code Reviews| Index: third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp |
| diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp |
| index d7e5a06b3d93e845749c12907c03f5ffbb1737c7..02490e4f022283958a5ebd716680ef72dc1d01dd 100644 |
| --- a/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp |
| +++ b/third_party/WebKit/Source/platform/image-decoders/ImageFrame.cpp |
| @@ -98,7 +98,7 @@ bool ImageFrame::setSize(int newWidth, int newHeight) |
| // setSize() should only be called once, it leaks memory otherwise. |
| ASSERT(!width() && !height()); |
| - m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight)); |
| + m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, computeAlphaType())); |
| if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
|
Noel Gordon
2016/03/21 22:37:16
Maybe don't call computeAlphaType() here? Instead
f(malita)
2016/03/21 22:46:24
Done.
|
| return false; |
| @@ -120,19 +120,14 @@ void ImageFrame::setHasAlpha(bool alpha) |
| { |
| m_hasAlpha = alpha; |
| - // If the frame is not fully loaded, there will be transparent pixels, |
| - // so we can't tell skia we're opaque, even for image types that logically |
| - // always are (e.g. jpeg). |
| - if (m_status != FrameComplete) |
| - alpha = true; |
| - m_bitmap.setAlphaType(alpha ? kPremul_SkAlphaType : kOpaque_SkAlphaType); |
| + m_bitmap.setAlphaType(computeAlphaType()); |
| } |
| void ImageFrame::setStatus(Status status) |
| { |
| m_status = status; |
| if (m_status == FrameComplete) { |
| - m_bitmap.setAlphaType(m_hasAlpha ? kPremul_SkAlphaType : kOpaque_SkAlphaType); |
| + m_bitmap.setAlphaType(computeAlphaType()); |
| // Send pending pixels changed notifications now, because we can't do this after |
| // the bitmap has been marked immutable. |
| notifyBitmapIfPixelsChanged(); |
| @@ -149,4 +144,15 @@ void ImageFrame::zeroFillFrameRect(const IntRect& rect) |
| setHasAlpha(true); |
| } |
| +SkAlphaType ImageFrame::computeAlphaType() const |
| +{ |
| + // If the frame is not fully loaded, there will be transparent pixels, |
| + // so we can't tell skia we're opaque, even for image types that logically |
| + // always are (e.g. jpeg). |
| + if (!m_hasAlpha && m_status == FrameComplete) |
| + return kOpaque_SkAlphaType; |
| + |
| + return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
| +} |
| + |
| } // namespace blink |