OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 if (this->quickReject(rect)) { | 1491 if (this->quickReject(rect)) { |
1492 fDeviceCMDirty = true; | 1492 fDeviceCMDirty = true; |
1493 fCachedLocalClipBoundsDirty = true; | 1493 fCachedLocalClipBoundsDirty = true; |
1494 | 1494 |
1495 fClipStack->clipEmpty(); | 1495 fClipStack->clipEmpty(); |
1496 return fMCRec->fRasterClip.setEmpty(); | 1496 return fMCRec->fRasterClip.setEmpty(); |
1497 } | 1497 } |
1498 } | 1498 } |
1499 #endif | 1499 #endif |
1500 | 1500 |
1501 if (!fAllowSoftClip) { | |
1502 edgeStyle = kHard_ClipEdgeStyle; | |
1503 } | |
1504 | |
1505 const bool rectStaysRect = fMCRec->fMatrix.rectStaysRect(); | |
1506 SkRect devR; | |
1507 if (rectStaysRect) { | |
1508 fMCRec->fMatrix.mapRect(&devR, rect); | |
1509 } | |
1510 | |
1511 // Check if we can quick-accept the clip call (and do nothing) | |
1512 // | |
1513 // TODO: investigate if a (conservative) version of this could be done in ::
clipRect, | |
1514 // so that subclasses (like PictureRecording) didn't see unnecessary c
lips, which in turn | |
1515 // might allow lazy save/restores to eliminate entire save/restore blo
cks. | |
1516 // | |
1517 if (SkRegion::kIntersect_Op == op && | |
1518 kHard_ClipEdgeStyle == edgeStyle | |
1519 && rectStaysRect) | |
1520 { | |
1521 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { | |
1522 #if 0 | |
1523 SkDebugf("------- ignored clipRect [%g %g %g %g]\n", | |
1524 rect.left(), rect.top(), rect.right(), rect.bottom()); | |
1525 #endif | |
1526 return; | |
1527 } | |
1528 } | |
1529 | |
1530 AutoValidateClip avc(this); | 1501 AutoValidateClip avc(this); |
1531 | 1502 |
1532 fDeviceCMDirty = true; | 1503 fDeviceCMDirty = true; |
1533 fCachedLocalClipBoundsDirty = true; | 1504 fCachedLocalClipBoundsDirty = true; |
| 1505 if (!fAllowSoftClip) { |
| 1506 edgeStyle = kHard_ClipEdgeStyle; |
| 1507 } |
1534 | 1508 |
1535 if (rectStaysRect) { | 1509 if (fMCRec->fMatrix.rectStaysRect()) { |
1536 const bool isAA = kSoft_ClipEdgeStyle == edgeStyle; | 1510 // for these simpler matrices, we can stay a rect even after applying |
1537 fClipStack->clipDevRect(devR, op, isAA); | 1511 // the matrix. This means we don't have to a) make a path, and b) tell |
1538 fMCRec->fRasterClip.op(devR, this->getBaseLayerSize(), op, isAA); | 1512 // the region code to scan-convert the path, only to discover that it |
| 1513 // is really just a rect. |
| 1514 SkRect r; |
| 1515 |
| 1516 fMCRec->fMatrix.mapRect(&r, rect); |
| 1517 fClipStack->clipDevRect(r, op, kSoft_ClipEdgeStyle == edgeStyle); |
| 1518 fMCRec->fRasterClip.op(r, this->getBaseLayerSize(), op, kSoft_ClipEdgeSt
yle == edgeStyle); |
1539 } else { | 1519 } else { |
1540 // since we're rotated or some such thing, we convert the rect to a path | 1520 // since we're rotated or some such thing, we convert the rect to a path |
1541 // and clip against that, since it can handle any matrix. However, to | 1521 // and clip against that, since it can handle any matrix. However, to |
1542 // avoid recursion in the case where we are subclassed (e.g. Pictures) | 1522 // avoid recursion in the case where we are subclassed (e.g. Pictures) |
1543 // we explicitly call "our" version of clipPath. | 1523 // we explicitly call "our" version of clipPath. |
1544 SkPath path; | 1524 SkPath path; |
1545 | 1525 |
1546 path.addRect(rect); | 1526 path.addRect(rect); |
1547 this->SkCanvas::onClipPath(path, op, edgeStyle); | 1527 this->SkCanvas::onClipPath(path, op, edgeStyle); |
1548 } | 1528 } |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2941 } | 2921 } |
2942 | 2922 |
2943 if (matrix) { | 2923 if (matrix) { |
2944 canvas->concat(*matrix); | 2924 canvas->concat(*matrix); |
2945 } | 2925 } |
2946 } | 2926 } |
2947 | 2927 |
2948 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2928 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2949 fCanvas->restoreToCount(fSaveCount); | 2929 fCanvas->restoreToCount(fSaveCount); |
2950 } | 2930 } |
OLD | NEW |