| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "bmpdecoderhelper.h" | 10 #include "bmpdecoderhelper.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 SkBitmap::Config config = this->getPrefConfig(k32Bit_SrcDepth, false); | 123 SkBitmap::Config config = this->getPrefConfig(k32Bit_SrcDepth, false); |
| 124 | 124 |
| 125 // only accept prefConfig if it makes sense for us | 125 // only accept prefConfig if it makes sense for us |
| 126 if (SkBitmap::kARGB_4444_Config != config && | 126 if (SkBitmap::kARGB_4444_Config != config && |
| 127 SkBitmap::kRGB_565_Config != config) { | 127 SkBitmap::kRGB_565_Config != config) { |
| 128 config = SkBitmap::kARGB_8888_Config; | 128 config = SkBitmap::kARGB_8888_Config; |
| 129 } | 129 } |
| 130 | 130 |
| 131 SkScaledBitmapSampler sampler(width, height, getSampleSize()); | 131 SkScaledBitmapSampler sampler(width, height, getSampleSize()); |
| 132 | 132 |
| 133 if (justBounds) { | |
| 134 bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); | |
| 135 bm->setIsOpaque(true); | |
| 136 return true; | |
| 137 } | |
| 138 // No Bitmap reuse supported for this format | |
| 139 if (!bm->isNull()) { | |
| 140 return false; | |
| 141 } | |
| 142 | |
| 143 bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); | 133 bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); |
| 144 bm->setIsOpaque(true); | 134 bm->setIsOpaque(true); |
| 145 | 135 |
| 136 if (justBounds) { |
| 137 return true; |
| 138 } |
| 139 |
| 146 if (!this->allocPixelRef(bm, NULL)) { | 140 if (!this->allocPixelRef(bm, NULL)) { |
| 147 return false; | 141 return false; |
| 148 } | 142 } |
| 149 | 143 |
| 150 SkAutoLockPixels alp(*bm); | 144 SkAutoLockPixels alp(*bm); |
| 151 | 145 |
| 152 if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, getDitherImage())) { | 146 if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, getDitherImage())) { |
| 153 return false; | 147 return false; |
| 154 } | 148 } |
| 155 | 149 |
| 156 const int srcRowBytes = width * 3; | 150 const int srcRowBytes = width * 3; |
| 157 const int dstHeight = sampler.scaledHeight(); | 151 const int dstHeight = sampler.scaledHeight(); |
| 158 const uint8_t* srcRow = callback.rgb(); | 152 const uint8_t* srcRow = callback.rgb(); |
| 159 | 153 |
| 160 srcRow += sampler.srcY0() * srcRowBytes; | 154 srcRow += sampler.srcY0() * srcRowBytes; |
| 161 for (int y = 0; y < dstHeight; y++) { | 155 for (int y = 0; y < dstHeight; y++) { |
| 162 sampler.next(srcRow); | 156 sampler.next(srcRow); |
| 163 srcRow += sampler.srcDY() * srcRowBytes; | 157 srcRow += sampler.srcDY() * srcRowBytes; |
| 164 } | 158 } |
| 165 return true; | 159 return true; |
| 166 } | 160 } |
| OLD | NEW |