| 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 const SkMatrix& ctm = this->getTotalMatrix(); | 78 if (!this->getTotalMatrix().isScaleTranslate()) { |
| 79 if (!ctm.isScaleTranslate()) { | |
| 80 return false; // conservative | 79 return false; // conservative |
| 81 } | 80 } |
| 82 if (!ctm.mapRectScaleTranslate(*rect).contains(bounds)) { | 81 |
| 82 SkRect devRect; |
| 83 this->getTotalMatrix().mapRectScaleTranslate(&devRect, *rect); |
| 84 if (!devRect.contains(bounds)) { |
| 83 return false; | 85 return false; |
| 84 } | 86 } |
| 85 } | 87 } |
| 86 | 88 |
| 87 if (paint) { | 89 if (paint) { |
| 88 SkPaint::Style paintStyle = paint->getStyle(); | 90 SkPaint::Style paintStyle = paint->getStyle(); |
| 89 if (!(paintStyle == SkPaint::kFill_Style || | 91 if (!(paintStyle == SkPaint::kFill_Style || |
| 90 paintStyle == SkPaint::kStrokeAndFill_Style)) { | 92 paintStyle == SkPaint::kStrokeAndFill_Style)) { |
| 91 return false; | 93 return false; |
| 92 } | 94 } |
| (...skipping 1442 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 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3119 | 3122 |
| 3120 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 3123 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 3121 fCanvas->restoreToCount(fSaveCount); | 3124 fCanvas->restoreToCount(fSaveCount); |
| 3122 } | 3125 } |
| 3123 | 3126 |
| 3124 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API | 3127 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API |
| 3125 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { | 3128 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p
rops) { |
| 3126 return this->makeSurface(info, props).release(); | 3129 return this->makeSurface(info, props).release(); |
| 3127 } | 3130 } |
| 3128 #endif | 3131 #endif |
| OLD | NEW |