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 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 const SkRect* dstBounds, const SkPaint& origPaint) const
{ | 1295 const SkRect* dstBounds, const SkPaint& origPaint) const
{ |
1296 SkDEBUGCODE(this->validate();) | 1296 SkDEBUGCODE(this->validate();) |
1297 | 1297 |
1298 // nothing to draw | 1298 // nothing to draw |
1299 if (fRC->isEmpty() || | 1299 if (fRC->isEmpty() || |
1300 bitmap.width() == 0 || bitmap.height() == 0 || | 1300 bitmap.width() == 0 || bitmap.height() == 0 || |
1301 bitmap.colorType() == kUnknown_SkColorType) { | 1301 bitmap.colorType() == kUnknown_SkColorType) { |
1302 return; | 1302 return; |
1303 } | 1303 } |
1304 | 1304 |
1305 SkPaint paint(origPaint); | 1305 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); |
1306 paint.setStyle(SkPaint::kFill_Style); | 1306 if (origPaint.getStyle() != SkPaint::kFill_Style) { |
| 1307 paint.writable()->setStyle(SkPaint::kFill_Style); |
| 1308 } |
1307 | 1309 |
1308 SkMatrix matrix; | 1310 SkMatrix matrix; |
1309 matrix.setConcat(*fMatrix, prematrix); | 1311 matrix.setConcat(*fMatrix, prematrix); |
1310 | 1312 |
1311 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) { | 1313 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) { |
1312 return; | 1314 return; |
1313 } | 1315 } |
1314 | 1316 |
1315 if (bitmap.colorType() != kAlpha_8_SkColorType | 1317 if (bitmap.colorType() != kAlpha_8_SkColorType |
1316 && SkTreatAsSprite(matrix, bitmap.dimensions(), paint)) { | 1318 && SkTreatAsSprite(matrix, bitmap.dimensions(), *paint)) { |
1317 // | 1319 // |
1318 // It is safe to call lock pixels now, since we know the matrix is | 1320 // It is safe to call lock pixels now, since we know the matrix is |
1319 // (more or less) identity. | 1321 // (more or less) identity. |
1320 // | 1322 // |
1321 SkAutoPixmapUnlock unlocker; | 1323 SkAutoPixmapUnlock unlocker; |
1322 if (!bitmap.requestLock(&unlocker)) { | 1324 if (!bitmap.requestLock(&unlocker)) { |
1323 return; | 1325 return; |
1324 } | 1326 } |
1325 const SkPixmap& pmap = unlocker.pixmap(); | 1327 const SkPixmap& pmap = unlocker.pixmap(); |
1326 int ix = SkScalarRoundToInt(matrix.getTranslateX()); | 1328 int ix = SkScalarRoundToInt(matrix.getTranslateX()); |
1327 int iy = SkScalarRoundToInt(matrix.getTranslateY()); | 1329 int iy = SkScalarRoundToInt(matrix.getTranslateY()); |
1328 if (clipHandlesSprite(*fRC, ix, iy, pmap)) { | 1330 if (clipHandlesSprite(*fRC, ix, iy, pmap)) { |
1329 SkTBlitterAllocator allocator; | 1331 SkTBlitterAllocator allocator; |
1330 // blitter will be owned by the allocator. | 1332 // blitter will be owned by the allocator. |
1331 SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, paint, pmap, ix,
iy, &allocator); | 1333 SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, *paint, pmap, ix,
iy, &allocator); |
1332 if (blitter) { | 1334 if (blitter) { |
1333 SkScan::FillIRect(SkIRect::MakeXYWH(ix, iy, pmap.width(), pmap.h
eight()), | 1335 SkScan::FillIRect(SkIRect::MakeXYWH(ix, iy, pmap.width(), pmap.h
eight()), |
1334 *fRC, blitter); | 1336 *fRC, blitter); |
1335 return; | 1337 return; |
1336 } | 1338 } |
1337 // if !blitter, then we fall-through to the slower case | 1339 // if !blitter, then we fall-through to the slower case |
1338 } | 1340 } |
1339 } | 1341 } |
1340 | 1342 |
1341 // now make a temp draw on the stack, and use it | 1343 // now make a temp draw on the stack, and use it |
1342 // | 1344 // |
1343 SkDraw draw(*this); | 1345 SkDraw draw(*this); |
1344 draw.fMatrix = &matrix; | 1346 draw.fMatrix = &matrix; |
1345 | 1347 |
1346 if (bitmap.colorType() == kAlpha_8_SkColorType) { | 1348 if (bitmap.colorType() == kAlpha_8_SkColorType) { |
1347 draw.drawBitmapAsMask(bitmap, paint); | 1349 draw.drawBitmapAsMask(bitmap, *paint); |
1348 } else { | 1350 } else { |
1349 SkAutoBitmapShaderInstall install(bitmap, paint); | 1351 SkAutoBitmapShaderInstall install(bitmap, *paint); |
1350 const SkPaint& paintWithShader = install.paintWithShader(); | 1352 const SkPaint& paintWithShader = install.paintWithShader(); |
1351 const SkRect srcBounds = SkRect::MakeIWH(bitmap.width(), bitmap.height()
); | 1353 const SkRect srcBounds = SkRect::MakeIWH(bitmap.width(), bitmap.height()
); |
1352 if (dstBounds) { | 1354 if (dstBounds) { |
1353 this->drawRect(srcBounds, paintWithShader, &prematrix, dstBounds); | 1355 this->drawRect(srcBounds, paintWithShader, &prematrix, dstBounds); |
1354 } else { | 1356 } else { |
1355 draw.drawRect(srcBounds, paintWithShader); | 1357 draw.drawRect(srcBounds, paintWithShader); |
1356 } | 1358 } |
1357 } | 1359 } |
1358 } | 1360 } |
1359 | 1361 |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 mask->fImage = SkMask::AllocImage(size); | 2109 mask->fImage = SkMask::AllocImage(size); |
2108 memset(mask->fImage, 0, mask->computeImageSize()); | 2110 memset(mask->fImage, 0, mask->computeImageSize()); |
2109 } | 2111 } |
2110 | 2112 |
2111 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2113 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2112 draw_into_mask(*mask, devPath, style); | 2114 draw_into_mask(*mask, devPath, style); |
2113 } | 2115 } |
2114 | 2116 |
2115 return true; | 2117 return true; |
2116 } | 2118 } |
OLD | NEW |