Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Unified Diff: Source/core/platform/graphics/BitmapImageTest.cpp

Issue 25976002: Remove ImageSource::bytesDecodedToDetermineProperties() and fallout (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: For landing again, rebased Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/platform/graphics/BitmapImage.cpp ('k') | Source/core/platform/graphics/FrameData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/graphics/BitmapImageTest.cpp
diff --git a/Source/core/platform/graphics/BitmapImageTest.cpp b/Source/core/platform/graphics/BitmapImageTest.cpp
index 734f38734232b63ae5a3773432b67f6fa5a97b42..b5c9b2c57690508ed52081b5f63d47623827aa95 100644
--- a/Source/core/platform/graphics/BitmapImageTest.cpp
+++ b/Source/core/platform/graphics/BitmapImageTest.cpp
@@ -70,6 +70,7 @@ public:
size_t frameCount() { return m_image->frameCount(); }
void setCurrentFrame(size_t frame) { m_image->m_currentFrame = frame; }
size_t frameDecodedSize(size_t frame) { return m_image->m_frames[frame].m_frameBytes; }
+ size_t decodedFramesCount() const { return m_image->m_frames.size(); }
void loadImage(const char* fileName)
{
@@ -77,13 +78,27 @@ public:
ASSERT_TRUE(imageData.get());
m_image->setData(imageData, true);
- EXPECT_EQ(0u, m_image->decodedSize());
+ EXPECT_EQ(0u, decodedSize());
size_t frameCount = m_image->frameCount();
for (size_t i = 0; i < frameCount; ++i)
m_image->frameAtIndex(i);
}
+ size_t decodedSize()
+ {
+ // In the context of this test, the following loop will give the correct result, but only because the test
+ // forces all frames to be decoded in loadImage() above. There is no general guarantee that frameDecodedSize()
+ // is up-to-date. Because of how multi frame images (like GIF) work, requesting one frame to be decoded may
+ // require other previous frames to be decoded as well. In those cases frameDecodedSize() wouldn't return the
+ // correct thing for the previous frame because the decoded size wouldn't have propagated upwards to the
+ // BitmapImage frame cache.
+ size_t size = 0;
+ for (size_t i = 0; i < decodedFramesCount(); ++i)
+ size += frameDecodedSize(i);
+ return size;
+ }
+
protected:
virtual void SetUp() OVERRIDE
{
@@ -97,7 +112,7 @@ protected:
TEST_F(BitmapImageTest, destroyDecodedDataExceptCurrentFrame)
{
loadImage("/LayoutTests/fast/images/resources/animated-10color.gif");
- size_t totalSize = m_image->decodedSize();
+ size_t totalSize = decodedSize();
size_t frame = frameCount() / 2;
setCurrentFrame(frame);
size_t size = frameDecodedSize(frame);
@@ -109,11 +124,11 @@ TEST_F(BitmapImageTest, destroyDecodedDataExceptCurrentFrame)
TEST_F(BitmapImageTest, destroyAllDecodedData)
{
loadImage("/LayoutTests/fast/images/resources/animated-10color.gif");
- size_t decodedSize = m_image->decodedSize();
- EXPECT_GT(decodedSize, 0u);
+ size_t totalSize = decodedSize();
+ EXPECT_GT(totalSize, 0u);
destroyDecodedData(true);
- EXPECT_EQ(-static_cast<int>(decodedSize), m_imageObserver.m_lastDecodedSizeChangedDelta);
- EXPECT_EQ(0u, m_image->decodedSize());
+ EXPECT_EQ(-static_cast<int>(totalSize), m_imageObserver.m_lastDecodedSizeChangedDelta);
+ EXPECT_EQ(0u, decodedSize());
}
} // namespace
« no previous file with comments | « Source/core/platform/graphics/BitmapImage.cpp ('k') | Source/core/platform/graphics/FrameData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698