| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkCodec.h" | 8 #include "SkCodec.h" |
| 9 #include "SkJpegCodec.h" | 9 #include "SkJpegCodec.h" |
| 10 #include "SkJpegDecoderMgr.h" | 10 #include "SkJpegDecoderMgr.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } else if (desiredScale > 0.375f) { | 181 } else if (desiredScale > 0.375f) { |
| 182 scale = 2; | 182 scale = 2; |
| 183 } else if (desiredScale > 0.1875f) { | 183 } else if (desiredScale > 0.1875f) { |
| 184 scale = 4; | 184 scale = 4; |
| 185 } else { | 185 } else { |
| 186 scale = 8; | 186 scale = 8; |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Set up a fake decompress struct in order to use libjpeg to calculate outp
ut dimensions | 189 // Set up a fake decompress struct in order to use libjpeg to calculate outp
ut dimensions |
| 190 jpeg_decompress_struct dinfo; | 190 jpeg_decompress_struct dinfo; |
| 191 sk_bzero(&dinfo, sizeof(dinfo)); |
| 191 dinfo.image_width = this->getInfo().width(); | 192 dinfo.image_width = this->getInfo().width(); |
| 192 dinfo.image_height = this->getInfo().height(); | 193 dinfo.image_height = this->getInfo().height(); |
| 193 dinfo.global_state = DSTATE_READY; | 194 dinfo.global_state = DSTATE_READY; |
| 194 dinfo.num_components = 0; | 195 dinfo.num_components = 0; |
| 195 dinfo.scale_num = 1; | 196 dinfo.scale_num = 1; |
| 196 dinfo.scale_denom = scale; | 197 dinfo.scale_denom = scale; |
| 197 jpeg_calc_output_dimensions(&dinfo); | 198 jpeg_calc_output_dimensions(&dinfo); |
| 198 | 199 |
| 199 // Return the calculated output dimensions for the given scale | 200 // Return the calculated output dimensions for the given scale |
| 200 return SkISize::Make(dinfo.output_width, dinfo.output_height); | 201 return SkISize::Make(dinfo.output_width, dinfo.output_height); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 339 |
| 339 // Finish the decode and indicate that the input was incomplete. | 340 // Finish the decode and indicate that the input was incomplete. |
| 340 jpeg_finish_decompress(dinfo); | 341 jpeg_finish_decompress(dinfo); |
| 341 return fDecoderMgr->returnFailure("Incomplete image data", kIncomple
teInput); | 342 return fDecoderMgr->returnFailure("Incomplete image data", kIncomple
teInput); |
| 342 } | 343 } |
| 343 } | 344 } |
| 344 jpeg_finish_decompress(dinfo); | 345 jpeg_finish_decompress(dinfo); |
| 345 | 346 |
| 346 return kSuccess; | 347 return kSuccess; |
| 347 } | 348 } |
| OLD | NEW |