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

Side by Side Diff: Source/platform/graphics/BitmapImageTest.cpp

Issue 985583002: Don't cache any SkBitmaps in DeferredImageDecoder (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: done now Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 filePath.append(fileName); 66 filePath.append(fileName);
67 return Platform::current()->unitTestSupport()->readFromFile(filePath); 67 return Platform::current()->unitTestSupport()->readFromFile(filePath);
68 } 68 }
69 69
70 // Accessors to BitmapImage's protected methods. 70 // Accessors to BitmapImage's protected methods.
71 void destroyDecodedData(bool destroyAll) { m_image->destroyDecodedData(destr oyAll); } 71 void destroyDecodedData(bool destroyAll) { m_image->destroyDecodedData(destr oyAll); }
72 size_t frameCount() { return m_image->frameCount(); } 72 size_t frameCount() { return m_image->frameCount(); }
73 void setCurrentFrame(size_t frame) { m_image->m_currentFrame = frame; } 73 void setCurrentFrame(size_t frame) { m_image->m_currentFrame = frame; }
74 size_t frameDecodedSize(size_t frame) { return m_image->m_frames[frame].m_fr ameBytes; } 74 size_t frameDecodedSize(size_t frame) { return m_image->m_frames[frame].m_fr ameBytes; }
75 size_t decodedFramesCount() const { return m_image->m_frames.size(); } 75 size_t decodedFramesCount() const { return m_image->m_frames.size(); }
76 void resetDecoder() { return m_image->resetDecoder(); }
77 76
78 void loadImage(const char* fileName) 77 void loadImage(const char* fileName)
79 { 78 {
80 RefPtr<SharedBuffer> imageData = readFile(fileName); 79 RefPtr<SharedBuffer> imageData = readFile(fileName);
81 ASSERT_TRUE(imageData.get()); 80 ASSERT_TRUE(imageData.get());
82 81
83 m_image->setData(imageData, true); 82 m_image->setData(imageData, true);
84 EXPECT_EQ(0u, decodedSize()); 83 EXPECT_EQ(0u, decodedSize());
85 84
86 size_t frameCount = m_image->frameCount(); 85 size_t frameCount = m_image->frameCount();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 180
182 image->setData(SharedBuffer::create("data", sizeof("data")), false); 181 image->setData(SharedBuffer::create("data", sizeof("data")), false);
183 EXPECT_FALSE(image->isAllDataReceived()); 182 EXPECT_FALSE(image->isAllDataReceived());
184 183
185 image->setData(imageData, true); 184 image->setData(imageData, true);
186 EXPECT_TRUE(image->isAllDataReceived()); 185 EXPECT_TRUE(image->isAllDataReceived());
187 } 186 }
188 187
189 #if USE(QCMSLIB) 188 #if USE(QCMSLIB)
190 189
190 TEST_F(BitmapImageTest, noColorProfile)
191 {
192 loadImage("/LayoutTests/fast/images/resources/green.jpg");
193 EXPECT_EQ(1u, decodedFramesCount());
194 EXPECT_EQ(1024u, decodedSize());
195 EXPECT_FALSE(m_image->hasColorProfile());
196 }
197
191 TEST_F(BitmapImageTest, jpegHasColorProfile) 198 TEST_F(BitmapImageTest, jpegHasColorProfile)
192 { 199 {
193 loadImage("/LayoutTests/fast/images/resources/icc-v2-gbr.jpg"); 200 loadImage("/LayoutTests/fast/images/resources/icc-v2-gbr.jpg");
194 EXPECT_EQ(1u, decodedFramesCount()); 201 EXPECT_EQ(1u, decodedFramesCount());
195 EXPECT_EQ(227700u, decodedSize()); 202 EXPECT_EQ(227700u, decodedSize());
196 EXPECT_TRUE(m_image->hasColorProfile()); 203 EXPECT_TRUE(m_image->hasColorProfile());
197 204
198 resetDecoder();
199 destroyDecodedData(true); 205 destroyDecodedData(true);
200
201 loadImage("/LayoutTests/fast/images/resources/green.jpg");
202 EXPECT_EQ(1u, decodedFramesCount());
203 EXPECT_EQ(1024u, decodedSize());
204 EXPECT_FALSE(m_image->hasColorProfile());
205 } 206 }
206 207
207 TEST_F(BitmapImageTest, pngHasColorProfile) 208 TEST_F(BitmapImageTest, pngHasColorProfile)
208 { 209 {
209 loadImage("/LayoutTests/fast/images/resources/palatted-color-png-gamma-one-c olor-profile.png"); 210 loadImage("/LayoutTests/fast/images/resources/palatted-color-png-gamma-one-c olor-profile.png");
210 EXPECT_EQ(1u, decodedFramesCount()); 211 EXPECT_EQ(1u, decodedFramesCount());
211 EXPECT_EQ(65536u, decodedSize()); 212 EXPECT_EQ(65536u, decodedSize());
212 EXPECT_TRUE(m_image->hasColorProfile()); 213 EXPECT_TRUE(m_image->hasColorProfile());
213 214
214 resetDecoder();
215 destroyDecodedData(true); 215 destroyDecodedData(true);
216
217 loadImage("/LayoutTests/fast/images/resources/green.jpg");
218 EXPECT_EQ(1u, decodedFramesCount());
219 EXPECT_EQ(1024u, decodedSize());
220 EXPECT_FALSE(m_image->hasColorProfile());
221 } 216 }
222 217
223 TEST_F(BitmapImageTest, webpHasColorProfile) 218 TEST_F(BitmapImageTest, webpHasColorProfile)
224 { 219 {
225 loadImage("/LayoutTests/fast/images/resources/webp-color-profile-lossy.webp" ); 220 loadImage("/LayoutTests/fast/images/resources/webp-color-profile-lossy.webp" );
226 EXPECT_EQ(1u, decodedFramesCount()); 221 EXPECT_EQ(1u, decodedFramesCount());
227 EXPECT_EQ(2560000u, decodedSize()); 222 EXPECT_EQ(2560000u, decodedSize());
228 EXPECT_TRUE(m_image->hasColorProfile()); 223 EXPECT_TRUE(m_image->hasColorProfile());
229 224
230 destroyDecodedData(true); 225 destroyDecodedData(true);
231 resetDecoder();
232
233 loadImage("/LayoutTests/fast/images/resources/test.webp");
234 EXPECT_EQ(1u, decodedFramesCount());
235 EXPECT_EQ(65536u, decodedSize());
236 EXPECT_FALSE(m_image->hasColorProfile());
237 } 226 }
238 227
239 TEST_F(BitmapImageTest, icoHasWrongFrameDimensions) 228 TEST_F(BitmapImageTest, icoHasWrongFrameDimensions)
240 { 229 {
241 loadImage("/LayoutTests/fast/images/resources/wrong-frame-dimensions.ico"); 230 loadImage("/LayoutTests/fast/images/resources/wrong-frame-dimensions.ico");
242 // This call would cause crash without fix for 408026 231 // This call would cause crash without fix for 408026
243 imageForDefaultFrame(); 232 imageForDefaultFrame();
244 } 233 }
245 234
246 #endif // USE(QCMSLIB) 235 #endif // USE(QCMSLIB)
247 236
248 } // namespace blink 237 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/BitmapImage.cpp ('k') | Source/platform/graphics/DeferredImageDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698