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

Side by Side Diff: ui/gfx/chromeos/codec/jpeg_codec_robust_slow.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr 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
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/codec/jpeg_codec.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h" 5 #include "ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h"
6 6
7 #include <setjmp.h> 7 #include <setjmp.h>
8 8
9 #include <memory>
10
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/core/SkColorPriv.h" 13 #include "third_party/skia/include/core/SkColorPriv.h"
13 14
14 extern "C" { 15 extern "C" {
15 // IJG provides robust JPEG decode 16 // IJG provides robust JPEG decode
16 #include "third_party/libjpeg/jpeglib.h" 17 #include "third_party/libjpeg/jpeglib.h"
17 } 18 }
18 19
19 namespace gfx { 20 namespace gfx {
20 21
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 row_write_stride = cinfo.output_width * 4; 299 row_write_stride = cinfo.output_width * 4;
299 converter = RGBtoBGRA; 300 converter = RGBtoBGRA;
300 } else { 301 } else {
301 NOTREACHED() << "Invalid pixel format"; 302 NOTREACHED() << "Invalid pixel format";
302 jpeg_destroy_decompress(&cinfo); 303 jpeg_destroy_decompress(&cinfo);
303 return false; 304 return false;
304 } 305 }
305 306
306 output->resize(row_write_stride * cinfo.output_height); 307 output->resize(row_write_stride * cinfo.output_height);
307 308
308 scoped_ptr<unsigned char[]> row_data(new unsigned char[row_read_stride]); 309 std::unique_ptr<unsigned char[]> row_data(
310 new unsigned char[row_read_stride]);
309 unsigned char* rowptr = row_data.get(); 311 unsigned char* rowptr = row_data.get();
310 for (int row = 0; row < static_cast<int>(cinfo.output_height); row++) { 312 for (int row = 0; row < static_cast<int>(cinfo.output_height); row++) {
311 if (!jpeg_read_scanlines(&cinfo, &rowptr, 1)) 313 if (!jpeg_read_scanlines(&cinfo, &rowptr, 1))
312 return false; 314 return false;
313 converter(rowptr, *w, &(*output)[row * row_write_stride]); 315 converter(rowptr, *w, &(*output)[row * row_write_stride]);
314 } 316 }
315 } 317 }
316 #endif 318 #endif
317 319
318 jpeg_finish_decompress(&cinfo); 320 jpeg_finish_decompress(&cinfo);
(...skipping 13 matching lines...) Expand all
332 int data_length = w * h * 4; 334 int data_length = w * h * 4;
333 335
334 SkBitmap* bitmap = new SkBitmap(); 336 SkBitmap* bitmap = new SkBitmap();
335 bitmap->allocN32Pixels(w, h); 337 bitmap->allocN32Pixels(w, h);
336 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length); 338 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length);
337 339
338 return bitmap; 340 return bitmap;
339 } 341 }
340 342
341 } // namespace gfx 343 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/codec/jpeg_codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698