| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |