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

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

Issue 352873002: [wip] image color correction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 filePath.append(fileName); 65 filePath.append(fileName);
66 return blink::Platform::current()->unitTestSupport()->readFromFile(fileP ath); 66 return blink::Platform::current()->unitTestSupport()->readFromFile(fileP ath);
67 } 67 }
68 68
69 // Accessors to BitmapImage's protected methods. 69 // Accessors to BitmapImage's protected methods.
70 void destroyDecodedData(bool destroyAll) { m_image->destroyDecodedData(destr oyAll); } 70 void destroyDecodedData(bool destroyAll) { m_image->destroyDecodedData(destr oyAll); }
71 size_t frameCount() { return m_image->frameCount(); } 71 size_t frameCount() { return m_image->frameCount(); }
72 void setCurrentFrame(size_t frame) { m_image->m_currentFrame = frame; } 72 void setCurrentFrame(size_t frame) { m_image->m_currentFrame = frame; }
73 size_t frameDecodedSize(size_t frame) { return m_image->m_frames[frame].m_fr ameBytes; } 73 size_t frameDecodedSize(size_t frame) { return m_image->m_frames[frame].m_fr ameBytes; }
74 size_t decodedFramesCount() const { return m_image->m_frames.size(); } 74 size_t decodedFramesCount() const { return m_image->m_frames.size(); }
75 void resetDecoder() { return m_image->resetDecoder(); }
75 76
76 void loadImage(const char* fileName) 77 void loadImage(const char* fileName)
77 { 78 {
78 RefPtr<SharedBuffer> imageData = readFile(fileName); 79 RefPtr<SharedBuffer> imageData = readFile(fileName);
79 ASSERT_TRUE(imageData.get()); 80 ASSERT_TRUE(imageData.get());
80 81
81 m_image->setData(imageData, true); 82 m_image->setData(imageData, true);
82 EXPECT_EQ(0u, decodedSize()); 83 EXPECT_EQ(0u, decodedSize());
83 84
84 size_t frameCount = m_image->frameCount(); 85 size_t frameCount = m_image->frameCount();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 image->setData(imageData, true); 179 image->setData(imageData, true);
179 EXPECT_TRUE(image->isAllDataReceived()); 180 EXPECT_TRUE(image->isAllDataReceived());
180 } 181 }
181 182
182 #if USE(QCMSLIB) 183 #if USE(QCMSLIB)
183 184
184 TEST_F(BitmapImageTest, jpegHasColorProfile) 185 TEST_F(BitmapImageTest, jpegHasColorProfile)
185 { 186 {
186 loadImage("/LayoutTests/fast/images/resources/icc-v2-gbr.jpg"); 187 loadImage("/LayoutTests/fast/images/resources/icc-v2-gbr.jpg");
187 EXPECT_EQ(1u, decodedFramesCount()); 188 EXPECT_EQ(1u, decodedFramesCount());
189 EXPECT_EQ(227700u, decodedSize());
188 EXPECT_TRUE(m_image->hasColorProfile()); 190 EXPECT_TRUE(m_image->hasColorProfile());
191
192 resetDecoder();
193 destroyDecodedData(true);
194
195 loadImage("/LayoutTests/fast/images/resources/green.jpg");
196 EXPECT_EQ(1u, decodedFramesCount());
197 EXPECT_EQ(1024u, decodedSize());
198 EXPECT_FALSE(m_image->hasColorProfile());
189 } 199 }
190 200
191 TEST_F(BitmapImageTest, pngHasColorProfile) 201 TEST_F(BitmapImageTest, pngHasColorProfile)
192 { 202 {
193 loadImage("/LayoutTests/fast/images/resources/palatted-color-png-gamma-one-c olor-profile.png"); 203 loadImage("/LayoutTests/fast/images/resources/palatted-color-png-gamma-one-c olor-profile.png");
194 EXPECT_EQ(1u, decodedFramesCount()); 204 EXPECT_EQ(1u, decodedFramesCount());
205 EXPECT_EQ(65536u, decodedSize());
195 EXPECT_TRUE(m_image->hasColorProfile()); 206 EXPECT_TRUE(m_image->hasColorProfile());
207
208 resetDecoder();
209 destroyDecodedData(true);
210
211 loadImage("/LayoutTests/fast/images/resources/green.jpg");
212 EXPECT_EQ(1u, decodedFramesCount());
213 EXPECT_EQ(1024u, decodedSize());
214 EXPECT_FALSE(m_image->hasColorProfile());
196 } 215 }
197 216
198 TEST_F(BitmapImageTest, webpHasColorProfile) 217 TEST_F(BitmapImageTest, webpHasColorProfile)
199 { 218 {
200 loadImage("/LayoutTests/fast/images/resources/webp-color-profile-lossy.webp" ); 219 loadImage("/LayoutTests/fast/images/resources/webp-color-profile-lossy.webp" );
201 EXPECT_EQ(1u, decodedFramesCount()); 220 EXPECT_EQ(1u, decodedFramesCount());
221 EXPECT_EQ(2560000u, decodedSize());
202 EXPECT_TRUE(m_image->hasColorProfile()); 222 EXPECT_TRUE(m_image->hasColorProfile());
223
224 destroyDecodedData(true);
225 resetDecoder();
226
227 loadImage("/LayoutTests/fast/images/resources/test.webp");
228 EXPECT_EQ(1u, decodedFramesCount());
229 EXPECT_EQ(65536u, decodedSize());
230 EXPECT_FALSE(m_image->hasColorProfile());
203 } 231 }
204 232
205 #endif // USE(QCMSLIB) 233 #endif // USE(QCMSLIB)
206 234
207 } // namespace 235 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698