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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 SkBitmap::Config config = this->getPrefConfig(k32Bit_SrcDepth, false); | 108 SkBitmap::Config config = this->getPrefConfig(k32Bit_SrcDepth, false); |
109 | 109 |
110 // only accept prefConfig if it makes sense for us | 110 // only accept prefConfig if it makes sense for us |
111 if (SkBitmap::kARGB_4444_Config != config && | 111 if (SkBitmap::kARGB_4444_Config != config && |
112 SkBitmap::kRGB_565_Config != config) { | 112 SkBitmap::kRGB_565_Config != config) { |
113 config = SkBitmap::kARGB_8888_Config; | 113 config = SkBitmap::kARGB_8888_Config; |
114 } | 114 } |
115 | 115 |
116 SkScaledBitmapSampler sampler(width, height, getSampleSize()); | 116 SkScaledBitmapSampler sampler(width, height, getSampleSize()); |
117 | 117 |
| 118 if (justBounds) { |
| 119 bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); |
| 120 bm->setIsOpaque(true); |
| 121 return true; |
| 122 } |
| 123 // No Bitmap reuse supported for this format |
| 124 if (!bm->isNull()) { |
| 125 return false; |
| 126 } |
| 127 |
118 bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); | 128 bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); |
119 bm->setIsOpaque(true); | 129 bm->setIsOpaque(true); |
120 if (justBounds) { | |
121 return true; | |
122 } | |
123 | 130 |
124 if (!this->allocPixelRef(bm, NULL)) { | 131 if (!this->allocPixelRef(bm, NULL)) { |
125 return false; | 132 return false; |
126 } | 133 } |
127 | 134 |
128 SkAutoLockPixels alp(*bm); | 135 SkAutoLockPixels alp(*bm); |
129 | 136 |
130 if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, getDitherImage())) { | 137 if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, getDitherImage())) { |
131 return false; | 138 return false; |
132 } | 139 } |
133 | 140 |
134 const int srcRowBytes = width * 3; | 141 const int srcRowBytes = width * 3; |
135 const int dstHeight = sampler.scaledHeight(); | 142 const int dstHeight = sampler.scaledHeight(); |
136 const uint8_t* srcRow = callback.rgb(); | 143 const uint8_t* srcRow = callback.rgb(); |
137 | 144 |
138 srcRow += sampler.srcY0() * srcRowBytes; | 145 srcRow += sampler.srcY0() * srcRowBytes; |
139 for (int y = 0; y < dstHeight; y++) { | 146 for (int y = 0; y < dstHeight; y++) { |
140 sampler.next(srcRow); | 147 sampler.next(srcRow); |
141 srcRow += sampler.srcDY() * srcRowBytes; | 148 srcRow += sampler.srcDY() * srcRowBytes; |
142 } | 149 } |
143 return true; | 150 return true; |
144 } | 151 } |
OLD | NEW |