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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 (int)kNotOpaque_ShaderOverrideOpacity, | 70 (int)kNotOpaque_ShaderOverrideOpacity, |
71 "need_matching_enums2"); | 71 "need_matching_enums2"); |
72 | 72 |
73 const SkISize size = this->getBaseLayerSize(); | 73 const SkISize size = this->getBaseLayerSize(); |
74 const SkRect bounds = SkRect::MakeIWH(size.width(), size.height()); | 74 const SkRect bounds = SkRect::MakeIWH(size.width(), size.height()); |
75 if (!this->getClipStack()->quickContains(bounds)) { | 75 if (!this->getClipStack()->quickContains(bounds)) { |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 if (rect) { | 79 if (rect) { |
80 const SkMatrix& ctm = this->getTotalMatrix(); | 80 if (!this->getTotalMatrix().isScaleTranslate()) { |
81 if (!ctm.isScaleTranslate()) { | |
82 return false; // conservative | 81 return false; // conservative |
83 } | 82 } |
84 if (!ctm.mapRectScaleTranslate(*rect).contains(bounds)) { | 83 |
| 84 SkRect devRect; |
| 85 this->getTotalMatrix().mapRectScaleTranslate(&devRect, *rect); |
| 86 if (!devRect.contains(bounds)) { |
85 return false; | 87 return false; |
86 } | 88 } |
87 } | 89 } |
88 | 90 |
89 if (paint) { | 91 if (paint) { |
90 SkPaint::Style paintStyle = paint->getStyle(); | 92 SkPaint::Style paintStyle = paint->getStyle(); |
91 if (!(paintStyle == SkPaint::kFill_Style || | 93 if (!(paintStyle == SkPaint::kFill_Style || |
92 paintStyle == SkPaint::kStrokeAndFill_Style)) { | 94 paintStyle == SkPaint::kStrokeAndFill_Style)) { |
93 return false; | 95 return false; |
94 } | 96 } |
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 | 1537 |
1536 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 1538 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
1537 if (!fAllowSoftClip) { | 1539 if (!fAllowSoftClip) { |
1538 doAA = false; | 1540 doAA = false; |
1539 } | 1541 } |
1540 | 1542 |
1541 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT | 1543 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT |
1542 // Check if we can quick-accept the clip call (and do nothing) | 1544 // Check if we can quick-accept the clip call (and do nothing) |
1543 // | 1545 // |
1544 if (SkRegion::kIntersect_Op == op && !doAA && fMCRec->fMatrix.isScaleTransla
te()) { | 1546 if (SkRegion::kIntersect_Op == op && !doAA && fMCRec->fMatrix.isScaleTransla
te()) { |
1545 SkRect devR = fMCRec->fMatrix.mapRectScaleTranslate(rect); | 1547 SkRect devR; |
| 1548 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect); |
1546 // NOTE: this check is CTM specific, since we might round differently wi
th a different | 1549 // NOTE: this check is CTM specific, since we might round differently wi
th a different |
1547 // CTM. Thus this is only 100% reliable if there is not global CTM
scale to be | 1550 // CTM. Thus this is only 100% reliable if there is not global CTM
scale to be |
1548 // applied later (i.e. if this is going into a picture). | 1551 // applied later (i.e. if this is going into a picture). |
1549 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { | 1552 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { |
1550 #if 0 | 1553 #if 0 |
1551 SkDebugf("ignored clipRect [%g %g %g %g]\n", | 1554 SkDebugf("ignored clipRect [%g %g %g %g]\n", |
1552 rect.left(), rect.top(), rect.right(), rect.bottom()); | 1555 rect.left(), rect.top(), rect.right(), rect.bottom()); |
1553 #endif | 1556 #endif |
1554 return; | 1557 return; |
1555 } | 1558 } |
(...skipping 19 matching lines...) Expand all Loading... |
1575 fClipStack->clipEmpty(); | 1578 fClipStack->clipEmpty(); |
1576 (void)fMCRec->fRasterClip.setEmpty(); | 1579 (void)fMCRec->fRasterClip.setEmpty(); |
1577 return; | 1580 return; |
1578 } | 1581 } |
1579 } | 1582 } |
1580 #endif | 1583 #endif |
1581 | 1584 |
1582 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate(); | 1585 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate(); |
1583 SkRect devR; | 1586 SkRect devR; |
1584 if (isScaleTrans) { | 1587 if (isScaleTrans) { |
1585 devR = fMCRec->fMatrix.mapRectScaleTranslate(rect); | 1588 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect); |
1586 } | 1589 } |
1587 | 1590 |
1588 #ifndef SK_SUPPORT_PRECHECK_CLIPRECT | 1591 #ifndef SK_SUPPORT_PRECHECK_CLIPRECT |
1589 if (SkRegion::kIntersect_Op == op && | 1592 if (SkRegion::kIntersect_Op == op && |
1590 kHard_ClipEdgeStyle == edgeStyle | 1593 kHard_ClipEdgeStyle == edgeStyle |
1591 && isScaleTrans) | 1594 && isScaleTrans) |
1592 { | 1595 { |
1593 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { | 1596 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { |
1594 #if 0 | 1597 #if 0 |
1595 SkDebugf("------- ignored clipRect [%g %g %g %g]\n", | 1598 SkDebugf("------- ignored clipRect [%g %g %g %g]\n", |
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3293 | 3296 |
3294 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3297 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
3295 fCanvas->restoreToCount(fSaveCount); | 3298 fCanvas->restoreToCount(fSaveCount); |
3296 } | 3299 } |
3297 | 3300 |
3298 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3301 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
3299 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3302 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
3300 return this->makeSurface(info, props).release(); | 3303 return this->makeSurface(info, props).release(); |
3301 } | 3304 } |
3302 #endif | 3305 #endif |
OLD | NEW |