Do not consolidate data in BMPImageDecoder
In BMPImageDecoder, never call SharedBuffer::data(), which potentially copies all the data. Instead, do the following: - Read directly from the SharedBuffer when it is safe to do so. e.g. when only one byte is needed. We already know there is enough data, and getSomeData will return at least a byte if there is enough data. - Use a FastSharedBufferReader when we may be on a segment boundary. As a result, we make fewer copies when decoding BMPs. We never call SharedBuffer::data(), which copies up to the entire encoded data received so far. Occasionally we will make small copies when a two or four byte number is on a segment boundary. Add a setter to FastSharedBufferReader to update its SharedBuffer, so the BMPImageReader can have one as a member, which it will reuse across calls. Remove BIG_ENDIAN, and eliminate another memcpy that was there to support it. Using my modified version of ImageDecodeBench (see crrev.com/1145373003), I see a slight speedup as compared to the old version which relied on SharedBuffer::data(). (My data can be found here: [1].) This matches my expectations, since the new version is copying less data. Using a version of ImageDecodeBench with a premerged buffer (see crrev.com/1318713005), I still see a speed improvement, although it is very small. (See sheet 2 of the above spreadsheet). [1] https://docs.google.com/a/google.com/spreadsheets/d/1GN2FDytKvkdZzV-WF4IEQaYQF65wa4bRxG67bNgpjAE/edit?usp=sharing BUG=467772 Review URL: https://codereview.chromium.org/1259083003 git-svn-id: svn://svn.chromium.org/blink/trunk@201811 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Showing
Please register or sign in to comment