| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 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 | 8 |
| 9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
| 10 #include "SkImageEncoder.h" | 10 #include "SkImageEncoder.h" |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 int h = rect.height() / actualSampleSize; | 845 int h = rect.height() / actualSampleSize; |
| 846 bool swapOnly = (rect == region) && bm->isNull() && | 846 bool swapOnly = (rect == region) && bm->isNull() && |
| 847 (w == bitmap.width()) && (h == bitmap.height()) && | 847 (w == bitmap.width()) && (h == bitmap.height()) && |
| 848 ((startX - rect.x()) / actualSampleSize == 0) && | 848 ((startX - rect.x()) / actualSampleSize == 0) && |
| 849 ((startY - rect.y()) / actualSampleSize == 0); | 849 ((startY - rect.y()) / actualSampleSize == 0); |
| 850 if (swapOnly) { | 850 if (swapOnly) { |
| 851 if (!this->allocPixelRef(&bitmap, NULL)) { | 851 if (!this->allocPixelRef(&bitmap, NULL)) { |
| 852 return return_false(*cinfo, bitmap, "allocPixelRef"); | 852 return return_false(*cinfo, bitmap, "allocPixelRef"); |
| 853 } | 853 } |
| 854 } else { | 854 } else { |
| 855 if (!bitmap.allocPixels()) { | 855 if (!bitmap.tryAllocPixels()) { |
| 856 return return_false(*cinfo, bitmap, "allocPixels"); | 856 return return_false(*cinfo, bitmap, "allocPixels"); |
| 857 } | 857 } |
| 858 } | 858 } |
| 859 | 859 |
| 860 SkAutoLockPixels alp(bitmap); | 860 SkAutoLockPixels alp(bitmap); |
| 861 | 861 |
| 862 #ifdef ANDROID_RGB | 862 #ifdef ANDROID_RGB |
| 863 /* short-circuit the SkScaledBitmapSampler when possible, as this gives | 863 /* short-circuit the SkScaledBitmapSampler when possible, as this gives |
| 864 a significant performance boost. | 864 a significant performance boost. |
| 865 */ | 865 */ |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 return SkImageDecoder::kUnknown_Format; | 1233 return SkImageDecoder::kUnknown_Format; |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { | 1236 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { |
| 1237 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; | 1237 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); | 1240 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); |
| 1241 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); | 1241 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); |
| 1242 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); | 1242 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); |
| OLD | NEW |