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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 (int)kNotOpaque_ShaderOverrideOpacity, | 68 (int)kNotOpaque_ShaderOverrideOpacity, |
69 "need_matching_enums2"); | 69 "need_matching_enums2"); |
70 | 70 |
71 const SkISize size = this->getBaseLayerSize(); | 71 const SkISize size = this->getBaseLayerSize(); |
72 const SkRect bounds = SkRect::MakeIWH(size.width(), size.height()); | 72 const SkRect bounds = SkRect::MakeIWH(size.width(), size.height()); |
73 if (!this->getClipStack()->quickContains(bounds)) { | 73 if (!this->getClipStack()->quickContains(bounds)) { |
74 return false; | 74 return false; |
75 } | 75 } |
76 | 76 |
77 if (rect) { | 77 if (rect) { |
78 if (!this->getTotalMatrix().rectStaysRect()) { | 78 if (!this->getTotalMatrix().isScaleTranslate()) { |
79 return false; // conservative | 79 return false; // conservative |
80 } | 80 } |
81 | 81 |
82 SkRect devRect; | 82 SkRect devRect; |
83 this->getTotalMatrix().mapRect(&devRect, *rect); | 83 this->getTotalMatrix().mapRectScaleTranslate(&devRect, *rect); |
84 if (!devRect.contains(bounds)) { | 84 if (!devRect.contains(bounds)) { |
85 return false; | 85 return false; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 if (paint) { | 89 if (paint) { |
90 SkPaint::Style paintStyle = paint->getStyle(); | 90 SkPaint::Style paintStyle = paint->getStyle(); |
91 if (!(paintStyle == SkPaint::kFill_Style || | 91 if (!(paintStyle == SkPaint::kFill_Style || |
92 paintStyle == SkPaint::kStrokeAndFill_Style)) { | 92 paintStyle == SkPaint::kStrokeAndFill_Style)) { |
93 return false; | 93 return false; |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 ////////////////////////////////////////////////////////////////////////////// | 1524 ////////////////////////////////////////////////////////////////////////////// |
1525 | 1525 |
1526 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 1526 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
1527 if (!fAllowSoftClip) { | 1527 if (!fAllowSoftClip) { |
1528 doAA = false; | 1528 doAA = false; |
1529 } | 1529 } |
1530 | 1530 |
1531 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT | 1531 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT |
1532 // Check if we can quick-accept the clip call (and do nothing) | 1532 // Check if we can quick-accept the clip call (and do nothing) |
1533 // | 1533 // |
1534 if (SkRegion::kIntersect_Op == op && !doAA && fMCRec->fMatrix.rectStaysRect(
)) { | 1534 if (SkRegion::kIntersect_Op == op && !doAA && fMCRec->fMatrix.isScaleTransla
te()) { |
1535 SkRect devR; | 1535 SkRect devR; |
1536 fMCRec->fMatrix.mapRect(&devR, rect); | 1536 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect); |
1537 // NOTE: this check is CTM specific, since we might round differently wi
th a different | 1537 // NOTE: this check is CTM specific, since we might round differently wi
th a different |
1538 // CTM. Thus this is only 100% reliable if there is not global CTM
scale to be | 1538 // CTM. Thus this is only 100% reliable if there is not global CTM
scale to be |
1539 // applied later (i.e. if this is going into a picture). | 1539 // applied later (i.e. if this is going into a picture). |
1540 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { | 1540 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { |
1541 #if 0 | 1541 #if 0 |
1542 SkDebugf("ignored clipRect [%g %g %g %g]\n", | 1542 SkDebugf("ignored clipRect [%g %g %g %g]\n", |
1543 rect.left(), rect.top(), rect.right(), rect.bottom()); | 1543 rect.left(), rect.top(), rect.right(), rect.bottom()); |
1544 #endif | 1544 #endif |
1545 return; | 1545 return; |
1546 } | 1546 } |
(...skipping 16 matching lines...) Expand all Loading... |
1563 fDeviceCMDirty = true; | 1563 fDeviceCMDirty = true; |
1564 fCachedLocalClipBoundsDirty = true; | 1564 fCachedLocalClipBoundsDirty = true; |
1565 | 1565 |
1566 fClipStack->clipEmpty(); | 1566 fClipStack->clipEmpty(); |
1567 (void)fMCRec->fRasterClip.setEmpty(); | 1567 (void)fMCRec->fRasterClip.setEmpty(); |
1568 return; | 1568 return; |
1569 } | 1569 } |
1570 } | 1570 } |
1571 #endif | 1571 #endif |
1572 | 1572 |
1573 const bool rectStaysRect = fMCRec->fMatrix.rectStaysRect(); | 1573 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate(); |
1574 SkRect devR; | 1574 SkRect devR; |
1575 if (rectStaysRect) { | 1575 if (isScaleTrans) { |
1576 fMCRec->fMatrix.mapRect(&devR, rect); | 1576 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect); |
1577 } | 1577 } |
1578 | 1578 |
1579 #ifndef SK_SUPPORT_PRECHECK_CLIPRECT | 1579 #ifndef SK_SUPPORT_PRECHECK_CLIPRECT |
1580 if (SkRegion::kIntersect_Op == op && | 1580 if (SkRegion::kIntersect_Op == op && |
1581 kHard_ClipEdgeStyle == edgeStyle | 1581 kHard_ClipEdgeStyle == edgeStyle |
1582 && rectStaysRect) | 1582 && isScaleTrans) |
1583 { | 1583 { |
1584 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { | 1584 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { |
1585 #if 0 | 1585 #if 0 |
1586 SkDebugf("------- ignored clipRect [%g %g %g %g]\n", | 1586 SkDebugf("------- ignored clipRect [%g %g %g %g]\n", |
1587 rect.left(), rect.top(), rect.right(), rect.bottom()); | 1587 rect.left(), rect.top(), rect.right(), rect.bottom()); |
1588 #endif | 1588 #endif |
1589 return; | 1589 return; |
1590 } | 1590 } |
1591 } | 1591 } |
1592 #endif | 1592 #endif |
1593 | 1593 |
1594 AutoValidateClip avc(this); | 1594 AutoValidateClip avc(this); |
1595 | 1595 |
1596 fDeviceCMDirty = true; | 1596 fDeviceCMDirty = true; |
1597 fCachedLocalClipBoundsDirty = true; | 1597 fCachedLocalClipBoundsDirty = true; |
1598 | 1598 |
1599 if (rectStaysRect) { | 1599 if (isScaleTrans) { |
1600 const bool isAA = kSoft_ClipEdgeStyle == edgeStyle; | 1600 const bool isAA = kSoft_ClipEdgeStyle == edgeStyle; |
1601 fClipStack->clipDevRect(devR, op, isAA); | 1601 fClipStack->clipDevRect(devR, op, isAA); |
1602 fMCRec->fRasterClip.op(devR, this->getTopLayerBounds(), op, isAA); | 1602 fMCRec->fRasterClip.op(devR, this->getTopLayerBounds(), op, isAA); |
1603 } else { | 1603 } else { |
1604 // since we're rotated or some such thing, we convert the rect to a path | 1604 // since we're rotated or some such thing, we convert the rect to a path |
1605 // and clip against that, since it can handle any matrix. However, to | 1605 // and clip against that, since it can handle any matrix. However, to |
1606 // avoid recursion in the case where we are subclassed (e.g. Pictures) | 1606 // avoid recursion in the case where we are subclassed (e.g. Pictures) |
1607 // we explicitly call "our" version of clipPath. | 1607 // we explicitly call "our" version of clipPath. |
1608 SkPath path; | 1608 SkPath path; |
1609 | 1609 |
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3094 | 3094 |
3095 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3095 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3096 fCanvas->restoreToCount(fSaveCount); | 3096 fCanvas->restoreToCount(fSaveCount); |
3097 } | 3097 } |
3098 | 3098 |
3099 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3099 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3100 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3100 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3101 return this->makeSurface(info, props).release(); | 3101 return this->makeSurface(info, props).release(); |
3102 } | 3102 } |
3103 #endif | 3103 #endif |
OLD | NEW |