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

Side by Side Diff: third_party/WebKit/Source/platform/image-encoders/JPEGImageEncoder.cpp

Issue 1983793002: Remove OwnPtr::release() calls in platform/ (part 2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add one more file. Created 4 years, 7 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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 cinfo->in_color_space = JCS_RGB; 162 cinfo->in_color_space = JCS_RGB;
163 cinfo->input_components = 3; 163 cinfo->input_components = 3;
164 164
165 jpeg_set_defaults(cinfo); 165 jpeg_set_defaults(cinfo);
166 int compressionQuality = JPEGImageEncoder::computeCompressionQuality(quality ); 166 int compressionQuality = JPEGImageEncoder::computeCompressionQuality(quality );
167 jpeg_set_quality(cinfo, compressionQuality, TRUE); 167 jpeg_set_quality(cinfo, compressionQuality, TRUE);
168 disableSubsamplingForHighQuality(cinfo, compressionQuality); 168 disableSubsamplingForHighQuality(cinfo, compressionQuality);
169 jpeg_start_compress(cinfo, TRUE); 169 jpeg_start_compress(cinfo, TRUE);
170 170
171 cinfo->client_data = 0; 171 cinfo->client_data = 0;
172 return encoderState.release(); 172 return std::move(encoderState);
173 } 173 }
174 174
175 int JPEGImageEncoder::computeCompressionQuality(const double& quality) 175 int JPEGImageEncoder::computeCompressionQuality(const double& quality)
176 { 176 {
177 int compressionQuality = JPEGImageEncoder::DefaultCompressionQuality; 177 int compressionQuality = JPEGImageEncoder::DefaultCompressionQuality;
178 if (quality >= 0.0 && quality <= 1.0) 178 if (quality >= 0.0 && quality <= 1.0)
179 compressionQuality = static_cast<int>(quality * 100 + 0.5); 179 compressionQuality = static_cast<int>(quality * 100 + 0.5);
180 return compressionQuality; 180 return compressionQuality;
181 } 181 }
182 182
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 bool JPEGImageEncoder::encode(const ImageDataBuffer& imageData, const double& qu ality, Vector<unsigned char>* output) 230 bool JPEGImageEncoder::encode(const ImageDataBuffer& imageData, const double& qu ality, Vector<unsigned char>* output)
231 { 231 {
232 if (!imageData.pixels()) 232 if (!imageData.pixels())
233 return false; 233 return false;
234 234
235 OwnPtr<JPEGImageEncoderState> encoderState = JPEGImageEncoderState::create(i mageData.size(), quality, output); 235 OwnPtr<JPEGImageEncoderState> encoderState = JPEGImageEncoderState::create(i mageData.size(), quality, output);
236 if (!encoderState) 236 if (!encoderState)
237 return false; 237 return false;
238 238
239 return JPEGImageEncoder::encodeWithPreInitializedState(encoderState.release( ), imageData.pixels()); 239 return JPEGImageEncoder::encodeWithPreInitializedState(std::move(encoderStat e), imageData.pixels());
240 } 240 }
241 241
242 } // namespace blink 242 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698