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

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: Merge. 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 22 matching lines...) Expand all
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 "platform/Histogram.h" 41 #include "platform/Histogram.h"
42 #include "png.h" 42 #include "png.h"
43 #include "wtf/PtrUtil.h"
43 #include "wtf/Threading.h" 44 #include "wtf/Threading.h"
45 #include <memory>
44 46
45 #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR) 47 #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR)
46 #error version error: compile against a versioned libpng. 48 #error version error: compile against a versioned libpng.
47 #endif 49 #endif
48 #if USE(QCMSLIB) 50 #if USE(QCMSLIB)
49 #include "qcms.h" 51 #include "qcms.h"
50 #endif 52 #endif
51 53
52 #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MIN OR >= 4) 54 #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MIN OR >= 4)
53 #define JMPBUF(png_ptr) png_jmpbuf(png_ptr) 55 #define JMPBUF(png_ptr) png_jmpbuf(png_ptr)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 png_infop infoPtr() const { return m_info; } 139 png_infop infoPtr() const { return m_info; }
138 140
139 size_t getReadOffset() const { return m_readOffset; } 141 size_t getReadOffset() const { return m_readOffset; }
140 void setReadOffset(size_t offset) { m_readOffset = offset; } 142 void setReadOffset(size_t offset) { m_readOffset = offset; }
141 size_t currentBufferSize() const { return m_currentBufferSize; } 143 size_t currentBufferSize() const { return m_currentBufferSize; }
142 bool decodingSizeOnly() const { return m_decodingSizeOnly; } 144 bool decodingSizeOnly() const { return m_decodingSizeOnly; }
143 void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; } 145 void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
144 bool hasAlpha() const { return m_hasAlpha; } 146 bool hasAlpha() const { return m_hasAlpha; }
145 147
146 png_bytep interlaceBuffer() const { return m_interlaceBuffer.get(); } 148 png_bytep interlaceBuffer() const { return m_interlaceBuffer.get(); }
147 void createInterlaceBuffer(int size) { m_interlaceBuffer = adoptArrayPtr(new png_byte[size]); } 149 void createInterlaceBuffer(int size) { m_interlaceBuffer = wrapArrayUnique(n ew png_byte[size]); }
148 #if USE(QCMSLIB) 150 #if USE(QCMSLIB)
149 png_bytep rowBuffer() const { return m_rowBuffer.get(); } 151 png_bytep rowBuffer() const { return m_rowBuffer.get(); }
150 void createRowBuffer(int size) { m_rowBuffer = adoptArrayPtr(new png_byte[si ze]); } 152 void createRowBuffer(int size) { m_rowBuffer = wrapArrayUnique(new png_byte[ size]); }
151 #endif 153 #endif
152 154
153 private: 155 private:
154 png_structp m_png; 156 png_structp m_png;
155 png_infop m_info; 157 png_infop m_info;
156 PNGImageDecoder* m_decoder; 158 PNGImageDecoder* m_decoder;
157 size_t m_readOffset; 159 size_t m_readOffset;
158 size_t m_currentBufferSize; 160 size_t m_currentBufferSize;
159 bool m_decodingSizeOnly; 161 bool m_decodingSizeOnly;
160 bool m_hasAlpha; 162 bool m_hasAlpha;
161 OwnPtr<png_byte[]> m_interlaceBuffer; 163 std::unique_ptr<png_byte[]> m_interlaceBuffer;
162 #if USE(QCMSLIB) 164 #if USE(QCMSLIB)
163 OwnPtr<png_byte[]> m_rowBuffer; 165 std::unique_ptr<png_byte[]> m_rowBuffer;
164 #endif 166 #endif
165 }; 167 };
166 168
167 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp tion colorOptions, size_t maxDecodedBytes, size_t offset) 169 PNGImageDecoder::PNGImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp tion colorOptions, size_t maxDecodedBytes, size_t offset)
168 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) 170 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes)
169 , m_offset(offset) 171 , m_offset(offset)
170 { 172 {
171 } 173 }
172 174
173 PNGImageDecoder::~PNGImageDecoder() 175 PNGImageDecoder::~PNGImageDecoder()
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 { 430 {
429 return decoder->frameIsCompleteAtIndex(0); 431 return decoder->frameIsCompleteAtIndex(0);
430 } 432 }
431 433
432 void PNGImageDecoder::decode(bool onlySize) 434 void PNGImageDecoder::decode(bool onlySize)
433 { 435 {
434 if (failed()) 436 if (failed())
435 return; 437 return;
436 438
437 if (!m_reader) 439 if (!m_reader)
438 m_reader = adoptPtr(new PNGImageReader(this, m_offset)); 440 m_reader = wrapUnique(new PNGImageReader(this, m_offset));
439 441
440 // If we couldn't decode the image but have received all the data, decoding 442 // If we couldn't decode the image but have received all the data, decoding
441 // has failed. 443 // has failed.
442 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 444 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
443 setFailed(); 445 setFailed();
444 446
445 // If decoding is done or failed, we don't need the PNGImageReader anymore. 447 // If decoding is done or failed, we don't need the PNGImageReader anymore.
446 if (isComplete(this) || failed()) 448 if (isComplete(this) || failed())
447 m_reader.reset(); 449 m_reader.reset();
448 } 450 }
449 451
450 } // namespace blink 452 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698