Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: tools/SkBitmapRegionCanvas.cpp

Issue 1393423004: SkBitmapRegionCanvas bug fix (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698