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

Side by Side Diff: Source/wtf/MathExtras.h

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: Created 7 years, 7 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) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 log2 += 8, i >>= 8; 427 log2 += 8, i >>= 8;
428 if (i >> 4) 428 if (i >> 4)
429 log2 += 4, i >>= 4; 429 log2 += 4, i >>= 4;
430 if (i >> 2) 430 if (i >> 2)
431 log2 += 2, i >>= 2; 431 log2 += 2, i >>= 2;
432 if (i >> 1) 432 if (i >> 1)
433 log2 += 1; 433 log2 += 1;
434 return log2; 434 return log2;
435 } 435 }
436 436
437 inline uint16_t fastDivideBy255(uint16_t value)
438 {
439 // This is an approximate algorithm for division by 255, but it gives accura te results for 16bit values.
440 uint16_t approximation = value >> 8;
441 uint16_t remainder = value - (approximation * 255) + 1;
442 return approximation + (remainder >> 8);
443 }
444
437 } // namespace WTF 445 } // namespace WTF
438 446
439 #endif // #ifndef WTF_MathExtras_h 447 #endif // #ifndef WTF_MathExtras_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698