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 "SkBitmapRegionCanvas.h" | 8 #include "SkBitmapRegionCanvas.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCodecPriv.h" | 10 #include "SkCodecPriv.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return nullptr; | 145 return nullptr; |
146 } | 146 } |
147 | 147 |
148 // Zero the bitmap if the region is not completely within the image. | 148 // Zero the bitmap if the region is not completely within the image. |
149 // TODO (msarett): Can we make this faster by implementing it to only | 149 // TODO (msarett): Can we make this faster by implementing it to only |
150 // zero parts of the image that we won't overwrite with | 150 // zero parts of the image that we won't overwrite with |
151 // pixels? | 151 // pixels? |
152 // TODO (msarett): This could be skipped if memory is zero initialized. | 152 // TODO (msarett): This could be skipped if memory is zero initialized. |
153 // This would matter if this code is moved to Android and | 153 // This would matter if this code is moved to Android and |
154 // uses Android bitmaps. | 154 // uses Android bitmaps. |
155 if (imageContainsEntireSubset) { | 155 if (!imageContainsEntireSubset) { |
156 bitmap->eraseColor(0); | 156 bitmap->eraseColor(0); |
157 } | 157 } |
158 | 158 |
159 // Use a canvas to crop and scale to the destination bitmap | 159 // Use a canvas to crop and scale to the destination bitmap |
160 SkCanvas canvas(*bitmap); | 160 SkCanvas canvas(*bitmap); |
161 // TODO (msarett): Maybe we can take advantage of the fact that SkRect uses
floats? | 161 // TODO (msarett): Maybe we can take advantage of the fact that SkRect uses
floats? |
162 SkRect src = SkRect::MakeXYWH((SkScalar) imageSubsetX, (SkScalar) 0, | 162 SkRect src = SkRect::MakeXYWH((SkScalar) imageSubsetX, (SkScalar) 0, |
163 (SkScalar) imageSubsetWidth, (SkScalar) imageSubsetHeight); | 163 (SkScalar) imageSubsetWidth, (SkScalar) imageSubsetHeight); |
164 SkRect dst = SkRect::MakeXYWH((SkScalar) (outX / sampleSize), (SkScalar) (ou
tY / sampleSize), | 164 SkRect dst = SkRect::MakeXYWH((SkScalar) (outX / sampleSize), (SkScalar) (ou
tY / sampleSize), |
165 (SkScalar) get_scaled_dimension(imageSubsetWidth, sampleSize), | 165 (SkScalar) get_scaled_dimension(imageSubsetWidth, sampleSize), |
(...skipping 11 matching lines...) Expand all Loading... |
177 // SkCanvas does not draw to these color types. | 177 // SkCanvas does not draw to these color types. |
178 if (kIndex_8_SkColorType == colorType || kGray_8_SkColorType == colorType) { | 178 if (kIndex_8_SkColorType == colorType || kGray_8_SkColorType == colorType) { |
179 return false; | 179 return false; |
180 } | 180 } |
181 | 181 |
182 // FIXME: Call virtual function when it lands. | 182 // FIXME: Call virtual function when it lands. |
183 SkImageInfo info = SkImageInfo::Make(0, 0, colorType, fDecoder->getInfo().al
phaType(), | 183 SkImageInfo info = SkImageInfo::Make(0, 0, colorType, fDecoder->getInfo().al
phaType(), |
184 fDecoder->getInfo().profileType()); | 184 fDecoder->getInfo().profileType()); |
185 return conversion_possible(info, fDecoder->getInfo()); | 185 return conversion_possible(info, fDecoder->getInfo()); |
186 } | 186 } |
OLD | NEW |