| 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 | 7 |
| 8 #include "SkDraw.h" | 8 #include "SkDraw.h" |
| 9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
| 10 #include "SkBounder.h" | 10 #include "SkBounder.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 int y = SkScalarFloorToInt(devPts[i].fY); | 392 int y = SkScalarFloorToInt(devPts[i].fY); |
| 393 if (r.contains(x, y)) { | 393 if (r.contains(x, y)) { |
| 394 ((SkPMColor*)((char*)addr + y * rb))[x] = value; | 394 ((SkPMColor*)((char*)addr + y * rb))[x] = value; |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 | 398 |
| 399 static void bw_pt_hair_proc(const PtProcRec& rec, const SkPoint devPts[], | 399 static void bw_pt_hair_proc(const PtProcRec& rec, const SkPoint devPts[], |
| 400 int count, SkBlitter* blitter) { | 400 int count, SkBlitter* blitter) { |
| 401 for (int i = 0; i < count; i++) { | 401 for (int i = 0; i < count; i++) { |
| 402 int x = SkScalarFloor(devPts[i].fX); | 402 int x = SkScalarFloorToInt(devPts[i].fX); |
| 403 int y = SkScalarFloor(devPts[i].fY); | 403 int y = SkScalarFloorToInt(devPts[i].fY); |
| 404 if (rec.fClip->contains(x, y)) { | 404 if (rec.fClip->contains(x, y)) { |
| 405 blitter->blitH(x, y, 1); | 405 blitter->blitH(x, y, 1); |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 static void bw_line_hair_proc(const PtProcRec& rec, const SkPoint devPts[], | 410 static void bw_line_hair_proc(const PtProcRec& rec, const SkPoint devPts[], |
| 411 int count, SkBlitter* blitter) { | 411 int count, SkBlitter* blitter) { |
| 412 for (int i = 0; i < count; i += 2) { | 412 for (int i = 0; i < count; i += 2) { |
| 413 SkScan::HairLine(devPts[i], devPts[i+1], *rec.fRC, blitter); | 413 SkScan::HairLine(devPts[i], devPts[i+1], *rec.fRC, blitter); |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 unsigned bits = 0; // TODO: find a way to allow the caller to tell us to | 1188 unsigned bits = 0; // TODO: find a way to allow the caller to tell us to |
| 1189 // respect filtering. | 1189 // respect filtering. |
| 1190 return SkTreatAsSprite(matrix, bitmap.width(), bitmap.height(), bits); | 1190 return SkTreatAsSprite(matrix, bitmap.width(), bitmap.height(), bits); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, | 1193 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, |
| 1194 const SkPaint& paint) const { | 1194 const SkPaint& paint) const { |
| 1195 SkASSERT(bitmap.config() == SkBitmap::kA8_Config); | 1195 SkASSERT(bitmap.config() == SkBitmap::kA8_Config); |
| 1196 | 1196 |
| 1197 if (just_translate(*fMatrix, bitmap)) { | 1197 if (just_translate(*fMatrix, bitmap)) { |
| 1198 int ix = SkScalarRound(fMatrix->getTranslateX()); | 1198 int ix = SkScalarRoundToInt(fMatrix->getTranslateX()); |
| 1199 int iy = SkScalarRound(fMatrix->getTranslateY()); | 1199 int iy = SkScalarRoundToInt(fMatrix->getTranslateY()); |
| 1200 | 1200 |
| 1201 SkAutoLockPixels alp(bitmap); | 1201 SkAutoLockPixels alp(bitmap); |
| 1202 if (!bitmap.readyToDraw()) { | 1202 if (!bitmap.readyToDraw()) { |
| 1203 return; | 1203 return; |
| 1204 } | 1204 } |
| 1205 | 1205 |
| 1206 SkMask mask; | 1206 SkMask mask; |
| 1207 mask.fBounds.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); | 1207 mask.fBounds.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); |
| 1208 mask.fFormat = SkMask::kA8_Format; | 1208 mask.fFormat = SkMask::kA8_Format; |
| 1209 mask.fRowBytes = SkToU32(bitmap.rowBytes()); | 1209 mask.fRowBytes = SkToU32(bitmap.rowBytes()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 if (!matrix.setConcat(*fMatrix, prematrix)) { | 1311 if (!matrix.setConcat(*fMatrix, prematrix)) { |
| 1312 return; | 1312 return; |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) { | 1315 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) { |
| 1316 return; | 1316 return; |
| 1317 } | 1317 } |
| 1318 | 1318 |
| 1319 if (fBounder && just_translate(matrix, bitmap)) { | 1319 if (fBounder && just_translate(matrix, bitmap)) { |
| 1320 SkIRect ir; | 1320 SkIRect ir; |
| 1321 int32_t ix = SkScalarRound(matrix.getTranslateX()); | 1321 int32_t ix = SkScalarRoundToInt(matrix.getTranslateX()); |
| 1322 int32_t iy = SkScalarRound(matrix.getTranslateY()); | 1322 int32_t iy = SkScalarRoundToInt(matrix.getTranslateY()); |
| 1323 ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); | 1323 ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); |
| 1324 if (!fBounder->doIRect(ir)) { | 1324 if (!fBounder->doIRect(ir)) { |
| 1325 return; | 1325 return; |
| 1326 } | 1326 } |
| 1327 } | 1327 } |
| 1328 | 1328 |
| 1329 if (bitmap.config() != SkBitmap::kA8_Config && | 1329 if (bitmap.config() != SkBitmap::kA8_Config && |
| 1330 just_translate(matrix, bitmap)) { | 1330 just_translate(matrix, bitmap)) { |
| 1331 // | 1331 // |
| 1332 // It is safe to call lock pixels now, since we know the matrix is | 1332 // It is safe to call lock pixels now, since we know the matrix is |
| 1333 // (more or less) identity. | 1333 // (more or less) identity. |
| 1334 // | 1334 // |
| 1335 SkAutoLockPixels alp(bitmap); | 1335 SkAutoLockPixels alp(bitmap); |
| 1336 if (!bitmap.readyToDraw()) { | 1336 if (!bitmap.readyToDraw()) { |
| 1337 return; | 1337 return; |
| 1338 } | 1338 } |
| 1339 int ix = SkScalarRound(matrix.getTranslateX()); | 1339 int ix = SkScalarRoundToInt(matrix.getTranslateX()); |
| 1340 int iy = SkScalarRound(matrix.getTranslateY()); | 1340 int iy = SkScalarRoundToInt(matrix.getTranslateY()); |
| 1341 if (clipHandlesSprite(*fRC, ix, iy, bitmap)) { | 1341 if (clipHandlesSprite(*fRC, ix, iy, bitmap)) { |
| 1342 uint32_t storage[kBlitterStorageLongCount]; | 1342 uint32_t storage[kBlitterStorageLongCount]; |
| 1343 SkBlitter* blitter = SkBlitter::ChooseSprite(*fBitmap, paint, bitma
p, | 1343 SkBlitter* blitter = SkBlitter::ChooseSprite(*fBitmap, paint, bitma
p, |
| 1344 ix, iy, storage, sizeof(storage)
); | 1344 ix, iy, storage, sizeof(storage)
); |
| 1345 if (blitter) { | 1345 if (blitter) { |
| 1346 SkAutoTPlacementDelete<SkBlitter> ad(blitter, storage); | 1346 SkAutoTPlacementDelete<SkBlitter> ad(blitter, storage); |
| 1347 | 1347 |
| 1348 SkIRect ir; | 1348 SkIRect ir; |
| 1349 ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); | 1349 ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height()); |
| 1350 | 1350 |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2734 bool SkBounder::doHairline(const SkPoint& pt0, const SkPoint& pt1, | 2734 bool SkBounder::doHairline(const SkPoint& pt0, const SkPoint& pt1, |
| 2735 const SkPaint& paint) { | 2735 const SkPaint& paint) { |
| 2736 SkIRect r; | 2736 SkIRect r; |
| 2737 SkScalar v0, v1; | 2737 SkScalar v0, v1; |
| 2738 | 2738 |
| 2739 v0 = pt0.fX; | 2739 v0 = pt0.fX; |
| 2740 v1 = pt1.fX; | 2740 v1 = pt1.fX; |
| 2741 if (v0 > v1) { | 2741 if (v0 > v1) { |
| 2742 SkTSwap<SkScalar>(v0, v1); | 2742 SkTSwap<SkScalar>(v0, v1); |
| 2743 } | 2743 } |
| 2744 r.fLeft = SkScalarFloor(v0); | 2744 r.fLeft = SkScalarFloorToInt(v0); |
| 2745 r.fRight = SkScalarCeil(v1); | 2745 r.fRight = SkScalarCeilToInt(v1); |
| 2746 | 2746 |
| 2747 v0 = pt0.fY; | 2747 v0 = pt0.fY; |
| 2748 v1 = pt1.fY; | 2748 v1 = pt1.fY; |
| 2749 if (v0 > v1) { | 2749 if (v0 > v1) { |
| 2750 SkTSwap<SkScalar>(v0, v1); | 2750 SkTSwap<SkScalar>(v0, v1); |
| 2751 } | 2751 } |
| 2752 r.fTop = SkScalarFloor(v0); | 2752 r.fTop = SkScalarFloorToInt(v0); |
| 2753 r.fBottom = SkScalarCeil(v1); | 2753 r.fBottom = SkScalarCeilToInt(v1); |
| 2754 | 2754 |
| 2755 if (paint.isAntiAlias()) { | 2755 if (paint.isAntiAlias()) { |
| 2756 r.inset(-1, -1); | 2756 r.inset(-1, -1); |
| 2757 } | 2757 } |
| 2758 return this->doIRect(r); | 2758 return this->doIRect(r); |
| 2759 } | 2759 } |
| 2760 | 2760 |
| 2761 bool SkBounder::doRect(const SkRect& rect, const SkPaint& paint) { | 2761 bool SkBounder::doRect(const SkRect& rect, const SkPaint& paint) { |
| 2762 SkIRect r; | 2762 SkIRect r; |
| 2763 | 2763 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2895 mask->fImage = SkMask::AllocImage(size); | 2895 mask->fImage = SkMask::AllocImage(size); |
| 2896 memset(mask->fImage, 0, mask->computeImageSize()); | 2896 memset(mask->fImage, 0, mask->computeImageSize()); |
| 2897 } | 2897 } |
| 2898 | 2898 |
| 2899 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2899 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
| 2900 draw_into_mask(*mask, devPath, style); | 2900 draw_into_mask(*mask, devPath, style); |
| 2901 } | 2901 } |
| 2902 | 2902 |
| 2903 return true; | 2903 return true; |
| 2904 } | 2904 } |
| OLD | NEW |