Don't attempt to destroy decoded frame if a BitmapImage doesn't have encoded raw data.

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

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2013-09-30
Reviewed by Daniel Bates.

With BitmapImage::create(PassNativeImagePtr, ImageObserver*), a BitmapImage could be created by
passing a native image.  If this image is added to memory cache, we shouldn't attempt to destroy
its decoded frames since there is no encoded raw data and we won't be able to reconstruct the image again.

No new tests for now. Currently there isn't a code path to add to the memory cache a BitmapImage
that was created by adopting a native image. We'll add such a code path in a subsequent patch.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::destroyDecodedDataIfNecessary):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156681 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0c4a2dbd
2013-09-30 Yongjun Zhang <yongjun_zhang@apple.com>
Don't attempt to destroy decoded frame if a BitmapImage doesn't have encoded raw data.
https://bugs.webkit.org/show_bug.cgi?id=122115
Reviewed by Daniel Bates.
With BitmapImage::create(PassNativeImagePtr, ImageObserver*), a BitmapImage could be created by
passing a native image. If this image is added to memory cache, we shouldn't attempt to destroy
its decoded frames since there is no encoded raw data and we won't be able to reconstruct the image again.
No new tests for now. Currently there isn't a code path to add to the memory cache a BitmapImage
that was created by adopting a native image. We'll add such a code path in a subsequent patch.
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::destroyDecodedDataIfNecessary):
2013-09-30 Brady Eidson <beidson@apple.com>
Remove IDBTracing.h.
......@@ -98,6 +98,12 @@ void BitmapImage::destroyDecodedDataIfNecessary(bool destroyAll)
// Animated images >5MB are considered large enough that we'll only hang on
// to one frame at a time.
static const unsigned cLargeAnimationCutoff = 5242880;
// If we have decoded frames but there is no encoded data, we shouldn't destroy
// the decoded image since we won't be able to reconstruct it later.
if (!data() && m_frames.size())
return;
unsigned allFrameBytes = 0;
for (size_t i = 0; i < m_frames.size(); ++i)
allFrameBytes += m_frames[i].m_frameBytes;
......
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