| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 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 #define __STDC_LIMIT_MACROS | 7 #define __STDC_LIMIT_MACROS |
| 8 | 8 |
| 9 #include "SkDraw.h" | 9 #include "SkDraw.h" |
| 10 #include "SkBlitter.h" | 10 #include "SkBlitter.h" |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, | 1151 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, |
| 1152 const SkPaint& paint) const { | 1152 const SkPaint& paint) const { |
| 1153 SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType); | 1153 SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType); |
| 1154 | 1154 |
| 1155 if (just_translate(*fMatrix, bitmap)) { | 1155 if (just_translate(*fMatrix, bitmap)) { |
| 1156 int ix = SkScalarRoundToInt(fMatrix->getTranslateX()); | 1156 int ix = SkScalarRoundToInt(fMatrix->getTranslateX()); |
| 1157 int iy = SkScalarRoundToInt(fMatrix->getTranslateY()); | 1157 int iy = SkScalarRoundToInt(fMatrix->getTranslateY()); |
| 1158 | 1158 |
| 1159 SkAutoLockPixels alp(bitmap); | 1159 SkAutoPixmapUnlock result; |
| 1160 if (!bitmap.readyToDraw()) { | 1160 if (!bitmap.requestLock(&result)) { |
| 1161 return; | 1161 return; |
| 1162 } | 1162 } |
| 1163 | 1163 const SkPixmap& pmap = result.pixmap(); |
| 1164 SkMask mask; | 1164 SkMask mask; |
| 1165 mask.fBounds.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); | 1165 mask.fBounds.set(ix, iy, ix + pmap.width(), iy + pmap.height()); |
| 1166 mask.fFormat = SkMask::kA8_Format; | 1166 mask.fFormat = SkMask::kA8_Format; |
| 1167 mask.fRowBytes = SkToU32(bitmap.rowBytes()); | 1167 mask.fRowBytes = SkToU32(pmap.rowBytes()); |
| 1168 mask.fImage = bitmap.getAddr8(0, 0); | 1168 // fImage is typed as writable, but in this case it is used read-only |
| 1169 mask.fImage = (uint8_t*)pmap.addr8(0, 0); |
| 1169 | 1170 |
| 1170 this->drawDevMask(mask, paint); | 1171 this->drawDevMask(mask, paint); |
| 1171 } else { // need to xform the bitmap first | 1172 } else { // need to xform the bitmap first |
| 1172 SkRect r; | 1173 SkRect r; |
| 1173 SkMask mask; | 1174 SkMask mask; |
| 1174 | 1175 |
| 1175 r.set(0, 0, | 1176 r.set(0, 0, |
| 1176 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())); | 1177 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())); |
| 1177 fMatrix->mapRect(&r); | 1178 fMatrix->mapRect(&r); |
| 1178 r.round(&mask.fBounds); | 1179 r.round(&mask.fBounds); |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2267 mask->fImage = SkMask::AllocImage(size); | 2268 mask->fImage = SkMask::AllocImage(size); |
| 2268 memset(mask->fImage, 0, mask->computeImageSize()); | 2269 memset(mask->fImage, 0, mask->computeImageSize()); |
| 2269 } | 2270 } |
| 2270 | 2271 |
| 2271 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2272 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
| 2272 draw_into_mask(*mask, devPath, style); | 2273 draw_into_mask(*mask, devPath, style); |
| 2273 } | 2274 } |
| 2274 | 2275 |
| 2275 return true; | 2276 return true; |
| 2276 } | 2277 } |
| OLD | NEW |