OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 tmpUnfiltered); | 1318 tmpUnfiltered); |
1319 } | 1319 } |
1320 } else { | 1320 } else { |
1321 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); | 1321 iter.fDevice->drawSprite(iter, bitmap, pos.x(), pos.y(), *paint); |
1322 } | 1322 } |
1323 } | 1323 } |
1324 LOOPER_END | 1324 LOOPER_END |
1325 } | 1325 } |
1326 | 1326 |
1327 ///////////////////////////////////////////////////////////////////////////// | 1327 ///////////////////////////////////////////////////////////////////////////// |
1328 void SkCanvas::didTranslate(SkScalar, SkScalar) { | |
1329 // Do nothing. Subclasses may do something. | |
1330 } | |
1331 | |
1332 void SkCanvas::translate(SkScalar dx, SkScalar dy) { | 1328 void SkCanvas::translate(SkScalar dx, SkScalar dy) { |
1333 fDeviceCMDirty = true; | 1329 SkMatrix m; |
1334 fCachedLocalClipBoundsDirty = true; | 1330 m.setTranslate(dx, dy); |
1335 fMCRec->fMatrix->preTranslate(dx, dy); | 1331 this->concat(m); |
1336 | |
1337 this->didTranslate(dx, dy); | |
1338 } | |
1339 | |
1340 void SkCanvas::didScale(SkScalar, SkScalar) { | |
1341 // Do nothing. Subclasses may do something. | |
1342 } | 1332 } |
1343 | 1333 |
1344 void SkCanvas::scale(SkScalar sx, SkScalar sy) { | 1334 void SkCanvas::scale(SkScalar sx, SkScalar sy) { |
1345 fDeviceCMDirty = true; | 1335 SkMatrix m; |
1346 fCachedLocalClipBoundsDirty = true; | 1336 m.setScale(sx, sy); |
1347 fMCRec->fMatrix->preScale(sx, sy); | 1337 this->concat(m); |
1348 | |
1349 this->didScale(sx, sy); | |
1350 } | |
1351 | |
1352 void SkCanvas::didRotate(SkScalar) { | |
1353 // Do nothing. Subclasses may do something. | |
1354 } | 1338 } |
1355 | 1339 |
1356 void SkCanvas::rotate(SkScalar degrees) { | 1340 void SkCanvas::rotate(SkScalar degrees) { |
1357 fDeviceCMDirty = true; | 1341 SkMatrix m; |
1358 fCachedLocalClipBoundsDirty = true; | 1342 m.setRotate(degrees); |
1359 fMCRec->fMatrix->preRotate(degrees); | 1343 this->concat(m); |
1360 | |
1361 this->didRotate(degrees); | |
1362 } | |
1363 | |
1364 void SkCanvas::didSkew(SkScalar, SkScalar) { | |
1365 // Do nothing. Subclasses may do something. | |
1366 } | 1344 } |
1367 | 1345 |
1368 void SkCanvas::skew(SkScalar sx, SkScalar sy) { | 1346 void SkCanvas::skew(SkScalar sx, SkScalar sy) { |
1369 fDeviceCMDirty = true; | 1347 SkMatrix m; |
1370 fCachedLocalClipBoundsDirty = true; | 1348 m.setSkew(sx, sy); |
1371 fMCRec->fMatrix->preSkew(sx, sy); | 1349 this->concat(m); |
1372 | |
1373 this->didSkew(sx, sy); | |
1374 } | 1350 } |
1375 | 1351 |
1376 void SkCanvas::didConcat(const SkMatrix&) { | 1352 void SkCanvas::didConcat(const SkMatrix&) { |
1377 // Do nothing. Subclasses may do something. | 1353 // Do nothing. Subclasses may do something. |
1378 } | 1354 } |
1379 | 1355 |
1380 void SkCanvas::concat(const SkMatrix& matrix) { | 1356 void SkCanvas::concat(const SkMatrix& matrix) { |
| 1357 if (matrix.isIdentity()) { |
| 1358 return; |
| 1359 } |
| 1360 |
1381 fDeviceCMDirty = true; | 1361 fDeviceCMDirty = true; |
1382 fCachedLocalClipBoundsDirty = true; | 1362 fCachedLocalClipBoundsDirty = true; |
1383 fMCRec->fMatrix->preConcat(matrix); | 1363 fMCRec->fMatrix->preConcat(matrix); |
1384 | 1364 |
1385 this->didConcat(matrix); | 1365 this->didConcat(matrix); |
1386 } | 1366 } |
1387 | 1367 |
1388 void SkCanvas::didSetMatrix(const SkMatrix&) { | 1368 void SkCanvas::didSetMatrix(const SkMatrix&) { |
1389 // Do nothing. Subclasses may do something. | 1369 // Do nothing. Subclasses may do something. |
1390 } | 1370 } |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 if (!bitmap.installPixels(info, pixels, rowBytes)) { | 2654 if (!bitmap.installPixels(info, pixels, rowBytes)) { |
2675 return NULL; | 2655 return NULL; |
2676 } | 2656 } |
2677 | 2657 |
2678 // should this functionality be moved into allocPixels()? | 2658 // should this functionality be moved into allocPixels()? |
2679 if (!bitmap.info().isOpaque()) { | 2659 if (!bitmap.info().isOpaque()) { |
2680 bitmap.eraseColor(0); | 2660 bitmap.eraseColor(0); |
2681 } | 2661 } |
2682 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2662 return SkNEW_ARGS(SkCanvas, (bitmap)); |
2683 } | 2663 } |
OLD | NEW |