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

Side by Side Diff: Source/core/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 15466004: Make image decoders faster by refactoring hot loops that fills the lines of ImageFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make image decoders faster by refactoring hot loops that fills the lines of ImageFrame. Created 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 188
189 ASSERT(width == size().width()); 189 ASSERT(width == size().width());
190 ASSERT(decodedHeight <= size().height()); 190 ASSERT(decodedHeight <= size().height());
191 191
192 for (int y = m_decodedHeight; y < decodedHeight; ++y) { 192 for (int y = m_decodedHeight; y < decodedHeight; ++y) {
193 uint8_t* row = reinterpret_cast<uint8_t*>(buffer.getAddr(0, y)); 193 uint8_t* row = reinterpret_cast<uint8_t*>(buffer.getAddr(0, y));
194 if (qcms_transform* transform = colorTransform()) 194 if (qcms_transform* transform = colorTransform())
195 qcms_transform_data_type(transform, row, row, width, QCMS_OUTPUT_RGB X); 195 qcms_transform_data_type(transform, row, row, width, QCMS_OUTPUT_RGB X);
196 uint8_t* pixel = row; 196 uint8_t* pixel = row;
197 for (int x = 0; x < width; ++x, pixel += 4) 197
198 buffer.setRGBA(x, y, pixel[0], pixel[1], pixel[2], pixel[3]); 198 // Do not merge the loops below. They are hand rolled for each case for maximal peformace.
199 ImageFrame::PixelData* dst = buffer.getAddr(0, y);
200 if (buffer.premultiplyAlpha()) {
201 for (int x = 0; x < width; ++x, pixel += 4)
202 buffer.setRGBAPremultiply(dst + x, pixel[0], pixel[1], pixel[2], pixel[3]);
203 } else {
204 for (int x = 0; x < width; ++x, pixel += 4)
205 buffer.setRGBANoPremultiply(dst + x, pixel[0], pixel[1], pixel[2 ], pixel[3]);
206 }
199 } 207 }
200 208
201 m_decodedHeight = decodedHeight; 209 m_decodedHeight = decodedHeight;
202 } 210 }
203 211
204 #endif // QCMS_WEBP_COLOR_CORRECTION 212 #endif // QCMS_WEBP_COLOR_CORRECTION
205 213
206 bool WEBPImageDecoder::decode(bool onlySize) 214 bool WEBPImageDecoder::decode(bool onlySize)
207 { 215 {
208 if (failed()) 216 if (failed())
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 if ((m_formatFlags & ICCP_FLAG) && !ignoresGammaAndColorProfile()) 300 if ((m_formatFlags & ICCP_FLAG) && !ignoresGammaAndColorProfile())
293 applyColorProfile(dataBytes, dataSize, buffer); 301 applyColorProfile(dataBytes, dataSize, buffer);
294 return false; 302 return false;
295 default: 303 default:
296 clear(); 304 clear();
297 return setFailed(); 305 return setFailed();
298 } 306 }
299 } 307 }
300 308
301 } // namespace WebCore 309 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698