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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 646 } |
647 | 647 |
648 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { | 648 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { |
649 if (device && device->forceConservativeRasterClip()) { | 649 if (device && device->forceConservativeRasterClip()) { |
650 flags = InitFlags(flags | kConservativeRasterClip_InitFlag); | 650 flags = InitFlags(flags | kConservativeRasterClip_InitFlag); |
651 } | 651 } |
652 // Since init() is only called once by our constructors, it is safe to perfo
rm this | 652 // Since init() is only called once by our constructors, it is safe to perfo
rm this |
653 // const-cast. | 653 // const-cast. |
654 *const_cast<bool*>(&fConservativeRasterClip) = SkToBool(flags & kConservativ
eRasterClip_InitFlag); | 654 *const_cast<bool*>(&fConservativeRasterClip) = SkToBool(flags & kConservativ
eRasterClip_InitFlag); |
655 | 655 |
656 fAllowSoftClip = true; | |
657 fAllowSimplifyClip = false; | 656 fAllowSimplifyClip = false; |
658 fDeviceCMDirty = true; | 657 fDeviceCMDirty = true; |
659 fSaveCount = 1; | 658 fSaveCount = 1; |
660 fMetaData = nullptr; | 659 fMetaData = nullptr; |
661 #ifdef SK_EXPERIMENTAL_SHADOWING | 660 #ifdef SK_EXPERIMENTAL_SHADOWING |
662 fLights = nullptr; | 661 fLights = nullptr; |
663 #endif | 662 #endif |
664 | 663 |
665 fClipStack.reset(new SkClipStack); | 664 fClipStack.reset(new SkClipStack); |
666 | 665 |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 } | 1532 } |
1534 | 1533 |
1535 sk_sp<SkLights> SkCanvas::getLights() const { | 1534 sk_sp<SkLights> SkCanvas::getLights() const { |
1536 return this->fLights; | 1535 return this->fLights; |
1537 } | 1536 } |
1538 #endif | 1537 #endif |
1539 | 1538 |
1540 ////////////////////////////////////////////////////////////////////////////// | 1539 ////////////////////////////////////////////////////////////////////////////// |
1541 | 1540 |
1542 void SkCanvas::clipRect(const SkRect& rect, ClipOp op, bool doAA) { | 1541 void SkCanvas::clipRect(const SkRect& rect, ClipOp op, bool doAA) { |
1543 if (!fAllowSoftClip) { | |
1544 doAA = false; | |
1545 } | |
1546 | |
1547 this->checkForDeferredSave(); | 1542 this->checkForDeferredSave(); |
1548 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; | 1543 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; |
1549 this->onClipRect(rect, op, edgeStyle); | 1544 this->onClipRect(rect, op, edgeStyle); |
1550 } | 1545 } |
1551 | 1546 |
1552 void SkCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle
) { | 1547 void SkCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle
) { |
1553 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate(); | 1548 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate(); |
1554 SkRect devR; | 1549 SkRect devR; |
1555 if (isScaleTrans) { | 1550 if (isScaleTrans) { |
1556 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect); | 1551 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 this->onClipRRect(rrect, op, edgeStyle); | 1593 this->onClipRRect(rrect, op, edgeStyle); |
1599 } | 1594 } |
1600 } | 1595 } |
1601 | 1596 |
1602 void SkCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeSt
yle) { | 1597 void SkCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeSt
yle) { |
1603 SkRRect transformedRRect; | 1598 SkRRect transformedRRect; |
1604 if (rrect.transform(fMCRec->fMatrix, &transformedRRect)) { | 1599 if (rrect.transform(fMCRec->fMatrix, &transformedRRect)) { |
1605 AutoValidateClip avc(this); | 1600 AutoValidateClip avc(this); |
1606 | 1601 |
1607 fDeviceCMDirty = true; | 1602 fDeviceCMDirty = true; |
1608 if (!fAllowSoftClip) { | |
1609 edgeStyle = kHard_ClipEdgeStyle; | |
1610 } | |
1611 | 1603 |
1612 fClipStack->clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == ed
geStyle); | 1604 fClipStack->clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == ed
geStyle); |
1613 | 1605 |
1614 fMCRec->fRasterClip.op(transformedRRect, this->getTopLayerBounds(), (SkR
egion::Op)op, | 1606 fMCRec->fRasterClip.op(transformedRRect, this->getTopLayerBounds(), (SkR
egion::Op)op, |
1615 kSoft_ClipEdgeStyle == edgeStyle); | 1607 kSoft_ClipEdgeStyle == edgeStyle); |
1616 fDeviceClipBounds = qr_clip_bounds(fMCRec->fRasterClip.getBounds()); | 1608 fDeviceClipBounds = qr_clip_bounds(fMCRec->fRasterClip.getBounds()); |
1617 return; | 1609 return; |
1618 } | 1610 } |
1619 | 1611 |
1620 SkPath path; | 1612 SkPath path; |
(...skipping 25 matching lines...) Expand all Loading... |
1646 } | 1638 } |
1647 } | 1639 } |
1648 | 1640 |
1649 this->onClipPath(path, op, edgeStyle); | 1641 this->onClipPath(path, op, edgeStyle); |
1650 } | 1642 } |
1651 | 1643 |
1652 void SkCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle
) { | 1644 void SkCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle
) { |
1653 AutoValidateClip avc(this); | 1645 AutoValidateClip avc(this); |
1654 | 1646 |
1655 fDeviceCMDirty = true; | 1647 fDeviceCMDirty = true; |
1656 if (!fAllowSoftClip) { | |
1657 edgeStyle = kHard_ClipEdgeStyle; | |
1658 } | |
1659 | 1648 |
1660 SkPath devPath; | 1649 SkPath devPath; |
1661 if (fMCRec->fMatrix.isIdentity()) { | 1650 if (fMCRec->fMatrix.isIdentity()) { |
1662 devPath = path; | 1651 devPath = path; |
1663 } else { | 1652 } else { |
1664 path.transform(fMCRec->fMatrix, &devPath); | 1653 path.transform(fMCRec->fMatrix, &devPath); |
1665 devPath.setIsVolatile(true); | 1654 devPath.setIsVolatile(true); |
1666 } | 1655 } |
1667 | 1656 |
1668 // Check if the transfomation, or the original path itself | 1657 // Check if the transfomation, or the original path itself |
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3456 const SkCanvas::ClipOp SkCanvas::kXOR_Op; | 3445 const SkCanvas::ClipOp SkCanvas::kXOR_Op; |
3457 const SkCanvas::ClipOp SkCanvas::kReverseDifference_Op; | 3446 const SkCanvas::ClipOp SkCanvas::kReverseDifference_Op; |
3458 const SkCanvas::ClipOp SkCanvas::kReplace_Op; | 3447 const SkCanvas::ClipOp SkCanvas::kReplace_Op; |
3459 | 3448 |
3460 static_assert((int)SkRegion::kDifference_Op == (int)kDifference_SkClipOp
, ""); | 3449 static_assert((int)SkRegion::kDifference_Op == (int)kDifference_SkClipOp
, ""); |
3461 static_assert((int)SkRegion::kIntersect_Op == (int)kIntersect_SkClipOp,
""); | 3450 static_assert((int)SkRegion::kIntersect_Op == (int)kIntersect_SkClipOp,
""); |
3462 static_assert((int)SkRegion::kUnion_Op == (int)kUnion_SkClipOp, "")
; | 3451 static_assert((int)SkRegion::kUnion_Op == (int)kUnion_SkClipOp, "")
; |
3463 static_assert((int)SkRegion::kXOR_Op == (int)kXOR_SkClipOp, ""); | 3452 static_assert((int)SkRegion::kXOR_Op == (int)kXOR_SkClipOp, ""); |
3464 static_assert((int)SkRegion::kReverseDifference_Op == (int)kReverseDifference_S
kClipOp, ""); | 3453 static_assert((int)SkRegion::kReverseDifference_Op == (int)kReverseDifference_S
kClipOp, ""); |
3465 static_assert((int)SkRegion::kReplace_Op == (int)kReplace_SkClipOp, "
"); | 3454 static_assert((int)SkRegion::kReplace_Op == (int)kReplace_SkClipOp, "
"); |
OLD | NEW |