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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.h

Issue 1812273003: Eliminate copies of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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) 2008, 2009, Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return *reinterpret_cast<const uint32_t*>(buffer); 58 return *reinterpret_cast<const uint32_t*>(buffer);
59 } 59 }
60 60
61 // |parent| is the decoder that owns us. 61 // |parent| is the decoder that owns us.
62 // |startOffset| points to the start of the BMP within the file. 62 // |startOffset| points to the start of the BMP within the file.
63 // |buffer| points at an empty ImageFrame that we'll initialize and 63 // |buffer| points at an empty ImageFrame that we'll initialize and
64 // fill with decoded data. 64 // fill with decoded data.
65 BMPImageReader(ImageDecoder* parent, size_t decodedAndHeaderOffset, size_t i mgDataOffset, bool isInICO); 65 BMPImageReader(ImageDecoder* parent, size_t decodedAndHeaderOffset, size_t i mgDataOffset, bool isInICO);
66 66
67 void setBuffer(ImageFrame* buffer) { m_buffer = buffer; } 67 void setBuffer(ImageFrame* buffer) { m_buffer = buffer; }
68 void setData(SharedBuffer* data) 68 void setData(SegmentReader* data)
69 { 69 {
70 m_data = data; 70 m_data = data;
71 m_fastReader.setData(data); 71 m_fastReader.setData(data);
72 } 72 }
73 73
74 // Does the actual decoding. If |onlySize| is true, decoding only 74 // Does the actual decoding. If |onlySize| is true, decoding only
75 // progresses as far as necessary to get the image size. Returns 75 // progresses as far as necessary to get the image size. Returns
76 // whether decoding succeeded. 76 // whether decoding succeeded.
77 bool decodeBMP(bool onlySize); 77 bool decodeBMP(bool onlySize);
78 78
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // depending on the value of |m_isTopDown|. 283 // depending on the value of |m_isTopDown|.
284 void moveBufferToNextRow(); 284 void moveBufferToNextRow();
285 285
286 // The decoder that owns us. 286 // The decoder that owns us.
287 ImageDecoder* m_parent; 287 ImageDecoder* m_parent;
288 288
289 // The destination for the pixel data. 289 // The destination for the pixel data.
290 ImageFrame* m_buffer; 290 ImageFrame* m_buffer;
291 291
292 // The file to decode. 292 // The file to decode.
293 RefPtr<SharedBuffer> m_data; 293 RefPtr<SegmentReader> m_data;
294 FastSharedBufferReader m_fastReader; 294 FastSharedBufferReader m_fastReader;
295 295
296 // An index into |m_data| representing how much we've already decoded. 296 // An index into |m_data| representing how much we've already decoded.
297 size_t m_decodedOffset; 297 size_t m_decodedOffset;
298 298
299 // The file offset at which the BMP info header starts. 299 // The file offset at which the BMP info header starts.
300 size_t m_headerOffset; 300 size_t m_headerOffset;
301 301
302 // The file offset at which the actual image bits start. When decoding 302 // The file offset at which the actual image bits start. When decoding
303 // ICO files, this is set to 0, since it's not stored anywhere in a 303 // ICO files, this is set to 0, since it's not stored anywhere in a
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // ICOs store a 1bpp "mask" immediately after the main bitmap image data 362 // ICOs store a 1bpp "mask" immediately after the main bitmap image data
363 // (and, confusingly, add its height to the biHeight value in the info 363 // (and, confusingly, add its height to the biHeight value in the info
364 // header, thus doubling it). If |m_isInICO| is true, this variable tracks 364 // header, thus doubling it). If |m_isInICO| is true, this variable tracks
365 // whether we've begun decoding this mask yet. 365 // whether we've begun decoding this mask yet.
366 bool m_decodingAndMask; 366 bool m_decodingAndMask;
367 }; 367 };
368 368
369 } // namespace blink 369 } // namespace blink
370 370
371 #endif 371 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698