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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 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) 2006 Apple Computer, Inc. 2 * Copyright (C) 2006 Apple Computer, Inc.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Portions are Copyright (C) 2001 mozilla.org 5 * Portions are Copyright (C) 2001 mozilla.org
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Stuart Parmenter <stuart@mozilla.com> 8 * Stuart Parmenter <stuart@mozilla.com>
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 21 matching lines...) Expand all
32 * version of this file under the LGPL, indicate your decision by 32 * version of this file under the LGPL, indicate your decision by
33 * deletingthe provisions above and replace them with the notice and 33 * deletingthe provisions above and replace them with the notice and
34 * other provisions required by the MPL or the GPL, as the case may be. 34 * other provisions required by the MPL or the GPL, as the case may be.
35 * If you do not delete the provisions above, a recipient may use your 35 * If you do not delete the provisions above, a recipient may use your
36 * version of this file under any of the LGPL, the MPL or the GPL. 36 * version of this file under any of the LGPL, the MPL or the GPL.
37 */ 37 */
38 38
39 #include "platform/image-decoders/png/PNGImageDecoder.h" 39 #include "platform/image-decoders/png/PNGImageDecoder.h"
40 40
41 #include "png.h" 41 #include "png.h"
42 #include "wtf/PtrUtil.h"
43 #include <memory>
42 44
43 #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR) 45 #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR)
44 #error version error: compile against a versioned libpng. 46 #error version error: compile against a versioned libpng.
45 #endif 47 #endif
46 #if USE(QCMSLIB) 48 #if USE(QCMSLIB)
47 #include "qcms.h" 49 #include "qcms.h"
48 #endif 50 #endif
49 51
50 #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MIN OR >= 4) 52 #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MIN OR >= 4)
51 #define JMPBUF(png_ptr) png_jmpbuf(png_ptr) 53 #define JMPBUF(png_ptr) png_jmpbuf(png_ptr)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 png_infop infoPtr() const { return m_info; } 137 png_infop infoPtr() const { return m_info; }
136 138
137 size_t getReadOffset() const { return m_readOffset; } 139 size_t getReadOffset() const { return m_readOffset; }
138 void setReadOffset(size_t offset) { m_readOffset = offset; } 140 void setReadOffset(size_t offset) { m_readOffset = offset; }
139 size_t currentBufferSize() const { return m_currentBufferSize; } 141 size_t currentBufferSize() const { return m_currentBufferSize; }
140 bool decodingSizeOnly() const { return m_decodingSizeOnly; } 142 bool decodingSizeOnly() const { return m_decodingSizeOnly; }
141 void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; } 143 void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
142 bool hasAlpha() const { return m_hasAlpha; } 144 bool hasAlpha() const { return m_hasAlpha; }
143 145
144 png_bytep interlaceBuffer() const { return m_interlaceBuffer.get(); } 146 png_bytep interlaceBuffer() const { return m_interlaceBuffer.get(); }
145 void createInterlaceBuffer(int size) { m_interlaceBuffer = adoptArrayPtr(new png_byte[size]); } 147 void createInterlaceBuffer(int size) { m_interlaceBuffer = wrapArrayUnique(n ew png_byte[size]); }
146 #if USE(QCMSLIB) 148 #if USE(QCMSLIB)
147 png_bytep rowBuffer() const { return m_rowBuffer.get(); } 149 png_bytep rowBuffer() const { return m_rowBuffer.get(); }
148 void createRowBuffer(int size) { m_rowBuffer = adoptArrayPtr(new png_byte[si ze]); } 150 void createRowBuffer(int size) { m_rowBuffer = wrapArrayUnique(new png_byte[ size]); }
149 #endif 151 #endif
150 152
151 private: 153 private:
152 png_structp m_png; 154 png_structp m_png;
153 png_infop m_info; 155 png_infop m_info;
154 PNGImageDecoder* m_decoder; 156 PNGImageDecoder* m_decoder;
155 size_t m_readOffset; 157 size_t m_readOffset;
156 size_t m_currentBufferSize; 158 size_t m_currentBufferSize;
157 bool m_decodingSizeOnly; 159 bool m_decodingSizeOnly;
158 bool m_hasAlpha; 160 bool m_hasAlpha;
159 OwnPtr<png_byte[]> m_interlaceBuffer; 161 std::unique_ptr<png_byte[]> m_interlaceBuffer;
160 #if USE(QCMSLIB) 162 #if USE(QCMSLIB)
161 OwnPtr<png_byte[]> m_rowBuffer; 163 std::unique_ptr<png_byte[]> m_rowBuffer;
162 #endif 164 #endif
163 }; 165 };
164 166
165 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp tion colorOptions, size_t maxDecodedBytes, size_t offset) 167 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp tion colorOptions, size_t maxDecodedBytes, size_t offset)
166 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) 168 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes)
167 , m_offset(offset) 169 , m_offset(offset)
168 { 170 {
169 } 171 }
170 172
171 PNGImageDecoder::~PNGImageDecoder() 173 PNGImageDecoder::~PNGImageDecoder()
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 { 423 {
422 return decoder->frameIsCompleteAtIndex(0); 424 return decoder->frameIsCompleteAtIndex(0);
423 } 425 }
424 426
425 void PNGImageDecoder::decode(bool onlySize) 427 void PNGImageDecoder::decode(bool onlySize)
426 { 428 {
427 if (failed()) 429 if (failed())
428 return; 430 return;
429 431
430 if (!m_reader) 432 if (!m_reader)
431 m_reader = adoptPtr(new PNGImageReader(this, m_offset)); 433 m_reader = wrapUnique(new PNGImageReader(this, m_offset));
432 434
433 // If we couldn't decode the image but have received all the data, decoding 435 // If we couldn't decode the image but have received all the data, decoding
434 // has failed. 436 // has failed.
435 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 437 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
436 setFailed(); 438 setFailed();
437 439
438 // If decoding is done or failed, we don't need the PNGImageReader anymore. 440 // If decoding is done or failed, we don't need the PNGImageReader anymore.
439 if (isComplete(this) || failed()) 441 if (isComplete(this) || failed())
440 m_reader.reset(); 442 m_reader.reset();
441 } 443 }
442 444
443 } // namespace blink 445 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698