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